From 7554ebdd2260c365ee3b6e1e80bad2da06e80fd7 Mon Sep 17 00:00:00 2001 From: anders-albert Date: Tue, 12 Nov 2024 07:40:18 +0100 Subject: [PATCH 1/6] tests: Extended tests --- tests/tests_unit/test_data_classes/test_capabilities.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/tests_unit/test_data_classes/test_capabilities.py b/tests/tests_unit/test_data_classes/test_capabilities.py index 34d197e24..993612084 100644 --- a/tests/tests_unit/test_data_classes/test_capabilities.py +++ b/tests/tests_unit/test_data_classes/test_capabilities.py @@ -94,6 +94,10 @@ def all_acls(): {"relationshipsAcl": {"actions": ["READ"], "scope": {"datasetScope": {"ids": ["372", "2332579"]}}}}, {"roboticsAcl": {"actions": ["READ", "CREATE", "UPDATE", "DELETE"], "scope": {"all": {}}}}, {"roboticsAcl": {"actions": ["READ"], "scope": {"datasetScope": {"ids": ["583194012260066"]}}}}, + {"sapWritebackAcl": {"actions": ["READ", "WRITE"], "scope": {"all": {}}}}, + {"sapWritebackAcl": {"actions": ["READ", "WRITE"], "scope": {"instancesScope": {"instances": ["123", "456"]}}}}, + {"sapWritebackRequestsAcl": {"actions": ["READ", "WRITE"], "scope": {"all": {}}}}, + {"sapWritebackRequestsAcl": {"actions": ["READ", "WRITE"], "instancesScope": {"instances": ["123", "456"]}}}, {"scheduledCalculationsAcl": {"actions": ["READ", "WRITE"], "scope": {"all": {}}}}, { "securityCategoriesAcl": { From ac2022ac129ab0546abf2310f920965ec2b6eb1a Mon Sep 17 00:00:00 2001 From: anders-albert Date: Tue, 12 Nov 2024 07:46:44 +0100 Subject: [PATCH 2/6] feat; added SAP Acls --- cognite/client/data_classes/capabilities.py | 39 +++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/cognite/client/data_classes/capabilities.py b/cognite/client/data_classes/capabilities.py index 1de5d53dc..5e402dbbe 100644 --- a/cognite/client/data_classes/capabilities.py +++ b/cognite/client/data_classes/capabilities.py @@ -389,6 +389,15 @@ def as_tuples(self) -> set[tuple[str, int]]: return {(self._scope_name, i) for i in self.ids} +@dataclass(frozen=True) +class InstancesScope(Capability.Scope): + _scope_name = "instancesScope" + instances: list[str] + + def as_tuples(self) -> set[tuple[str, str]]: + return {(self._scope_name, s) for s in self.instances} + + @dataclass(frozen=True) class ExtractionPipelineScope(Capability.Scope): _scope_name = "extractionPipelineScope" @@ -859,6 +868,36 @@ class Scope: DataSet = DataSetScope +@dataclass +class SAPWritebackAcl(Capability): + _capability_name = "sapWritebackAcl" + actions: Sequence[Action] + scope: AllScope | InstancesScope + + class Action(Capability.Action): # type: ignore [misc] + Read = "READ" + Write = "WRITE" + + class Scope: + All = AllScope + Instances = InstancesScope + + +@dataclass +class SAPWritebackRequestsAcl(Capability): + _capability_name = "sapWritebackRequestsAcl" + actions: Sequence[Action] + scope: AllScope | InstancesScope + + class Action(Capability.Action): # type: ignore [misc] + Read = "READ" + Write = "WRITE" + + class Scope: + All = AllScope + Instances = InstancesScope + + @dataclass class SecurityCategoriesAcl(Capability): _capability_name = "securityCategoriesAcl" From 882da4adb2e1241597dea86e015c54552b470bcf Mon Sep 17 00:00:00 2001 From: anders-albert Date: Tue, 12 Nov 2024 07:48:56 +0100 Subject: [PATCH 3/6] build; changelog --- CHANGELOG.md | 4 ++++ cognite/client/_version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc16f3ba6..0be01fb29 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. +## [7.64.13] - 2024-11-12 +### Added +- Added new `SAPWriteback` and `SAPWritebackRequests` capabilities. + ## [7.64.12] - 2024-11-11 ### Fixed - `FunctionSchedulesAPI.__call__()` calls `FunctionSchedulesAPI.list()` instead of `APIClient._list_generator()`. diff --git a/cognite/client/_version.py b/cognite/client/_version.py index 11a073317..5afe8ff0f 100644 --- a/cognite/client/_version.py +++ b/cognite/client/_version.py @@ -1,4 +1,4 @@ from __future__ import annotations -__version__ = "7.64.12" +__version__ = "7.64.13" __api_subversion__ = "20230101" diff --git a/pyproject.toml b/pyproject.toml index f2cc3010d..6d3073ae2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "cognite-sdk" -version = "7.64.12" +version = "7.64.13" description = "Cognite Python SDK" readme = "README.md" documentation = "https://cognite-sdk-python.readthedocs-hosted.com" From 50b958eac362609c762d15b498cc48755af0b5f9 Mon Sep 17 00:00:00 2001 From: anders-albert Date: Tue, 12 Nov 2024 07:55:47 +0100 Subject: [PATCH 4/6] fix: tests --- tests/tests_unit/test_data_classes/test_capabilities.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/tests_unit/test_data_classes/test_capabilities.py b/tests/tests_unit/test_data_classes/test_capabilities.py index 993612084..c7e5995ca 100644 --- a/tests/tests_unit/test_data_classes/test_capabilities.py +++ b/tests/tests_unit/test_data_classes/test_capabilities.py @@ -97,7 +97,12 @@ def all_acls(): {"sapWritebackAcl": {"actions": ["READ", "WRITE"], "scope": {"all": {}}}}, {"sapWritebackAcl": {"actions": ["READ", "WRITE"], "scope": {"instancesScope": {"instances": ["123", "456"]}}}}, {"sapWritebackRequestsAcl": {"actions": ["READ", "WRITE"], "scope": {"all": {}}}}, - {"sapWritebackRequestsAcl": {"actions": ["READ", "WRITE"], "instancesScope": {"instances": ["123", "456"]}}}, + { + "sapWritebackRequestsAcl": { + "actions": ["READ", "WRITE"], + "scope": {"instancesScope": {"instances": ["123", "456"]}}, + } + }, {"scheduledCalculationsAcl": {"actions": ["READ", "WRITE"], "scope": {"all": {}}}}, { "securityCategoriesAcl": { From b42889b77ea2420de76cc032942f204e80f29002 Mon Sep 17 00:00:00 2001 From: anders-albert Date: Tue, 12 Nov 2024 08:05:37 +0100 Subject: [PATCH 5/6] fix: LIST not Write --- cognite/client/data_classes/capabilities.py | 2 +- tests/tests_unit/test_data_classes/test_capabilities.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cognite/client/data_classes/capabilities.py b/cognite/client/data_classes/capabilities.py index 5e402dbbe..5fbb58fe0 100644 --- a/cognite/client/data_classes/capabilities.py +++ b/cognite/client/data_classes/capabilities.py @@ -890,8 +890,8 @@ class SAPWritebackRequestsAcl(Capability): scope: AllScope | InstancesScope class Action(Capability.Action): # type: ignore [misc] - Read = "READ" Write = "WRITE" + List = "LIST" class Scope: All = AllScope diff --git a/tests/tests_unit/test_data_classes/test_capabilities.py b/tests/tests_unit/test_data_classes/test_capabilities.py index c7e5995ca..b092c7131 100644 --- a/tests/tests_unit/test_data_classes/test_capabilities.py +++ b/tests/tests_unit/test_data_classes/test_capabilities.py @@ -96,10 +96,10 @@ def all_acls(): {"roboticsAcl": {"actions": ["READ"], "scope": {"datasetScope": {"ids": ["583194012260066"]}}}}, {"sapWritebackAcl": {"actions": ["READ", "WRITE"], "scope": {"all": {}}}}, {"sapWritebackAcl": {"actions": ["READ", "WRITE"], "scope": {"instancesScope": {"instances": ["123", "456"]}}}}, - {"sapWritebackRequestsAcl": {"actions": ["READ", "WRITE"], "scope": {"all": {}}}}, + {"sapWritebackRequestsAcl": {"actions": ["WRITE", "LIST"], "scope": {"all": {}}}}, { "sapWritebackRequestsAcl": { - "actions": ["READ", "WRITE"], + "actions": ["WRITE", "LIST"], "scope": {"instancesScope": {"instances": ["123", "456"]}}, } }, From ccd94a2b093b42b410a57e869d3046c78b797fa1 Mon Sep 17 00:00:00 2001 From: anders-albert Date: Tue, 12 Nov 2024 10:13:39 +0100 Subject: [PATCH 6/6] tests: extended test with for comparing --- tests/tests_unit/test_data_classes/test_capabilities.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/tests_unit/test_data_classes/test_capabilities.py b/tests/tests_unit/test_data_classes/test_capabilities.py index b092c7131..7dcc257a5 100644 --- a/tests/tests_unit/test_data_classes/test_capabilities.py +++ b/tests/tests_unit/test_data_classes/test_capabilities.py @@ -21,6 +21,7 @@ ProjectCapabilityList, ProjectsAcl, RawAcl, + SAPWritebackAcl, SpaceIDScope, TableScope, UnknownAcl, @@ -380,6 +381,13 @@ def proj_capabs_list(project_name): ), project_scope=ProjectCapability.Scope.Projects([project_name]), ), + ProjectCapability( + capability=SAPWritebackAcl( + [SAPWritebackAcl.Action.Read, SAPWritebackAcl.Action.Write], + scope=SAPWritebackAcl.Scope.All(), + ), + project_scope=ProjectCapability.Scope.Projects([project_name]), + ), ] ) @@ -475,6 +483,7 @@ class TestIAMCompareCapabilities: EventsAcl([EventsAcl.Action.Read], scope=EventsAcl.Scope.All()), EventsAcl([EventsAcl.Action.Write], scope=EventsAcl.Scope.DataSet([1, "2"])), RawAcl([RawAcl.Action.Read], scope=RawAcl.Scope.Table({"my_db": ["my_table"]})), + SAPWritebackAcl([SAPWritebackAcl.Action.Write], scope=SAPWritebackAcl.Scope.Instances(["1", "2"])), ], ) def test_has_capability(