From 88d63ddf40dfe620a5973c52ab5e1ce97cf3088f Mon Sep 17 00:00:00 2001 From: Cecilie Seim <68303562+tilen1976@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:21:22 +0100 Subject: [PATCH 1/3] update Vardef --- .../generated/.openapi-generator/FILES | 1 - .../generated/.openapi-generator/VERSION | 2 +- .../vardef_client/api/validity_periods_api.py | 14 +-- .../api/variable_definitions_api.py | 28 ++--- .../vardef_client/models/__init__.py | 1 - .../vardef_client/models/complete_response.py | 33 +---- .../resources/variable-definitions-0.1.yml | 117 ++++-------------- 7 files changed, 54 insertions(+), 142 deletions(-) diff --git a/src/dapla_metadata/variable_definitions/generated/.openapi-generator/FILES b/src/dapla_metadata/variable_definitions/generated/.openapi-generator/FILES index c3ef681..443edb4 100644 --- a/src/dapla_metadata/variable_definitions/generated/.openapi-generator/FILES +++ b/src/dapla_metadata/variable_definitions/generated/.openapi-generator/FILES @@ -13,7 +13,6 @@ vardef_client/models/klass_reference.py vardef_client/models/language_string_type.py vardef_client/models/owner.py vardef_client/models/patch.py -vardef_client/models/person.py vardef_client/models/problem.py vardef_client/models/rendered_contact.py vardef_client/models/rendered_variable_definition.py diff --git a/src/dapla_metadata/variable_definitions/generated/.openapi-generator/VERSION b/src/dapla_metadata/variable_definitions/generated/.openapi-generator/VERSION index 4bc5d61..758bb9c 100644 --- a/src/dapla_metadata/variable_definitions/generated/.openapi-generator/VERSION +++ b/src/dapla_metadata/variable_definitions/generated/.openapi-generator/VERSION @@ -1 +1 @@ -7.9.0 +7.10.0 diff --git a/src/dapla_metadata/variable_definitions/generated/vardef_client/api/validity_periods_api.py b/src/dapla_metadata/variable_definitions/generated/vardef_client/api/validity_periods_api.py index 3f265ce..c3bab61 100644 --- a/src/dapla_metadata/variable_definitions/generated/vardef_client/api/validity_periods_api.py +++ b/src/dapla_metadata/variable_definitions/generated/vardef_client/api/validity_periods_api.py @@ -352,7 +352,7 @@ def _create_validity_period_serialize( ) @validate_call - def list_public_validity_periods_0( + def list_public_validity_periods( self, variable_definition_id: Annotated[ StrictStr, @@ -401,7 +401,7 @@ def list_public_validity_periods_0( :type _host_index: int, optional :return: Returns the result object. """ - _param = self._list_public_validity_periods_0_serialize( + _param = self._list_public_validity_periods_serialize( variable_definition_id=variable_definition_id, accept_language=accept_language, _request_auth=_request_auth, @@ -424,7 +424,7 @@ def list_public_validity_periods_0( ).data @validate_call - def list_public_validity_periods_0_with_http_info( + def list_public_validity_periods_with_http_info( self, variable_definition_id: Annotated[ StrictStr, @@ -473,7 +473,7 @@ def list_public_validity_periods_0_with_http_info( :type _host_index: int, optional :return: Returns the result object. """ - _param = self._list_public_validity_periods_0_serialize( + _param = self._list_public_validity_periods_serialize( variable_definition_id=variable_definition_id, accept_language=accept_language, _request_auth=_request_auth, @@ -496,7 +496,7 @@ def list_public_validity_periods_0_with_http_info( ) @validate_call - def list_public_validity_periods_0_without_preload_content( + def list_public_validity_periods_without_preload_content( self, variable_definition_id: Annotated[ StrictStr, @@ -545,7 +545,7 @@ def list_public_validity_periods_0_without_preload_content( :type _host_index: int, optional :return: Returns the result object. """ - _param = self._list_public_validity_periods_0_serialize( + _param = self._list_public_validity_periods_serialize( variable_definition_id=variable_definition_id, accept_language=accept_language, _request_auth=_request_auth, @@ -563,7 +563,7 @@ def list_public_validity_periods_0_without_preload_content( ) return response_data.response - def _list_public_validity_periods_0_serialize( + def _list_public_validity_periods_serialize( self, variable_definition_id, accept_language, diff --git a/src/dapla_metadata/variable_definitions/generated/vardef_client/api/variable_definitions_api.py b/src/dapla_metadata/variable_definitions/generated/vardef_client/api/variable_definitions_api.py index 550d8c5..9b888c6 100644 --- a/src/dapla_metadata/variable_definitions/generated/vardef_client/api/variable_definitions_api.py +++ b/src/dapla_metadata/variable_definitions/generated/vardef_client/api/variable_definitions_api.py @@ -41,7 +41,7 @@ def __init__(self, api_client=None) -> None: self.api_client = api_client @validate_call - def get_public_variable_definition_by_id_0( + def get_public_variable_definition_by_id( self, variable_definition_id: Annotated[ StrictStr, @@ -98,7 +98,7 @@ def get_public_variable_definition_by_id_0( :type _host_index: int, optional :return: Returns the result object. """ - _param = self._get_public_variable_definition_by_id_0_serialize( + _param = self._get_public_variable_definition_by_id_serialize( variable_definition_id=variable_definition_id, accept_language=accept_language, date_of_validity=date_of_validity, @@ -123,7 +123,7 @@ def get_public_variable_definition_by_id_0( ).data @validate_call - def get_public_variable_definition_by_id_0_with_http_info( + def get_public_variable_definition_by_id_with_http_info( self, variable_definition_id: Annotated[ StrictStr, @@ -180,7 +180,7 @@ def get_public_variable_definition_by_id_0_with_http_info( :type _host_index: int, optional :return: Returns the result object. """ - _param = self._get_public_variable_definition_by_id_0_serialize( + _param = self._get_public_variable_definition_by_id_serialize( variable_definition_id=variable_definition_id, accept_language=accept_language, date_of_validity=date_of_validity, @@ -205,7 +205,7 @@ def get_public_variable_definition_by_id_0_with_http_info( ) @validate_call - def get_public_variable_definition_by_id_0_without_preload_content( + def get_public_variable_definition_by_id_without_preload_content( self, variable_definition_id: Annotated[ StrictStr, @@ -262,7 +262,7 @@ def get_public_variable_definition_by_id_0_without_preload_content( :type _host_index: int, optional :return: Returns the result object. """ - _param = self._get_public_variable_definition_by_id_0_serialize( + _param = self._get_public_variable_definition_by_id_serialize( variable_definition_id=variable_definition_id, accept_language=accept_language, date_of_validity=date_of_validity, @@ -282,7 +282,7 @@ def get_public_variable_definition_by_id_0_without_preload_content( ) return response_data.response - def _get_public_variable_definition_by_id_0_serialize( + def _get_public_variable_definition_by_id_serialize( self, variable_definition_id, accept_language, @@ -651,7 +651,7 @@ def _get_variable_definition_by_id_serialize( ) @validate_call - def list_public_variable_definitions_0( + def list_public_variable_definitions( self, accept_language: Annotated[ SupportedLanguages, @@ -702,7 +702,7 @@ def list_public_variable_definitions_0( :type _host_index: int, optional :return: Returns the result object. """ - _param = self._list_public_variable_definitions_0_serialize( + _param = self._list_public_variable_definitions_serialize( accept_language=accept_language, date_of_validity=date_of_validity, _request_auth=_request_auth, @@ -725,7 +725,7 @@ def list_public_variable_definitions_0( ).data @validate_call - def list_public_variable_definitions_0_with_http_info( + def list_public_variable_definitions_with_http_info( self, accept_language: Annotated[ SupportedLanguages, @@ -776,7 +776,7 @@ def list_public_variable_definitions_0_with_http_info( :type _host_index: int, optional :return: Returns the result object. """ - _param = self._list_public_variable_definitions_0_serialize( + _param = self._list_public_variable_definitions_serialize( accept_language=accept_language, date_of_validity=date_of_validity, _request_auth=_request_auth, @@ -799,7 +799,7 @@ def list_public_variable_definitions_0_with_http_info( ) @validate_call - def list_public_variable_definitions_0_without_preload_content( + def list_public_variable_definitions_without_preload_content( self, accept_language: Annotated[ SupportedLanguages, @@ -850,7 +850,7 @@ def list_public_variable_definitions_0_without_preload_content( :type _host_index: int, optional :return: Returns the result object. """ - _param = self._list_public_variable_definitions_0_serialize( + _param = self._list_public_variable_definitions_serialize( accept_language=accept_language, date_of_validity=date_of_validity, _request_auth=_request_auth, @@ -868,7 +868,7 @@ def list_public_variable_definitions_0_without_preload_content( ) return response_data.response - def _list_public_variable_definitions_0_serialize( + def _list_public_variable_definitions_serialize( self, accept_language, date_of_validity, diff --git a/src/dapla_metadata/variable_definitions/generated/vardef_client/models/__init__.py b/src/dapla_metadata/variable_definitions/generated/vardef_client/models/__init__.py index 21d6382..7bd09af 100644 --- a/src/dapla_metadata/variable_definitions/generated/vardef_client/models/__init__.py +++ b/src/dapla_metadata/variable_definitions/generated/vardef_client/models/__init__.py @@ -21,7 +21,6 @@ from ..models.language_string_type import LanguageStringType from ..models.owner import Owner from ..models.patch import Patch -from ..models.person import Person from ..models.problem import Problem from ..models.rendered_contact import RenderedContact from ..models.rendered_variable_definition import RenderedVariableDefinition diff --git a/src/dapla_metadata/variable_definitions/generated/vardef_client/models/complete_response.py b/src/dapla_metadata/variable_definitions/generated/vardef_client/models/complete_response.py index 0985abf..e27cf2b 100644 --- a/src/dapla_metadata/variable_definitions/generated/vardef_client/models/complete_response.py +++ b/src/dapla_metadata/variable_definitions/generated/vardef_client/models/complete_response.py @@ -30,7 +30,6 @@ from ..models.contact import Contact from ..models.language_string_type import LanguageStringType from ..models.owner import Owner -from ..models.person import Person from ..models.variable_status import VariableStatus @@ -93,14 +92,14 @@ class CompleteResponse(BaseModel): created_at: datetime = Field( description="The timestamp at which this variable definition was first created." ) - created_by: Person | None = Field( - default=None, description="The user who created this variable definition." + created_by: StrictStr = Field( + description="The user who created this variable definition." ) last_updated_at: datetime = Field( description="The timestamp at which this variable definition was last modified." ) - last_updated_by: Person | None = Field( - default=None, description="The user who last modified this variable definition." + last_updated_by: StrictStr = Field( + description="The user who last modified this variable definition." ) __properties: ClassVar[list[str]] = [ "id", @@ -179,12 +178,6 @@ def to_dict(self) -> dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of contact if self.contact: _dict["contact"] = self.contact.to_dict() - # override the default output from pydantic by calling `to_dict()` of created_by - if self.created_by: - _dict["created_by"] = self.created_by.to_dict() - # override the default output from pydantic by calling `to_dict()` of last_updated_by - if self.last_updated_by: - _dict["last_updated_by"] = self.last_updated_by.to_dict() # set to None if classification_reference (nullable) is None # and model_fields_set contains the field if ( @@ -237,16 +230,6 @@ def to_dict(self) -> dict[str, Any]: if self.contact is None and "contact" in self.model_fields_set: _dict["contact"] = None - # set to None if created_by (nullable) is None - # and model_fields_set contains the field - if self.created_by is None and "created_by" in self.model_fields_set: - _dict["created_by"] = None - - # set to None if last_updated_by (nullable) is None - # and model_fields_set contains the field - if self.last_updated_by is None and "last_updated_by" in self.model_fields_set: - _dict["last_updated_by"] = None - return _dict @classmethod @@ -293,13 +276,9 @@ def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: if obj.get("contact") is not None else None, "created_at": obj.get("created_at"), - "created_by": Person.from_dict(obj["created_by"]) - if obj.get("created_by") is not None - else None, + "created_by": obj.get("created_by"), "last_updated_at": obj.get("last_updated_at"), - "last_updated_by": Person.from_dict(obj["last_updated_by"]) - if obj.get("last_updated_by") is not None - else None, + "last_updated_by": obj.get("last_updated_by"), } ) return _obj diff --git a/tests/variable_definitions/resources/variable-definitions-0.1.yml b/tests/variable_definitions/resources/variable-definitions-0.1.yml index 857ecf2..f24b725 100644 --- a/tests/variable_definitions/resources/variable-definitions-0.1.yml +++ b/tests/variable_definitions/resources/variable-definitions-0.1.yml @@ -443,13 +443,9 @@ paths: nn: Seksjon for befolkningsstatistikk email: s320@ssb.no created_at: 2024-06-11T08:15:19.038Z - created_by: - code: ano@ssb.no - name: Ola Nordmann + created_by: ano@ssb.no last_updated_at: 2024-06-11T08:15:19.038Z - last_updated_by: - code: ano@ssb.no - name: Ola Nordmann + last_updated_by: ano@ssb.no "400": description: Bad request. content: @@ -550,15 +546,9 @@ paths: "email": "s320@ssb.no" }, "created_at": "2024-06-11T08:15:19.038Z", - "created_by": { - "code": "ano@ssb.no", - "name": "Ola Nordmann" - }, + "created_by": "ano@ssb.no", "last_updated_at": "2024-06-11T08:15:19.038Z", - "last_updated_by": { - "code": "ano@ssb.no", - "name": "Ola Nordmann" - } + "last_updated_by": "ano@ssb.no" } ] @@ -716,13 +706,9 @@ paths: nn: Seksjon for befolkningsstatistikk email: s320@ssb.no created_at: 2024-06-11T08:15:19.038Z - created_by: - code: ano@ssb.no - name: Ola Nordmann + created_by: ano@ssb.no last_updated_at: 2024-06-11T08:15:19.038Z - last_updated_by: - code: ano@ssb.no - name: Ola Nordmann + last_updated_by: ano@ssb.no "400": description: Bad request. content: @@ -862,13 +848,9 @@ paths: nn: Seksjon for befolkningsstatistikk email: s320@ssb.no created_at: 2024-06-11T08:15:19.038Z - created_by: - code: ano@ssb.no - name: Ola Nordmann + created_by: ano@ssb.no last_updated_at: 2024-06-11T08:15:19.038Z - last_updated_by: - code: ano@ssb.no - name: Ola Nordmann + last_updated_by: ano@ssb.no Specific date: value: id: wypvb3wd @@ -932,13 +914,9 @@ paths: nn: Seksjon for befolkningsstatistikk email: s320@ssb.no created_at: 2024-06-11T08:15:19.038Z - created_by: - code: ano@ssb.no - name: Ola Nordmann + created_by: ano@ssb.no last_updated_at: 2024-06-11T08:15:19.038Z - last_updated_by: - code: ano@ssb.no - name: Ola Nordmann + last_updated_by: ano@ssb.no "404": description: Not found content: @@ -1128,13 +1106,9 @@ paths: nn: Seksjon for befolkningsstatistikk email: s320@ssb.no created_at: 2024-06-11T08:15:19.038Z - created_by: - code: ano@ssb.no - name: Ola Nordmann + created_by: ano@ssb.no last_updated_at: 2024-06-11T08:15:19.038Z - last_updated_by: - code: ano@ssb.no - name: Ola Nordmann + last_updated_by: ano@ssb.no "400": description: Bad request. content: @@ -1274,15 +1248,9 @@ paths: "email": "s320@ssb.no" }, "created_at": "2024-06-11T08:15:19.038Z", - "created_by": { - "code": "ano@ssb.no", - "name": "Ola Nordmann" - }, + "created_by": "ano@ssb.no", "last_updated_at": "2024-06-11T08:15:19.038Z", - "last_updated_by": { - "code": "ano@ssb.no", - "name": "Ola Nordmann" - } + "last_updated_by": "ano@ssb.no" } ] @@ -1466,13 +1434,9 @@ paths: nn: Seksjon for befolkningsstatistikk email: s320@ssb.no created_at: 2024-06-11T08:15:19.038Z - created_by: - code: ano@ssb.no - name: Ola Nordmann + created_by: ano@ssb.no last_updated_at: 2024-06-11T08:15:19.038Z - last_updated_by: - code: ano@ssb.no - name: Ola Nordmann + last_updated_by: ano@ssb.no "404": description: Not found content: @@ -1626,13 +1590,9 @@ paths: nn: Seksjon for befolkningsstatistikk email: s320@ssb.no created_at: 2024-06-11T08:15:19.038Z - created_by: - code: ano@ssb.no - name: Ola Nordmann + created_by: ano@ssb.no last_updated_at: 2024-06-11T08:15:19.038Z - last_updated_by: - code: ano@ssb.no - name: Ola Nordmann + last_updated_by: ano@ssb.no "404": description: Not found content: @@ -1724,15 +1684,9 @@ paths: "email": "s320@ssb.no" }, "created_at": "2024-06-11T08:15:19.038Z", - "created_by": { - "code": "ano@ssb.no", - "name": "Ola Nordmann" - }, + "created_by": "ano@ssb.no", "last_updated_at": "2024-06-11T08:15:19.038Z", - "last_updated_by": { - "code": "ano@ssb.no", - "name": "Ola Nordmann" - } + "last_updated_by": "ano@ssb.no" } ] @@ -1887,13 +1841,9 @@ paths: nn: Seksjon for befolkningsstatistikk email: s320@ssb.no created_at: 2024-06-11T08:15:19.038Z - created_by: - code: ano@ssb.no - name: Ola Nordmann + created_by: ano@ssb.no last_updated_at: 2024-06-11T08:15:19.038Z - last_updated_by: - code: ano@ssb.no - name: Ola Nordmann + last_updated_by: ano@ssb.no "404": description: Not found content: @@ -1950,9 +1900,11 @@ components: required: - contains_special_categories_of_personal_data - created_at + - created_by - definition - id - last_updated_at + - last_updated_by - name - owner - patch_id @@ -2063,19 +2015,15 @@ components: description: The timestamp at which this variable definition was first created. format: date-time created_by: + type: string description: The user who created this variable definition. - nullable: true - allOf: - - $ref: "#/components/schemas/Person" last_updated_at: type: string description: The timestamp at which this variable definition was last modified. format: date-time last_updated_by: + type: string description: The user who last modified this variable definition. - nullable: true - allOf: - - $ref: "#/components/schemas/Person" description: Complete response For internal users who need all details while maintaining variable definitions. Contact: @@ -2409,19 +2357,6 @@ components: nb: Seksjon for befolkningsstatistikk nn: Seksjon for befolkningsstatistikk email: s320@ssb.no - Person: - required: - - code - - name - type: object - properties: - code: - type: string - name: - type: string - example: - code: ano@ssb.no - name: Ola Nordmann RenderedContact: required: - email From eac0a1f562ac18234140f219aecb8378d94f7e4e Mon Sep 17 00:00:00 2001 From: Cecilie Seim <68303562+tilen1976@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:30:50 +0100 Subject: [PATCH 2/3] update tests --- tests/variable_definitions/conftest.py | 4 ++-- tests/variable_definitions/test_variable_definition.py | 10 ++-------- .../vardef_client/models/test_models_instantiation.py | 4 ---- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/tests/variable_definitions/conftest.py b/tests/variable_definitions/conftest.py index 6e2aa3e..767e827 100644 --- a/tests/variable_definitions/conftest.py +++ b/tests/variable_definitions/conftest.py @@ -115,9 +115,9 @@ def sample_variable_definition() -> VariableDefinition: ), owner=Owner(team="my_team", groups=["my_team_developers"]), created_at=date(2024, 11, 1), - created_by=Person(code="724", name="name"), + created_by="ano@ssb.no", last_updated_at=date(2024, 11, 1), - last_updated_by=Person(code="724", name="name"), + last_updated_by="ano@ssb.no", ) diff --git a/tests/variable_definitions/test_variable_definition.py b/tests/variable_definitions/test_variable_definition.py index b76ce11..9fe3d9f 100644 --- a/tests/variable_definitions/test_variable_definition.py +++ b/tests/variable_definitions/test_variable_definition.py @@ -52,14 +52,8 @@ def test_str(variable_definition): "email": "me@example.com" }, "created_at": "2024-11-01T00:00:00", - "created_by": { - "code": "724", - "name": "name" - }, + "created_by": "ano@ssb.no", "last_updated_at": "2024-11-01T00:00:00", - "last_updated_by": { - "code": "724", - "name": "name" - } + "last_updated_by": "ano@ssb.no" }""" ) diff --git a/tests/variable_definitions/vardef_client/models/test_models_instantiation.py b/tests/variable_definitions/vardef_client/models/test_models_instantiation.py index c355dc1..1c81661 100644 --- a/tests/variable_definitions/vardef_client/models/test_models_instantiation.py +++ b/tests/variable_definitions/vardef_client/models/test_models_instantiation.py @@ -22,9 +22,6 @@ from dapla_metadata.variable_definitions.generated.vardef_client.models.patch import ( Patch, ) -from dapla_metadata.variable_definitions.generated.vardef_client.models.person import ( - Person, -) from dapla_metadata.variable_definitions.generated.vardef_client.models.update_draft import ( UpdateDraft, ) @@ -45,7 +42,6 @@ CompleteResponse, Contact, Owner, - Person, ValidityPeriod, ], ) From 63e109a7921e79699ecbb0eb19e180d1c5b67614 Mon Sep 17 00:00:00 2001 From: Cecilie Seim <68303562+tilen1976@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:52:57 +0100 Subject: [PATCH 3/3] remove unused import --- tests/variable_definitions/conftest.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/variable_definitions/conftest.py b/tests/variable_definitions/conftest.py index 767e827..bf9460f 100644 --- a/tests/variable_definitions/conftest.py +++ b/tests/variable_definitions/conftest.py @@ -25,9 +25,6 @@ from dapla_metadata.variable_definitions.generated.vardef_client.models.patch import ( Patch, ) -from dapla_metadata.variable_definitions.generated.vardef_client.models.person import ( - Person, -) from dapla_metadata.variable_definitions.generated.vardef_client.models.update_draft import ( UpdateDraft, )