funapi-sciencedb 1.0.1__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 (54) hide show
  1. funapi_sciencedb-1.0.1.dist-info/LICENSE +21 -0
  2. funapi_sciencedb-1.0.1.dist-info/METADATA +10 -0
  3. funapi_sciencedb-1.0.1.dist-info/RECORD +54 -0
  4. funapi_sciencedb-1.0.1.dist-info/WHEEL +5 -0
  5. funapi_sciencedb-1.0.1.dist-info/top_level.txt +1 -0
  6. sciencedb/__init__.py +8 -0
  7. sciencedb/api/__init__.py +1 -0
  8. sciencedb/api/open_api_controller/__init__.py +0 -0
  9. sciencedb/api/open_api_controller/harvest_using_get.py +211 -0
  10. sciencedb/api/open_api_controller/json_using_get.py +164 -0
  11. sciencedb/api/open_api_controller/metrics_using_get.py +166 -0
  12. sciencedb/api/open_api_controller/search_using_get.py +196 -0
  13. sciencedb/api/sushi_controller/__init__.py +0 -0
  14. sciencedb/api/sushi_controller/get_api_status.py +171 -0
  15. sciencedb/api/sushi_controller/get_report_by_id_using_get.py +173 -0
  16. sciencedb/api/sushi_controller/get_reports.py +181 -0
  17. sciencedb/client.py +286 -0
  18. sciencedb/errors.py +16 -0
  19. sciencedb/models/__init__.py +75 -0
  20. sciencedb/models/api_result_metrics_result.py +99 -0
  21. sciencedb/models/api_result_search_result.py +99 -0
  22. sciencedb/models/counter_dataset_attributes.py +69 -0
  23. sciencedb/models/counter_dataset_attributes_type.py +10 -0
  24. sciencedb/models/counter_dataset_contributors.py +68 -0
  25. sciencedb/models/counter_dataset_contributors_type.py +10 -0
  26. sciencedb/models/counter_dataset_dates.py +68 -0
  27. sciencedb/models/counter_dataset_dates_type.py +10 -0
  28. sciencedb/models/counter_dataset_identifiers.py +68 -0
  29. sciencedb/models/counter_dataset_identifiers_type.py +10 -0
  30. sciencedb/models/counter_dataset_instance.py +98 -0
  31. sciencedb/models/counter_dataset_instance_access_method.py +9 -0
  32. sciencedb/models/counter_dataset_instance_metric_type.py +11 -0
  33. sciencedb/models/counter_dataset_performance.py +82 -0
  34. sciencedb/models/counter_dataset_period.py +83 -0
  35. sciencedb/models/counter_dataset_report.py +106 -0
  36. sciencedb/models/counter_dataset_usage.py +230 -0
  37. sciencedb/models/counter_dataset_usage_data_type.py +8 -0
  38. sciencedb/models/counter_publisher_identifiers.py +68 -0
  39. sciencedb/models/counter_publisher_identifiers_type.py +10 -0
  40. sciencedb/models/metrics_result.py +95 -0
  41. sciencedb/models/search_record.py +150 -0
  42. sciencedb/models/search_result.py +111 -0
  43. sciencedb/models/sushi_error_model.py +97 -0
  44. sciencedb/models/sushi_error_model_severity.py +11 -0
  45. sciencedb/models/sushi_page_meta.py +77 -0
  46. sciencedb/models/sushi_report.py +72 -0
  47. sciencedb/models/sushi_report_header.py +189 -0
  48. sciencedb/models/sushi_report_header_report_attributes_item.py +43 -0
  49. sciencedb/models/sushi_report_header_report_filters_item.py +43 -0
  50. sciencedb/models/sushi_report_list.py +82 -0
  51. sciencedb/models/sushi_report_page.py +93 -0
  52. sciencedb/models/sushi_service_status.py +118 -0
  53. sciencedb/models/sushi_service_status_alerts_item.py +43 -0
  54. sciencedb/types.py +53 -0
sciencedb/client.py ADDED
@@ -0,0 +1,286 @@
1
+ import ssl
2
+ from typing import Any, Dict, Optional, Union
3
+
4
+ import httpx
5
+ from attrs import define, evolve, field
6
+
7
+
8
+ @define
9
+ class Client:
10
+ """A class for keeping track of data related to the API
11
+
12
+ The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
13
+
14
+ ``base_url``: The base URL for the API, all requests are made to a relative path to this URL
15
+
16
+ ``cookies``: A dictionary of cookies to be sent with every request
17
+
18
+ ``headers``: A dictionary of headers to be sent with every request
19
+
20
+ ``timeout``: The maximum amount of a time a request can take. API functions will raise
21
+ httpx.TimeoutException if this is exceeded.
22
+
23
+ ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
24
+ but can be set to False for testing purposes.
25
+
26
+ ``follow_redirects``: Whether or not to follow redirects. Default value is False.
27
+
28
+ ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
29
+
30
+
31
+ Attributes:
32
+ raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
33
+ status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
34
+ argument to the constructor.
35
+ """
36
+
37
+ raise_on_unexpected_status: bool = field(default=False, kw_only=True)
38
+ _base_url: str = field(alias="base_url")
39
+ _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
40
+ _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
41
+ _timeout: Optional[httpx.Timeout] = field(
42
+ default=None, kw_only=True, alias="timeout"
43
+ )
44
+ _verify_ssl: Union[str, bool, ssl.SSLContext] = field(
45
+ default=True, kw_only=True, alias="verify_ssl"
46
+ )
47
+ _follow_redirects: bool = field(
48
+ default=False, kw_only=True, alias="follow_redirects"
49
+ )
50
+ _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
51
+ _client: Optional[httpx.Client] = field(default=None, init=False)
52
+ _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
53
+
54
+ def with_headers(self, headers: Dict[str, str]) -> "Client":
55
+ """Get a new client matching this one with additional headers"""
56
+ if self._client is not None:
57
+ self._client.headers.update(headers)
58
+ if self._async_client is not None:
59
+ self._async_client.headers.update(headers)
60
+ return evolve(self, headers={**self._headers, **headers})
61
+
62
+ def with_cookies(self, cookies: Dict[str, str]) -> "Client":
63
+ """Get a new client matching this one with additional cookies"""
64
+ if self._client is not None:
65
+ self._client.cookies.update(cookies)
66
+ if self._async_client is not None:
67
+ self._async_client.cookies.update(cookies)
68
+ return evolve(self, cookies={**self._cookies, **cookies})
69
+
70
+ def with_timeout(self, timeout: httpx.Timeout) -> "Client":
71
+ """Get a new client matching this one with a new timeout (in seconds)"""
72
+ if self._client is not None:
73
+ self._client.timeout = timeout
74
+ if self._async_client is not None:
75
+ self._async_client.timeout = timeout
76
+ return evolve(self, timeout=timeout)
77
+
78
+ def set_httpx_client(self, client: httpx.Client) -> "Client":
79
+ """Manually set the underlying httpx.Client
80
+
81
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
82
+ """
83
+ self._client = client
84
+ return self
85
+
86
+ def get_httpx_client(self) -> httpx.Client:
87
+ """Get the underlying httpx.Client, constructing a new one if not previously set"""
88
+ if self._client is None:
89
+ self._client = httpx.Client(
90
+ base_url=self._base_url,
91
+ cookies=self._cookies,
92
+ headers=self._headers,
93
+ timeout=self._timeout,
94
+ verify=self._verify_ssl,
95
+ follow_redirects=self._follow_redirects,
96
+ **self._httpx_args,
97
+ )
98
+ return self._client
99
+
100
+ def __enter__(self) -> "Client":
101
+ """Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
102
+ self.get_httpx_client().__enter__()
103
+ return self
104
+
105
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
106
+ """Exit a context manager for internal httpx.Client (see httpx docs)"""
107
+ self.get_httpx_client().__exit__(*args, **kwargs)
108
+
109
+ def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
110
+ """Manually the underlying httpx.AsyncClient
111
+
112
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
113
+ """
114
+ self._async_client = async_client
115
+ return self
116
+
117
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
118
+ """Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
119
+ if self._async_client is None:
120
+ self._async_client = httpx.AsyncClient(
121
+ base_url=self._base_url,
122
+ cookies=self._cookies,
123
+ headers=self._headers,
124
+ timeout=self._timeout,
125
+ verify=self._verify_ssl,
126
+ follow_redirects=self._follow_redirects,
127
+ **self._httpx_args,
128
+ )
129
+ return self._async_client
130
+
131
+ async def __aenter__(self) -> "Client":
132
+ """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
133
+ await self.get_async_httpx_client().__aenter__()
134
+ return self
135
+
136
+ async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
137
+ """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
138
+ await self.get_async_httpx_client().__aexit__(*args, **kwargs)
139
+
140
+
141
+ @define
142
+ class AuthenticatedClient:
143
+ """A Client which has been authenticated for use on secured endpoints
144
+
145
+ The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
146
+
147
+ ``base_url``: The base URL for the API, all requests are made to a relative path to this URL
148
+
149
+ ``cookies``: A dictionary of cookies to be sent with every request
150
+
151
+ ``headers``: A dictionary of headers to be sent with every request
152
+
153
+ ``timeout``: The maximum amount of a time a request can take. API functions will raise
154
+ httpx.TimeoutException if this is exceeded.
155
+
156
+ ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
157
+ but can be set to False for testing purposes.
158
+
159
+ ``follow_redirects``: Whether or not to follow redirects. Default value is False.
160
+
161
+ ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
162
+
163
+
164
+ Attributes:
165
+ raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
166
+ status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
167
+ argument to the constructor.
168
+ token: The token to use for authentication
169
+ prefix: The prefix to use for the Authorization header
170
+ auth_header_name: The name of the Authorization header
171
+ """
172
+
173
+ raise_on_unexpected_status: bool = field(default=False, kw_only=True)
174
+ _base_url: str = field(alias="base_url")
175
+ _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
176
+ _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
177
+ _timeout: Optional[httpx.Timeout] = field(
178
+ default=None, kw_only=True, alias="timeout"
179
+ )
180
+ _verify_ssl: Union[str, bool, ssl.SSLContext] = field(
181
+ default=True, kw_only=True, alias="verify_ssl"
182
+ )
183
+ _follow_redirects: bool = field(
184
+ default=False, kw_only=True, alias="follow_redirects"
185
+ )
186
+ _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
187
+ _client: Optional[httpx.Client] = field(default=None, init=False)
188
+ _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
189
+
190
+ token: str
191
+ prefix: str = "Bearer"
192
+ auth_header_name: str = "Authorization"
193
+
194
+ def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient":
195
+ """Get a new client matching this one with additional headers"""
196
+ if self._client is not None:
197
+ self._client.headers.update(headers)
198
+ if self._async_client is not None:
199
+ self._async_client.headers.update(headers)
200
+ return evolve(self, headers={**self._headers, **headers})
201
+
202
+ def with_cookies(self, cookies: Dict[str, str]) -> "AuthenticatedClient":
203
+ """Get a new client matching this one with additional cookies"""
204
+ if self._client is not None:
205
+ self._client.cookies.update(cookies)
206
+ if self._async_client is not None:
207
+ self._async_client.cookies.update(cookies)
208
+ return evolve(self, cookies={**self._cookies, **cookies})
209
+
210
+ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
211
+ """Get a new client matching this one with a new timeout (in seconds)"""
212
+ if self._client is not None:
213
+ self._client.timeout = timeout
214
+ if self._async_client is not None:
215
+ self._async_client.timeout = timeout
216
+ return evolve(self, timeout=timeout)
217
+
218
+ def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
219
+ """Manually set the underlying httpx.Client
220
+
221
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
222
+ """
223
+ self._client = client
224
+ return self
225
+
226
+ def get_httpx_client(self) -> httpx.Client:
227
+ """Get the underlying httpx.Client, constructing a new one if not previously set"""
228
+ if self._client is None:
229
+ self._headers[self.auth_header_name] = (
230
+ f"{self.prefix} {self.token}" if self.prefix else self.token
231
+ )
232
+ self._client = httpx.Client(
233
+ base_url=self._base_url,
234
+ cookies=self._cookies,
235
+ headers=self._headers,
236
+ timeout=self._timeout,
237
+ verify=self._verify_ssl,
238
+ follow_redirects=self._follow_redirects,
239
+ **self._httpx_args,
240
+ )
241
+ return self._client
242
+
243
+ def __enter__(self) -> "AuthenticatedClient":
244
+ """Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
245
+ self.get_httpx_client().__enter__()
246
+ return self
247
+
248
+ def __exit__(self, *args: Any, **kwargs: Any) -> None:
249
+ """Exit a context manager for internal httpx.Client (see httpx docs)"""
250
+ self.get_httpx_client().__exit__(*args, **kwargs)
251
+
252
+ def set_async_httpx_client(
253
+ self, async_client: httpx.AsyncClient
254
+ ) -> "AuthenticatedClient":
255
+ """Manually the underlying httpx.AsyncClient
256
+
257
+ **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
258
+ """
259
+ self._async_client = async_client
260
+ return self
261
+
262
+ def get_async_httpx_client(self) -> httpx.AsyncClient:
263
+ """Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
264
+ if self._async_client is None:
265
+ self._headers[self.auth_header_name] = (
266
+ f"{self.prefix} {self.token}" if self.prefix else self.token
267
+ )
268
+ self._async_client = httpx.AsyncClient(
269
+ base_url=self._base_url,
270
+ cookies=self._cookies,
271
+ headers=self._headers,
272
+ timeout=self._timeout,
273
+ verify=self._verify_ssl,
274
+ follow_redirects=self._follow_redirects,
275
+ **self._httpx_args,
276
+ )
277
+ return self._async_client
278
+
279
+ async def __aenter__(self) -> "AuthenticatedClient":
280
+ """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
281
+ await self.get_async_httpx_client().__aenter__()
282
+ return self
283
+
284
+ async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
285
+ """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
286
+ await self.get_async_httpx_client().__aexit__(*args, **kwargs)
sciencedb/errors.py ADDED
@@ -0,0 +1,16 @@
1
+ """Contains shared errors types that can be raised from API functions"""
2
+
3
+
4
+ class UnexpectedStatus(Exception):
5
+ """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
6
+
7
+ def __init__(self, status_code: int, content: bytes):
8
+ self.status_code = status_code
9
+ self.content = content
10
+
11
+ super().__init__(
12
+ f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
13
+ )
14
+
15
+
16
+ __all__ = ["UnexpectedStatus"]
@@ -0,0 +1,75 @@
1
+ """Contains all the data models used in inputs/outputs"""
2
+
3
+ from .api_result_metrics_result import APIResultMetricsResult
4
+ from .api_result_search_result import APIResultSearchResult
5
+ from .counter_dataset_attributes import COUNTERDatasetAttributes
6
+ from .counter_dataset_attributes_type import COUNTERDatasetAttributesType
7
+ from .counter_dataset_contributors import COUNTERDatasetContributors
8
+ from .counter_dataset_contributors_type import COUNTERDatasetContributorsType
9
+ from .counter_dataset_dates import COUNTERDatasetDates
10
+ from .counter_dataset_dates_type import COUNTERDatasetDatesType
11
+ from .counter_dataset_identifiers import COUNTERDatasetIdentifiers
12
+ from .counter_dataset_identifiers_type import COUNTERDatasetIdentifiersType
13
+ from .counter_dataset_instance import COUNTERDatasetInstance
14
+ from .counter_dataset_instance_access_method import COUNTERDatasetInstanceAccessMethod
15
+ from .counter_dataset_instance_metric_type import COUNTERDatasetInstanceMetricType
16
+ from .counter_dataset_performance import COUNTERDatasetPerformance
17
+ from .counter_dataset_period import COUNTERDatasetPeriod
18
+ from .counter_dataset_report import COUNTERDatasetReport
19
+ from .counter_dataset_usage import COUNTERDatasetUsage
20
+ from .counter_dataset_usage_data_type import COUNTERDatasetUsageDataType
21
+ from .counter_publisher_identifiers import COUNTERPublisherIdentifiers
22
+ from .counter_publisher_identifiers_type import COUNTERPublisherIdentifiersType
23
+ from .metrics_result import MetricsResult
24
+ from .search_record import SearchRecord
25
+ from .search_result import SearchResult
26
+ from .sushi_error_model import SUSHIErrorModel
27
+ from .sushi_error_model_severity import SUSHIErrorModelSeverity
28
+ from .sushi_page_meta import SUSHIPageMeta
29
+ from .sushi_report import SUSHIReport
30
+ from .sushi_report_header import SUSHIReportHeader
31
+ from .sushi_report_header_report_attributes_item import (
32
+ SUSHIReportHeaderReportAttributesItem,
33
+ )
34
+ from .sushi_report_header_report_filters_item import SUSHIReportHeaderReportFiltersItem
35
+ from .sushi_report_list import SUSHIReportList
36
+ from .sushi_report_page import SUSHIReportPage
37
+ from .sushi_service_status import SUSHIServiceStatus
38
+ from .sushi_service_status_alerts_item import SUSHIServiceStatusAlertsItem
39
+
40
+ __all__ = (
41
+ "APIResultMetricsResult",
42
+ "APIResultSearchResult",
43
+ "COUNTERDatasetAttributes",
44
+ "COUNTERDatasetAttributesType",
45
+ "COUNTERDatasetContributors",
46
+ "COUNTERDatasetContributorsType",
47
+ "COUNTERDatasetDates",
48
+ "COUNTERDatasetDatesType",
49
+ "COUNTERDatasetIdentifiers",
50
+ "COUNTERDatasetIdentifiersType",
51
+ "COUNTERDatasetInstance",
52
+ "COUNTERDatasetInstanceAccessMethod",
53
+ "COUNTERDatasetInstanceMetricType",
54
+ "COUNTERDatasetPerformance",
55
+ "COUNTERDatasetPeriod",
56
+ "COUNTERDatasetReport",
57
+ "COUNTERDatasetUsage",
58
+ "COUNTERDatasetUsageDataType",
59
+ "COUNTERPublisherIdentifiers",
60
+ "COUNTERPublisherIdentifiersType",
61
+ "MetricsResult",
62
+ "SearchRecord",
63
+ "SearchResult",
64
+ "SUSHIErrorModel",
65
+ "SUSHIErrorModelSeverity",
66
+ "SUSHIPageMeta",
67
+ "SUSHIReport",
68
+ "SUSHIReportHeader",
69
+ "SUSHIReportHeaderReportAttributesItem",
70
+ "SUSHIReportHeaderReportFiltersItem",
71
+ "SUSHIReportList",
72
+ "SUSHIReportPage",
73
+ "SUSHIServiceStatus",
74
+ "SUSHIServiceStatusAlertsItem",
75
+ )
@@ -0,0 +1,99 @@
1
+ from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union
2
+
3
+ from attrs import define as _attrs_define
4
+ from attrs import field as _attrs_field
5
+
6
+ from ..types import UNSET, Unset
7
+
8
+ if TYPE_CHECKING:
9
+ from ..models.metrics_result import MetricsResult
10
+
11
+
12
+ T = TypeVar("T", bound="APIResultMetricsResult")
13
+
14
+
15
+ @_attrs_define
16
+ class APIResultMetricsResult:
17
+ """the api result model
18
+
19
+ Attributes:
20
+ code (Union[Unset, int]): 20000 means success, other means error
21
+ message (Union[Unset, str]): code's description in Chinese
22
+ get_message_en (Union[Unset, str]): code's description in English
23
+ data (Union[Unset, MetricsResult]): wrapper of records of '/harvest' and '/search' and '/metrics' API
24
+ """
25
+
26
+ code: Union[Unset, int] = UNSET
27
+ message: Union[Unset, str] = UNSET
28
+ get_message_en: Union[Unset, str] = UNSET
29
+ data: Union[Unset, "MetricsResult"] = UNSET
30
+ additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
31
+
32
+ def to_dict(self) -> Dict[str, Any]:
33
+ code = self.code
34
+
35
+ message = self.message
36
+
37
+ get_message_en = self.get_message_en
38
+
39
+ data: Union[Unset, Dict[str, Any]] = UNSET
40
+ if not isinstance(self.data, Unset):
41
+ data = self.data.to_dict()
42
+
43
+ field_dict: Dict[str, Any] = {}
44
+ field_dict.update(self.additional_properties)
45
+ field_dict.update({})
46
+ if code is not UNSET:
47
+ field_dict["code"] = code
48
+ if message is not UNSET:
49
+ field_dict["message"] = message
50
+ if get_message_en is not UNSET:
51
+ field_dict["getMessageEn"] = get_message_en
52
+ if data is not UNSET:
53
+ field_dict["data"] = data
54
+
55
+ return field_dict
56
+
57
+ @classmethod
58
+ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
59
+ from ..models.metrics_result import MetricsResult
60
+
61
+ d = src_dict.copy()
62
+ code = d.pop("code", UNSET)
63
+
64
+ message = d.pop("message", UNSET)
65
+
66
+ get_message_en = d.pop("getMessageEn", UNSET)
67
+
68
+ _data = d.pop("data", UNSET)
69
+ data: Union[Unset, MetricsResult]
70
+ if isinstance(_data, Unset):
71
+ data = UNSET
72
+ else:
73
+ data = MetricsResult.from_dict(_data)
74
+
75
+ api_result_metrics_result = cls(
76
+ code=code,
77
+ message=message,
78
+ get_message_en=get_message_en,
79
+ data=data,
80
+ )
81
+
82
+ api_result_metrics_result.additional_properties = d
83
+ return api_result_metrics_result
84
+
85
+ @property
86
+ def additional_keys(self) -> List[str]:
87
+ return list(self.additional_properties.keys())
88
+
89
+ def __getitem__(self, key: str) -> Any:
90
+ return self.additional_properties[key]
91
+
92
+ def __setitem__(self, key: str, value: Any) -> None:
93
+ self.additional_properties[key] = value
94
+
95
+ def __delitem__(self, key: str) -> None:
96
+ del self.additional_properties[key]
97
+
98
+ def __contains__(self, key: str) -> bool:
99
+ return key in self.additional_properties
@@ -0,0 +1,99 @@
1
+ from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union
2
+
3
+ from attrs import define as _attrs_define
4
+ from attrs import field as _attrs_field
5
+
6
+ from ..types import UNSET, Unset
7
+
8
+ if TYPE_CHECKING:
9
+ from ..models.search_result import SearchResult
10
+
11
+
12
+ T = TypeVar("T", bound="APIResultSearchResult")
13
+
14
+
15
+ @_attrs_define
16
+ class APIResultSearchResult:
17
+ """the api result model
18
+
19
+ Attributes:
20
+ code (Union[Unset, int]): 20000 means success, other means error
21
+ message (Union[Unset, str]): code's description in Chinese
22
+ get_message_en (Union[Unset, str]): code's description in English
23
+ data (Union[Unset, SearchResult]): wrapper of records of '/harvest' and '/search' API
24
+ """
25
+
26
+ code: Union[Unset, int] = UNSET
27
+ message: Union[Unset, str] = UNSET
28
+ get_message_en: Union[Unset, str] = UNSET
29
+ data: Union[Unset, "SearchResult"] = UNSET
30
+ additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
31
+
32
+ def to_dict(self) -> Dict[str, Any]:
33
+ code = self.code
34
+
35
+ message = self.message
36
+
37
+ get_message_en = self.get_message_en
38
+
39
+ data: Union[Unset, Dict[str, Any]] = UNSET
40
+ if not isinstance(self.data, Unset):
41
+ data = self.data.to_dict()
42
+
43
+ field_dict: Dict[str, Any] = {}
44
+ field_dict.update(self.additional_properties)
45
+ field_dict.update({})
46
+ if code is not UNSET:
47
+ field_dict["code"] = code
48
+ if message is not UNSET:
49
+ field_dict["message"] = message
50
+ if get_message_en is not UNSET:
51
+ field_dict["getMessageEn"] = get_message_en
52
+ if data is not UNSET:
53
+ field_dict["data"] = data
54
+
55
+ return field_dict
56
+
57
+ @classmethod
58
+ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
59
+ from ..models.search_result import SearchResult
60
+
61
+ d = src_dict.copy()
62
+ code = d.pop("code", UNSET)
63
+
64
+ message = d.pop("message", UNSET)
65
+
66
+ get_message_en = d.pop("getMessageEn", UNSET)
67
+
68
+ _data = d.pop("data", UNSET)
69
+ data: Union[Unset, SearchResult]
70
+ if isinstance(_data, Unset):
71
+ data = UNSET
72
+ else:
73
+ data = SearchResult.from_dict(_data)
74
+
75
+ api_result_search_result = cls(
76
+ code=code,
77
+ message=message,
78
+ get_message_en=get_message_en,
79
+ data=data,
80
+ )
81
+
82
+ api_result_search_result.additional_properties = d
83
+ return api_result_search_result
84
+
85
+ @property
86
+ def additional_keys(self) -> List[str]:
87
+ return list(self.additional_properties.keys())
88
+
89
+ def __getitem__(self, key: str) -> Any:
90
+ return self.additional_properties[key]
91
+
92
+ def __setitem__(self, key: str, value: Any) -> None:
93
+ self.additional_properties[key] = value
94
+
95
+ def __delitem__(self, key: str) -> None:
96
+ del self.additional_properties[key]
97
+
98
+ def __contains__(self, key: str) -> bool:
99
+ return key in self.additional_properties
@@ -0,0 +1,69 @@
1
+ from typing import Any, Dict, List, Type, TypeVar
2
+
3
+ from attrs import define as _attrs_define
4
+ from attrs import field as _attrs_field
5
+
6
+ from ..models.counter_dataset_attributes_type import COUNTERDatasetAttributesType
7
+
8
+ T = TypeVar("T", bound="COUNTERDatasetAttributes")
9
+
10
+
11
+ @_attrs_define
12
+ class COUNTERDatasetAttributes:
13
+ """
14
+ Attributes:
15
+ type (COUNTERDatasetAttributesType): Item attribute types are defined by NISO Journal Article Version and other
16
+ work... Example: dataset-version.
17
+ value (str): Value of the item attribute Example: VoR.
18
+ """
19
+
20
+ type: COUNTERDatasetAttributesType
21
+ value: str
22
+ additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict)
23
+
24
+ def to_dict(self) -> Dict[str, Any]:
25
+ type = self.type.value
26
+
27
+ value = self.value
28
+
29
+ field_dict: Dict[str, Any] = {}
30
+ field_dict.update(self.additional_properties)
31
+ field_dict.update(
32
+ {
33
+ "Type": type,
34
+ "Value": value,
35
+ }
36
+ )
37
+
38
+ return field_dict
39
+
40
+ @classmethod
41
+ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
42
+ d = src_dict.copy()
43
+ type = COUNTERDatasetAttributesType(d.pop("Type"))
44
+
45
+ value = d.pop("Value")
46
+
47
+ counter_dataset_attributes = cls(
48
+ type=type,
49
+ value=value,
50
+ )
51
+
52
+ counter_dataset_attributes.additional_properties = d
53
+ return counter_dataset_attributes
54
+
55
+ @property
56
+ def additional_keys(self) -> List[str]:
57
+ return list(self.additional_properties.keys())
58
+
59
+ def __getitem__(self, key: str) -> Any:
60
+ return self.additional_properties[key]
61
+
62
+ def __setitem__(self, key: str, value: Any) -> None:
63
+ self.additional_properties[key] = value
64
+
65
+ def __delitem__(self, key: str) -> None:
66
+ del self.additional_properties[key]
67
+
68
+ def __contains__(self, key: str) -> bool:
69
+ return key in self.additional_properties
@@ -0,0 +1,10 @@
1
+ from enum import Enum
2
+
3
+
4
+ class COUNTERDatasetAttributesType(str, Enum):
5
+ DATASET_TYPE = "dataset=-type"
6
+ DATASET_VERSION = "dataset-version"
7
+ PROPRIETARY = "proprietary"
8
+
9
+ def __str__(self) -> str:
10
+ return str(self.value)