entryscape 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. entryscape/__init__.py +219 -0
  2. entryscape/api/__init__.py +26 -0
  3. entryscape/api/app_token_api.py +835 -0
  4. entryscape/api/auth_api.py +965 -0
  5. entryscape/api/catalog_api.py +4473 -0
  6. entryscape/api/contact_api.py +3135 -0
  7. entryscape/api/dataservice_api.py +3135 -0
  8. entryscape/api/dataset_api.py +3804 -0
  9. entryscape/api/distribution_api.py +3135 -0
  10. entryscape/api/document_api.py +2740 -0
  11. entryscape/api/idea_api.py +2740 -0
  12. entryscape/api/job_api.py +360 -0
  13. entryscape/api/model_api.py +2446 -0
  14. entryscape/api/model_class_api.py +2611 -0
  15. entryscape/api/model_diagram_api.py +2611 -0
  16. entryscape/api/model_field_api.py +2611 -0
  17. entryscape/api/model_form_api.py +2611 -0
  18. entryscape/api/model_namespace_api.py +2611 -0
  19. entryscape/api/model_property_api.py +2611 -0
  20. entryscape/api/organization_api.py +3135 -0
  21. entryscape/api/search_api.py +1513 -0
  22. entryscape/api/showcase_api.py +2740 -0
  23. entryscape/api/suggestion_api.py +2740 -0
  24. entryscape/api/terminology_api.py +1726 -0
  25. entryscape/api/upload_api.py +814 -0
  26. entryscape/api_client.py +763 -0
  27. entryscape/api_response.py +20 -0
  28. entryscape/configuration.py +673 -0
  29. entryscape/exceptions.py +222 -0
  30. entryscape/models/__init__.py +71 -0
  31. entryscape/models/app_token.py +156 -0
  32. entryscape/models/app_token_create_request.py +98 -0
  33. entryscape/models/app_token_create_response.py +169 -0
  34. entryscape/models/app_token_status.py +35 -0
  35. entryscape/models/app_token_verify_request.py +109 -0
  36. entryscape/models/entity_list_item.py +175 -0
  37. entryscape/models/entity_list_response.py +139 -0
  38. entryscape/models/entity_reference.py +189 -0
  39. entryscape/models/entity_type.py +57 -0
  40. entryscape/models/error.py +135 -0
  41. entryscape/models/facet_field.py +115 -0
  42. entryscape/models/facet_field_values_inner.py +100 -0
  43. entryscape/models/facet_list.py +113 -0
  44. entryscape/models/facet_list_available_inner.py +107 -0
  45. entryscape/models/job_response.py +112 -0
  46. entryscape/models/job_status.py +189 -0
  47. entryscape/models/job_status_progress.py +100 -0
  48. entryscape/models/job_status_value.py +37 -0
  49. entryscape/models/job_type.py +37 -0
  50. entryscape/models/list_catalogs_entry_type_parameter.py +37 -0
  51. entryscape/models/list_catalogs_graph_type_parameter.py +44 -0
  52. entryscape/models/list_catalogs_resource_type_parameter.py +37 -0
  53. entryscape/models/login_request.py +108 -0
  54. entryscape/models/login_response.py +115 -0
  55. entryscape/models/metadata_format.py +38 -0
  56. entryscape/models/metadata_request.py +99 -0
  57. entryscape/models/parent_reference.py +130 -0
  58. entryscape/models/search_request.py +158 -0
  59. entryscape/models/search_request_filters.py +144 -0
  60. entryscape/models/search_request_filters_graph_type.py +44 -0
  61. entryscape/models/search_request_filters_resource_type.py +37 -0
  62. entryscape/models/search_request_sort.py +38 -0
  63. entryscape/models/search_request_sort_order.py +35 -0
  64. entryscape/models/search_response.py +175 -0
  65. entryscape/models/search_result.py +175 -0
  66. entryscape/models/search_result_graph_type.py +44 -0
  67. entryscape/models/search_result_resource_type.py +37 -0
  68. entryscape/models/search_sort_order_parameter.py +35 -0
  69. entryscape/models/terminology_import_mode.py +35 -0
  70. entryscape/models/validation_profile.py +36 -0
  71. entryscape/models/validation_response.py +149 -0
  72. entryscape/models/validation_result.py +162 -0
  73. entryscape/models/validation_severity.py +36 -0
  74. entryscape/models/validation_summary.py +122 -0
  75. entryscape/models/whoami_response.py +104 -0
  76. entryscape/py.typed +0 -0
  77. entryscape/rest.py +210 -0
  78. entryscape-1.3.0.dist-info/METADATA +696 -0
  79. entryscape-1.3.0.dist-info/RECORD +82 -0
  80. entryscape-1.3.0.dist-info/WHEEL +5 -0
  81. entryscape-1.3.0.dist-info/licenses/LICENSE.txt +165 -0
  82. entryscape-1.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,814 @@
1
+ """
2
+ EntryScape API
3
+
4
+ This API provides structured access to EntryScape data following DCAT-AP standards. All entity endpoints follow a consistent pattern: - GET /{entity} - List all entities - POST /{entity} - Create a new entity (DCAT types only) - GET /{entity}/{context_id}/{entry_id} - Get entity reference info - DELETE /{entity}/{context_id}/{entry_id} - Delete an entity (DCAT types only) - GET /{entity}/{context_id}/{entry_id}/metadata - Get raw RDF metadata - PUT /{entity}/{context_id}/{entry_id}/metadata - Replace raw RDF metadata (JSON-LD, Turtle, RDF/XML, or N-Triples passthrough) ## Reading and consistency Reads of a single entity — `GET /{entity}/{context_id}/{entry_id}` and its `/metadata` — go straight to the store and always reflect the latest write. Lists and search do not. They are answered from a search index that is updated asynchronously, so for a short interval after a write: - an entry that was just created may be missing from the list it belongs to, while reading it by id already works; - an entry that was just deleted may still appear; - `results` counts what the index holds, not what the store holds. Write a client that tolerates this: after creating an entry, use the id the create returned rather than searching for what you just wrote. `results` is also an upper bound rather than an exact count when the caller cannot read every hit (see the field's own description). Separately, responses are cached for 15 minutes by default, which is a second and unrelated source of staleness. A write invalidates the cache entries it affects, but a read that lands in the indexing gap can cache a list that does not yet show it. ## Authentication Most endpoints require an authenticated session. Reading public data works without authentication, while creating, updating, and deleting entities requires a valid user session. 1. **Log in** with `POST /auth/login`, supplying an EntryStore username and password. The response returns an `auth_token`. 2. **Send the token** on subsequent requests via the `X-Auth-Token` header. This is the recommended method for SDK and programmatic access. Browser clients can instead rely on the `auth_token` cookie, which the server sets automatically on login (`SameSite=Lax; Secure`). 3. **Inspect the session** with `GET /auth/whoami`, which returns the current user or an anonymous/guest identity when no valid token is supplied. 4. **Log out** with `POST /auth/logout` to invalidate the token and clear the cookie. ### Writes and CSRF Send the token as the `X-Auth-Token` **header** and there is nothing else to do: creates, updates and deletes work as they are, which is how the SDKs and the MCP server are built. The `auth_token` cookie is different. A cookie is attached by the browser automatically, so a state-changing request authenticated by it alone is what cross-site request forgery abuses, and those requests additionally need a double-submit token: read the `XSRF-TOKEN` cookie the server sets on any response and send its value back as the `X-XSRF-TOKEN` header. Without it the request is rejected with `403` before it reaches the endpoint. A custom header cannot be forged this way — cross-origin JavaScript cannot set one without a CORS preflight, which this API grants only to configured origins — so the header is the recommended path for anything that is not a browser session. ### App Tokens An app token identifies an integration. Create one with `POST /app-token` (unauthenticated). Creation requires an email address: the token starts in the `pending` state and a 6-digit code is emailed to the owner. Confirm the code with `POST /app-token/verify` to activate the token and receive its value, which is shown only once — store it securely. `GET /app-token/{app_token_id}` then returns its details and quota usage, authenticated by the token itself via the `X-App-Token` header. **The `X-App-Token` header is accepted only by `GET /app-token/{app_token_id}`.** No other operation reads it, and the read quota is recorded but not yet enforced: reading public data needs no token of any kind, and sending an app token with a read neither grants nor meters anything. Metered public read access is the intent of the two-token model, not a description of this release — see the `security` declared on each operation for what it actually accepts. ## SDKs Generated clients for Python, TypeScript, JavaScript and C# wrap every operation below, and each operation on this page shows the SDK call beside the `curl` command. Two of them install from a public registry: ``` pip install entryscape # Python npm install @entryscape/api-client # TypeScript and JavaScript ``` `@entryscape/api-client` ships an ESM and a CommonJS build, so `import` and `require()` both work and TypeScript is not required to use it — the name describes what it is written in, not what you have to write. There is a separate generated JavaScript SDK, and it is deliberately **not** on npm; this package is the npm client for both languages. Every SDK, including the C# and JavaScript ones, is also published as a tarball. The downloads are linked in the sidebar, they are the route to take when a registry is unreachable or a build has to vendor its dependencies, and each archive carries the SDK's own README: - **Python** — `pip install entryscape`, or `python-sdk.tar.gz`. - **TypeScript and JavaScript** — `npm install @entryscape/api-client`, or `typescript-sdk.tar.gz`. - **JavaScript (the separate generated client)** — not published to a registry, by design; `javascript-sdk.tar.gz` only. - **C#** — not published to NuGet yet; `csharp-sdk.tar.gz` only. - **MCP server** — `npx -y @entryscape/mcp-server`, or `mcp-server.tar.gz`. ## MCP Server A Model Context Protocol (MCP) server is generated from this specification and published alongside the SDKs (`@entryscape/mcp-server`), exposing the API as tools for AI assistants and agents. Each operation becomes one tool named after its `operationId` — `listDatasets`, `createCatalog`, `search`, `getJobStatus`. The `auth` operations are the exception: the server reads its token once at startup, so a `login` tool could install nothing and a `logout` tool would only invalidate the token the server was started with. On connect the server also hands the assistant a short set of rules that hold across every tool: a token is bound to one EntryStore instance, the search index lags a write, uploads finish as jobs. ### Install The server is on npm, and MCP servers are normally launched straight from there, so nothing has to be installed first: ``` npx -y @entryscape/mcp-server ``` `npm install -g @entryscape/mcp-server` works too and puts an `entryscape-mcp` binary on `PATH`. It is also listed in the MCP Registry as `com.entryscape/mcp-server`, which is where clients and marketplaces look it up. Without npm, download `mcp-server.tar.gz` from the SDK downloads and unpack it. The package ships prebuilt; install its runtime dependency once: ``` mkdir entryscape-mcp && tar -xzf mcp-server.tar.gz -C entryscape-mcp cd entryscape-mcp && npm install --omit=dev ``` ### Configure The server is a stdio MCP server configured through environment variables, read once at startup: - `ENTRYSCAPE_API_URL` — base URL of the API server, path included. Required: there is no default, and the server refuses to start without it. - `ENTRYSCAPE_AUTH_TOKEN` — a session token from `POST /auth/login`, sent as the `X-Auth-Token` header. Optional: without it reads see public entries and every write is refused. A token is valid only for the EntryStore instance that issued it. - `ENTRYSCAPE_ENTRYSTORE_HOST` — the EntryStore instance the API server should use, for example `dev.entryscape.com/store/`. Unset means the API server's own default. - `ENTRYSCAPE_MCP_UPLOAD_ROOT` — the directory the upload tools may read files from. **Unset means uploads are disabled**: `addFileToDistribution`, `replaceFileInDistribution` and `importTerminology` refuse and say so. - `ENTRYSCAPE_MCP_TAGS` — comma-separated tags to serve tools for, for example `catalog,dataset,distribution,search`. Unset serves every tool. The package's `README.md` lists the remaining variables (timeouts and size caps). Register the server with any MCP-capable client by adding it to the client's `mcpServers` configuration: ```json { \"mcpServers\": { \"entryscape\": { \"command\": \"npx\", \"args\": [\"-y\", \"@entryscape/mcp-server\"], \"env\": { \"ENTRYSCAPE_API_URL\": \"https://<your EntryScape API host>\", \"ENTRYSCAPE_AUTH_TOKEN\": \"your-session-token\" } } } } ``` From an unpacked download instead, the command is `\"command\": \"node\", \"args\": [\"/path/to/entryscape-mcp/dist/bin/entryscape-mcp.js\"]`. ### Claude Code The unpacked package is also a Claude Code plugin, so one install gives the server and the skills below together. Claude Code installs plugins from marketplaces, and the package carries a one-entry marketplace pointing at itself: ``` claude plugin marketplace add /path/to/entryscape-mcp claude plugin install entryscape@entryscape --scope user ``` The plugin passes `ENTRYSCAPE_API_URL`, `ENTRYSCAPE_AUTH_TOKEN`, `ENTRYSCAPE_ENTRYSTORE_HOST`, `ENTRYSCAPE_MCP_TAGS` and `ENTRYSCAPE_MCP_UPLOAD_ROOT` through from the shell Claude Code was started in, so set them there. To try the plugin for one session without installing it, start Claude Code with `--plugin-dir /path/to/entryscape-mcp`. ### Skills `skills/` in the package holds procedures that span several tools, in the Agent Skills format (a `SKILL.md` with `name` and `description`): which tools to call in which order, what to check between calls, and where to stop. Claude Code loads them from the plugin; other clients that read the format can be pointed at the directory. The `find` skill covers discovery, facets and selective metadata reads; `publish-dataset` takes a dataset from catalog to validated distribution with its file; `edit-metadata` changes an entry that already exists without dropping the rest of its graph, models included; `migrate-from-taskrunner` moves an integration off the deprecated Taskrunner API. Every tool a skill names is checked against this specification when the package is built. ## Deprecation Policy When endpoints or features are deprecated: 1. The operation is marked with `deprecated: true` in this spec 2. The operation description documents the replacement endpoint and sunset date 3. Deprecated endpoints remain functional for at least 6 months after announcement 4. The server returns a `Sunset` header with the planned removal date 5. After the sunset date, the endpoint may be removed in a future release
5
+
6
+ The version of the OpenAPI document: 1.3.0
7
+ Contact: contact@entryscape.com
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+ import warnings
14
+ from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
15
+ from typing import Any, Dict, List, Optional, Tuple, Union
16
+ from typing_extensions import Annotated
17
+
18
+ from pydantic import Field, StrictBytes, StrictStr
19
+ from typing import Optional, Tuple, Union
20
+ from typing_extensions import Annotated
21
+ from entryscape.models.job_response import JobResponse
22
+
23
+ from entryscape.api_client import ApiClient, RequestSerialized
24
+ from entryscape.api_response import ApiResponse
25
+ from entryscape.rest import RESTResponseType
26
+
27
+
28
+ class UploadApi:
29
+ """NOTE: This class is auto generated by OpenAPI Generator
30
+ Ref: https://openapi-generator.tech
31
+
32
+ Do not edit the class manually.
33
+ """
34
+
35
+ def __init__(self, api_client=None) -> None:
36
+ if api_client is None:
37
+ api_client = ApiClient.get_default()
38
+ self.api_client = api_client
39
+
40
+ @validate_call
41
+ async def add_file_to_distribution(
42
+ self,
43
+ resource_uri: Annotated[
44
+ str,
45
+ Field(
46
+ min_length=1,
47
+ strict=True,
48
+ max_length=2048,
49
+ description='The resource URI of the **distribution** to add the file to, of the form `{store}/{context}/resource/{entry}`. In EntryScape Catalog it is shown as "Resource" under the distribution\'s information icon. A URI that identifies something other than a `dcat:Distribution` (for example a file entry) is rejected with 422; one that does not resolve to a readable entry with 404. ',
50
+ ),
51
+ ],
52
+ file: Annotated[
53
+ Union[StrictBytes, StrictStr, Tuple[StrictStr, StrictBytes]],
54
+ Field(description="The file to upload"),
55
+ ],
56
+ x_entrystore_host: Annotated[
57
+ Optional[StrictStr],
58
+ Field(
59
+ description="Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance. "
60
+ ),
61
+ ] = None,
62
+ entrystore_host: Annotated[
63
+ Optional[StrictStr],
64
+ Field(
65
+ description="Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance. "
66
+ ),
67
+ ] = None,
68
+ _request_timeout: Union[
69
+ None,
70
+ Annotated[StrictFloat, Field(gt=0)],
71
+ Tuple[
72
+ Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
73
+ ],
74
+ ] = None,
75
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
76
+ _content_type: Optional[StrictStr] = None,
77
+ _headers: Optional[Dict[StrictStr, Any]] = None,
78
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
79
+ ) -> JobResponse:
80
+ """Add file to distribution
81
+
82
+ Adds a file to a distribution. Pass the resource URI of the **distribution**: the job creates a new file entry in the distribution's context, stores the upload as its resource, links it from the distribution with `dcat:accessURL` and `dcat:downloadURL`, and replaces the distribution's `dcterms:modified`. The new file entry's resource URI is reported as `resultUrl` on the job, and is what a later `replaceFile` takes. If the distribution has a connected auto-generated API (an API distribution whose `dcterms:source` is this distribution), the file's rows are appended to the API's dataset and the API distribution is marked modified. Such a distribution only accepts CSV; any other upload fails the job before anything is written. The upload is processed asynchronously: the response carries a job ID for `GET /job/{job_id}`. A URI that is not a distribution is rejected with 422 before anything is queued, one that does not resolve to a readable entry with 404. Requires authentication with write access to the distribution's context.
83
+
84
+ :param resource_uri: The resource URI of the **distribution** to add the file to, of the form `{store}/{context}/resource/{entry}`. In EntryScape Catalog it is shown as \"Resource\" under the distribution's information icon. A URI that identifies something other than a `dcat:Distribution` (for example a file entry) is rejected with 422; one that does not resolve to a readable entry with 404. (required)
85
+ :type resource_uri: str
86
+ :param file: The file to upload (required)
87
+ :type file: bytes
88
+ :param x_entrystore_host: Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance.
89
+ :type x_entrystore_host: str
90
+ :param entrystore_host: Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance.
91
+ :type entrystore_host: str
92
+ :param _request_timeout: timeout setting for this request. If one
93
+ number provided, it will be total request
94
+ timeout. It can also be a pair (tuple) of
95
+ (connection, read) timeouts.
96
+ :type _request_timeout: int, tuple(int, int), optional
97
+ :param _request_auth: set to override the auth_settings for an a single
98
+ request; this effectively ignores the
99
+ authentication in the spec for a single request.
100
+ :type _request_auth: dict, optional
101
+ :param _content_type: force content-type for the request.
102
+ :type _content_type: str, Optional
103
+ :param _headers: set to override the headers for a single
104
+ request; this effectively ignores the headers
105
+ in the spec for a single request.
106
+ :type _headers: dict, optional
107
+ :param _host_index: set to override the host_index for a single
108
+ request; this effectively ignores the host_index
109
+ in the spec for a single request.
110
+ :type _host_index: int, optional
111
+ :return: Returns the result object.
112
+ """ # noqa: E501
113
+
114
+ _param = self._add_file_to_distribution_serialize(
115
+ resource_uri=resource_uri,
116
+ file=file,
117
+ x_entrystore_host=x_entrystore_host,
118
+ entrystore_host=entrystore_host,
119
+ _request_auth=_request_auth,
120
+ _content_type=_content_type,
121
+ _headers=_headers,
122
+ _host_index=_host_index,
123
+ )
124
+
125
+ _response_types_map: Dict[str, Optional[str]] = {
126
+ "202": "JobResponse",
127
+ "400": "Error",
128
+ "401": "Error",
129
+ "403": "Error",
130
+ "404": "Error",
131
+ "413": "Error",
132
+ "422": "Error",
133
+ "500": "Error",
134
+ "503": "Error",
135
+ }
136
+ response_data = await self.api_client.call_api(
137
+ *_param, _request_timeout=_request_timeout
138
+ )
139
+ await response_data.read()
140
+ return self.api_client.response_deserialize(
141
+ response_data=response_data,
142
+ response_types_map=_response_types_map,
143
+ ).data
144
+
145
+ @validate_call
146
+ async def add_file_to_distribution_with_http_info(
147
+ self,
148
+ resource_uri: Annotated[
149
+ str,
150
+ Field(
151
+ min_length=1,
152
+ strict=True,
153
+ max_length=2048,
154
+ description='The resource URI of the **distribution** to add the file to, of the form `{store}/{context}/resource/{entry}`. In EntryScape Catalog it is shown as "Resource" under the distribution\'s information icon. A URI that identifies something other than a `dcat:Distribution` (for example a file entry) is rejected with 422; one that does not resolve to a readable entry with 404. ',
155
+ ),
156
+ ],
157
+ file: Annotated[
158
+ Union[StrictBytes, StrictStr, Tuple[StrictStr, StrictBytes]],
159
+ Field(description="The file to upload"),
160
+ ],
161
+ x_entrystore_host: Annotated[
162
+ Optional[StrictStr],
163
+ Field(
164
+ description="Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance. "
165
+ ),
166
+ ] = None,
167
+ entrystore_host: Annotated[
168
+ Optional[StrictStr],
169
+ Field(
170
+ description="Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance. "
171
+ ),
172
+ ] = None,
173
+ _request_timeout: Union[
174
+ None,
175
+ Annotated[StrictFloat, Field(gt=0)],
176
+ Tuple[
177
+ Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
178
+ ],
179
+ ] = None,
180
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
181
+ _content_type: Optional[StrictStr] = None,
182
+ _headers: Optional[Dict[StrictStr, Any]] = None,
183
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
184
+ ) -> ApiResponse[JobResponse]:
185
+ """Add file to distribution
186
+
187
+ Adds a file to a distribution. Pass the resource URI of the **distribution**: the job creates a new file entry in the distribution's context, stores the upload as its resource, links it from the distribution with `dcat:accessURL` and `dcat:downloadURL`, and replaces the distribution's `dcterms:modified`. The new file entry's resource URI is reported as `resultUrl` on the job, and is what a later `replaceFile` takes. If the distribution has a connected auto-generated API (an API distribution whose `dcterms:source` is this distribution), the file's rows are appended to the API's dataset and the API distribution is marked modified. Such a distribution only accepts CSV; any other upload fails the job before anything is written. The upload is processed asynchronously: the response carries a job ID for `GET /job/{job_id}`. A URI that is not a distribution is rejected with 422 before anything is queued, one that does not resolve to a readable entry with 404. Requires authentication with write access to the distribution's context.
188
+
189
+ :param resource_uri: The resource URI of the **distribution** to add the file to, of the form `{store}/{context}/resource/{entry}`. In EntryScape Catalog it is shown as \"Resource\" under the distribution's information icon. A URI that identifies something other than a `dcat:Distribution` (for example a file entry) is rejected with 422; one that does not resolve to a readable entry with 404. (required)
190
+ :type resource_uri: str
191
+ :param file: The file to upload (required)
192
+ :type file: bytes
193
+ :param x_entrystore_host: Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance.
194
+ :type x_entrystore_host: str
195
+ :param entrystore_host: Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance.
196
+ :type entrystore_host: str
197
+ :param _request_timeout: timeout setting for this request. If one
198
+ number provided, it will be total request
199
+ timeout. It can also be a pair (tuple) of
200
+ (connection, read) timeouts.
201
+ :type _request_timeout: int, tuple(int, int), optional
202
+ :param _request_auth: set to override the auth_settings for an a single
203
+ request; this effectively ignores the
204
+ authentication in the spec for a single request.
205
+ :type _request_auth: dict, optional
206
+ :param _content_type: force content-type for the request.
207
+ :type _content_type: str, Optional
208
+ :param _headers: set to override the headers for a single
209
+ request; this effectively ignores the headers
210
+ in the spec for a single request.
211
+ :type _headers: dict, optional
212
+ :param _host_index: set to override the host_index for a single
213
+ request; this effectively ignores the host_index
214
+ in the spec for a single request.
215
+ :type _host_index: int, optional
216
+ :return: Returns the result object.
217
+ """ # noqa: E501
218
+
219
+ _param = self._add_file_to_distribution_serialize(
220
+ resource_uri=resource_uri,
221
+ file=file,
222
+ x_entrystore_host=x_entrystore_host,
223
+ entrystore_host=entrystore_host,
224
+ _request_auth=_request_auth,
225
+ _content_type=_content_type,
226
+ _headers=_headers,
227
+ _host_index=_host_index,
228
+ )
229
+
230
+ _response_types_map: Dict[str, Optional[str]] = {
231
+ "202": "JobResponse",
232
+ "400": "Error",
233
+ "401": "Error",
234
+ "403": "Error",
235
+ "404": "Error",
236
+ "413": "Error",
237
+ "422": "Error",
238
+ "500": "Error",
239
+ "503": "Error",
240
+ }
241
+ response_data = await self.api_client.call_api(
242
+ *_param, _request_timeout=_request_timeout
243
+ )
244
+ await response_data.read()
245
+ return self.api_client.response_deserialize(
246
+ response_data=response_data,
247
+ response_types_map=_response_types_map,
248
+ )
249
+
250
+ @validate_call
251
+ async def add_file_to_distribution_without_preload_content(
252
+ self,
253
+ resource_uri: Annotated[
254
+ str,
255
+ Field(
256
+ min_length=1,
257
+ strict=True,
258
+ max_length=2048,
259
+ description='The resource URI of the **distribution** to add the file to, of the form `{store}/{context}/resource/{entry}`. In EntryScape Catalog it is shown as "Resource" under the distribution\'s information icon. A URI that identifies something other than a `dcat:Distribution` (for example a file entry) is rejected with 422; one that does not resolve to a readable entry with 404. ',
260
+ ),
261
+ ],
262
+ file: Annotated[
263
+ Union[StrictBytes, StrictStr, Tuple[StrictStr, StrictBytes]],
264
+ Field(description="The file to upload"),
265
+ ],
266
+ x_entrystore_host: Annotated[
267
+ Optional[StrictStr],
268
+ Field(
269
+ description="Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance. "
270
+ ),
271
+ ] = None,
272
+ entrystore_host: Annotated[
273
+ Optional[StrictStr],
274
+ Field(
275
+ description="Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance. "
276
+ ),
277
+ ] = None,
278
+ _request_timeout: Union[
279
+ None,
280
+ Annotated[StrictFloat, Field(gt=0)],
281
+ Tuple[
282
+ Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
283
+ ],
284
+ ] = None,
285
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
286
+ _content_type: Optional[StrictStr] = None,
287
+ _headers: Optional[Dict[StrictStr, Any]] = None,
288
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
289
+ ) -> RESTResponseType:
290
+ """Add file to distribution
291
+
292
+ Adds a file to a distribution. Pass the resource URI of the **distribution**: the job creates a new file entry in the distribution's context, stores the upload as its resource, links it from the distribution with `dcat:accessURL` and `dcat:downloadURL`, and replaces the distribution's `dcterms:modified`. The new file entry's resource URI is reported as `resultUrl` on the job, and is what a later `replaceFile` takes. If the distribution has a connected auto-generated API (an API distribution whose `dcterms:source` is this distribution), the file's rows are appended to the API's dataset and the API distribution is marked modified. Such a distribution only accepts CSV; any other upload fails the job before anything is written. The upload is processed asynchronously: the response carries a job ID for `GET /job/{job_id}`. A URI that is not a distribution is rejected with 422 before anything is queued, one that does not resolve to a readable entry with 404. Requires authentication with write access to the distribution's context.
293
+
294
+ :param resource_uri: The resource URI of the **distribution** to add the file to, of the form `{store}/{context}/resource/{entry}`. In EntryScape Catalog it is shown as \"Resource\" under the distribution's information icon. A URI that identifies something other than a `dcat:Distribution` (for example a file entry) is rejected with 422; one that does not resolve to a readable entry with 404. (required)
295
+ :type resource_uri: str
296
+ :param file: The file to upload (required)
297
+ :type file: bytes
298
+ :param x_entrystore_host: Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance.
299
+ :type x_entrystore_host: str
300
+ :param entrystore_host: Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance.
301
+ :type entrystore_host: str
302
+ :param _request_timeout: timeout setting for this request. If one
303
+ number provided, it will be total request
304
+ timeout. It can also be a pair (tuple) of
305
+ (connection, read) timeouts.
306
+ :type _request_timeout: int, tuple(int, int), optional
307
+ :param _request_auth: set to override the auth_settings for an a single
308
+ request; this effectively ignores the
309
+ authentication in the spec for a single request.
310
+ :type _request_auth: dict, optional
311
+ :param _content_type: force content-type for the request.
312
+ :type _content_type: str, Optional
313
+ :param _headers: set to override the headers for a single
314
+ request; this effectively ignores the headers
315
+ in the spec for a single request.
316
+ :type _headers: dict, optional
317
+ :param _host_index: set to override the host_index for a single
318
+ request; this effectively ignores the host_index
319
+ in the spec for a single request.
320
+ :type _host_index: int, optional
321
+ :return: Returns the result object.
322
+ """ # noqa: E501
323
+
324
+ _param = self._add_file_to_distribution_serialize(
325
+ resource_uri=resource_uri,
326
+ file=file,
327
+ x_entrystore_host=x_entrystore_host,
328
+ entrystore_host=entrystore_host,
329
+ _request_auth=_request_auth,
330
+ _content_type=_content_type,
331
+ _headers=_headers,
332
+ _host_index=_host_index,
333
+ )
334
+
335
+ _response_types_map: Dict[str, Optional[str]] = {
336
+ "202": "JobResponse",
337
+ "400": "Error",
338
+ "401": "Error",
339
+ "403": "Error",
340
+ "404": "Error",
341
+ "413": "Error",
342
+ "422": "Error",
343
+ "500": "Error",
344
+ "503": "Error",
345
+ }
346
+ response_data = await self.api_client.call_api(
347
+ *_param, _request_timeout=_request_timeout
348
+ )
349
+ return response_data.response
350
+
351
+ def _add_file_to_distribution_serialize(
352
+ self,
353
+ resource_uri,
354
+ file,
355
+ x_entrystore_host,
356
+ entrystore_host,
357
+ _request_auth,
358
+ _content_type,
359
+ _headers,
360
+ _host_index,
361
+ ) -> RequestSerialized:
362
+
363
+ _host = None
364
+
365
+ _collection_formats: Dict[str, str] = {}
366
+
367
+ _path_params: Dict[str, str] = {}
368
+ _query_params: List[Tuple[str, str]] = []
369
+ _header_params: Dict[str, Optional[str]] = _headers or {}
370
+ _form_params: List[Tuple[str, str]] = []
371
+ _files: Dict[
372
+ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
373
+ ] = {}
374
+ _body_params: Optional[bytes] = None
375
+
376
+ # process the path parameters
377
+ # process the query parameters
378
+ if entrystore_host is not None:
379
+
380
+ _query_params.append(("entrystore_host", entrystore_host))
381
+
382
+ if resource_uri is not None:
383
+
384
+ _query_params.append(("resourceURI", resource_uri))
385
+
386
+ # process the header parameters
387
+ if x_entrystore_host is not None:
388
+ _header_params["X-Entrystore-Host"] = x_entrystore_host
389
+ # process the form parameters
390
+ if file is not None:
391
+ _files["file"] = file
392
+ # process the body parameter
393
+
394
+ # set the HTTP header `Accept`
395
+ if "Accept" not in _header_params:
396
+ _header_params["Accept"] = self.api_client.select_header_accept(
397
+ ["application/json"]
398
+ )
399
+
400
+ # set the HTTP header `Content-Type`
401
+ if _content_type:
402
+ _header_params["Content-Type"] = _content_type
403
+ else:
404
+ _default_content_type = self.api_client.select_header_content_type(
405
+ ["multipart/form-data"]
406
+ )
407
+ if _default_content_type is not None:
408
+ _header_params["Content-Type"] = _default_content_type
409
+
410
+ # authentication setting
411
+ _auth_settings: List[str] = ["auth_token", "auth_header"]
412
+
413
+ return self.api_client.param_serialize(
414
+ method="POST",
415
+ resource_path="/distribution/addFile",
416
+ path_params=_path_params,
417
+ query_params=_query_params,
418
+ header_params=_header_params,
419
+ body=_body_params,
420
+ post_params=_form_params,
421
+ files=_files,
422
+ auth_settings=_auth_settings,
423
+ collection_formats=_collection_formats,
424
+ _host=_host,
425
+ _request_auth=_request_auth,
426
+ )
427
+
428
+ @validate_call
429
+ async def replace_file_in_distribution(
430
+ self,
431
+ resource_uri: Annotated[
432
+ str,
433
+ Field(
434
+ min_length=1,
435
+ strict=True,
436
+ max_length=2048,
437
+ description="The resource URI of the **file entry** to replace, of the form `{store}/{context}/resource/{entry}`. This is the distribution's download URL (`dcat:downloadURL`), shown as \"web address for access\" under the distribution's information icon in EntryScape Catalog, and the `resultUrl` an earlier add job reported. A URI that identifies something other than a file entry (for example the distribution itself) is rejected with 422; one that does not resolve to a readable entry with 404. ",
438
+ ),
439
+ ],
440
+ file: Annotated[
441
+ Union[StrictBytes, StrictStr, Tuple[StrictStr, StrictBytes]],
442
+ Field(description="The file to upload"),
443
+ ],
444
+ x_entrystore_host: Annotated[
445
+ Optional[StrictStr],
446
+ Field(
447
+ description="Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance. "
448
+ ),
449
+ ] = None,
450
+ entrystore_host: Annotated[
451
+ Optional[StrictStr],
452
+ Field(
453
+ description="Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance. "
454
+ ),
455
+ ] = None,
456
+ _request_timeout: Union[
457
+ None,
458
+ Annotated[StrictFloat, Field(gt=0)],
459
+ Tuple[
460
+ Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
461
+ ],
462
+ ] = None,
463
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
464
+ _content_type: Optional[StrictStr] = None,
465
+ _headers: Optional[Dict[StrictStr, Any]] = None,
466
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
467
+ ) -> JobResponse:
468
+ """Replace file in distribution
469
+
470
+ Replaces the content of a file in a distribution. Pass the resource URI of the **file entry** (the distribution's download URL): the job overwrites its resource with the upload, sets its title and format from the upload, and replaces `dcterms:modified` on every distribution in the context that links to the file. The file entry's resource URI is reported as `resultUrl` on the job. If a linking distribution has a connected auto-generated API (an API distribution whose `dcterms:source` is that distribution), the API's dataset is rebuilt from the distribution's files and the API distribution is marked modified. Such a distribution only accepts CSV; any other upload fails the job before anything is written. The upload is processed asynchronously: the response carries a job ID for `GET /job/{job_id}`. A URI that is not a file entry is rejected with 422 before anything is queued, one that does not resolve to a readable entry with 404. Requires authentication with write access to the file's context.
471
+
472
+ :param resource_uri: The resource URI of the **file entry** to replace, of the form `{store}/{context}/resource/{entry}`. This is the distribution's download URL (`dcat:downloadURL`), shown as \"web address for access\" under the distribution's information icon in EntryScape Catalog, and the `resultUrl` an earlier add job reported. A URI that identifies something other than a file entry (for example the distribution itself) is rejected with 422; one that does not resolve to a readable entry with 404. (required)
473
+ :type resource_uri: str
474
+ :param file: The file to upload (required)
475
+ :type file: bytes
476
+ :param x_entrystore_host: Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance.
477
+ :type x_entrystore_host: str
478
+ :param entrystore_host: Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance.
479
+ :type entrystore_host: str
480
+ :param _request_timeout: timeout setting for this request. If one
481
+ number provided, it will be total request
482
+ timeout. It can also be a pair (tuple) of
483
+ (connection, read) timeouts.
484
+ :type _request_timeout: int, tuple(int, int), optional
485
+ :param _request_auth: set to override the auth_settings for an a single
486
+ request; this effectively ignores the
487
+ authentication in the spec for a single request.
488
+ :type _request_auth: dict, optional
489
+ :param _content_type: force content-type for the request.
490
+ :type _content_type: str, Optional
491
+ :param _headers: set to override the headers for a single
492
+ request; this effectively ignores the headers
493
+ in the spec for a single request.
494
+ :type _headers: dict, optional
495
+ :param _host_index: set to override the host_index for a single
496
+ request; this effectively ignores the host_index
497
+ in the spec for a single request.
498
+ :type _host_index: int, optional
499
+ :return: Returns the result object.
500
+ """ # noqa: E501
501
+
502
+ _param = self._replace_file_in_distribution_serialize(
503
+ resource_uri=resource_uri,
504
+ file=file,
505
+ x_entrystore_host=x_entrystore_host,
506
+ entrystore_host=entrystore_host,
507
+ _request_auth=_request_auth,
508
+ _content_type=_content_type,
509
+ _headers=_headers,
510
+ _host_index=_host_index,
511
+ )
512
+
513
+ _response_types_map: Dict[str, Optional[str]] = {
514
+ "202": "JobResponse",
515
+ "400": "Error",
516
+ "401": "Error",
517
+ "403": "Error",
518
+ "404": "Error",
519
+ "413": "Error",
520
+ "422": "Error",
521
+ "500": "Error",
522
+ "503": "Error",
523
+ }
524
+ response_data = await self.api_client.call_api(
525
+ *_param, _request_timeout=_request_timeout
526
+ )
527
+ await response_data.read()
528
+ return self.api_client.response_deserialize(
529
+ response_data=response_data,
530
+ response_types_map=_response_types_map,
531
+ ).data
532
+
533
+ @validate_call
534
+ async def replace_file_in_distribution_with_http_info(
535
+ self,
536
+ resource_uri: Annotated[
537
+ str,
538
+ Field(
539
+ min_length=1,
540
+ strict=True,
541
+ max_length=2048,
542
+ description="The resource URI of the **file entry** to replace, of the form `{store}/{context}/resource/{entry}`. This is the distribution's download URL (`dcat:downloadURL`), shown as \"web address for access\" under the distribution's information icon in EntryScape Catalog, and the `resultUrl` an earlier add job reported. A URI that identifies something other than a file entry (for example the distribution itself) is rejected with 422; one that does not resolve to a readable entry with 404. ",
543
+ ),
544
+ ],
545
+ file: Annotated[
546
+ Union[StrictBytes, StrictStr, Tuple[StrictStr, StrictBytes]],
547
+ Field(description="The file to upload"),
548
+ ],
549
+ x_entrystore_host: Annotated[
550
+ Optional[StrictStr],
551
+ Field(
552
+ description="Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance. "
553
+ ),
554
+ ] = None,
555
+ entrystore_host: Annotated[
556
+ Optional[StrictStr],
557
+ Field(
558
+ description="Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance. "
559
+ ),
560
+ ] = None,
561
+ _request_timeout: Union[
562
+ None,
563
+ Annotated[StrictFloat, Field(gt=0)],
564
+ Tuple[
565
+ Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
566
+ ],
567
+ ] = None,
568
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
569
+ _content_type: Optional[StrictStr] = None,
570
+ _headers: Optional[Dict[StrictStr, Any]] = None,
571
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
572
+ ) -> ApiResponse[JobResponse]:
573
+ """Replace file in distribution
574
+
575
+ Replaces the content of a file in a distribution. Pass the resource URI of the **file entry** (the distribution's download URL): the job overwrites its resource with the upload, sets its title and format from the upload, and replaces `dcterms:modified` on every distribution in the context that links to the file. The file entry's resource URI is reported as `resultUrl` on the job. If a linking distribution has a connected auto-generated API (an API distribution whose `dcterms:source` is that distribution), the API's dataset is rebuilt from the distribution's files and the API distribution is marked modified. Such a distribution only accepts CSV; any other upload fails the job before anything is written. The upload is processed asynchronously: the response carries a job ID for `GET /job/{job_id}`. A URI that is not a file entry is rejected with 422 before anything is queued, one that does not resolve to a readable entry with 404. Requires authentication with write access to the file's context.
576
+
577
+ :param resource_uri: The resource URI of the **file entry** to replace, of the form `{store}/{context}/resource/{entry}`. This is the distribution's download URL (`dcat:downloadURL`), shown as \"web address for access\" under the distribution's information icon in EntryScape Catalog, and the `resultUrl` an earlier add job reported. A URI that identifies something other than a file entry (for example the distribution itself) is rejected with 422; one that does not resolve to a readable entry with 404. (required)
578
+ :type resource_uri: str
579
+ :param file: The file to upload (required)
580
+ :type file: bytes
581
+ :param x_entrystore_host: Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance.
582
+ :type x_entrystore_host: str
583
+ :param entrystore_host: Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance.
584
+ :type entrystore_host: str
585
+ :param _request_timeout: timeout setting for this request. If one
586
+ number provided, it will be total request
587
+ timeout. It can also be a pair (tuple) of
588
+ (connection, read) timeouts.
589
+ :type _request_timeout: int, tuple(int, int), optional
590
+ :param _request_auth: set to override the auth_settings for an a single
591
+ request; this effectively ignores the
592
+ authentication in the spec for a single request.
593
+ :type _request_auth: dict, optional
594
+ :param _content_type: force content-type for the request.
595
+ :type _content_type: str, Optional
596
+ :param _headers: set to override the headers for a single
597
+ request; this effectively ignores the headers
598
+ in the spec for a single request.
599
+ :type _headers: dict, optional
600
+ :param _host_index: set to override the host_index for a single
601
+ request; this effectively ignores the host_index
602
+ in the spec for a single request.
603
+ :type _host_index: int, optional
604
+ :return: Returns the result object.
605
+ """ # noqa: E501
606
+
607
+ _param = self._replace_file_in_distribution_serialize(
608
+ resource_uri=resource_uri,
609
+ file=file,
610
+ x_entrystore_host=x_entrystore_host,
611
+ entrystore_host=entrystore_host,
612
+ _request_auth=_request_auth,
613
+ _content_type=_content_type,
614
+ _headers=_headers,
615
+ _host_index=_host_index,
616
+ )
617
+
618
+ _response_types_map: Dict[str, Optional[str]] = {
619
+ "202": "JobResponse",
620
+ "400": "Error",
621
+ "401": "Error",
622
+ "403": "Error",
623
+ "404": "Error",
624
+ "413": "Error",
625
+ "422": "Error",
626
+ "500": "Error",
627
+ "503": "Error",
628
+ }
629
+ response_data = await self.api_client.call_api(
630
+ *_param, _request_timeout=_request_timeout
631
+ )
632
+ await response_data.read()
633
+ return self.api_client.response_deserialize(
634
+ response_data=response_data,
635
+ response_types_map=_response_types_map,
636
+ )
637
+
638
+ @validate_call
639
+ async def replace_file_in_distribution_without_preload_content(
640
+ self,
641
+ resource_uri: Annotated[
642
+ str,
643
+ Field(
644
+ min_length=1,
645
+ strict=True,
646
+ max_length=2048,
647
+ description="The resource URI of the **file entry** to replace, of the form `{store}/{context}/resource/{entry}`. This is the distribution's download URL (`dcat:downloadURL`), shown as \"web address for access\" under the distribution's information icon in EntryScape Catalog, and the `resultUrl` an earlier add job reported. A URI that identifies something other than a file entry (for example the distribution itself) is rejected with 422; one that does not resolve to a readable entry with 404. ",
648
+ ),
649
+ ],
650
+ file: Annotated[
651
+ Union[StrictBytes, StrictStr, Tuple[StrictStr, StrictBytes]],
652
+ Field(description="The file to upload"),
653
+ ],
654
+ x_entrystore_host: Annotated[
655
+ Optional[StrictStr],
656
+ Field(
657
+ description="Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance. "
658
+ ),
659
+ ] = None,
660
+ entrystore_host: Annotated[
661
+ Optional[StrictStr],
662
+ Field(
663
+ description="Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance. "
664
+ ),
665
+ ] = None,
666
+ _request_timeout: Union[
667
+ None,
668
+ Annotated[StrictFloat, Field(gt=0)],
669
+ Tuple[
670
+ Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
671
+ ],
672
+ ] = None,
673
+ _request_auth: Optional[Dict[StrictStr, Any]] = None,
674
+ _content_type: Optional[StrictStr] = None,
675
+ _headers: Optional[Dict[StrictStr, Any]] = None,
676
+ _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
677
+ ) -> RESTResponseType:
678
+ """Replace file in distribution
679
+
680
+ Replaces the content of a file in a distribution. Pass the resource URI of the **file entry** (the distribution's download URL): the job overwrites its resource with the upload, sets its title and format from the upload, and replaces `dcterms:modified` on every distribution in the context that links to the file. The file entry's resource URI is reported as `resultUrl` on the job. If a linking distribution has a connected auto-generated API (an API distribution whose `dcterms:source` is that distribution), the API's dataset is rebuilt from the distribution's files and the API distribution is marked modified. Such a distribution only accepts CSV; any other upload fails the job before anything is written. The upload is processed asynchronously: the response carries a job ID for `GET /job/{job_id}`. A URI that is not a file entry is rejected with 422 before anything is queued, one that does not resolve to a readable entry with 404. Requires authentication with write access to the file's context.
681
+
682
+ :param resource_uri: The resource URI of the **file entry** to replace, of the form `{store}/{context}/resource/{entry}`. This is the distribution's download URL (`dcat:downloadURL`), shown as \"web address for access\" under the distribution's information icon in EntryScape Catalog, and the `resultUrl` an earlier add job reported. A URI that identifies something other than a file entry (for example the distribution itself) is rejected with 422; one that does not resolve to a readable entry with 404. (required)
683
+ :type resource_uri: str
684
+ :param file: The file to upload (required)
685
+ :type file: bytes
686
+ :param x_entrystore_host: Target EntryStore instance (alternative to the entrystore_host query parameter, which wins if both are sent). The value has to be an instance this deployment has been configured to allow; any other host is refused with 400. Omit it for the deployment's default instance.
687
+ :type x_entrystore_host: str
688
+ :param entrystore_host: Target EntryStore instance. Overrides the X-Entrystore-Host header if both are provided. The value has to be an instance this deployment has been configured to allow; any other host is refused with 400, so a target you cannot reach is a request to the deployment's operator, not a different value to try. Omit it for the deployment's default instance.
689
+ :type entrystore_host: str
690
+ :param _request_timeout: timeout setting for this request. If one
691
+ number provided, it will be total request
692
+ timeout. It can also be a pair (tuple) of
693
+ (connection, read) timeouts.
694
+ :type _request_timeout: int, tuple(int, int), optional
695
+ :param _request_auth: set to override the auth_settings for an a single
696
+ request; this effectively ignores the
697
+ authentication in the spec for a single request.
698
+ :type _request_auth: dict, optional
699
+ :param _content_type: force content-type for the request.
700
+ :type _content_type: str, Optional
701
+ :param _headers: set to override the headers for a single
702
+ request; this effectively ignores the headers
703
+ in the spec for a single request.
704
+ :type _headers: dict, optional
705
+ :param _host_index: set to override the host_index for a single
706
+ request; this effectively ignores the host_index
707
+ in the spec for a single request.
708
+ :type _host_index: int, optional
709
+ :return: Returns the result object.
710
+ """ # noqa: E501
711
+
712
+ _param = self._replace_file_in_distribution_serialize(
713
+ resource_uri=resource_uri,
714
+ file=file,
715
+ x_entrystore_host=x_entrystore_host,
716
+ entrystore_host=entrystore_host,
717
+ _request_auth=_request_auth,
718
+ _content_type=_content_type,
719
+ _headers=_headers,
720
+ _host_index=_host_index,
721
+ )
722
+
723
+ _response_types_map: Dict[str, Optional[str]] = {
724
+ "202": "JobResponse",
725
+ "400": "Error",
726
+ "401": "Error",
727
+ "403": "Error",
728
+ "404": "Error",
729
+ "413": "Error",
730
+ "422": "Error",
731
+ "500": "Error",
732
+ "503": "Error",
733
+ }
734
+ response_data = await self.api_client.call_api(
735
+ *_param, _request_timeout=_request_timeout
736
+ )
737
+ return response_data.response
738
+
739
+ def _replace_file_in_distribution_serialize(
740
+ self,
741
+ resource_uri,
742
+ file,
743
+ x_entrystore_host,
744
+ entrystore_host,
745
+ _request_auth,
746
+ _content_type,
747
+ _headers,
748
+ _host_index,
749
+ ) -> RequestSerialized:
750
+
751
+ _host = None
752
+
753
+ _collection_formats: Dict[str, str] = {}
754
+
755
+ _path_params: Dict[str, str] = {}
756
+ _query_params: List[Tuple[str, str]] = []
757
+ _header_params: Dict[str, Optional[str]] = _headers or {}
758
+ _form_params: List[Tuple[str, str]] = []
759
+ _files: Dict[
760
+ str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
761
+ ] = {}
762
+ _body_params: Optional[bytes] = None
763
+
764
+ # process the path parameters
765
+ # process the query parameters
766
+ if entrystore_host is not None:
767
+
768
+ _query_params.append(("entrystore_host", entrystore_host))
769
+
770
+ if resource_uri is not None:
771
+
772
+ _query_params.append(("resourceURI", resource_uri))
773
+
774
+ # process the header parameters
775
+ if x_entrystore_host is not None:
776
+ _header_params["X-Entrystore-Host"] = x_entrystore_host
777
+ # process the form parameters
778
+ if file is not None:
779
+ _files["file"] = file
780
+ # process the body parameter
781
+
782
+ # set the HTTP header `Accept`
783
+ if "Accept" not in _header_params:
784
+ _header_params["Accept"] = self.api_client.select_header_accept(
785
+ ["application/json"]
786
+ )
787
+
788
+ # set the HTTP header `Content-Type`
789
+ if _content_type:
790
+ _header_params["Content-Type"] = _content_type
791
+ else:
792
+ _default_content_type = self.api_client.select_header_content_type(
793
+ ["multipart/form-data"]
794
+ )
795
+ if _default_content_type is not None:
796
+ _header_params["Content-Type"] = _default_content_type
797
+
798
+ # authentication setting
799
+ _auth_settings: List[str] = ["auth_token", "auth_header"]
800
+
801
+ return self.api_client.param_serialize(
802
+ method="POST",
803
+ resource_path="/distribution/replaceFile",
804
+ path_params=_path_params,
805
+ query_params=_query_params,
806
+ header_params=_header_params,
807
+ body=_body_params,
808
+ post_params=_form_params,
809
+ files=_files,
810
+ auth_settings=_auth_settings,
811
+ collection_formats=_collection_formats,
812
+ _host=_host,
813
+ _request_auth=_request_auth,
814
+ )