dapla-toolbelt-metadata 0.4.2__py3-none-any.whl → 0.5.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 (81) hide show
  1. dapla_metadata/__init__.py +7 -0
  2. dapla_metadata/dapla/__init__.py +1 -0
  3. dapla_metadata/{_shared → dapla}/user_info.py +55 -8
  4. dapla_metadata/datasets/code_list.py +1 -1
  5. dapla_metadata/datasets/core.py +1 -1
  6. dapla_metadata/datasets/dataset_parser.py +1 -1
  7. dapla_metadata/datasets/model_backwards_compatibility.py +6 -6
  8. dapla_metadata/datasets/model_validation.py +2 -2
  9. dapla_metadata/datasets/utility/constants.py +1 -0
  10. dapla_metadata/datasets/utility/enums.py +1 -1
  11. dapla_metadata/datasets/utility/utils.py +7 -11
  12. dapla_metadata/variable_definitions/__init__.py +5 -3
  13. dapla_metadata/variable_definitions/{generated → _generated}/.openapi-generator/FILES +0 -5
  14. dapla_metadata/variable_definitions/_generated/.openapi-generator/VERSION +1 -0
  15. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/__init__.py +0 -5
  16. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/api/__init__.py +0 -1
  17. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/api/data_migration_api.py +2 -2
  18. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/api/draft_variable_definitions_api.py +14 -14
  19. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/api/patches_api.py +15 -15
  20. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/api/validity_periods_api.py +8 -281
  21. dapla_metadata/variable_definitions/{generated/vardef_client/api/public_api.py → _generated/vardef_client/api/variable_definitions_api.py} +73 -358
  22. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/models/__init__.py +2 -6
  23. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/models/complete_response.py +8 -32
  24. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/models/contact.py +2 -2
  25. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/models/draft.py +8 -23
  26. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/models/language_string_type.py +7 -6
  27. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/models/owner.py +2 -2
  28. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/models/patch.py +16 -61
  29. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/models/problem.py +2 -2
  30. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/models/update_draft.py +22 -55
  31. dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/models/validity_period.py +14 -48
  32. dapla_metadata/variable_definitions/_generated/vardef_client/models/variable_status.py +33 -0
  33. dapla_metadata/variable_definitions/_utils/__init__.py +1 -0
  34. dapla_metadata/variable_definitions/{_client.py → _utils/_client.py} +5 -3
  35. dapla_metadata/variable_definitions/{config.py → _utils/config.py} +25 -1
  36. dapla_metadata/variable_definitions/_utils/constants.py +41 -0
  37. dapla_metadata/variable_definitions/_utils/descriptions.py +86 -0
  38. dapla_metadata/variable_definitions/_utils/files.py +273 -0
  39. dapla_metadata/variable_definitions/_utils/template_files.py +112 -0
  40. dapla_metadata/variable_definitions/_utils/variable_definition_files.py +93 -0
  41. dapla_metadata/variable_definitions/exceptions.py +141 -11
  42. dapla_metadata/variable_definitions/resources/vardef_model_descriptions_nb.yaml +63 -0
  43. dapla_metadata/variable_definitions/vardef.py +131 -10
  44. dapla_metadata/variable_definitions/variable_definition.py +241 -43
  45. {dapla_toolbelt_metadata-0.4.2.dist-info → dapla_toolbelt_metadata-0.5.0.dist-info}/METADATA +5 -7
  46. dapla_toolbelt_metadata-0.5.0.dist-info/RECORD +84 -0
  47. {dapla_toolbelt_metadata-0.4.2.dist-info → dapla_toolbelt_metadata-0.5.0.dist-info}/WHEEL +1 -1
  48. dapla_metadata/variable_definitions/generated/.openapi-generator/VERSION +0 -1
  49. dapla_metadata/variable_definitions/generated/vardef_client/api/variable_definitions_api.py +0 -1205
  50. dapla_metadata/variable_definitions/generated/vardef_client/models/klass_reference.py +0 -99
  51. dapla_metadata/variable_definitions/generated/vardef_client/models/rendered_contact.py +0 -92
  52. dapla_metadata/variable_definitions/generated/vardef_client/models/rendered_variable_definition.py +0 -235
  53. dapla_metadata/variable_definitions/generated/vardef_client/models/supported_languages.py +0 -33
  54. dapla_metadata/variable_definitions/generated/vardef_client/models/variable_status.py +0 -33
  55. dapla_toolbelt_metadata-0.4.2.dist-info/RECORD +0 -81
  56. /dapla_metadata/variable_definitions/{generated → _generated}/.openapi-generator-ignore +0 -0
  57. /dapla_metadata/variable_definitions/{generated → _generated}/README.md +0 -0
  58. /dapla_metadata/variable_definitions/{generated → _generated}/__init__.py +0 -0
  59. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/api_client.py +0 -0
  60. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/api_response.py +0 -0
  61. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/configuration.py +0 -0
  62. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/CompleteResponse.md +0 -0
  63. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/Contact.md +0 -0
  64. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/DataMigrationApi.md +0 -0
  65. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/Draft.md +0 -0
  66. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/DraftVariableDefinitionsApi.md +0 -0
  67. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/LanguageStringType.md +0 -0
  68. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/Owner.md +0 -0
  69. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/Patch.md +0 -0
  70. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/PatchesApi.md +0 -0
  71. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/PublicApi.md +0 -0
  72. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/SupportedLanguages.md +0 -0
  73. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/UpdateDraft.md +0 -0
  74. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/ValidityPeriod.md +0 -0
  75. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/ValidityPeriodsApi.md +0 -0
  76. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/VariableDefinitionsApi.md +0 -0
  77. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/docs/VariableStatus.md +0 -0
  78. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/exceptions.py +0 -0
  79. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/py.typed +0 -0
  80. /dapla_metadata/variable_definitions/{generated → _generated}/vardef_client/rest.py +0 -0
  81. {dapla_toolbelt_metadata-0.4.2.dist-info → dapla_toolbelt_metadata-0.5.0.dist-info}/LICENSE +0 -0
@@ -1,5 +1,12 @@
1
1
  """Tools and clients for working with the Dapla Metadata system."""
2
2
 
3
+ import warnings
4
+
5
+ warnings.filterwarnings(
6
+ "ignore",
7
+ message="As the c extension couldn't be imported, `google-crc32c` is using a pure python implementation that is significantly slower.",
8
+ )
9
+
3
10
  import datadoc_model.model as datadoc_model
4
11
 
5
12
  from . import datasets
@@ -0,0 +1 @@
1
+ """Expose information specific to the Dapla platform."""
@@ -14,6 +14,8 @@ logger = logging.getLogger(__name__)
14
14
 
15
15
 
16
16
  PLACEHOLDER_EMAIL_ADDRESS = "default_user@ssb.no"
17
+ PLACEHOLDER_GROUP = "default-team-developers"
18
+ PLACEHOLDER_TEAM = "default-team"
17
19
 
18
20
 
19
21
  class UserInfo(Protocol):
@@ -27,6 +29,16 @@ class UserInfo(Protocol):
27
29
  """Get the short email address."""
28
30
  ...
29
31
 
32
+ @property
33
+ def current_group(self) -> str:
34
+ """Get the group which the user is currently representing."""
35
+ ...
36
+
37
+ @property
38
+ def current_team(self) -> str:
39
+ """Get the team which the user is currently representing."""
40
+ ...
41
+
30
42
 
31
43
  class UnknownUserInfo:
32
44
  """Fallback when no implementation is found."""
@@ -36,6 +48,16 @@ class UnknownUserInfo:
36
48
  """Unknown email address."""
37
49
  return None
38
50
 
51
+ @property
52
+ def current_group(self) -> str:
53
+ """Get the group which the user is currently representing."""
54
+ return ""
55
+
56
+ @property
57
+ def current_team(self) -> str:
58
+ """Get the team which the user is currently representing."""
59
+ return ""
60
+
39
61
 
40
62
  class TestUserInfo:
41
63
  """Information about the current user for local development and testing."""
@@ -45,6 +67,16 @@ class TestUserInfo:
45
67
  """Get the short email address."""
46
68
  return PLACEHOLDER_EMAIL_ADDRESS
47
69
 
70
+ @property
71
+ def current_group(self) -> str | None:
72
+ """Get the group which the user is currently representing."""
73
+ return PLACEHOLDER_GROUP
74
+
75
+ @property
76
+ def current_team(self) -> str | None:
77
+ """Get the team which the user is currently representing."""
78
+ return PLACEHOLDER_TEAM
79
+
48
80
 
49
81
  class DaplaLabUserInfo:
50
82
  """Information about the current user when running on Dapla Lab."""
@@ -65,6 +97,19 @@ class DaplaLabUserInfo:
65
97
  )
66
98
  return None
67
99
 
100
+ @property
101
+ def current_group(self) -> str:
102
+ """Get the group which the user is currently representing."""
103
+ if group := config.get_dapla_group_context():
104
+ return group
105
+ msg = "DAPLA_GROUP_CONTEXT environment variable not found"
106
+ raise OSError(msg)
107
+
108
+ @property
109
+ def current_team(self) -> str:
110
+ """Get the team which the user is currently representing."""
111
+ return parse_team_name(self.current_group)
112
+
68
113
 
69
114
  class JupyterHubUserInfo:
70
115
  """Information about the current user when running on JupyterHub."""
@@ -74,6 +119,16 @@ class JupyterHubUserInfo:
74
119
  """Get the short email address."""
75
120
  return config.get_jupyterhub_user()
76
121
 
122
+ @property
123
+ def current_group(self) -> str:
124
+ """Get the group which the user is currently representing."""
125
+ raise NotImplementedError
126
+
127
+ @property
128
+ def current_team(self) -> str:
129
+ """Get the team which the user is currently representing."""
130
+ raise NotImplementedError
131
+
77
132
 
78
133
  def get_user_info_for_current_platform() -> UserInfo:
79
134
  """Return the correct implementation of UserInfo for the current platform."""
@@ -88,14 +143,6 @@ def get_user_info_for_current_platform() -> UserInfo:
88
143
  return UnknownUserInfo()
89
144
 
90
145
 
91
- def get_owner() -> str:
92
- """Returns the owner read from the GROUP_CONTEXT environment variable."""
93
- if group := config.get_dapla_group_context():
94
- return parse_team_name(group)
95
- msg = "DAPLA_GROUP_CONTEXT environment variable not found"
96
- raise OSError(msg)
97
-
98
-
99
146
  def parse_team_name(group: str) -> str:
100
147
  """Parses the group to get the current team.
101
148
 
@@ -127,7 +127,7 @@ class CodeList(GetExternalSource):
127
127
  .get_codes()
128
128
  .data
129
129
  )
130
- except Exception: # noqa: PERF203
130
+ except Exception:
131
131
  logger.exception(
132
132
  "Exception while getting classifications from Klass",
133
133
  )
@@ -14,7 +14,7 @@ from datadoc_model import model
14
14
  from datadoc_model.model import DataSetStatus
15
15
 
16
16
  from dapla_metadata._shared import config
17
- from dapla_metadata._shared import user_info
17
+ from dapla_metadata.dapla import user_info
18
18
  from dapla_metadata.datasets.dapla_dataset_path_info import DaplaDatasetPathInfo
19
19
  from dapla_metadata.datasets.dataset_parser import DatasetParser
20
20
  from dapla_metadata.datasets.model_backwards_compatibility import (
@@ -5,7 +5,7 @@ Handles reading in the data and transforming data types to generic metadata type
5
5
 
6
6
  from __future__ import annotations
7
7
 
8
- import pathlib # noqa: TCH003 import is needed for docs build
8
+ import pathlib # noqa: TC003 import is needed for docs build
9
9
  import re
10
10
  import typing as t
11
11
  from abc import ABC
@@ -15,8 +15,8 @@ from __future__ import annotations
15
15
 
16
16
  from collections import OrderedDict
17
17
  from dataclasses import dataclass
18
+ from datetime import UTC
18
19
  from datetime import datetime
19
- from datetime import timezone
20
20
  from typing import TYPE_CHECKING
21
21
  from typing import Any
22
22
 
@@ -305,10 +305,10 @@ def handle_version_2_2_0(supplied_metadata: dict[str, Any]) -> dict[str, Any]:
305
305
  )
306
306
  supplied_metadata["datadoc"]["variables"][i]["special_value"] = None
307
307
  supplied_metadata["datadoc"]["variables"][i]["custom_type"] = None
308
- supplied_metadata["datadoc"]["variables"][
309
- i
310
- ] = _find_and_update_language_strings(
311
- supplied_metadata["datadoc"]["variables"][i],
308
+ supplied_metadata["datadoc"]["variables"][i] = (
309
+ _find_and_update_language_strings(
310
+ supplied_metadata["datadoc"]["variables"][i],
311
+ )
312
312
  )
313
313
  supplied_metadata["datadoc"]["dataset"]["custom_type"] = None
314
314
  supplied_metadata["datadoc"]["dataset"] = _find_and_update_language_strings(
@@ -384,7 +384,7 @@ def handle_version_1_0_0(supplied_metadata: dict[str, Any]) -> dict[str, Any]:
384
384
  if supplied_metadata["dataset"][field]:
385
385
  supplied_metadata["dataset"][field] = datetime.isoformat(
386
386
  datetime.fromisoformat(supplied_metadata["dataset"][field]).astimezone(
387
- tz=timezone.utc,
387
+ tz=UTC,
388
388
  ),
389
389
  timespec="seconds",
390
390
  )
@@ -5,11 +5,11 @@ from __future__ import annotations
5
5
  import logging
6
6
  import warnings
7
7
  from typing import TYPE_CHECKING
8
+ from typing import Self
8
9
  from typing import TextIO
9
10
 
10
11
  from datadoc_model import model
11
12
  from pydantic import model_validator
12
- from typing_extensions import Self
13
13
 
14
14
  from dapla_metadata.datasets.utility.constants import DATE_VALIDATION_MESSAGE
15
15
  from dapla_metadata.datasets.utility.constants import NUM_OBLIGATORY_DATASET_FIELDS
@@ -176,7 +176,7 @@ class ObligatoryVariableWarning(UserWarning):
176
176
  """Custom warning for checking obligatory metadata for variables."""
177
177
 
178
178
 
179
- def custom_warning_handler( # noqa: PLR0913 remove fields causes incompatible types
179
+ def custom_warning_handler(
180
180
  message: Warning | str,
181
181
  category: type[Warning],
182
182
  filename: str,
@@ -87,6 +87,7 @@ DATASET_FIELDS_FROM_EXISTING_METADATA = [
87
87
  "use_restriction_date",
88
88
  "custom_type",
89
89
  "owner",
90
+ "version_description",
90
91
  ]
91
92
 
92
93
  METADATA_DOCUMENT_FILE_SUFFIX = "__DOC.json"
@@ -11,6 +11,6 @@ class SupportedLanguages(str, Enum):
11
11
  Reference: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
12
12
  """
13
13
 
14
- NORSK_BOKMÅL = "nb"
14
+ NORSK_BOKMÅL = "nb" # noqa: PLC2401 the listed problems do not apply in this case
15
15
  NORSK_NYNORSK = "nn"
16
16
  ENGLISH = "en"
@@ -8,13 +8,13 @@ import uuid
8
8
  from cloudpathlib import CloudPath
9
9
  from cloudpathlib import GSClient
10
10
  from cloudpathlib import GSPath
11
- from dapla import AuthClient
12
11
  from datadoc_model import model
13
12
  from datadoc_model.model import Assessment
14
13
  from datadoc_model.model import DataSetState
15
14
  from datadoc_model.model import VariableRole
16
15
 
17
- from dapla_metadata._shared import user_info
16
+ from dapla import AuthClient
17
+ from dapla_metadata.dapla import user_info
18
18
  from dapla_metadata.datasets.utility.constants import (
19
19
  DATASET_FIELDS_FROM_EXISTING_METADATA,
20
20
  )
@@ -37,7 +37,7 @@ logger = logging.getLogger(__name__)
37
37
 
38
38
  def get_timestamp_now() -> datetime.datetime:
39
39
  """Return a timestamp for the current moment."""
40
- return datetime.datetime.now(tz=datetime.timezone.utc)
40
+ return datetime.datetime.now(tz=datetime.UTC)
41
41
 
42
42
 
43
43
  def normalize_path(path: str) -> pathlib.Path | CloudPath:
@@ -79,7 +79,7 @@ def derive_assessment_from_state(state: DataSetState) -> Assessment:
79
79
  Returns:
80
80
  The derived assessment of the dataset.
81
81
  """
82
- match (state):
82
+ match state:
83
83
  case (
84
84
  DataSetState.INPUT_DATA
85
85
  | DataSetState.PROCESSED_DATA
@@ -147,7 +147,7 @@ def set_dataset_owner(dataset: model.Dataset) -> None:
147
147
  dataset: The dataset object to set default values on.
148
148
  """
149
149
  try:
150
- dataset.owner = user_info.get_owner()
150
+ dataset.owner = user_info.get_user_info_for_current_platform().current_team
151
151
  except OSError:
152
152
  logger.exception("Failed to find environment variable DAPLA_GROUP_CONTEXT")
153
153
 
@@ -245,10 +245,7 @@ def _is_missing_multilanguage_value(
245
245
  len(field_value[0]) > 0
246
246
  and not field_value[0]["languageText"]
247
247
  and (len(field_value) <= 1 or not field_value[1]["languageText"])
248
- and (
249
- len(field_value) <= 2 # noqa: PLR2004 approve magic value
250
- or not field_value[2]["languageText"]
251
- )
248
+ and (len(field_value) <= 2 or not field_value[2]["languageText"])
252
249
  ),
253
250
  )
254
251
 
@@ -277,8 +274,7 @@ def _is_missing_metadata(
277
274
  True if the field doesn't have a value, False otherwise.
278
275
  """
279
276
  return bool(
280
- field_name in obligatory_list
281
- and field_value is None
277
+ (field_name in obligatory_list and field_value is None)
282
278
  or _is_missing_multilanguage_value(
283
279
  field_name,
284
280
  field_value,
@@ -1,7 +1,9 @@
1
1
  """Client for working with Variable Definitions at Statistics Norway."""
2
2
 
3
- from .generated.vardef_client import models
4
- from .generated.vardef_client.exceptions import * # noqa: F403
3
+ from ._generated.vardef_client import models
4
+ from ._generated.vardef_client.exceptions import * # noqa: F403
5
+ from .exceptions import VardefClientError
6
+ from .exceptions import VardefFileError
7
+ from .exceptions import VariableNotFoundError
5
8
  from .vardef import Vardef
6
- from .variable_definition import CompletePatchOutput
7
9
  from .variable_definition import VariableDefinition
@@ -2,21 +2,16 @@ vardef_client/api/__init__.py
2
2
  vardef_client/api/data_migration_api.py
3
3
  vardef_client/api/draft_variable_definitions_api.py
4
4
  vardef_client/api/patches_api.py
5
- vardef_client/api/public_api.py
6
5
  vardef_client/api/validity_periods_api.py
7
6
  vardef_client/api/variable_definitions_api.py
8
7
  vardef_client/models/__init__.py
9
8
  vardef_client/models/complete_response.py
10
9
  vardef_client/models/contact.py
11
10
  vardef_client/models/draft.py
12
- vardef_client/models/klass_reference.py
13
11
  vardef_client/models/language_string_type.py
14
12
  vardef_client/models/owner.py
15
13
  vardef_client/models/patch.py
16
14
  vardef_client/models/problem.py
17
- vardef_client/models/rendered_contact.py
18
- vardef_client/models/rendered_variable_definition.py
19
- vardef_client/models/supported_languages.py
20
15
  vardef_client/models/update_draft.py
21
16
  vardef_client/models/validity_period.py
22
17
  vardef_client/models/variable_status.py
@@ -20,7 +20,6 @@ __version__ = "1.0.0"
20
20
  from .api.data_migration_api import DataMigrationApi
21
21
  from .api.draft_variable_definitions_api import DraftVariableDefinitionsApi
22
22
  from .api.patches_api import PatchesApi
23
- from .api.public_api import PublicApi
24
23
  from .api.validity_periods_api import ValidityPeriodsApi
25
24
  from .api.variable_definitions_api import VariableDefinitionsApi
26
25
 
@@ -39,14 +38,10 @@ from .exceptions import ApiException
39
38
  from .models.complete_response import CompleteResponse
40
39
  from .models.contact import Contact
41
40
  from .models.draft import Draft
42
- from .models.klass_reference import KlassReference
43
41
  from .models.language_string_type import LanguageStringType
44
42
  from .models.owner import Owner
45
43
  from .models.patch import Patch
46
44
  from .models.problem import Problem
47
- from .models.rendered_contact import RenderedContact
48
- from .models.rendered_variable_definition import RenderedVariableDefinition
49
- from .models.supported_languages import SupportedLanguages
50
45
  from .models.update_draft import UpdateDraft
51
46
  from .models.validity_period import ValidityPeriod
52
47
  from .models.variable_status import VariableStatus
@@ -4,6 +4,5 @@
4
4
  from ..api.data_migration_api import DataMigrationApi
5
5
  from ..api.draft_variable_definitions_api import DraftVariableDefinitionsApi
6
6
  from ..api.patches_api import PatchesApi
7
- from ..api.public_api import PublicApi
8
7
  from ..api.validity_periods_api import ValidityPeriodsApi
9
8
  from ..api.variable_definitions_api import VariableDefinitionsApi
@@ -1,6 +1,6 @@
1
- """Variable Definitions
1
+ """Internal Variable Definitions Administration API
2
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.
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
4
 
5
5
  The version of the OpenAPI document: 0.1
6
6
  Contact: metadata@ssb.no
@@ -1,6 +1,6 @@
1
- """Variable Definitions
1
+ """Internal Variable Definitions Administration API
2
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.
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
4
 
5
5
  The version of the OpenAPI document: 0.1
6
6
  Contact: metadata@ssb.no
@@ -46,7 +46,7 @@ class DraftVariableDefinitionsApi:
46
46
  StrictStr,
47
47
  Field(description="The group which the user currently represents."),
48
48
  ],
49
- draft: Draft,
49
+ draft: Draft | None = None,
50
50
  _request_timeout: None
51
51
  | Annotated[StrictFloat, Field(gt=0)]
52
52
  | tuple[
@@ -63,7 +63,7 @@ class DraftVariableDefinitionsApi:
63
63
 
64
64
  :param active_group: The group which the user currently represents. (required)
65
65
  :type active_group: str
66
- :param draft: (required)
66
+ :param draft:
67
67
  :type draft: Draft
68
68
  :param _request_timeout: timeout setting for this request. If one
69
69
  number provided, it will be total request
@@ -117,7 +117,7 @@ class DraftVariableDefinitionsApi:
117
117
  StrictStr,
118
118
  Field(description="The group which the user currently represents."),
119
119
  ],
120
- draft: Draft,
120
+ draft: Draft | None = None,
121
121
  _request_timeout: None
122
122
  | Annotated[StrictFloat, Field(gt=0)]
123
123
  | tuple[
@@ -134,7 +134,7 @@ class DraftVariableDefinitionsApi:
134
134
 
135
135
  :param active_group: The group which the user currently represents. (required)
136
136
  :type active_group: str
137
- :param draft: (required)
137
+ :param draft:
138
138
  :type draft: Draft
139
139
  :param _request_timeout: timeout setting for this request. If one
140
140
  number provided, it will be total request
@@ -188,7 +188,7 @@ class DraftVariableDefinitionsApi:
188
188
  StrictStr,
189
189
  Field(description="The group which the user currently represents."),
190
190
  ],
191
- draft: Draft,
191
+ draft: Draft | None = None,
192
192
  _request_timeout: None
193
193
  | Annotated[StrictFloat, Field(gt=0)]
194
194
  | tuple[
@@ -205,7 +205,7 @@ class DraftVariableDefinitionsApi:
205
205
 
206
206
  :param active_group: The group which the user currently represents. (required)
207
207
  :type active_group: str
208
- :param draft: (required)
208
+ :param draft:
209
209
  :type draft: Draft
210
210
  :param _request_timeout: timeout setting for this request. If one
211
211
  number provided, it will be total request
@@ -615,7 +615,7 @@ class DraftVariableDefinitionsApi:
615
615
  StrictStr,
616
616
  Field(description="The group which the user currently represents."),
617
617
  ],
618
- update_draft: UpdateDraft,
618
+ update_draft: UpdateDraft | None = None,
619
619
  _request_timeout: None
620
620
  | Annotated[StrictFloat, Field(gt=0)]
621
621
  | tuple[
@@ -634,7 +634,7 @@ class DraftVariableDefinitionsApi:
634
634
  :type variable_definition_id: str
635
635
  :param active_group: The group which the user currently represents. (required)
636
636
  :type active_group: str
637
- :param update_draft: (required)
637
+ :param update_draft:
638
638
  :type update_draft: UpdateDraft
639
639
  :param _request_timeout: timeout setting for this request. If one
640
640
  number provided, it will be total request
@@ -695,7 +695,7 @@ class DraftVariableDefinitionsApi:
695
695
  StrictStr,
696
696
  Field(description="The group which the user currently represents."),
697
697
  ],
698
- update_draft: UpdateDraft,
698
+ update_draft: UpdateDraft | None = None,
699
699
  _request_timeout: None
700
700
  | Annotated[StrictFloat, Field(gt=0)]
701
701
  | tuple[
@@ -714,7 +714,7 @@ class DraftVariableDefinitionsApi:
714
714
  :type variable_definition_id: str
715
715
  :param active_group: The group which the user currently represents. (required)
716
716
  :type active_group: str
717
- :param update_draft: (required)
717
+ :param update_draft:
718
718
  :type update_draft: UpdateDraft
719
719
  :param _request_timeout: timeout setting for this request. If one
720
720
  number provided, it will be total request
@@ -775,7 +775,7 @@ class DraftVariableDefinitionsApi:
775
775
  StrictStr,
776
776
  Field(description="The group which the user currently represents."),
777
777
  ],
778
- update_draft: UpdateDraft,
778
+ update_draft: UpdateDraft | None = None,
779
779
  _request_timeout: None
780
780
  | Annotated[StrictFloat, Field(gt=0)]
781
781
  | tuple[
@@ -794,7 +794,7 @@ class DraftVariableDefinitionsApi:
794
794
  :type variable_definition_id: str
795
795
  :param active_group: The group which the user currently represents. (required)
796
796
  :type active_group: str
797
- :param update_draft: (required)
797
+ :param update_draft:
798
798
  :type update_draft: UpdateDraft
799
799
  :param _request_timeout: timeout setting for this request. If one
800
800
  number provided, it will be total request
@@ -1,6 +1,6 @@
1
- """Variable Definitions
1
+ """Internal Variable Definitions Administration API
2
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.
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
4
 
5
5
  The version of the OpenAPI document: 0.1
6
6
  Contact: metadata@ssb.no
@@ -50,13 +50,13 @@ class PatchesApi:
50
50
  StrictStr,
51
51
  Field(description="The group which the user currently represents."),
52
52
  ],
53
- patch: Patch,
54
53
  valid_from: Annotated[
55
54
  date | None,
56
55
  Field(
57
56
  description="Valid from date for the specific validity period to be patched."
58
57
  ),
59
58
  ] = None,
59
+ patch: Patch | None = None,
60
60
  _request_timeout: None
61
61
  | Annotated[StrictFloat, Field(gt=0)]
62
62
  | tuple[
@@ -75,10 +75,10 @@ class PatchesApi:
75
75
  :type variable_definition_id: str
76
76
  :param active_group: The group which the user currently represents. (required)
77
77
  :type active_group: str
78
- :param patch: (required)
79
- :type patch: Patch
80
78
  :param valid_from: Valid from date for the specific validity period to be patched.
81
79
  :type valid_from: date
80
+ :param patch:
81
+ :type patch: Patch
82
82
  :param _request_timeout: timeout setting for this request. If one
83
83
  number provided, it will be total request
84
84
  timeout. It can also be a pair (tuple) of
@@ -103,8 +103,8 @@ class PatchesApi:
103
103
  _param = self._create_patch_serialize(
104
104
  variable_definition_id=variable_definition_id,
105
105
  active_group=active_group,
106
- patch=patch,
107
106
  valid_from=valid_from,
107
+ patch=patch,
108
108
  _request_auth=_request_auth,
109
109
  _content_type=_content_type,
110
110
  _headers=_headers,
@@ -138,13 +138,13 @@ class PatchesApi:
138
138
  StrictStr,
139
139
  Field(description="The group which the user currently represents."),
140
140
  ],
141
- patch: Patch,
142
141
  valid_from: Annotated[
143
142
  date | None,
144
143
  Field(
145
144
  description="Valid from date for the specific validity period to be patched."
146
145
  ),
147
146
  ] = None,
147
+ patch: Patch | None = None,
148
148
  _request_timeout: None
149
149
  | Annotated[StrictFloat, Field(gt=0)]
150
150
  | tuple[
@@ -163,10 +163,10 @@ class PatchesApi:
163
163
  :type variable_definition_id: str
164
164
  :param active_group: The group which the user currently represents. (required)
165
165
  :type active_group: str
166
- :param patch: (required)
167
- :type patch: Patch
168
166
  :param valid_from: Valid from date for the specific validity period to be patched.
169
167
  :type valid_from: date
168
+ :param patch:
169
+ :type patch: Patch
170
170
  :param _request_timeout: timeout setting for this request. If one
171
171
  number provided, it will be total request
172
172
  timeout. It can also be a pair (tuple) of
@@ -191,8 +191,8 @@ class PatchesApi:
191
191
  _param = self._create_patch_serialize(
192
192
  variable_definition_id=variable_definition_id,
193
193
  active_group=active_group,
194
- patch=patch,
195
194
  valid_from=valid_from,
195
+ patch=patch,
196
196
  _request_auth=_request_auth,
197
197
  _content_type=_content_type,
198
198
  _headers=_headers,
@@ -226,13 +226,13 @@ class PatchesApi:
226
226
  StrictStr,
227
227
  Field(description="The group which the user currently represents."),
228
228
  ],
229
- patch: Patch,
230
229
  valid_from: Annotated[
231
230
  date | None,
232
231
  Field(
233
232
  description="Valid from date for the specific validity period to be patched."
234
233
  ),
235
234
  ] = None,
235
+ patch: Patch | None = None,
236
236
  _request_timeout: None
237
237
  | Annotated[StrictFloat, Field(gt=0)]
238
238
  | tuple[
@@ -251,10 +251,10 @@ class PatchesApi:
251
251
  :type variable_definition_id: str
252
252
  :param active_group: The group which the user currently represents. (required)
253
253
  :type active_group: str
254
- :param patch: (required)
255
- :type patch: Patch
256
254
  :param valid_from: Valid from date for the specific validity period to be patched.
257
255
  :type valid_from: date
256
+ :param patch:
257
+ :type patch: Patch
258
258
  :param _request_timeout: timeout setting for this request. If one
259
259
  number provided, it will be total request
260
260
  timeout. It can also be a pair (tuple) of
@@ -279,8 +279,8 @@ class PatchesApi:
279
279
  _param = self._create_patch_serialize(
280
280
  variable_definition_id=variable_definition_id,
281
281
  active_group=active_group,
282
- patch=patch,
283
282
  valid_from=valid_from,
283
+ patch=patch,
284
284
  _request_auth=_request_auth,
285
285
  _content_type=_content_type,
286
286
  _headers=_headers,
@@ -303,8 +303,8 @@ class PatchesApi:
303
303
  self,
304
304
  variable_definition_id,
305
305
  active_group,
306
- patch,
307
306
  valid_from,
307
+ patch,
308
308
  _request_auth,
309
309
  _content_type,
310
310
  _headers,