reportnet-api 0.1.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.
- reportnet_api/__init__.py +38 -0
- reportnet_api/_auth.py +30 -0
- reportnet_api/_core.py +222 -0
- reportnet_api/_exceptions.py +243 -0
- reportnet_api/async_client.py +113 -0
- reportnet_api/cli.py +212 -0
- reportnet_api/client.py +114 -0
- reportnet_api/demo.py +148 -0
- reportnet_api/discover.py +106 -0
- reportnet_api/easy.py +1359 -0
- reportnet_api/handles.py +326 -0
- reportnet_api/jobs.py +383 -0
- reportnet_api/models/__init__.py +0 -0
- reportnet_api/models/generated.py +555 -0
- reportnet_api/py.typed +0 -0
- reportnet_api/resources/__init__.py +0 -0
- reportnet_api/resources/dataflow_ext.py +239 -0
- reportnet_api/resources/dataset_schema.py +274 -0
- reportnet_api/resources/dataset_schema_ext.py +589 -0
- reportnet_api/resources/dataset_snapshot.py +173 -0
- reportnet_api/resources/datasets.py +1810 -0
- reportnet_api/resources/datasets_ext.py +1001 -0
- reportnet_api/resources/eu_datasets.py +44 -0
- reportnet_api/resources/reference_dataset_ext.py +75 -0
- reportnet_api/resources/release_receipts.py +122 -0
- reportnet_api/resources/representative_ext.py +366 -0
- reportnet_api/resources/user_ext.py +53 -0
- reportnet_api/resources/validation_ext.py +447 -0
- reportnet_api-0.1.0.dist-info/METADATA +307 -0
- reportnet_api-0.1.0.dist-info/RECORD +33 -0
- reportnet_api-0.1.0.dist-info/WHEEL +4 -0
- reportnet_api-0.1.0.dist-info/entry_points.txt +2 -0
- reportnet_api-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Generated from spec/api-docs.json by scripts/generate_resources.py.
|
|
2
|
+
# Do not edit by hand.
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
from typing import TYPE_CHECKING
|
|
8
|
+
|
|
9
|
+
from ..models import generated
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from ..async_client import AsyncReportnetClient
|
|
13
|
+
from ..client import ReportnetClient
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DatasetSnapshotResource:
|
|
17
|
+
def __init__(self, client: ReportnetClient) -> None:
|
|
18
|
+
self._client = client
|
|
19
|
+
|
|
20
|
+
def delete_snapshot(
|
|
21
|
+
self,
|
|
22
|
+
id_dataset: int,
|
|
23
|
+
id_snapshot: int,
|
|
24
|
+
) -> None:
|
|
25
|
+
"""Allowed roles:
|
|
26
|
+
|
|
27
|
+
Reporting dataset: STEWARD, LEAD REPORTER, CUSTODIAN, REPORTER WRITE
|
|
28
|
+
|
|
29
|
+
Data collection: CUSTODIAN, STEWARD
|
|
30
|
+
|
|
31
|
+
Test dataset: CUSTODIAN, STEWARD, STEWARD SUPPORT
|
|
32
|
+
|
|
33
|
+
Reference dataset: CUSTODIAN, STEWARD"""
|
|
34
|
+
params = None
|
|
35
|
+
url = f"/snapshot/v1/{id_snapshot}/dataset/{id_dataset}/delete"
|
|
36
|
+
self._client.request("DELETE", url, params=params)
|
|
37
|
+
return None
|
|
38
|
+
|
|
39
|
+
def download_historic_releases_csv(
|
|
40
|
+
self,
|
|
41
|
+
dataflow_id: int,
|
|
42
|
+
dataset_id: int,
|
|
43
|
+
file_name: str,
|
|
44
|
+
dest: str | os.PathLike[str],
|
|
45
|
+
process_id: str | None = None,
|
|
46
|
+
) -> None:
|
|
47
|
+
"""downloadHistoricReleasesCSV
|
|
48
|
+
|
|
49
|
+
Caution: if the export identified by `process_id` is still in progress
|
|
50
|
+
or was canceled, the backend answers 200 with a plain-text "not ready"
|
|
51
|
+
message instead of CSV, and that text is what lands in `dest`. Check the
|
|
52
|
+
file content before trusting it."""
|
|
53
|
+
params = {"dataflowId": dataflow_id, "fileName": file_name, "processId": process_id}
|
|
54
|
+
params = {k: v for k, v in params.items() if v is not None}
|
|
55
|
+
url = f"/snapshot/downloadHistoricReleases/{dataset_id}"
|
|
56
|
+
self._client.download("GET", url, params=params, dest=dest)
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
def export_historic_releases_csv(
|
|
60
|
+
self,
|
|
61
|
+
dataflow_id: int,
|
|
62
|
+
dataset_id: int,
|
|
63
|
+
) -> str:
|
|
64
|
+
"""exportHistoricReleasesCSV
|
|
65
|
+
|
|
66
|
+
Returns the download URL string (not CSV content): the backend starts an
|
|
67
|
+
async export and answers with
|
|
68
|
+
`/snapshot/downloadHistoricReleases/{id}?dataflowId=..&fileName=..&processId=..`.
|
|
69
|
+
Pass its `fileName`/`processId` to `download_historic_releases_csv`."""
|
|
70
|
+
params = {"dataflowId": dataflow_id}
|
|
71
|
+
params = {k: v for k, v in params.items() if v is not None}
|
|
72
|
+
url = f"/snapshot/exportHistoricReleases/{dataset_id}"
|
|
73
|
+
response = self._client.request("POST", url, params=params)
|
|
74
|
+
return response.text
|
|
75
|
+
|
|
76
|
+
def historic_releases(
|
|
77
|
+
self,
|
|
78
|
+
dataflow_id: int | None = None,
|
|
79
|
+
*,
|
|
80
|
+
dataset_id: int,
|
|
81
|
+
) -> list[generated.ReleaseVO]:
|
|
82
|
+
"""Allowed roles:
|
|
83
|
+
|
|
84
|
+
Reporting dataset: CUSTODIAN, STEWARD
|
|
85
|
+
|
|
86
|
+
Data collection: CUSTODIAN, STEWARD
|
|
87
|
+
|
|
88
|
+
EU dataset: CUSTODIAN, STEWARD"""
|
|
89
|
+
params = {"dataflowId": dataflow_id, "datasetId": dataset_id}
|
|
90
|
+
params = {k: v for k, v in params.items() if v is not None}
|
|
91
|
+
url = "/snapshot/v1/historicReleases"
|
|
92
|
+
response = self._client.request("GET", url, params=params)
|
|
93
|
+
return [generated.ReleaseVO.model_validate(item) for item in response.json()]
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class AsyncDatasetSnapshotResource:
|
|
97
|
+
def __init__(self, client: AsyncReportnetClient) -> None:
|
|
98
|
+
self._client = client
|
|
99
|
+
|
|
100
|
+
async def delete_snapshot(
|
|
101
|
+
self,
|
|
102
|
+
id_dataset: int,
|
|
103
|
+
id_snapshot: int,
|
|
104
|
+
) -> None:
|
|
105
|
+
"""Allowed roles:
|
|
106
|
+
|
|
107
|
+
Reporting dataset: STEWARD, LEAD REPORTER, CUSTODIAN, REPORTER WRITE
|
|
108
|
+
|
|
109
|
+
Data collection: CUSTODIAN, STEWARD
|
|
110
|
+
|
|
111
|
+
Test dataset: CUSTODIAN, STEWARD, STEWARD SUPPORT
|
|
112
|
+
|
|
113
|
+
Reference dataset: CUSTODIAN, STEWARD"""
|
|
114
|
+
params = None
|
|
115
|
+
url = f"/snapshot/v1/{id_snapshot}/dataset/{id_dataset}/delete"
|
|
116
|
+
await self._client.request("DELETE", url, params=params)
|
|
117
|
+
return None
|
|
118
|
+
|
|
119
|
+
async def download_historic_releases_csv(
|
|
120
|
+
self,
|
|
121
|
+
dataflow_id: int,
|
|
122
|
+
dataset_id: int,
|
|
123
|
+
file_name: str,
|
|
124
|
+
dest: str | os.PathLike[str],
|
|
125
|
+
process_id: str | None = None,
|
|
126
|
+
) -> None:
|
|
127
|
+
"""downloadHistoricReleasesCSV
|
|
128
|
+
|
|
129
|
+
Caution: if the export identified by `process_id` is still in progress
|
|
130
|
+
or was canceled, the backend answers 200 with a plain-text "not ready"
|
|
131
|
+
message instead of CSV, and that text is what lands in `dest`. Check the
|
|
132
|
+
file content before trusting it."""
|
|
133
|
+
params = {"dataflowId": dataflow_id, "fileName": file_name, "processId": process_id}
|
|
134
|
+
params = {k: v for k, v in params.items() if v is not None}
|
|
135
|
+
url = f"/snapshot/downloadHistoricReleases/{dataset_id}"
|
|
136
|
+
await self._client.download("GET", url, params=params, dest=dest)
|
|
137
|
+
return None
|
|
138
|
+
|
|
139
|
+
async def export_historic_releases_csv(
|
|
140
|
+
self,
|
|
141
|
+
dataflow_id: int,
|
|
142
|
+
dataset_id: int,
|
|
143
|
+
) -> str:
|
|
144
|
+
"""exportHistoricReleasesCSV
|
|
145
|
+
|
|
146
|
+
Returns the download URL string (not CSV content): the backend starts an
|
|
147
|
+
async export and answers with
|
|
148
|
+
`/snapshot/downloadHistoricReleases/{id}?dataflowId=..&fileName=..&processId=..`.
|
|
149
|
+
Pass its `fileName`/`processId` to `download_historic_releases_csv`."""
|
|
150
|
+
params = {"dataflowId": dataflow_id}
|
|
151
|
+
params = {k: v for k, v in params.items() if v is not None}
|
|
152
|
+
url = f"/snapshot/exportHistoricReleases/{dataset_id}"
|
|
153
|
+
response = await self._client.request("POST", url, params=params)
|
|
154
|
+
return response.text
|
|
155
|
+
|
|
156
|
+
async def historic_releases(
|
|
157
|
+
self,
|
|
158
|
+
dataflow_id: int | None = None,
|
|
159
|
+
*,
|
|
160
|
+
dataset_id: int,
|
|
161
|
+
) -> list[generated.ReleaseVO]:
|
|
162
|
+
"""Allowed roles:
|
|
163
|
+
|
|
164
|
+
Reporting dataset: CUSTODIAN, STEWARD
|
|
165
|
+
|
|
166
|
+
Data collection: CUSTODIAN, STEWARD
|
|
167
|
+
|
|
168
|
+
EU dataset: CUSTODIAN, STEWARD"""
|
|
169
|
+
params = {"dataflowId": dataflow_id, "datasetId": dataset_id}
|
|
170
|
+
params = {k: v for k, v in params.items() if v is not None}
|
|
171
|
+
url = "/snapshot/v1/historicReleases"
|
|
172
|
+
response = await self._client.request("GET", url, params=params)
|
|
173
|
+
return [generated.ReleaseVO.model_validate(item) for item in response.json()]
|