dapla-toolbelt-metadata 0.3.0__py3-none-any.whl → 0.4.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.

Potentially problematic release.


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

Files changed (69) hide show
  1. dapla_metadata/__init__.py +1 -0
  2. dapla_metadata/_shared/__init__.py +1 -0
  3. dapla_metadata/{datasets → _shared}/config.py +39 -13
  4. dapla_metadata/_shared/enums.py +28 -0
  5. dapla_metadata/{datasets → _shared}/user_info.py +4 -4
  6. dapla_metadata/datasets/core.py +2 -2
  7. dapla_metadata/datasets/utility/enums.py +0 -19
  8. dapla_metadata/datasets/utility/utils.py +1 -1
  9. dapla_metadata/variable_definitions/__init__.py +7 -0
  10. dapla_metadata/variable_definitions/_client.py +30 -0
  11. dapla_metadata/variable_definitions/config.py +49 -0
  12. dapla_metadata/variable_definitions/exceptions.py +66 -0
  13. dapla_metadata/variable_definitions/generated/.openapi-generator/FILES +22 -0
  14. dapla_metadata/variable_definitions/generated/.openapi-generator/VERSION +1 -0
  15. dapla_metadata/variable_definitions/generated/.openapi-generator-ignore +6 -0
  16. dapla_metadata/variable_definitions/generated/README.md +148 -0
  17. dapla_metadata/variable_definitions/generated/__init__.py +0 -0
  18. dapla_metadata/variable_definitions/generated/vardef_client/__init__.py +52 -0
  19. dapla_metadata/variable_definitions/generated/vardef_client/api/__init__.py +9 -0
  20. dapla_metadata/variable_definitions/generated/vardef_client/api/data_migration_api.py +313 -0
  21. dapla_metadata/variable_definitions/generated/vardef_client/api/draft_variable_definitions_api.py +919 -0
  22. dapla_metadata/variable_definitions/generated/vardef_client/api/patches_api.py +919 -0
  23. dapla_metadata/variable_definitions/generated/vardef_client/api/public_api.py +915 -0
  24. dapla_metadata/variable_definitions/generated/vardef_client/api/validity_periods_api.py +876 -0
  25. dapla_metadata/variable_definitions/generated/vardef_client/api/variable_definitions_api.py +1205 -0
  26. dapla_metadata/variable_definitions/generated/vardef_client/api_client.py +779 -0
  27. dapla_metadata/variable_definitions/generated/vardef_client/api_response.py +27 -0
  28. dapla_metadata/variable_definitions/generated/vardef_client/configuration.py +474 -0
  29. dapla_metadata/variable_definitions/generated/vardef_client/docs/CompleteResponse.md +51 -0
  30. dapla_metadata/variable_definitions/generated/vardef_client/docs/Contact.md +30 -0
  31. dapla_metadata/variable_definitions/generated/vardef_client/docs/DataMigrationApi.md +90 -0
  32. dapla_metadata/variable_definitions/generated/vardef_client/docs/Draft.md +42 -0
  33. dapla_metadata/variable_definitions/generated/vardef_client/docs/DraftVariableDefinitionsApi.md +259 -0
  34. dapla_metadata/variable_definitions/generated/vardef_client/docs/LanguageStringType.md +31 -0
  35. dapla_metadata/variable_definitions/generated/vardef_client/docs/Owner.md +31 -0
  36. dapla_metadata/variable_definitions/generated/vardef_client/docs/Patch.md +43 -0
  37. dapla_metadata/variable_definitions/generated/vardef_client/docs/PatchesApi.md +249 -0
  38. dapla_metadata/variable_definitions/generated/vardef_client/docs/PublicApi.md +218 -0
  39. dapla_metadata/variable_definitions/generated/vardef_client/docs/SupportedLanguages.md +15 -0
  40. dapla_metadata/variable_definitions/generated/vardef_client/docs/UpdateDraft.md +44 -0
  41. dapla_metadata/variable_definitions/generated/vardef_client/docs/ValidityPeriod.md +42 -0
  42. dapla_metadata/variable_definitions/generated/vardef_client/docs/ValidityPeriodsApi.md +236 -0
  43. dapla_metadata/variable_definitions/generated/vardef_client/docs/VariableDefinitionsApi.md +304 -0
  44. dapla_metadata/variable_definitions/generated/vardef_client/docs/VariableStatus.md +17 -0
  45. dapla_metadata/variable_definitions/generated/vardef_client/exceptions.py +193 -0
  46. dapla_metadata/variable_definitions/generated/vardef_client/models/__init__.py +30 -0
  47. dapla_metadata/variable_definitions/generated/vardef_client/models/complete_response.py +284 -0
  48. dapla_metadata/variable_definitions/generated/vardef_client/models/contact.py +94 -0
  49. dapla_metadata/variable_definitions/generated/vardef_client/models/draft.py +243 -0
  50. dapla_metadata/variable_definitions/generated/vardef_client/models/klass_reference.py +99 -0
  51. dapla_metadata/variable_definitions/generated/vardef_client/models/language_string_type.py +104 -0
  52. dapla_metadata/variable_definitions/generated/vardef_client/models/owner.py +90 -0
  53. dapla_metadata/variable_definitions/generated/vardef_client/models/patch.py +289 -0
  54. dapla_metadata/variable_definitions/generated/vardef_client/models/problem.py +118 -0
  55. dapla_metadata/variable_definitions/generated/vardef_client/models/rendered_contact.py +92 -0
  56. dapla_metadata/variable_definitions/generated/vardef_client/models/rendered_variable_definition.py +235 -0
  57. dapla_metadata/variable_definitions/generated/vardef_client/models/supported_languages.py +33 -0
  58. dapla_metadata/variable_definitions/generated/vardef_client/models/update_draft.py +307 -0
  59. dapla_metadata/variable_definitions/generated/vardef_client/models/validity_period.py +259 -0
  60. dapla_metadata/variable_definitions/generated/vardef_client/models/variable_status.py +33 -0
  61. dapla_metadata/variable_definitions/generated/vardef_client/py.typed +0 -0
  62. dapla_metadata/variable_definitions/generated/vardef_client/rest.py +249 -0
  63. dapla_metadata/variable_definitions/vardef.py +173 -0
  64. dapla_metadata/variable_definitions/variable_definition.py +212 -0
  65. {dapla_toolbelt_metadata-0.3.0.dist-info → dapla_toolbelt_metadata-0.4.0.dist-info}/METADATA +1 -1
  66. dapla_toolbelt_metadata-0.4.0.dist-info/RECORD +80 -0
  67. dapla_toolbelt_metadata-0.3.0.dist-info/RECORD +0 -22
  68. {dapla_toolbelt_metadata-0.3.0.dist-info → dapla_toolbelt_metadata-0.4.0.dist-info}/LICENSE +0 -0
  69. {dapla_toolbelt_metadata-0.3.0.dist-info → dapla_toolbelt_metadata-0.4.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,118 @@
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 __future__ import annotations
13
+
14
+ import json
15
+ import pprint
16
+ import re # noqa: F401
17
+ from typing import Annotated
18
+ from typing import Any
19
+ from typing import ClassVar
20
+
21
+ from pydantic import BaseModel
22
+ from pydantic import ConfigDict
23
+ from pydantic import Field
24
+ from pydantic import StrictStr
25
+ from typing_extensions import Self
26
+
27
+
28
+ class Problem(BaseModel):
29
+ """Problem"""
30
+
31
+ type: StrictStr | None = Field(
32
+ default="about:blank",
33
+ description="A URI reference that uniquely identifies the problem type only in the context of the provided API. Opposed to the specification in RFC-9457, it is neither recommended to be dereferenceable and point to a human-readable documentation nor globally unique for the problem type. ",
34
+ )
35
+ title: StrictStr | None = Field(
36
+ default=None,
37
+ description="A short summary of the problem type. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized. ",
38
+ )
39
+ status: Annotated[int, Field(lt=600, strict=True, ge=100)] | None = Field(
40
+ default=None,
41
+ description="The HTTP status code generated by the origin server for this occurrence of the problem. ",
42
+ )
43
+ detail: StrictStr | None = Field(
44
+ default=None,
45
+ description="A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized. ",
46
+ )
47
+ instance: StrictStr | None = Field(
48
+ default=None,
49
+ description="A URI reference that identifies the specific occurrence of the problem, e.g. by adding a fragment identifier or sub-path to the problem type. May be used to locate the root of this problem in the source code. ",
50
+ )
51
+ __properties: ClassVar[list[str]] = [
52
+ "type",
53
+ "title",
54
+ "status",
55
+ "detail",
56
+ "instance",
57
+ ]
58
+
59
+ model_config = ConfigDict(
60
+ populate_by_name=True,
61
+ validate_assignment=True,
62
+ protected_namespaces=(),
63
+ )
64
+
65
+ def to_str(self) -> str:
66
+ """Returns the string representation of the model using alias"""
67
+ return pprint.pformat(self.model_dump(by_alias=True))
68
+
69
+ def to_json(self) -> str:
70
+ """Returns the JSON representation of the model using alias"""
71
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
72
+ return json.dumps(self.to_dict())
73
+
74
+ @classmethod
75
+ def from_json(cls, json_str: str) -> Self | None:
76
+ """Create an instance of Problem from a JSON string"""
77
+ return cls.from_dict(json.loads(json_str))
78
+
79
+ def to_dict(self) -> dict[str, Any]:
80
+ """Return the dictionary representation of the model using alias.
81
+
82
+ This has the following differences from calling pydantic's
83
+ `self.model_dump(by_alias=True)`:
84
+
85
+ * `None` is only added to the output dict for nullable fields that
86
+ were set at model initialization. Other fields with value `None`
87
+ are ignored.
88
+ """
89
+ excluded_fields: set[str] = set([])
90
+
91
+ _dict = self.model_dump(
92
+ by_alias=True,
93
+ exclude=excluded_fields,
94
+ exclude_none=True,
95
+ )
96
+ return _dict
97
+
98
+ @classmethod
99
+ def from_dict(cls, obj: dict[str, Any] | None) -> Self | None:
100
+ """Create an instance of Problem from a dict"""
101
+ if obj is None:
102
+ return None
103
+
104
+ if not isinstance(obj, dict):
105
+ return cls.model_validate(obj)
106
+
107
+ _obj = cls.model_validate(
108
+ {
109
+ "type": obj.get("type")
110
+ if obj.get("type") is not None
111
+ else "about:blank",
112
+ "title": obj.get("title"),
113
+ "status": obj.get("status"),
114
+ "detail": obj.get("detail"),
115
+ "instance": obj.get("instance"),
116
+ }
117
+ )
118
+ return _obj
@@ -0,0 +1,92 @@
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 __future__ import annotations
13
+
14
+ import json
15
+ import pprint
16
+ import re # noqa: F401
17
+ from typing import Any
18
+ from typing import ClassVar
19
+
20
+ from pydantic import BaseModel
21
+ from pydantic import ConfigDict
22
+ from pydantic import StrictStr
23
+ from typing_extensions import Self
24
+
25
+
26
+ class RenderedContact(BaseModel):
27
+ """RenderedContact"""
28
+
29
+ title: StrictStr | None = None
30
+ email: StrictStr
31
+ __properties: ClassVar[list[str]] = ["title", "email"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+ def to_str(self) -> str:
40
+ """Returns the string representation of the model using alias"""
41
+ return pprint.pformat(self.model_dump(by_alias=True))
42
+
43
+ def to_json(self) -> str:
44
+ """Returns the JSON representation of the model using alias"""
45
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
46
+ return json.dumps(self.to_dict())
47
+
48
+ @classmethod
49
+ def from_json(cls, json_str: str) -> Self | None:
50
+ """Create an instance of RenderedContact from a JSON string"""
51
+ return cls.from_dict(json.loads(json_str))
52
+
53
+ def to_dict(self) -> dict[str, Any]:
54
+ """Return the dictionary representation of the model using alias.
55
+
56
+ This has the following differences from calling pydantic's
57
+ `self.model_dump(by_alias=True)`:
58
+
59
+ * `None` is only added to the output dict for nullable fields that
60
+ were set at model initialization. Other fields with value `None`
61
+ are ignored.
62
+ """
63
+ excluded_fields: set[str] = set([])
64
+
65
+ _dict = self.model_dump(
66
+ by_alias=True,
67
+ exclude=excluded_fields,
68
+ exclude_none=True,
69
+ )
70
+ # set to None if title (nullable) is None
71
+ # and model_fields_set contains the field
72
+ if self.title is None and "title" in self.model_fields_set:
73
+ _dict["title"] = None
74
+
75
+ return _dict
76
+
77
+ @classmethod
78
+ def from_dict(cls, obj: dict[str, Any] | None) -> Self | None:
79
+ """Create an instance of RenderedContact from a dict"""
80
+ if obj is None:
81
+ return None
82
+
83
+ if not isinstance(obj, dict):
84
+ return cls.model_validate(obj)
85
+
86
+ _obj = cls.model_validate(
87
+ {
88
+ "title": obj.get("title"),
89
+ "email": obj.get("email"),
90
+ }
91
+ )
92
+ return _obj
@@ -0,0 +1,235 @@
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 __future__ import annotations
13
+
14
+ import json
15
+ import pprint
16
+ import re # noqa: F401
17
+ from datetime import date
18
+ from datetime import datetime
19
+ from typing import Any
20
+ from typing import ClassVar
21
+
22
+ from pydantic import BaseModel
23
+ from pydantic import ConfigDict
24
+ from pydantic import StrictBool
25
+ from pydantic import StrictInt
26
+ from pydantic import StrictStr
27
+ from typing_extensions import Self
28
+
29
+ from ..models.klass_reference import KlassReference
30
+ from ..models.rendered_contact import RenderedContact
31
+
32
+
33
+ class RenderedVariableDefinition(BaseModel):
34
+ """Render a Variable Definition in a specific language, for display to end users."""
35
+
36
+ id: StrictStr
37
+ patch_id: StrictInt
38
+ name: StrictStr | None = None
39
+ short_name: StrictStr
40
+ definition: StrictStr | None = None
41
+ classification_uri: StrictStr | None = None
42
+ unit_types: list[KlassReference | None]
43
+ subject_fields: list[KlassReference | None]
44
+ contains_special_categories_of_personal_data: StrictBool
45
+ measurement_type: KlassReference | None = None
46
+ valid_from: date
47
+ valid_until: date | None = None
48
+ external_reference_uri: StrictStr | None = None
49
+ comment: StrictStr | None = None
50
+ related_variable_definition_uris: list[StrictStr] | None = None
51
+ contact: RenderedContact | None = None
52
+ last_updated_at: datetime
53
+ __properties: ClassVar[list[str]] = [
54
+ "id",
55
+ "patch_id",
56
+ "name",
57
+ "short_name",
58
+ "definition",
59
+ "classification_uri",
60
+ "unit_types",
61
+ "subject_fields",
62
+ "contains_special_categories_of_personal_data",
63
+ "measurement_type",
64
+ "valid_from",
65
+ "valid_until",
66
+ "external_reference_uri",
67
+ "comment",
68
+ "related_variable_definition_uris",
69
+ "contact",
70
+ "last_updated_at",
71
+ ]
72
+
73
+ model_config = ConfigDict(
74
+ populate_by_name=True,
75
+ validate_assignment=True,
76
+ protected_namespaces=(),
77
+ )
78
+
79
+ def to_str(self) -> str:
80
+ """Returns the string representation of the model using alias"""
81
+ return pprint.pformat(self.model_dump(by_alias=True))
82
+
83
+ def to_json(self) -> str:
84
+ """Returns the JSON representation of the model using alias"""
85
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
86
+ return json.dumps(self.to_dict())
87
+
88
+ @classmethod
89
+ def from_json(cls, json_str: str) -> Self | None:
90
+ """Create an instance of RenderedVariableDefinition from a JSON string"""
91
+ return cls.from_dict(json.loads(json_str))
92
+
93
+ def to_dict(self) -> dict[str, Any]:
94
+ """Return the dictionary representation of the model using alias.
95
+
96
+ This has the following differences from calling pydantic's
97
+ `self.model_dump(by_alias=True)`:
98
+
99
+ * `None` is only added to the output dict for nullable fields that
100
+ were set at model initialization. Other fields with value `None`
101
+ are ignored.
102
+ """
103
+ excluded_fields: set[str] = set([])
104
+
105
+ _dict = self.model_dump(
106
+ by_alias=True,
107
+ exclude=excluded_fields,
108
+ exclude_none=True,
109
+ )
110
+ # override the default output from pydantic by calling `to_dict()` of each item in unit_types (list)
111
+ _items = []
112
+ if self.unit_types:
113
+ for _item_unit_types in self.unit_types:
114
+ if _item_unit_types:
115
+ _items.append(_item_unit_types.to_dict())
116
+ _dict["unit_types"] = _items
117
+ # override the default output from pydantic by calling `to_dict()` of each item in subject_fields (list)
118
+ _items = []
119
+ if self.subject_fields:
120
+ for _item_subject_fields in self.subject_fields:
121
+ if _item_subject_fields:
122
+ _items.append(_item_subject_fields.to_dict())
123
+ _dict["subject_fields"] = _items
124
+ # override the default output from pydantic by calling `to_dict()` of measurement_type
125
+ if self.measurement_type:
126
+ _dict["measurement_type"] = self.measurement_type.to_dict()
127
+ # override the default output from pydantic by calling `to_dict()` of contact
128
+ if self.contact:
129
+ _dict["contact"] = self.contact.to_dict()
130
+ # set to None if name (nullable) is None
131
+ # and model_fields_set contains the field
132
+ if self.name is None and "name" in self.model_fields_set:
133
+ _dict["name"] = None
134
+
135
+ # set to None if definition (nullable) is None
136
+ # and model_fields_set contains the field
137
+ if self.definition is None and "definition" in self.model_fields_set:
138
+ _dict["definition"] = None
139
+
140
+ # set to None if classification_uri (nullable) is None
141
+ # and model_fields_set contains the field
142
+ if (
143
+ self.classification_uri is None
144
+ and "classification_uri" in self.model_fields_set
145
+ ):
146
+ _dict["classification_uri"] = None
147
+
148
+ # set to None if measurement_type (nullable) is None
149
+ # and model_fields_set contains the field
150
+ if (
151
+ self.measurement_type is None
152
+ and "measurement_type" in self.model_fields_set
153
+ ):
154
+ _dict["measurement_type"] = None
155
+
156
+ # set to None if valid_until (nullable) is None
157
+ # and model_fields_set contains the field
158
+ if self.valid_until is None and "valid_until" in self.model_fields_set:
159
+ _dict["valid_until"] = None
160
+
161
+ # set to None if external_reference_uri (nullable) is None
162
+ # and model_fields_set contains the field
163
+ if (
164
+ self.external_reference_uri is None
165
+ and "external_reference_uri" in self.model_fields_set
166
+ ):
167
+ _dict["external_reference_uri"] = None
168
+
169
+ # set to None if comment (nullable) is None
170
+ # and model_fields_set contains the field
171
+ if self.comment is None and "comment" in self.model_fields_set:
172
+ _dict["comment"] = None
173
+
174
+ # set to None if related_variable_definition_uris (nullable) is None
175
+ # and model_fields_set contains the field
176
+ if (
177
+ self.related_variable_definition_uris is None
178
+ and "related_variable_definition_uris" in self.model_fields_set
179
+ ):
180
+ _dict["related_variable_definition_uris"] = None
181
+
182
+ # set to None if contact (nullable) is None
183
+ # and model_fields_set contains the field
184
+ if self.contact is None and "contact" in self.model_fields_set:
185
+ _dict["contact"] = None
186
+
187
+ return _dict
188
+
189
+ @classmethod
190
+ def from_dict(cls, obj: dict[str, Any] | None) -> Self | None:
191
+ """Create an instance of RenderedVariableDefinition from a dict"""
192
+ if obj is None:
193
+ return None
194
+
195
+ if not isinstance(obj, dict):
196
+ return cls.model_validate(obj)
197
+
198
+ _obj = cls.model_validate(
199
+ {
200
+ "id": obj.get("id"),
201
+ "patch_id": obj.get("patch_id"),
202
+ "name": obj.get("name"),
203
+ "short_name": obj.get("short_name"),
204
+ "definition": obj.get("definition"),
205
+ "classification_uri": obj.get("classification_uri"),
206
+ "unit_types": [
207
+ KlassReference.from_dict(_item) for _item in obj["unit_types"]
208
+ ]
209
+ if obj.get("unit_types") is not None
210
+ else None,
211
+ "subject_fields": [
212
+ KlassReference.from_dict(_item) for _item in obj["subject_fields"]
213
+ ]
214
+ if obj.get("subject_fields") is not None
215
+ else None,
216
+ "contains_special_categories_of_personal_data": obj.get(
217
+ "contains_special_categories_of_personal_data"
218
+ ),
219
+ "measurement_type": KlassReference.from_dict(obj["measurement_type"])
220
+ if obj.get("measurement_type") is not None
221
+ else None,
222
+ "valid_from": obj.get("valid_from"),
223
+ "valid_until": obj.get("valid_until"),
224
+ "external_reference_uri": obj.get("external_reference_uri"),
225
+ "comment": obj.get("comment"),
226
+ "related_variable_definition_uris": obj.get(
227
+ "related_variable_definition_uris"
228
+ ),
229
+ "contact": RenderedContact.from_dict(obj["contact"])
230
+ if obj.get("contact") is not None
231
+ else None,
232
+ "last_updated_at": obj.get("last_updated_at"),
233
+ }
234
+ )
235
+ return _obj
@@ -0,0 +1,33 @@
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 __future__ import annotations
13
+
14
+ import json
15
+ from enum import Enum
16
+
17
+ from typing_extensions import Self
18
+
19
+
20
+ class SupportedLanguages(str, Enum):
21
+ """Languages the application supports."""
22
+
23
+ """
24
+ allowed enum values
25
+ """
26
+ NB = "nb"
27
+ NN = "nn"
28
+ EN = "en"
29
+
30
+ @classmethod
31
+ def from_json(cls, json_str: str) -> Self:
32
+ """Create an instance of SupportedLanguages from a JSON string"""
33
+ return cls(json.loads(json_str))