dapla-toolbelt-metadata 0.2.1__py3-none-any.whl → 0.9.11__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.

Potentially problematic release.


This version of dapla-toolbelt-metadata might be problematic. Click here for more details.

Files changed (97) hide show
  1. dapla_metadata/__init__.py +11 -1
  2. dapla_metadata/_shared/__init__.py +1 -0
  3. dapla_metadata/_shared/config.py +109 -0
  4. dapla_metadata/_shared/enums.py +27 -0
  5. dapla_metadata/_shared/py.typed +0 -0
  6. dapla_metadata/dapla/__init__.py +4 -0
  7. dapla_metadata/dapla/user_info.py +138 -0
  8. dapla_metadata/datasets/__init__.py +1 -1
  9. dapla_metadata/datasets/_merge.py +333 -0
  10. dapla_metadata/datasets/code_list.py +5 -6
  11. dapla_metadata/datasets/compatibility/__init__.py +10 -0
  12. dapla_metadata/datasets/compatibility/_handlers.py +363 -0
  13. dapla_metadata/datasets/compatibility/_utils.py +259 -0
  14. dapla_metadata/datasets/compatibility/model_backwards_compatibility.py +135 -0
  15. dapla_metadata/datasets/core.py +136 -182
  16. dapla_metadata/datasets/dapla_dataset_path_info.py +145 -19
  17. dapla_metadata/datasets/dataset_parser.py +41 -28
  18. dapla_metadata/datasets/model_validation.py +29 -20
  19. dapla_metadata/datasets/statistic_subject_mapping.py +5 -1
  20. dapla_metadata/datasets/utility/constants.py +22 -15
  21. dapla_metadata/datasets/utility/enums.py +8 -20
  22. dapla_metadata/datasets/utility/urn.py +234 -0
  23. dapla_metadata/datasets/utility/utils.py +183 -111
  24. dapla_metadata/standards/__init__.py +4 -0
  25. dapla_metadata/standards/name_validator.py +250 -0
  26. dapla_metadata/standards/standard_validators.py +98 -0
  27. dapla_metadata/standards/utils/__init__.py +1 -0
  28. dapla_metadata/standards/utils/constants.py +49 -0
  29. dapla_metadata/variable_definitions/__init__.py +11 -0
  30. dapla_metadata/variable_definitions/_generated/.openapi-generator/FILES +20 -0
  31. dapla_metadata/variable_definitions/_generated/.openapi-generator/VERSION +1 -0
  32. dapla_metadata/variable_definitions/_generated/.openapi-generator-ignore +6 -0
  33. dapla_metadata/variable_definitions/_generated/README.md +148 -0
  34. dapla_metadata/variable_definitions/_generated/__init__.py +0 -0
  35. dapla_metadata/variable_definitions/_generated/vardef_client/__init__.py +47 -0
  36. dapla_metadata/variable_definitions/_generated/vardef_client/api/__init__.py +8 -0
  37. dapla_metadata/variable_definitions/_generated/vardef_client/api/data_migration_api.py +766 -0
  38. dapla_metadata/variable_definitions/_generated/vardef_client/api/draft_variable_definitions_api.py +888 -0
  39. dapla_metadata/variable_definitions/_generated/vardef_client/api/patches_api.py +888 -0
  40. dapla_metadata/variable_definitions/_generated/vardef_client/api/validity_periods_api.py +583 -0
  41. dapla_metadata/variable_definitions/_generated/vardef_client/api/variable_definitions_api.py +613 -0
  42. dapla_metadata/variable_definitions/_generated/vardef_client/api_client.py +779 -0
  43. dapla_metadata/variable_definitions/_generated/vardef_client/api_response.py +27 -0
  44. dapla_metadata/variable_definitions/_generated/vardef_client/configuration.py +474 -0
  45. dapla_metadata/variable_definitions/_generated/vardef_client/docs/CompleteResponse.md +51 -0
  46. dapla_metadata/variable_definitions/_generated/vardef_client/docs/Contact.md +30 -0
  47. dapla_metadata/variable_definitions/_generated/vardef_client/docs/DataMigrationApi.md +90 -0
  48. dapla_metadata/variable_definitions/_generated/vardef_client/docs/Draft.md +42 -0
  49. dapla_metadata/variable_definitions/_generated/vardef_client/docs/DraftVariableDefinitionsApi.md +259 -0
  50. dapla_metadata/variable_definitions/_generated/vardef_client/docs/LanguageStringType.md +31 -0
  51. dapla_metadata/variable_definitions/_generated/vardef_client/docs/Owner.md +31 -0
  52. dapla_metadata/variable_definitions/_generated/vardef_client/docs/Patch.md +43 -0
  53. dapla_metadata/variable_definitions/_generated/vardef_client/docs/PatchesApi.md +249 -0
  54. dapla_metadata/variable_definitions/_generated/vardef_client/docs/PublicApi.md +218 -0
  55. dapla_metadata/variable_definitions/_generated/vardef_client/docs/SupportedLanguages.md +15 -0
  56. dapla_metadata/variable_definitions/_generated/vardef_client/docs/UpdateDraft.md +44 -0
  57. dapla_metadata/variable_definitions/_generated/vardef_client/docs/ValidityPeriod.md +42 -0
  58. dapla_metadata/variable_definitions/_generated/vardef_client/docs/ValidityPeriodsApi.md +236 -0
  59. dapla_metadata/variable_definitions/_generated/vardef_client/docs/VariableDefinitionsApi.md +304 -0
  60. dapla_metadata/variable_definitions/_generated/vardef_client/docs/VariableStatus.md +17 -0
  61. dapla_metadata/variable_definitions/_generated/vardef_client/exceptions.py +193 -0
  62. dapla_metadata/variable_definitions/_generated/vardef_client/models/__init__.py +31 -0
  63. dapla_metadata/variable_definitions/_generated/vardef_client/models/complete_response.py +260 -0
  64. dapla_metadata/variable_definitions/_generated/vardef_client/models/contact.py +94 -0
  65. dapla_metadata/variable_definitions/_generated/vardef_client/models/draft.py +228 -0
  66. dapla_metadata/variable_definitions/_generated/vardef_client/models/get_vardok_vardef_mapping_by_id200_response.py +158 -0
  67. dapla_metadata/variable_definitions/_generated/vardef_client/models/language_string_type.py +101 -0
  68. dapla_metadata/variable_definitions/_generated/vardef_client/models/owner.py +87 -0
  69. dapla_metadata/variable_definitions/_generated/vardef_client/models/patch.py +244 -0
  70. dapla_metadata/variable_definitions/_generated/vardef_client/models/problem.py +118 -0
  71. dapla_metadata/variable_definitions/_generated/vardef_client/models/update_draft.py +274 -0
  72. dapla_metadata/variable_definitions/_generated/vardef_client/models/validity_period.py +225 -0
  73. dapla_metadata/variable_definitions/_generated/vardef_client/models/vardok_id_response.py +81 -0
  74. dapla_metadata/variable_definitions/_generated/vardef_client/models/vardok_vardef_id_pair_response.py +84 -0
  75. dapla_metadata/variable_definitions/_generated/vardef_client/models/variable_status.py +33 -0
  76. dapla_metadata/variable_definitions/_generated/vardef_client/py.typed +0 -0
  77. dapla_metadata/variable_definitions/_generated/vardef_client/rest.py +249 -0
  78. dapla_metadata/variable_definitions/_utils/__init__.py +1 -0
  79. dapla_metadata/variable_definitions/_utils/_client.py +32 -0
  80. dapla_metadata/variable_definitions/_utils/config.py +54 -0
  81. dapla_metadata/variable_definitions/_utils/constants.py +80 -0
  82. dapla_metadata/variable_definitions/_utils/files.py +309 -0
  83. dapla_metadata/variable_definitions/_utils/template_files.py +99 -0
  84. dapla_metadata/variable_definitions/_utils/variable_definition_files.py +143 -0
  85. dapla_metadata/variable_definitions/exceptions.py +255 -0
  86. dapla_metadata/variable_definitions/vardef.py +372 -0
  87. dapla_metadata/variable_definitions/vardok_id.py +48 -0
  88. dapla_metadata/variable_definitions/vardok_vardef_id_pair.py +47 -0
  89. dapla_metadata/variable_definitions/variable_definition.py +422 -0
  90. {dapla_toolbelt_metadata-0.2.1.dist-info → dapla_toolbelt_metadata-0.9.11.dist-info}/METADATA +34 -36
  91. dapla_toolbelt_metadata-0.9.11.dist-info/RECORD +97 -0
  92. {dapla_toolbelt_metadata-0.2.1.dist-info → dapla_toolbelt_metadata-0.9.11.dist-info}/WHEEL +1 -1
  93. dapla_metadata/datasets/config.py +0 -80
  94. dapla_metadata/datasets/model_backwards_compatibility.py +0 -520
  95. dapla_metadata/datasets/user_info.py +0 -88
  96. dapla_toolbelt_metadata-0.2.1.dist-info/RECORD +0 -22
  97. {dapla_toolbelt_metadata-0.2.1.dist-info → dapla_toolbelt_metadata-0.9.11.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,304 @@
1
+ # vardef_client.VariableDefinitionsApi
2
+
3
+ All URIs are relative to *https://metadata.intern.test.ssb.no*
4
+
5
+ Method | HTTP request | Description
6
+ ------------- | ------------- | -------------
7
+ [**get_public_variable_definition_by_id_0**](VariableDefinitionsApi.md#get_public_variable_definition_by_id_0) | **GET** /public/variable-definitions/{variable-definition-id} | Get one variable definition.
8
+ [**get_variable_definition_by_id**](VariableDefinitionsApi.md#get_variable_definition_by_id) | **GET** /variable-definitions/{variable-definition-id} | Get one variable definition.
9
+ [**list_public_variable_definitions_0**](VariableDefinitionsApi.md#list_public_variable_definitions_0) | **GET** /public/variable-definitions | List all variable definitions.
10
+ [**list_variable_definitions**](VariableDefinitionsApi.md#list_variable_definitions) | **GET** /variable-definitions | List all variable definitions.
11
+
12
+
13
+ # **get_public_variable_definition_by_id_0**
14
+ > get_public_variable_definition_by_id_0(variable_definition_id, accept_language, date_of_validity=date_of_validity)
15
+
16
+ Get one variable definition.
17
+
18
+ Get one variable definition. This is rendered in the given language, with the default being Norwegian Bokmål.
19
+
20
+ ### Example
21
+
22
+
23
+ ```python
24
+ import vardef_client
25
+ from vardef_client.models.supported_languages import SupportedLanguages
26
+ from vardef_client.rest import ApiException
27
+ from pprint import pprint
28
+
29
+ # Defining the host is optional and defaults to https://metadata.intern.test.ssb.no
30
+ # See configuration.py for a list of all supported configuration parameters.
31
+ configuration = vardef_client.Configuration(
32
+ host = "https://metadata.intern.test.ssb.no"
33
+ )
34
+
35
+
36
+ # Enter a context with an instance of the API client
37
+ with vardef_client.ApiClient(configuration) as api_client:
38
+ # Create an instance of the API class
39
+ api_instance = vardef_client.VariableDefinitionsApi(api_client)
40
+ variable_definition_id = 'wypvb3wd' # str | Unique identifier for the variable definition.
41
+ accept_language = vardef_client.SupportedLanguages() # SupportedLanguages | Render the variable definition in the given language.
42
+ date_of_validity = '' # date | List only variable definitions which are valid on this date. (optional)
43
+
44
+ try:
45
+ # Get one variable definition.
46
+ api_instance.get_public_variable_definition_by_id_0(variable_definition_id, accept_language, date_of_validity=date_of_validity)
47
+ except Exception as e:
48
+ print("Exception when calling VariableDefinitionsApi->get_public_variable_definition_by_id_0: %s\n" % e)
49
+ ```
50
+
51
+
52
+
53
+ ### Parameters
54
+
55
+
56
+ Name | Type | Description | Notes
57
+ ------------- | ------------- | ------------- | -------------
58
+ **variable_definition_id** | **str**| Unique identifier for the variable definition. |
59
+ **accept_language** | [**SupportedLanguages**](.md)| Render the variable definition in the given language. |
60
+ **date_of_validity** | **date**| List only variable definitions which are valid on this date. | [optional]
61
+
62
+ ### Return type
63
+
64
+ void (empty response body)
65
+
66
+ ### Authorization
67
+
68
+ No authorization required
69
+
70
+ ### HTTP request headers
71
+
72
+ - **Content-Type**: Not defined
73
+ - **Accept**: application/json
74
+
75
+ ### HTTP response details
76
+
77
+ | Status code | Description | Response headers |
78
+ |-------------|-------------|------------------|
79
+ **200** | Ok | - |
80
+ **404** | No such variable definition found | - |
81
+
82
+ [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
83
+
84
+ # **get_variable_definition_by_id**
85
+ > get_variable_definition_by_id(variable_definition_id, date_of_validity=date_of_validity)
86
+
87
+ Get one variable definition.
88
+
89
+ Get one variable definition.
90
+
91
+ ### Example
92
+
93
+ * Bearer (JWT) Authentication (Keycloak token):
94
+
95
+ ```python
96
+ import vardef_client
97
+ from vardef_client.rest import ApiException
98
+ from pprint import pprint
99
+
100
+ # Defining the host is optional and defaults to https://metadata.intern.test.ssb.no
101
+ # See configuration.py for a list of all supported configuration parameters.
102
+ configuration = vardef_client.Configuration(
103
+ host = "https://metadata.intern.test.ssb.no"
104
+ )
105
+
106
+ # The client must configure the authentication and authorization parameters
107
+ # in accordance with the API server security policy.
108
+ # Examples for each auth method are provided below, use the example that
109
+ # satisfies your auth use case.
110
+
111
+ # Configure Bearer authorization (JWT): Keycloak token
112
+ configuration = vardef_client.Configuration(
113
+ access_token = os.environ["BEARER_TOKEN"]
114
+ )
115
+
116
+ # Enter a context with an instance of the API client
117
+ with vardef_client.ApiClient(configuration) as api_client:
118
+ # Create an instance of the API class
119
+ api_instance = vardef_client.VariableDefinitionsApi(api_client)
120
+ variable_definition_id = 'wypvb3wd' # str | Unique identifier for the variable definition.
121
+ date_of_validity = '' # date | List only variable definitions which are valid on this date. (optional)
122
+
123
+ try:
124
+ # Get one variable definition.
125
+ api_instance.get_variable_definition_by_id(variable_definition_id, date_of_validity=date_of_validity)
126
+ except Exception as e:
127
+ print("Exception when calling VariableDefinitionsApi->get_variable_definition_by_id: %s\n" % e)
128
+ ```
129
+
130
+
131
+
132
+ ### Parameters
133
+
134
+
135
+ Name | Type | Description | Notes
136
+ ------------- | ------------- | ------------- | -------------
137
+ **variable_definition_id** | **str**| Unique identifier for the variable definition. |
138
+ **date_of_validity** | **date**| List only variable definitions which are valid on this date. | [optional]
139
+
140
+ ### Return type
141
+
142
+ void (empty response body)
143
+
144
+ ### Authorization
145
+
146
+ [Keycloak token](../README.md#Keycloak token)
147
+
148
+ ### HTTP request headers
149
+
150
+ - **Content-Type**: Not defined
151
+ - **Accept**: application/json
152
+
153
+ ### HTTP response details
154
+
155
+ | Status code | Description | Response headers |
156
+ |-------------|-------------|------------------|
157
+ **200** | Ok | - |
158
+ **404** | No such variable definition found | - |
159
+
160
+ [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
161
+
162
+ # **list_public_variable_definitions_0**
163
+ > list_public_variable_definitions_0(accept_language, date_of_validity=date_of_validity)
164
+
165
+ List all variable definitions.
166
+
167
+ List all variable definitions. These are rendered in the given language, with the default being Norwegian Bokmål.
168
+
169
+ ### Example
170
+
171
+
172
+ ```python
173
+ import vardef_client
174
+ from vardef_client.models.supported_languages import SupportedLanguages
175
+ from vardef_client.rest import ApiException
176
+ from pprint import pprint
177
+
178
+ # Defining the host is optional and defaults to https://metadata.intern.test.ssb.no
179
+ # See configuration.py for a list of all supported configuration parameters.
180
+ configuration = vardef_client.Configuration(
181
+ host = "https://metadata.intern.test.ssb.no"
182
+ )
183
+
184
+
185
+ # Enter a context with an instance of the API client
186
+ with vardef_client.ApiClient(configuration) as api_client:
187
+ # Create an instance of the API class
188
+ api_instance = vardef_client.VariableDefinitionsApi(api_client)
189
+ accept_language = vardef_client.SupportedLanguages() # SupportedLanguages | Render the variable definition in the given language.
190
+ date_of_validity = '' # str | List only variable definitions which are valid on this date. (optional)
191
+
192
+ try:
193
+ # List all variable definitions.
194
+ api_instance.list_public_variable_definitions_0(accept_language, date_of_validity=date_of_validity)
195
+ except Exception as e:
196
+ print("Exception when calling VariableDefinitionsApi->list_public_variable_definitions_0: %s\n" % e)
197
+ ```
198
+
199
+
200
+
201
+ ### Parameters
202
+
203
+
204
+ Name | Type | Description | Notes
205
+ ------------- | ------------- | ------------- | -------------
206
+ **accept_language** | [**SupportedLanguages**](.md)| Render the variable definition in the given language. |
207
+ **date_of_validity** | **str**| List only variable definitions which are valid on this date. | [optional]
208
+
209
+ ### Return type
210
+
211
+ void (empty response body)
212
+
213
+ ### Authorization
214
+
215
+ No authorization required
216
+
217
+ ### HTTP request headers
218
+
219
+ - **Content-Type**: Not defined
220
+ - **Accept**: application/json
221
+
222
+ ### HTTP response details
223
+
224
+ | Status code | Description | Response headers |
225
+ |-------------|-------------|------------------|
226
+ **200** | OK response | - |
227
+
228
+ [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
229
+
230
+ # **list_variable_definitions**
231
+ > list_variable_definitions(date_of_validity=date_of_validity)
232
+
233
+ List all variable definitions.
234
+
235
+ List all variable definitions.
236
+
237
+ ### Example
238
+
239
+ * Bearer (JWT) Authentication (Keycloak token):
240
+
241
+ ```python
242
+ import vardef_client
243
+ from vardef_client.rest import ApiException
244
+ from pprint import pprint
245
+
246
+ # Defining the host is optional and defaults to https://metadata.intern.test.ssb.no
247
+ # See configuration.py for a list of all supported configuration parameters.
248
+ configuration = vardef_client.Configuration(
249
+ host = "https://metadata.intern.test.ssb.no"
250
+ )
251
+
252
+ # The client must configure the authentication and authorization parameters
253
+ # in accordance with the API server security policy.
254
+ # Examples for each auth method are provided below, use the example that
255
+ # satisfies your auth use case.
256
+
257
+ # Configure Bearer authorization (JWT): Keycloak token
258
+ configuration = vardef_client.Configuration(
259
+ access_token = os.environ["BEARER_TOKEN"]
260
+ )
261
+
262
+ # Enter a context with an instance of the API client
263
+ with vardef_client.ApiClient(configuration) as api_client:
264
+ # Create an instance of the API class
265
+ api_instance = vardef_client.VariableDefinitionsApi(api_client)
266
+ date_of_validity = '' # str | List only variable definitions which are valid on this date. (optional)
267
+
268
+ try:
269
+ # List all variable definitions.
270
+ api_instance.list_variable_definitions(date_of_validity=date_of_validity)
271
+ except Exception as e:
272
+ print("Exception when calling VariableDefinitionsApi->list_variable_definitions: %s\n" % e)
273
+ ```
274
+
275
+
276
+
277
+ ### Parameters
278
+
279
+
280
+ Name | Type | Description | Notes
281
+ ------------- | ------------- | ------------- | -------------
282
+ **date_of_validity** | **str**| List only variable definitions which are valid on this date. | [optional]
283
+
284
+ ### Return type
285
+
286
+ void (empty response body)
287
+
288
+ ### Authorization
289
+
290
+ [Keycloak token](../README.md#Keycloak token)
291
+
292
+ ### HTTP request headers
293
+
294
+ - **Content-Type**: Not defined
295
+ - **Accept**: application/json
296
+
297
+ ### HTTP response details
298
+
299
+ | Status code | Description | Response headers |
300
+ |-------------|-------------|------------------|
301
+ **200** | OK response | - |
302
+
303
+ [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
304
+
@@ -0,0 +1,17 @@
1
+ # VariableStatus
2
+
3
+ Life cycle status of a variable definition.
4
+
5
+ ## Enum
6
+
7
+ * `DRAFT` (value: `'DRAFT'`)
8
+
9
+ * `PUBLISHED_INTERNAL` (value: `'PUBLISHED_INTERNAL'`)
10
+
11
+ * `PUBLISHED_EXTERNAL` (value: `'PUBLISHED_EXTERNAL'`)
12
+
13
+ * `DEPRECATED` (value: `'DEPRECATED'`)
14
+
15
+ [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
16
+
17
+
@@ -0,0 +1,193 @@
1
+ """Variable Definitions
2
+
3
+ ## Introduction Variable Definitions are centralized definitions of concrete variables which are typically present in multiple datasets. Variable Definitions support standardization of data and metadata and facilitate sharing and joining of data by clarifying when variables have an identical definition. ## Maintenance of Variable Definitions This API allows for creation, maintenance and access of Variable Definitions. ### Ownership Creation and maintenance of variables may only be performed by Statistics Norway employees representing a specific Dapla team, who are defined as the owners of a given Variable Definition. The team an owner represents must be specified when making a request through the `active_group` query parameter. All maintenance is to be performed by the owners, with no intervention from administrators. ### Status All Variable Definitions have an associated status. The possible values for status are `DRAFT`, `PUBLISHED_INTERNAL` and `PUBLISHED_EXTERNAL`. #### Draft When a Variable Definition is created it is assigned the status `DRAFT`. Under this status the Variable Definition is: - Only visible to Statistics Norway employees. - Mutable (it may be changed directly without need for versioning). - Not suitable to refer to from other systems. This status may be changed to `PUBLISHED_INTERNAL` or `PUBLISHED_EXTERNAL` with a direct update. #### Published Internal Under this status the Variable Definition is: - Only visible to Statistics Norway employees. - Immutable (all changes are versioned). - Suitable to refer to in internal systems for statistics production. - Not suitable to refer to for external use (for example in Statistikkbanken). This status may be changed to `PUBLISHED_EXTERNAL` by creating a Patch version. #### Published External Under this status the Variable Definition is: - Visible to the general public. - Immutable (all changes are versioned). - Suitable to refer to from any system. This status may not be changed as it would break immutability. If a Variable Definition is no longer relevant then its period of validity should be ended by specifying a `valid_until` date in a Patch version. ### Immutability Variable Definitions are immutable. This means that any changes must be performed in a strict versioning system. Consumers can avoid being exposed to breaking changes by specifying a `date_of_validity` when they request a Variable Definition. #### Patches Patches are for changes which do not affect the fundamental meaning of the Variable Definition. #### Validity Periods Validity Periods are versions with a period defined by a `valid_from` date and optionally a `valid_until` date. If the fundamental meaning of a Variable Definition is to be changed, it should be done by creating a new Validity Period.
4
+
5
+ The version of the OpenAPI document: 0.1
6
+ Contact: metadata@ssb.no
7
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
8
+
9
+ Do not edit the class manually.
10
+ """
11
+
12
+ from typing import Any
13
+
14
+ from typing_extensions import Self
15
+
16
+
17
+ class OpenApiException(Exception):
18
+ """The base exception class for all OpenAPIExceptions"""
19
+
20
+
21
+ class ApiTypeError(OpenApiException, TypeError):
22
+ def __init__(
23
+ self, msg, path_to_item=None, valid_classes=None, key_type=None
24
+ ) -> None:
25
+ """Raises an exception for TypeErrors
26
+
27
+ Args:
28
+ msg (str): the exception message
29
+
30
+ Keyword Args:
31
+ path_to_item (list): a list of keys an indices to get to the
32
+ current_item
33
+ None if unset
34
+ valid_classes (tuple): the primitive classes that current item
35
+ should be an instance of
36
+ None if unset
37
+ key_type (bool): False if our value is a value in a dict
38
+ True if it is a key in a dict
39
+ False if our item is an item in a list
40
+ None if unset
41
+ """
42
+ self.path_to_item = path_to_item
43
+ self.valid_classes = valid_classes
44
+ self.key_type = key_type
45
+ full_msg = msg
46
+ if path_to_item:
47
+ full_msg = f"{msg} at {render_path(path_to_item)}"
48
+ super(ApiTypeError, self).__init__(full_msg)
49
+
50
+
51
+ class ApiValueError(OpenApiException, ValueError):
52
+ def __init__(self, msg, path_to_item=None) -> None:
53
+ """Args:
54
+ msg (str): the exception message
55
+
56
+ Keyword Args:
57
+ path_to_item (list) the path to the exception in the
58
+ received_data dict. None if unset
59
+ """
60
+ self.path_to_item = path_to_item
61
+ full_msg = msg
62
+ if path_to_item:
63
+ full_msg = f"{msg} at {render_path(path_to_item)}"
64
+ super(ApiValueError, self).__init__(full_msg)
65
+
66
+
67
+ class ApiAttributeError(OpenApiException, AttributeError):
68
+ def __init__(self, msg, path_to_item=None) -> None:
69
+ """Raised when an attribute reference or assignment fails.
70
+
71
+ Args:
72
+ msg (str): the exception message
73
+
74
+ Keyword Args:
75
+ path_to_item (None/list) the path to the exception in the
76
+ received_data dict
77
+ """
78
+ self.path_to_item = path_to_item
79
+ full_msg = msg
80
+ if path_to_item:
81
+ full_msg = f"{msg} at {render_path(path_to_item)}"
82
+ super(ApiAttributeError, self).__init__(full_msg)
83
+
84
+
85
+ class ApiKeyError(OpenApiException, KeyError):
86
+ def __init__(self, msg, path_to_item=None) -> None:
87
+ """Args:
88
+ msg (str): the exception message
89
+
90
+ Keyword Args:
91
+ path_to_item (None/list) the path to the exception in the
92
+ received_data dict
93
+ """
94
+ self.path_to_item = path_to_item
95
+ full_msg = msg
96
+ if path_to_item:
97
+ full_msg = f"{msg} at {render_path(path_to_item)}"
98
+ super(ApiKeyError, self).__init__(full_msg)
99
+
100
+
101
+ class ApiException(OpenApiException):
102
+ def __init__(
103
+ self,
104
+ status=None,
105
+ reason=None,
106
+ http_resp=None,
107
+ *,
108
+ body: str | None = None,
109
+ data: Any | None = None,
110
+ ) -> None:
111
+ self.status = status
112
+ self.reason = reason
113
+ self.body = body
114
+ self.data = data
115
+ self.headers = None
116
+
117
+ if http_resp:
118
+ if self.status is None:
119
+ self.status = http_resp.status
120
+ if self.reason is None:
121
+ self.reason = http_resp.reason
122
+ if self.body is None:
123
+ try:
124
+ self.body = http_resp.data.decode("utf-8")
125
+ except Exception:
126
+ pass
127
+ self.headers = http_resp.getheaders()
128
+
129
+ @classmethod
130
+ def from_response(
131
+ cls,
132
+ *,
133
+ http_resp,
134
+ body: str | None,
135
+ data: Any | None,
136
+ ) -> Self:
137
+ if http_resp.status == 400:
138
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
139
+
140
+ if http_resp.status == 401:
141
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
142
+
143
+ if http_resp.status == 403:
144
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
145
+
146
+ if http_resp.status == 404:
147
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
148
+
149
+ if 500 <= http_resp.status <= 599:
150
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
151
+ raise ApiException(http_resp=http_resp, body=body, data=data)
152
+
153
+ def __str__(self):
154
+ """Custom error messages for exception"""
155
+ error_message = f"({self.status})\nReason: {self.reason}\n"
156
+ if self.headers:
157
+ error_message += f"HTTP response headers: {self.headers}\n"
158
+
159
+ if self.data or self.body:
160
+ error_message += f"HTTP response body: {self.data or self.body}\n"
161
+
162
+ return error_message
163
+
164
+
165
+ class BadRequestException(ApiException):
166
+ pass
167
+
168
+
169
+ class NotFoundException(ApiException):
170
+ pass
171
+
172
+
173
+ class UnauthorizedException(ApiException):
174
+ pass
175
+
176
+
177
+ class ForbiddenException(ApiException):
178
+ pass
179
+
180
+
181
+ class ServiceException(ApiException):
182
+ pass
183
+
184
+
185
+ def render_path(path_to_item):
186
+ """Returns a string representation of a path"""
187
+ result = ""
188
+ for pth in path_to_item:
189
+ if isinstance(pth, int):
190
+ result += f"[{pth}]"
191
+ else:
192
+ result += f"['{pth}']"
193
+ return result
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ Internal Variable Definitions Administration API
6
+
7
+ ## Introduction Variable Definitions are centralized definitions of concrete variables which are typically present in multiple datasets. Variable Definitions support standardization of data and metadata and facilitate sharing and joining of data by clarifying when variables have an identical definition. ## Maintenance of Variable Definitions This API allows for creation, maintenance and access of Variable Definitions. ### Ownership Creation and maintenance of variables may only be performed by Statistics Norway employees representing a specific Dapla team, who are defined as the owners of a given Variable Definition. The team an owner represents must be specified when making a request through the `active_group` query parameter. All maintenance is to be performed by the owners, with no intervention from administrators. ### Status All Variable Definitions have an associated status. The possible values for status are `DRAFT`, `PUBLISHED_INTERNAL` and `PUBLISHED_EXTERNAL`. #### Draft When a Variable Definition is created it is assigned the status `DRAFT`. Under this status the Variable Definition is: - Only visible to Statistics Norway employees. - Mutable (it may be changed directly without need for versioning). - Not suitable to refer to from other systems. This status may be changed to `PUBLISHED_INTERNAL` or `PUBLISHED_EXTERNAL` with a direct update. #### Published Internal Under this status the Variable Definition is: - Only visible to Statistics Norway employees. - Immutable (all changes are versioned). - Suitable to refer to in internal systems for statistics production. - Not suitable to refer to for external use (for example in Statistikkbanken). This status may be changed to `PUBLISHED_EXTERNAL` by creating a Patch version. #### Published External Under this status the Variable Definition is: - Visible to the general public. - Immutable (all changes are versioned). - Suitable to refer to from any system. This status may not be changed as it would break immutability. If a Variable Definition is no longer relevant then its period of validity should be ended by specifying a `valid_until` date in a Patch version. ### Immutability Variable Definitions are immutable. This means that any changes must be performed in a strict versioning system. Consumers can avoid being exposed to breaking changes by specifying a `date_of_validity` when they request a Variable Definition. #### Patches Patches are for changes which do not affect the fundamental meaning of the Variable Definition. #### Validity Periods Validity Periods are versions with a period defined by a `valid_from` date and optionally a `valid_until` date. If the fundamental meaning of a Variable Definition is to be changed, it should be done by creating a new Validity Period.
8
+
9
+ The version of the OpenAPI document: 0.1
10
+ Contact: metadata@ssb.no
11
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
12
+
13
+ Do not edit the class manually.
14
+ """ # noqa: E501
15
+
16
+ # import models into model package
17
+ from ..models.complete_response import CompleteResponse
18
+ from ..models.contact import Contact
19
+ from ..models.draft import Draft
20
+ from ..models.get_vardok_vardef_mapping_by_id200_response import (
21
+ GetVardokVardefMappingById200Response,
22
+ )
23
+ from ..models.language_string_type import LanguageStringType
24
+ from ..models.owner import Owner
25
+ from ..models.patch import Patch
26
+ from ..models.problem import Problem
27
+ from ..models.update_draft import UpdateDraft
28
+ from ..models.validity_period import ValidityPeriod
29
+ from ..models.vardok_id_response import VardokIdResponse
30
+ from ..models.vardok_vardef_id_pair_response import VardokVardefIdPairResponse
31
+ from ..models.variable_status import VariableStatus