Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CDF-23253] SAP writeback acls #2019

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations

__version__ = "7.64.12"
__version__ = "7.64.13"
__api_subversion__ = "20230101"
39 changes: 39 additions & 0 deletions cognite/client/data_classes/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]
Write = "WRITE"
List = "LIST"

class Scope:
All = AllScope
Instances = InstancesScope


@dataclass
class SecurityCategoriesAcl(Capability):
_capability_name = "securityCategoriesAcl"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
18 changes: 18 additions & 0 deletions tests/tests_unit/test_data_classes/test_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
ProjectCapabilityList,
ProjectsAcl,
RawAcl,
SAPWritebackAcl,
SpaceIDScope,
TableScope,
UnknownAcl,
Expand Down Expand Up @@ -94,6 +95,15 @@ 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": ["WRITE", "LIST"], "scope": {"all": {}}}},
{
"sapWritebackRequestsAcl": {
"actions": ["WRITE", "LIST"],
"scope": {"instancesScope": {"instances": ["123", "456"]}},
}
},
{"scheduledCalculationsAcl": {"actions": ["READ", "WRITE"], "scope": {"all": {}}}},
{
"securityCategoriesAcl": {
Expand Down Expand Up @@ -371,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]),
),
]
)

Expand Down Expand Up @@ -466,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(
Expand Down