The server submodule
This module provides functions to interact with the metadata server web application.
- send new dataset metadata to the server
- update the resources on the server to match the local versions.
post_metadata(metadata, zenodo, server_resources)
Post the dataset metadata and zenodo metadata to the metadata server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
dict
|
The dataset metadata dictionary for a dataset |
required |
zenodo
|
dict
|
The dataset metadata dictionary for a deposit |
required |
server_resources
|
MetadataResources
|
The server resources to be used. |
required |
Returns:
| Type | Description |
|---|---|
MetadataResponse
|
See here. |
Source code in safedata_validator/server.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
update_resources(server_resources)
Update the resources on the metadata server.
The metadata server provides the gazetteer, location aliases and any project IDs as part of the safedata R package workflow. The web server also uses those resources internally to provide information. This function is used to post the current resources to an API on the server that is used to refresh those reseources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_resources
|
MetadataResources
|
The server resources to be used. |
required |
Returns:
| Type | Description |
|---|---|
MetadataResponse
|
See here. |
Source code in safedata_validator/server.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
MetadataResponse
dataclass
Metadata server response processor.
This dataclass is a processor around requests.Response objects from calls to a
metadata server. If the response is successful, it parses the returned data payload;
otherwise it formats as much information as possible into an error message.
Source code in safedata_validator/server.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
__post_init__(response)
Populate the ZenodoResponse object.
Source code in safedata_validator/server.py
60 61 62 63 64 65 66 67 68 69 | |
error_message = field(init=False, default=None)
class-attribute
instance-attribute
A formatted error message from a failed response.
json_data = field(init=False, default_factory=(lambda: dict()))
class-attribute
instance-attribute
The JSON data payload from a successful response.
ok = field(init=False)
class-attribute
instance-attribute
Was the response ok.
status_code = field(init=False)
class-attribute
instance-attribute
The status code returned by the response.
MetadataResources
dataclass
Packaging for Metadata resources.
This dataclass is used to package the Metadata server specific elements of the configuration.
Source code in safedata_validator/server.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
__post_init__()
Populate the post init attributes.
Source code in safedata_validator/server.py
31 32 33 34 35 36 37 | |
api = field(init=False)
class-attribute
instance-attribute
The configured Zenodo API to be used.
resources
instance-attribute
A safedata_validator resources instance.
token = field(init=False)
class-attribute
instance-attribute
A dictionary providing the authentication token for the API.