Skip to content

Commit

Permalink
Add seismic partition scope (#1643)
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonvt authored Feb 24, 2024
1 parent e37b11c commit 6dd8adf
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
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.23.1] - 2024-02-23
### Fixed
- Add missing `partition` scope to `seismicAcl`.

## [7.23.0] - 2024-02-23
### Added
- Make properties on instances (`Node`, `Edge`) easier to work with, by implementing support for direct indexing (and a `.get` method).
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.23.0"
__version__ = "7.23.1"
__api_subversion__ = "20230101"
15 changes: 14 additions & 1 deletion cognite/client/data_classes/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,18 @@ def as_tuples(self) -> set[tuple]:
return {(self._scope_name, s) for s in self.space_ids}


@dataclass(frozen=True)
class PartitionScope(Capability.Scope):
_scope_name = "partition"
partition_ids: list[int]

def __post_init__(self) -> None:
object.__setattr__(self, "partition_ids", [int(i) for i in self.partition_ids])

def as_tuples(self) -> set[tuple]:
return {(self._scope_name, i) for i in self.partition_ids}


@dataclass(frozen=True)
class LegacySpaceScope(Capability.Scope):
_scope_name = "spaceScope"
Expand Down Expand Up @@ -777,14 +789,15 @@ class Scope:
class SeismicAcl(Capability):
_capability_name = "seismicAcl"
actions: Sequence[Action]
scope: AllScope = field(default_factory=AllScope)
scope: AllScope

class Action(Capability.Action):
Read = "READ"
Write = "WRITE"

class Scope:
All = AllScope
Partition = PartitionScope


@dataclass
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.23.0"
version = "7.23.1"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down
1 change: 1 addition & 0 deletions tests/tests_unit/test_data_classes/test_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def all_acls():
}
},
{"seismicAcl": {"actions": ["READ", "WRITE"], "scope": {"all": {}}}},
{"seismicAcl": {"actions": ["WRITE"], "scope": {"partition": {"partitionIds": ["123", 456]}}}},
{"sequencesAcl": {"actions": ["READ"], "scope": {"all": {}}}},
{"sequencesAcl": {"actions": ["WRITE"], "scope": {"datasetScope": {"ids": ["2332579", "372"]}}}},
{"sessionsAcl": {"actions": ["LIST", "CREATE", "DELETE"], "scope": {"all": {}}}},
Expand Down

0 comments on commit 6dd8adf

Please sign in to comment.