From aef945ce042a6b15d870c460e264dca4278da0c5 Mon Sep 17 00:00:00 2001 From: Anders Hafreager Date: Wed, 8 Nov 2023 18:56:58 +0100 Subject: [PATCH] ConnectionType Optional (#1480) Co-authored-by: anders-albert --- CHANGELOG.md | 4 ++++ cognite/client/_version.py | 2 +- .../client/data_classes/data_modeling/views.py | 18 ++++++++++++------ pyproject.toml | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca3d223f5..83158a05a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ Changes are grouped as follows - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities. +## [6.39.3] - 2023-11-08 +## Fixed +- The newely introduced parameter `connectionType` was assumed to be required from the API. This is not the case. + ## [6.39.2] - 2023-11-08 ## Fixed - When listing `client.data_modeling.views` the SDK raises a `TypeError`. This is now fixed. diff --git a/cognite/client/_version.py b/cognite/client/_version.py index 2b83329ba..abad9454d 100644 --- a/cognite/client/_version.py +++ b/cognite/client/_version.py @@ -1,4 +1,4 @@ from __future__ import annotations -__version__ = "6.39.2" +__version__ = "6.39.3" __api_subversion__ = "V20220125" diff --git a/cognite/client/data_classes/data_modeling/views.py b/cognite/client/data_classes/data_modeling/views.py index c1c9c50f3..c4efd40c7 100644 --- a/cognite/client/data_classes/data_modeling/views.py +++ b/cognite/client/data_classes/data_modeling/views.py @@ -390,15 +390,18 @@ class SingleHopConnectionDefinition(ConnectionDefinition): @classmethod def load(cls, data: dict[str, Any]) -> SingleHopConnectionDefinition: - return cls( + instance = cls( type=DirectRelationReference.load(data["type"]), source=ViewId.load(data["source"]), name=data.get("name"), description=data.get("description"), edge_source=(edge_source := data.get("edgeSource")) and ViewId.load(edge_source), - direction=data["direction"], - connection_type=data["connectionType"], ) + if "direction" in data: + instance.direction = data["direction"] + if "connectionType" in data: + instance.connection_type = data["connectionType"] + return instance def dump(self, camel_case: bool = False) -> dict[str, Any]: output = asdict(self) @@ -448,15 +451,18 @@ class SingleHopConnectionDefinitionApply(ConnectionDefinitionApply): @classmethod def load(cls, data: dict[str, Any]) -> SingleHopConnectionDefinitionApply: - return cls( + instance = cls( type=DirectRelationReference.load(data["type"]), source=ViewId.load(data["source"]), name=data.get("name"), description=data.get("description"), edge_source=(edge_source := data.get("edgeSource")) and ViewId.load(edge_source), - direction=data["direction"], - connection_type=data["connectionType"], ) + if "direction" in data: + instance.direction = data["direction"] + if "connectionType" in data: + instance.connection_type = data["connectionType"] + return instance def dump(self, camel_case: bool = False) -> dict: output: dict[str, Any] = { diff --git a/pyproject.toml b/pyproject.toml index 342f4b61c..526c57716 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "cognite-sdk" -version = "6.39.2" +version = "6.39.3" description = "Cognite Python SDK" readme = "README.md" documentation = "https://cognite-sdk-python.readthedocs-hosted.com"