cognite-toolkit 0.6.97__py3-none-any.whl → 0.7.39__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cognite_toolkit/_cdf.py +21 -23
- cognite_toolkit/_cdf_tk/apps/__init__.py +4 -0
- cognite_toolkit/_cdf_tk/apps/_core_app.py +19 -5
- cognite_toolkit/_cdf_tk/apps/_data_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_dev_app.py +86 -0
- cognite_toolkit/_cdf_tk/apps/_download_app.py +693 -25
- cognite_toolkit/_cdf_tk/apps/_dump_app.py +44 -102
- cognite_toolkit/_cdf_tk/apps/_import_app.py +41 -0
- cognite_toolkit/_cdf_tk/apps/_landing_app.py +18 -4
- cognite_toolkit/_cdf_tk/apps/_migrate_app.py +424 -9
- cognite_toolkit/_cdf_tk/apps/_modules_app.py +0 -3
- cognite_toolkit/_cdf_tk/apps/_purge.py +15 -43
- cognite_toolkit/_cdf_tk/apps/_run.py +11 -0
- cognite_toolkit/_cdf_tk/apps/_upload_app.py +45 -6
- cognite_toolkit/_cdf_tk/builders/__init__.py +2 -2
- cognite_toolkit/_cdf_tk/builders/_base.py +28 -42
- cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/cdf_toml.py +20 -1
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +32 -12
- cognite_toolkit/_cdf_tk/client/api/infield.py +114 -17
- cognite_toolkit/_cdf_tk/client/api/{canvas.py → legacy/canvas.py} +15 -7
- cognite_toolkit/_cdf_tk/client/api/{charts.py → legacy/charts.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_data_modeling.py → legacy/extended_data_modeling.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_files.py → legacy/extended_files.py} +2 -2
- cognite_toolkit/_cdf_tk/client/api/{extended_functions.py → legacy/extended_functions.py} +15 -18
- cognite_toolkit/_cdf_tk/client/api/{extended_raw.py → legacy/extended_raw.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_timeseries.py → legacy/extended_timeseries.py} +5 -2
- cognite_toolkit/_cdf_tk/client/api/{location_filters.py → legacy/location_filters.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/__init__.py +8 -0
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/capabilities.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/data_postprocessing.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/frames.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/locations.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/maps.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/robots.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/{search_config.py → legacy/search_config.py} +5 -1
- cognite_toolkit/_cdf_tk/client/api/migration.py +177 -4
- cognite_toolkit/_cdf_tk/client/api/project.py +9 -8
- cognite_toolkit/_cdf_tk/client/api/search.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/streams.py +88 -0
- cognite_toolkit/_cdf_tk/client/api/three_d.py +384 -0
- cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +13 -0
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +37 -33
- cognite_toolkit/_cdf_tk/client/data_classes/charts_data.py +95 -213
- cognite_toolkit/_cdf_tk/client/data_classes/infield.py +32 -18
- cognite_toolkit/_cdf_tk/client/data_classes/instance_api.py +18 -13
- cognite_toolkit/_cdf_tk/client/data_classes/legacy/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/client/data_classes/{canvas.py → legacy/canvas.py} +47 -4
- cognite_toolkit/_cdf_tk/client/data_classes/{charts.py → legacy/charts.py} +3 -3
- cognite_toolkit/_cdf_tk/client/data_classes/{migration.py → legacy/migration.py} +10 -2
- cognite_toolkit/_cdf_tk/client/data_classes/streams.py +90 -0
- cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +112 -0
- cognite_toolkit/_cdf_tk/client/testing.py +42 -18
- cognite_toolkit/_cdf_tk/commands/__init__.py +7 -6
- cognite_toolkit/_cdf_tk/commands/_changes.py +3 -42
- cognite_toolkit/_cdf_tk/commands/_download.py +21 -11
- cognite_toolkit/_cdf_tk/commands/_migrate/__init__.py +0 -2
- cognite_toolkit/_cdf_tk/commands/_migrate/command.py +22 -20
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +140 -92
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +108 -26
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +448 -45
- cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py +1 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +6 -6
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +52 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +377 -11
- cognite_toolkit/_cdf_tk/commands/_migrate/selectors.py +9 -4
- cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_purge.py +36 -39
- cognite_toolkit/_cdf_tk/commands/_questionary_style.py +16 -0
- cognite_toolkit/_cdf_tk/commands/_upload.py +109 -86
- cognite_toolkit/_cdf_tk/commands/about.py +221 -0
- cognite_toolkit/_cdf_tk/commands/auth.py +19 -12
- cognite_toolkit/_cdf_tk/commands/build_cmd.py +16 -62
- cognite_toolkit/_cdf_tk/commands/build_v2/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_cmd.py +241 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_input.py +85 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_issues.py +27 -0
- cognite_toolkit/_cdf_tk/commands/clean.py +63 -16
- cognite_toolkit/_cdf_tk/commands/deploy.py +20 -17
- cognite_toolkit/_cdf_tk/commands/dump_resource.py +10 -8
- cognite_toolkit/_cdf_tk/commands/init.py +225 -3
- cognite_toolkit/_cdf_tk/commands/modules.py +20 -44
- cognite_toolkit/_cdf_tk/commands/pull.py +6 -19
- cognite_toolkit/_cdf_tk/commands/resources.py +179 -0
- cognite_toolkit/_cdf_tk/commands/run.py +1 -1
- cognite_toolkit/_cdf_tk/constants.py +20 -1
- cognite_toolkit/_cdf_tk/cruds/__init__.py +19 -5
- cognite_toolkit/_cdf_tk/cruds/_base_cruds.py +14 -70
- cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +10 -19
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/__init__.py +4 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/agent.py +11 -9
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +5 -15
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +45 -44
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +5 -12
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/data_organization.py +4 -13
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +206 -67
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +6 -18
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +126 -35
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +7 -28
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +23 -30
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/hosted_extractors.py +12 -30
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +4 -8
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +4 -16
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +5 -13
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +5 -11
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +3 -8
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +16 -45
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +94 -0
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/three_d_model.py +3 -7
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +5 -15
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +75 -32
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/workflow.py +20 -40
- cognite_toolkit/_cdf_tk/cruds/_worker.py +24 -36
- cognite_toolkit/_cdf_tk/data_classes/_module_toml.py +1 -0
- cognite_toolkit/_cdf_tk/feature_flags.py +16 -36
- cognite_toolkit/_cdf_tk/plugins.py +2 -1
- cognite_toolkit/_cdf_tk/resource_classes/__init__.py +4 -0
- cognite_toolkit/_cdf_tk/resource_classes/capabilities.py +12 -0
- cognite_toolkit/_cdf_tk/resource_classes/functions.py +3 -1
- cognite_toolkit/_cdf_tk/resource_classes/infield_cdm_location_config.py +109 -0
- cognite_toolkit/_cdf_tk/resource_classes/migration.py +8 -17
- cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/resource_classes/streams.py +29 -0
- cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +164 -5
- cognite_toolkit/_cdf_tk/storageio/__init__.py +9 -21
- cognite_toolkit/_cdf_tk/storageio/_annotations.py +19 -16
- cognite_toolkit/_cdf_tk/storageio/_applications.py +340 -28
- cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +67 -104
- cognite_toolkit/_cdf_tk/storageio/_base.py +61 -29
- cognite_toolkit/_cdf_tk/storageio/_datapoints.py +276 -20
- cognite_toolkit/_cdf_tk/storageio/_file_content.py +435 -0
- cognite_toolkit/_cdf_tk/storageio/_instances.py +35 -3
- cognite_toolkit/_cdf_tk/storageio/_raw.py +26 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/__init__.py +71 -4
- cognite_toolkit/_cdf_tk/storageio/selectors/_base.py +14 -2
- cognite_toolkit/_cdf_tk/storageio/selectors/_canvas.py +14 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/_charts.py +14 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/_datapoints.py +23 -3
- cognite_toolkit/_cdf_tk/storageio/selectors/_file_content.py +164 -0
- cognite_toolkit/_cdf_tk/storageio/selectors/_three_d.py +34 -0
- cognite_toolkit/_cdf_tk/tk_warnings/other.py +4 -0
- cognite_toolkit/_cdf_tk/tracker.py +2 -2
- cognite_toolkit/_cdf_tk/utils/cdf.py +1 -1
- cognite_toolkit/_cdf_tk/utils/dtype_conversion.py +9 -3
- cognite_toolkit/_cdf_tk/utils/fileio/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/utils/fileio/_base.py +5 -1
- cognite_toolkit/_cdf_tk/utils/fileio/_readers.py +112 -20
- cognite_toolkit/_cdf_tk/utils/fileio/_writers.py +15 -15
- cognite_toolkit/_cdf_tk/utils/http_client/__init__.py +28 -0
- cognite_toolkit/_cdf_tk/utils/http_client/_client.py +285 -18
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes.py +56 -4
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +247 -0
- cognite_toolkit/_cdf_tk/utils/http_client/_tracker.py +5 -2
- cognite_toolkit/_cdf_tk/utils/interactive_select.py +60 -18
- cognite_toolkit/_cdf_tk/utils/sql_parser.py +2 -3
- cognite_toolkit/_cdf_tk/utils/useful_types.py +6 -2
- cognite_toolkit/_cdf_tk/validation.py +83 -1
- cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml +1 -1
- cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml +1 -1
- cognite_toolkit/_resources/cdf.toml +5 -4
- cognite_toolkit/_version.py +1 -1
- cognite_toolkit/config.dev.yaml +13 -0
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.39.dist-info}/METADATA +24 -24
- cognite_toolkit-0.7.39.dist-info/RECORD +322 -0
- cognite_toolkit-0.7.39.dist-info/WHEEL +4 -0
- {cognite_toolkit-0.6.97.dist-info → cognite_toolkit-0.7.39.dist-info}/entry_points.txt +1 -0
- cognite_toolkit/_cdf_tk/client/api/robotics/__init__.py +0 -3
- cognite_toolkit/_cdf_tk/commands/_migrate/canvas.py +0 -201
- cognite_toolkit/_cdf_tk/commands/dump_data.py +0 -489
- cognite_toolkit/_cdf_tk/commands/featureflag.py +0 -27
- cognite_toolkit/_cdf_tk/prototypes/import_app.py +0 -41
- cognite_toolkit/_cdf_tk/utils/table_writers.py +0 -434
- cognite_toolkit-0.6.97.dist-info/RECORD +0 -306
- cognite_toolkit-0.6.97.dist-info/WHEEL +0 -4
- cognite_toolkit-0.6.97.dist-info/licenses/LICENSE +0 -18
- /cognite_toolkit/_cdf_tk/{prototypes/commands → client/api/legacy}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{dml.py → legacy/dml.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{fixed_transformations.py → legacy/fixed_transformations.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/api.py +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/utlis.py +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{apm_config_v1.py → legacy/apm_config_v1.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extendable_cognite_file.py → legacy/extendable_cognite_file.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_filemetadata.py → legacy/extended_filemetadata.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_filemetdata.py → legacy/extended_filemetdata.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_timeseries.py → legacy/extended_timeseries.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{functions.py → legacy/functions.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{graphql_data_models.py → legacy/graphql_data_models.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{instances.py → legacy/instances.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{location_filters.py → legacy/location_filters.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{pending_instances_ids.py → legacy/pending_instances_ids.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{project.py → legacy/project.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{raw.py → legacy/raw.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{robotics.py → legacy/robotics.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{search_config.py → legacy/search_config.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{sequences.py → legacy/sequences.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{streamlit_.py → legacy/streamlit_.py} +0 -0
- /cognite_toolkit/_cdf_tk/{prototypes/commands/import_.py → commands/_import_cmd.py} +0 -0
|
@@ -7,11 +7,10 @@ from cognite.client.data_classes.capabilities import Capability, LocationFilters
|
|
|
7
7
|
from cognite.client.data_classes.data_modeling import DataModelId, ViewId
|
|
8
8
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
9
9
|
|
|
10
|
-
from cognite_toolkit._cdf_tk.client.data_classes.location_filters import (
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.location_filters import (
|
|
11
11
|
LocationFilter,
|
|
12
12
|
LocationFilterList,
|
|
13
13
|
LocationFilterWrite,
|
|
14
|
-
LocationFilterWriteList,
|
|
15
14
|
)
|
|
16
15
|
from cognite_toolkit._cdf_tk.constants import BUILD_FOLDER_ENCODING
|
|
17
16
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
@@ -28,15 +27,10 @@ from .timeseries import TimeSeriesCRUD
|
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
@final
|
|
31
|
-
class LocationFilterCRUD(
|
|
32
|
-
ResourceCRUD[str, LocationFilterWrite, LocationFilter, LocationFilterWriteList, LocationFilterList]
|
|
33
|
-
):
|
|
30
|
+
class LocationFilterCRUD(ResourceCRUD[str, LocationFilterWrite, LocationFilter]):
|
|
34
31
|
folder_name = "locations"
|
|
35
|
-
filename_pattern = r"^.*LocationFilter$"
|
|
36
32
|
resource_cls = LocationFilter
|
|
37
33
|
resource_write_cls = LocationFilterWrite
|
|
38
|
-
list_cls = LocationFilterList
|
|
39
|
-
list_write_cls = LocationFilterWriteList
|
|
40
34
|
yaml_cls = LocationYAML
|
|
41
35
|
dependencies = frozenset(
|
|
42
36
|
{
|
|
@@ -182,10 +176,7 @@ class LocationFilterCRUD(
|
|
|
182
176
|
*e.args[1:],
|
|
183
177
|
) from None
|
|
184
178
|
|
|
185
|
-
def create(self, items: LocationFilterWrite
|
|
186
|
-
if isinstance(items, LocationFilterWrite):
|
|
187
|
-
items = LocationFilterWriteList([items])
|
|
188
|
-
|
|
179
|
+
def create(self, items: Sequence[LocationFilterWrite]) -> LocationFilterList:
|
|
189
180
|
created: list[LocationFilter] = []
|
|
190
181
|
# Note: the Location API does not support batch creation, so we need to do this one by one.
|
|
191
182
|
# Furthermore, we could not do the parentExternalId->parentId lookup before the parent was created,
|
|
@@ -213,10 +204,7 @@ class LocationFilterCRUD(
|
|
|
213
204
|
_recursive_find(all_locations)
|
|
214
205
|
return LocationFilterList(found_locations)
|
|
215
206
|
|
|
216
|
-
def update(self, items: LocationFilterWrite
|
|
217
|
-
if isinstance(items, LocationFilterWrite):
|
|
218
|
-
items = LocationFilterWriteList([items])
|
|
219
|
-
|
|
207
|
+
def update(self, items: Sequence[LocationFilterWrite]) -> LocationFilterList:
|
|
220
208
|
updated = []
|
|
221
209
|
ids = {item.external_id: item.id for item in self.retrieve([item.external_id for item in items])}
|
|
222
210
|
for update in items:
|
|
@@ -3,10 +3,10 @@ from typing import Any, final
|
|
|
3
3
|
|
|
4
4
|
from cognite.client.data_classes import capabilities
|
|
5
5
|
from cognite.client.data_classes.capabilities import Capability
|
|
6
|
-
from cognite.client.data_classes.data_modeling import
|
|
6
|
+
from cognite.client.data_classes.data_modeling import NodeList, ViewId
|
|
7
7
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
8
8
|
|
|
9
|
-
from cognite_toolkit._cdf_tk.client.data_classes.migration import (
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.migration import (
|
|
10
10
|
ResourceViewMapping,
|
|
11
11
|
ResourceViewMappingApply,
|
|
12
12
|
)
|
|
@@ -19,18 +19,10 @@ from .datamodel import SpaceCRUD, ViewCRUD
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
@final
|
|
22
|
-
class ResourceViewMappingCRUD(
|
|
23
|
-
ResourceCRUD[str, ResourceViewMappingApply, ResourceViewMapping, NodeApplyList, NodeList[ResourceViewMapping]]
|
|
24
|
-
):
|
|
22
|
+
class ResourceViewMappingCRUD(ResourceCRUD[str, ResourceViewMappingApply, ResourceViewMapping]):
|
|
25
23
|
folder_name = "migration"
|
|
26
|
-
filename_pattern = (
|
|
27
|
-
r"^.*\.ResourceViewMapping$" # Matches all yaml files whose stem ends with '.ResourceViewMapping$'.
|
|
28
|
-
)
|
|
29
|
-
filetypes = frozenset({"yaml", "yml"})
|
|
30
24
|
resource_cls = ResourceViewMapping
|
|
31
25
|
resource_write_cls = ResourceViewMappingApply
|
|
32
|
-
list_cls = NodeList[ResourceViewMapping]
|
|
33
|
-
list_write_cls = NodeApplyList
|
|
34
26
|
kind = "ResourceViewMapping"
|
|
35
27
|
dependencies = frozenset({SpaceCRUD, ViewCRUD})
|
|
36
28
|
_doc_url = "Instances/operation/applyNodeAndEdges"
|
|
@@ -74,10 +66,10 @@ class ResourceViewMappingCRUD(
|
|
|
74
66
|
return None
|
|
75
67
|
return f"{self.display_name} requires the {view_id!r} to be deployed. run `cdf migrate prepare` to deploy it."
|
|
76
68
|
|
|
77
|
-
def create(self, items:
|
|
69
|
+
def create(self, items: Sequence[ResourceViewMappingApply]) -> Sized:
|
|
78
70
|
return self.client.migration.resource_view_mapping.upsert(items)
|
|
79
71
|
|
|
80
|
-
def update(self, items:
|
|
72
|
+
def update(self, items: Sequence[ResourceViewMappingApply]) -> Sized:
|
|
81
73
|
return self.client.migration.resource_view_mapping.upsert(items)
|
|
82
74
|
|
|
83
75
|
def retrieve(self, ids: SequenceNotStr[str]) -> NodeList[ResourceViewMapping]:
|
|
@@ -29,7 +29,7 @@ from rich import print
|
|
|
29
29
|
from rich.console import Console
|
|
30
30
|
|
|
31
31
|
from cognite_toolkit._cdf_tk.client import ToolkitClient
|
|
32
|
-
from cognite_toolkit._cdf_tk.client.data_classes.raw import RawDatabase, RawDatabaseList, RawTable, RawTableList
|
|
32
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.raw import RawDatabase, RawDatabaseList, RawTable, RawTableList
|
|
33
33
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceContainerCRUD, ResourceCRUD
|
|
34
34
|
from cognite_toolkit._cdf_tk.resource_classes import DatabaseYAML, TableYAML
|
|
35
35
|
|
|
@@ -37,14 +37,11 @@ from .auth import GroupAllScopedCRUD
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
@final
|
|
40
|
-
class RawDatabaseCRUD(ResourceContainerCRUD[RawDatabase, RawDatabase, RawDatabase
|
|
40
|
+
class RawDatabaseCRUD(ResourceContainerCRUD[RawDatabase, RawDatabase, RawDatabase]):
|
|
41
41
|
item_name = "raw tables"
|
|
42
42
|
folder_name = "raw"
|
|
43
|
-
filename_pattern = r"^(?!.*Table$).*$"
|
|
44
43
|
resource_cls = RawDatabase
|
|
45
44
|
resource_write_cls = RawDatabase
|
|
46
|
-
list_cls = RawDatabaseList
|
|
47
|
-
list_write_cls = RawDatabaseList
|
|
48
45
|
kind = "Database"
|
|
49
46
|
yaml_cls = DatabaseYAML
|
|
50
47
|
dependencies = frozenset({GroupAllScopedCRUD})
|
|
@@ -92,7 +89,7 @@ class RawDatabaseCRUD(ResourceContainerCRUD[RawDatabase, RawDatabase, RawDatabas
|
|
|
92
89
|
def dump_id(cls, id: RawDatabase) -> dict[str, Any]:
|
|
93
90
|
return {"dbName": id.db_name}
|
|
94
91
|
|
|
95
|
-
def create(self, items:
|
|
92
|
+
def create(self, items: Sequence[RawDatabase]) -> RawDatabaseList:
|
|
96
93
|
database_list = self.client.raw.databases.create([db.db_name for db in items])
|
|
97
94
|
return RawDatabaseList([RawDatabase(db_name=db.name) for db in database_list if db.name])
|
|
98
95
|
|
|
@@ -151,14 +148,11 @@ class RawDatabaseCRUD(ResourceContainerCRUD[RawDatabase, RawDatabase, RawDatabas
|
|
|
151
148
|
|
|
152
149
|
|
|
153
150
|
@final
|
|
154
|
-
class RawTableCRUD(ResourceContainerCRUD[RawTable, RawTable, RawTable
|
|
151
|
+
class RawTableCRUD(ResourceContainerCRUD[RawTable, RawTable, RawTable]):
|
|
155
152
|
item_name = "raw rows"
|
|
156
153
|
folder_name = "raw"
|
|
157
|
-
filename_pattern = r"^(?!.*Database$).*$"
|
|
158
154
|
resource_cls = RawTable
|
|
159
155
|
resource_write_cls = RawTable
|
|
160
|
-
list_cls = RawTableList
|
|
161
|
-
list_write_cls = RawTableList
|
|
162
156
|
kind = "Table"
|
|
163
157
|
yaml_cls = TableYAML
|
|
164
158
|
support_update = False
|
|
@@ -215,7 +209,7 @@ class RawTableCRUD(ResourceContainerCRUD[RawTable, RawTable, RawTable, RawTableL
|
|
|
215
209
|
if "dbName" in item:
|
|
216
210
|
yield RawDatabaseCRUD, RawDatabase(item["dbName"])
|
|
217
211
|
|
|
218
|
-
def create(self, items:
|
|
212
|
+
def create(self, items: Sequence[RawTable]) -> RawTableList:
|
|
219
213
|
created = RawTableList([])
|
|
220
214
|
for db_name, raw_tables in itertools.groupby(sorted(items, key=lambda x: x.db_name), key=lambda x: x.db_name):
|
|
221
215
|
tables = [table.table_name for table in raw_tables]
|
|
@@ -5,7 +5,6 @@ from cognite.client.data_classes import (
|
|
|
5
5
|
Relationship,
|
|
6
6
|
RelationshipList,
|
|
7
7
|
RelationshipWrite,
|
|
8
|
-
RelationshipWriteList,
|
|
9
8
|
capabilities,
|
|
10
9
|
)
|
|
11
10
|
from cognite.client.data_classes.capabilities import Capability
|
|
@@ -22,14 +21,10 @@ from .timeseries import TimeSeriesCRUD
|
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
@final
|
|
25
|
-
class RelationshipCRUD(ResourceCRUD[str, RelationshipWrite, Relationship
|
|
24
|
+
class RelationshipCRUD(ResourceCRUD[str, RelationshipWrite, Relationship]):
|
|
26
25
|
folder_name = "classic"
|
|
27
|
-
filename_pattern = r"^.*\.Relationship$" # Matches all yaml files whose stem ends with '.Asset'.
|
|
28
|
-
filetypes = frozenset({"yaml", "yml"})
|
|
29
26
|
resource_cls = Relationship
|
|
30
27
|
resource_write_cls = RelationshipWrite
|
|
31
|
-
list_cls = RelationshipList
|
|
32
|
-
list_write_cls = RelationshipWriteList
|
|
33
28
|
kind = "Relationship"
|
|
34
29
|
yaml_cls = RelationshipYAML
|
|
35
30
|
dependencies = frozenset(
|
|
@@ -75,13 +70,13 @@ class RelationshipCRUD(ResourceCRUD[str, RelationshipWrite, Relationship, Relati
|
|
|
75
70
|
|
|
76
71
|
return capabilities.RelationshipsAcl(actions, scope)
|
|
77
72
|
|
|
78
|
-
def create(self, items:
|
|
73
|
+
def create(self, items: Sequence[RelationshipWrite]) -> RelationshipList:
|
|
79
74
|
return self.client.relationships.create(items)
|
|
80
75
|
|
|
81
76
|
def retrieve(self, ids: SequenceNotStr[str]) -> RelationshipList:
|
|
82
77
|
return self.client.relationships.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
83
78
|
|
|
84
|
-
def update(self, items:
|
|
79
|
+
def update(self, items: Sequence[RelationshipWrite]) -> RelationshipList:
|
|
85
80
|
return self.client.relationships.update(items)
|
|
86
81
|
|
|
87
82
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -9,27 +9,22 @@ from cognite.client.data_classes.capabilities import Capability
|
|
|
9
9
|
from cognite.client.exceptions import CogniteAPIError
|
|
10
10
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
11
11
|
|
|
12
|
-
from cognite_toolkit._cdf_tk.client.data_classes.robotics import (
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.robotics import (
|
|
13
13
|
DataPostProcessing,
|
|
14
14
|
DataPostProcessingList,
|
|
15
15
|
DataPostProcessingWrite,
|
|
16
|
-
DataPostProcessingWriteList,
|
|
17
16
|
Frame,
|
|
18
17
|
FrameList,
|
|
19
18
|
FrameWrite,
|
|
20
|
-
FrameWriteList,
|
|
21
19
|
Location,
|
|
22
20
|
LocationList,
|
|
23
21
|
LocationWrite,
|
|
24
|
-
LocationWriteList,
|
|
25
22
|
Map,
|
|
26
23
|
MapList,
|
|
27
24
|
MapWrite,
|
|
28
|
-
MapWriteList,
|
|
29
25
|
RobotCapability,
|
|
30
26
|
RobotCapabilityList,
|
|
31
27
|
RobotCapabilityWrite,
|
|
32
|
-
RobotCapabilityWriteList,
|
|
33
28
|
)
|
|
34
29
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
35
30
|
from cognite_toolkit._cdf_tk.resource_classes import (
|
|
@@ -42,13 +37,10 @@ from cognite_toolkit._cdf_tk.resource_classes import (
|
|
|
42
37
|
from cognite_toolkit._cdf_tk.utils.diff_list import diff_list_hashable
|
|
43
38
|
|
|
44
39
|
|
|
45
|
-
class RoboticFrameCRUD(ResourceCRUD[str, FrameWrite, Frame
|
|
40
|
+
class RoboticFrameCRUD(ResourceCRUD[str, FrameWrite, Frame]):
|
|
46
41
|
folder_name = "robotics"
|
|
47
|
-
filename_pattern = r"^.*\.Frame$" # Matches all yaml files whose stem ends with '.Frame'.
|
|
48
42
|
resource_cls = Frame
|
|
49
43
|
resource_write_cls = FrameWrite
|
|
50
|
-
list_cls = FrameList
|
|
51
|
-
list_write_cls = FrameWriteList
|
|
52
44
|
kind = "Frame"
|
|
53
45
|
yaml_cls = RobotFrameYAML
|
|
54
46
|
_doc_url = "Frames/operation/createFrames"
|
|
@@ -81,18 +73,17 @@ class RoboticFrameCRUD(ResourceCRUD[str, FrameWrite, Frame, FrameWriteList, Fram
|
|
|
81
73
|
capabilities.RoboticsAcl.Action.Create,
|
|
82
74
|
capabilities.RoboticsAcl.Action.Delete,
|
|
83
75
|
capabilities.RoboticsAcl.Action.Update,
|
|
84
|
-
capabilities.RoboticsAcl.Action.Delete,
|
|
85
76
|
],
|
|
86
77
|
capabilities.RoboticsAcl.Scope.All(),
|
|
87
78
|
)
|
|
88
79
|
|
|
89
|
-
def create(self, items:
|
|
80
|
+
def create(self, items: Sequence[FrameWrite]) -> FrameList:
|
|
90
81
|
return self.client.robotics.frames.create(items)
|
|
91
82
|
|
|
92
83
|
def retrieve(self, ids: SequenceNotStr[str]) -> FrameList:
|
|
93
84
|
return _fallback_to_one_by_one(self.client.robotics.frames.retrieve, ids, FrameList)
|
|
94
85
|
|
|
95
|
-
def update(self, items:
|
|
86
|
+
def update(self, items: Sequence[FrameWrite]) -> FrameList:
|
|
96
87
|
return self.client.robotics.frames.update(items)
|
|
97
88
|
|
|
98
89
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -111,13 +102,10 @@ class RoboticFrameCRUD(ResourceCRUD[str, FrameWrite, Frame, FrameWriteList, Fram
|
|
|
111
102
|
return iter(self.client.robotics.frames)
|
|
112
103
|
|
|
113
104
|
|
|
114
|
-
class RoboticLocationCRUD(ResourceCRUD[str, LocationWrite, Location
|
|
105
|
+
class RoboticLocationCRUD(ResourceCRUD[str, LocationWrite, Location]):
|
|
115
106
|
folder_name = "robotics"
|
|
116
|
-
filename_pattern = r"^.*\.Location$" # Matches all yaml files whose stem ends with '.Location'.
|
|
117
107
|
resource_cls = Location
|
|
118
108
|
resource_write_cls = LocationWrite
|
|
119
|
-
list_cls = LocationList
|
|
120
|
-
list_write_cls = LocationWriteList
|
|
121
109
|
kind = "Location"
|
|
122
110
|
yaml_cls = RobotLocationYAML
|
|
123
111
|
_doc_url = "Locations/operation/createLocations"
|
|
@@ -154,19 +142,18 @@ class RoboticLocationCRUD(ResourceCRUD[str, LocationWrite, Location, LocationWri
|
|
|
154
142
|
capabilities.RoboticsAcl.Action.Create,
|
|
155
143
|
capabilities.RoboticsAcl.Action.Delete,
|
|
156
144
|
capabilities.RoboticsAcl.Action.Update,
|
|
157
|
-
capabilities.RoboticsAcl.Action.Delete,
|
|
158
145
|
]
|
|
159
146
|
)
|
|
160
147
|
|
|
161
148
|
return capabilities.RoboticsAcl(actions, capabilities.RoboticsAcl.Scope.All())
|
|
162
149
|
|
|
163
|
-
def create(self, items:
|
|
150
|
+
def create(self, items: Sequence[LocationWrite]) -> LocationList:
|
|
164
151
|
return self.client.robotics.locations.create(items)
|
|
165
152
|
|
|
166
153
|
def retrieve(self, ids: SequenceNotStr[str]) -> LocationList:
|
|
167
154
|
return _fallback_to_one_by_one(self.client.robotics.locations.retrieve, ids, LocationList)
|
|
168
155
|
|
|
169
|
-
def update(self, items:
|
|
156
|
+
def update(self, items: Sequence[LocationWrite]) -> LocationList:
|
|
170
157
|
return self.client.robotics.locations.update(items)
|
|
171
158
|
|
|
172
159
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -185,15 +172,10 @@ class RoboticLocationCRUD(ResourceCRUD[str, LocationWrite, Location, LocationWri
|
|
|
185
172
|
return iter(self.client.robotics.locations)
|
|
186
173
|
|
|
187
174
|
|
|
188
|
-
class RoboticsDataPostProcessingCRUD(
|
|
189
|
-
ResourceCRUD[str, DataPostProcessingWrite, DataPostProcessing, DataPostProcessingWriteList, DataPostProcessingList]
|
|
190
|
-
):
|
|
175
|
+
class RoboticsDataPostProcessingCRUD(ResourceCRUD[str, DataPostProcessingWrite, DataPostProcessing]):
|
|
191
176
|
folder_name = "robotics"
|
|
192
|
-
filename_pattern = r"^.*\.DataPostProcessing$" # Matches all yaml files whose stem ends with '.DataPostProcessing'.
|
|
193
177
|
resource_cls = DataPostProcessing
|
|
194
178
|
resource_write_cls = DataPostProcessingWrite
|
|
195
|
-
list_cls = DataPostProcessingList
|
|
196
|
-
list_write_cls = DataPostProcessingWriteList
|
|
197
179
|
kind = "DataPostProcessing"
|
|
198
180
|
yaml_cls = RobotDataPostProcessingYAML
|
|
199
181
|
_doc_url = "DataPostProcessing/operation/createDataPostProcessing"
|
|
@@ -230,19 +212,18 @@ class RoboticsDataPostProcessingCRUD(
|
|
|
230
212
|
capabilities.RoboticsAcl.Action.Create,
|
|
231
213
|
capabilities.RoboticsAcl.Action.Delete,
|
|
232
214
|
capabilities.RoboticsAcl.Action.Update,
|
|
233
|
-
capabilities.RoboticsAcl.Action.Delete,
|
|
234
215
|
]
|
|
235
216
|
)
|
|
236
217
|
|
|
237
218
|
return capabilities.RoboticsAcl(actions, capabilities.RoboticsAcl.Scope.All())
|
|
238
219
|
|
|
239
|
-
def create(self, items:
|
|
220
|
+
def create(self, items: Sequence[DataPostProcessingWrite]) -> DataPostProcessingList:
|
|
240
221
|
return self.client.robotics.data_postprocessing.create(items)
|
|
241
222
|
|
|
242
223
|
def retrieve(self, ids: SequenceNotStr[str]) -> DataPostProcessingList:
|
|
243
224
|
return _fallback_to_one_by_one(self.client.robotics.data_postprocessing.retrieve, ids, DataPostProcessingList)
|
|
244
225
|
|
|
245
|
-
def update(self, items:
|
|
226
|
+
def update(self, items: Sequence[DataPostProcessingWrite]) -> DataPostProcessingList:
|
|
246
227
|
# There is a bug in the /update endpoint that requires the input_schema to be a string
|
|
247
228
|
# and not an object. This is a workaround until the bug is fixed.
|
|
248
229
|
# We do the serialization to avoid modifying the original object.
|
|
@@ -280,15 +261,10 @@ class RoboticsDataPostProcessingCRUD(
|
|
|
280
261
|
return super().diff_list(local, cdf, json_path)
|
|
281
262
|
|
|
282
263
|
|
|
283
|
-
class RobotCapabilityCRUD(
|
|
284
|
-
ResourceCRUD[str, RobotCapabilityWrite, RobotCapability, RobotCapabilityWriteList, RobotCapabilityList]
|
|
285
|
-
):
|
|
264
|
+
class RobotCapabilityCRUD(ResourceCRUD[str, RobotCapabilityWrite, RobotCapability]):
|
|
286
265
|
folder_name = "robotics"
|
|
287
|
-
filename_pattern = r"^.*\.RobotCapability$" # Matches all yaml files whose stem ends with '.RobotCapability'.
|
|
288
266
|
resource_cls = RobotCapability
|
|
289
267
|
resource_write_cls = RobotCapabilityWrite
|
|
290
|
-
list_cls = RobotCapabilityList
|
|
291
|
-
list_write_cls = RobotCapabilityWriteList
|
|
292
268
|
kind = "RobotCapability"
|
|
293
269
|
yaml_cls = RobotCapabilityYAML
|
|
294
270
|
_doc_url = "RobotCapabilities/operation/createRobotCapabilities"
|
|
@@ -325,19 +301,18 @@ class RobotCapabilityCRUD(
|
|
|
325
301
|
capabilities.RoboticsAcl.Action.Create,
|
|
326
302
|
capabilities.RoboticsAcl.Action.Delete,
|
|
327
303
|
capabilities.RoboticsAcl.Action.Update,
|
|
328
|
-
capabilities.RoboticsAcl.Action.Delete,
|
|
329
304
|
]
|
|
330
305
|
)
|
|
331
306
|
|
|
332
307
|
return capabilities.RoboticsAcl(actions, capabilities.RoboticsAcl.Scope.All())
|
|
333
308
|
|
|
334
|
-
def create(self, items:
|
|
309
|
+
def create(self, items: Sequence[RobotCapabilityWrite]) -> RobotCapabilityList:
|
|
335
310
|
return self.client.robotics.capabilities.create(items)
|
|
336
311
|
|
|
337
312
|
def retrieve(self, ids: SequenceNotStr[str]) -> RobotCapabilityList:
|
|
338
313
|
return _fallback_to_one_by_one(self.client.robotics.capabilities.retrieve, ids, RobotCapabilityList)
|
|
339
314
|
|
|
340
|
-
def update(self, items:
|
|
315
|
+
def update(self, items: Sequence[RobotCapabilityWrite]) -> RobotCapabilityList:
|
|
341
316
|
# There is a bug in the /update endpoint that requires the input_schema to be a string
|
|
342
317
|
# and not an object. This is a workaround until the bug is fixed.
|
|
343
318
|
# We do the serialization to avoid modifying the original object.
|
|
@@ -378,13 +353,10 @@ class RobotCapabilityCRUD(
|
|
|
378
353
|
return super().diff_list(local, cdf, json_path)
|
|
379
354
|
|
|
380
355
|
|
|
381
|
-
class RoboticMapCRUD(ResourceCRUD[str, MapWrite, Map
|
|
356
|
+
class RoboticMapCRUD(ResourceCRUD[str, MapWrite, Map]):
|
|
382
357
|
folder_name = "robotics"
|
|
383
|
-
filename_pattern = r"^.*\.Map$" # Matches all yaml files whose stem ends with '.Map'.
|
|
384
358
|
resource_cls = Map
|
|
385
359
|
resource_write_cls = MapWrite
|
|
386
|
-
list_cls = MapList
|
|
387
|
-
list_write_cls = MapWriteList
|
|
388
360
|
kind = "Map"
|
|
389
361
|
dependencies = frozenset({RoboticFrameCRUD, RoboticLocationCRUD})
|
|
390
362
|
yaml_cls = RobotMapYAML
|
|
@@ -423,7 +395,6 @@ class RoboticMapCRUD(ResourceCRUD[str, MapWrite, Map, MapWriteList, MapList]):
|
|
|
423
395
|
capabilities.RoboticsAcl.Action.Create,
|
|
424
396
|
capabilities.RoboticsAcl.Action.Delete,
|
|
425
397
|
capabilities.RoboticsAcl.Action.Update,
|
|
426
|
-
capabilities.RoboticsAcl.Action.Delete,
|
|
427
398
|
]
|
|
428
399
|
)
|
|
429
400
|
|
|
@@ -437,13 +408,13 @@ class RoboticMapCRUD(ResourceCRUD[str, MapWrite, Map, MapWriteList, MapList]):
|
|
|
437
408
|
del dump["scale"]
|
|
438
409
|
return dump
|
|
439
410
|
|
|
440
|
-
def create(self, items:
|
|
411
|
+
def create(self, items: Sequence[MapWrite]) -> MapList:
|
|
441
412
|
return self.client.robotics.maps.create(items)
|
|
442
413
|
|
|
443
414
|
def retrieve(self, ids: SequenceNotStr[str]) -> MapList:
|
|
444
415
|
return _fallback_to_one_by_one(self.client.robotics.maps.retrieve, ids, MapList)
|
|
445
416
|
|
|
446
|
-
def update(self, items:
|
|
417
|
+
def update(self, items: Sequence[MapWrite]) -> MapList:
|
|
447
418
|
return self.client.robotics.maps.update(items)
|
|
448
419
|
|
|
449
420
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from collections.abc import Hashable, Iterable, Sequence
|
|
2
|
+
from typing import Any, final
|
|
3
|
+
|
|
4
|
+
from cognite.client.data_classes.capabilities import Capability, StreamsAcl
|
|
5
|
+
from cognite.client.utils.useful_types import SequenceNotStr
|
|
6
|
+
|
|
7
|
+
from cognite_toolkit._cdf_tk.client.data_classes.streams import (
|
|
8
|
+
StreamRequest,
|
|
9
|
+
StreamResponse,
|
|
10
|
+
StreamResponseList,
|
|
11
|
+
)
|
|
12
|
+
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
13
|
+
from cognite_toolkit._cdf_tk.resource_classes import StreamYAML
|
|
14
|
+
from cognite_toolkit._cdf_tk.utils.http_client import ToolkitAPIError
|
|
15
|
+
|
|
16
|
+
from .datamodel import ContainerCRUD
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@final
|
|
20
|
+
class StreamCRUD(ResourceCRUD[str, StreamRequest, StreamResponse]):
|
|
21
|
+
folder_name = "streams"
|
|
22
|
+
resource_cls = StreamResponse
|
|
23
|
+
resource_write_cls = StreamRequest
|
|
24
|
+
kind = "Streams"
|
|
25
|
+
yaml_cls = StreamYAML
|
|
26
|
+
dependencies = frozenset({ContainerCRUD})
|
|
27
|
+
_doc_url = "Streams/operation/createStream"
|
|
28
|
+
support_update = False
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def display_name(self) -> str:
|
|
32
|
+
return "streams"
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def get_id(cls, item: StreamRequest | StreamResponse | dict) -> str:
|
|
36
|
+
if isinstance(item, dict):
|
|
37
|
+
return item["externalId"]
|
|
38
|
+
return item.external_id
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def dump_id(cls, id: str) -> dict[str, Any]:
|
|
42
|
+
return {"externalId": id}
|
|
43
|
+
|
|
44
|
+
@classmethod
|
|
45
|
+
def get_required_capability(
|
|
46
|
+
cls, items: Sequence[StreamRequest] | None, read_only: bool
|
|
47
|
+
) -> Capability | list[Capability]:
|
|
48
|
+
if not items and items is not None:
|
|
49
|
+
return []
|
|
50
|
+
|
|
51
|
+
actions = (
|
|
52
|
+
[StreamsAcl.Action.Read]
|
|
53
|
+
if read_only
|
|
54
|
+
else [StreamsAcl.Action.Read, StreamsAcl.Action.Create, StreamsAcl.Action.Delete]
|
|
55
|
+
)
|
|
56
|
+
return StreamsAcl(actions, StreamsAcl.Scope.All())
|
|
57
|
+
|
|
58
|
+
def create(self, items: Sequence[StreamRequest]) -> StreamResponseList:
|
|
59
|
+
created = self.client.streams.create(list(items))
|
|
60
|
+
return StreamResponseList(created)
|
|
61
|
+
|
|
62
|
+
def retrieve(self, ids: SequenceNotStr[str]) -> StreamResponseList:
|
|
63
|
+
retrieved: list[StreamResponse] = []
|
|
64
|
+
for _id in ids:
|
|
65
|
+
try:
|
|
66
|
+
_resp = self.client.streams.retrieve(_id)
|
|
67
|
+
except ToolkitAPIError:
|
|
68
|
+
continue
|
|
69
|
+
if _resp is not None:
|
|
70
|
+
retrieved.append(_resp)
|
|
71
|
+
return StreamResponseList(retrieved)
|
|
72
|
+
|
|
73
|
+
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
74
|
+
count = 0
|
|
75
|
+
for _id in ids:
|
|
76
|
+
try:
|
|
77
|
+
self.client.streams.delete(_id)
|
|
78
|
+
except ToolkitAPIError:
|
|
79
|
+
continue
|
|
80
|
+
count += 1
|
|
81
|
+
return count
|
|
82
|
+
|
|
83
|
+
def _iterate(
|
|
84
|
+
self,
|
|
85
|
+
data_set_external_id: str | None = None,
|
|
86
|
+
space: str | None = None,
|
|
87
|
+
parent_ids: list[Hashable] | None = None,
|
|
88
|
+
) -> Iterable[StreamResponse]:
|
|
89
|
+
if data_set_external_id or space or parent_ids:
|
|
90
|
+
# These filters are not supported for Streams
|
|
91
|
+
return iter([])
|
|
92
|
+
|
|
93
|
+
all_streams = self.client.streams.list()
|
|
94
|
+
return iter(all_streams)
|
|
@@ -6,7 +6,6 @@ from cognite.client.data_classes import (
|
|
|
6
6
|
ThreeDModelList,
|
|
7
7
|
ThreeDModelUpdate,
|
|
8
8
|
ThreeDModelWrite,
|
|
9
|
-
ThreeDModelWriteList,
|
|
10
9
|
capabilities,
|
|
11
10
|
)
|
|
12
11
|
from cognite.client.data_classes.capabilities import Capability
|
|
@@ -20,13 +19,10 @@ from .data_organization import DataSetsCRUD
|
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
@final
|
|
23
|
-
class ThreeDModelCRUD(ResourceContainerCRUD[str, ThreeDModelWrite, ThreeDModel
|
|
22
|
+
class ThreeDModelCRUD(ResourceContainerCRUD[str, ThreeDModelWrite, ThreeDModel]):
|
|
24
23
|
folder_name = "3dmodels"
|
|
25
|
-
filename_pattern = r"^.*\.3DModel$" # Matches all yaml files whose stem ends with '.3DModel'.
|
|
26
24
|
resource_cls = ThreeDModel
|
|
27
25
|
resource_write_cls = ThreeDModelWrite
|
|
28
|
-
list_cls = ThreeDModelList
|
|
29
|
-
list_write_cls = ThreeDModelWriteList
|
|
30
26
|
kind = "3DModel"
|
|
31
27
|
yaml_cls = ThreeDModelYAML
|
|
32
28
|
dependencies = frozenset({DataSetsCRUD})
|
|
@@ -83,7 +79,7 @@ class ThreeDModelCRUD(ResourceContainerCRUD[str, ThreeDModelWrite, ThreeDModel,
|
|
|
83
79
|
|
|
84
80
|
return capabilities.ThreeDAcl(actions, scope)
|
|
85
81
|
|
|
86
|
-
def create(self, items:
|
|
82
|
+
def create(self, items: Sequence[ThreeDModelWrite]) -> ThreeDModelList:
|
|
87
83
|
created = ThreeDModelList([])
|
|
88
84
|
for item in items:
|
|
89
85
|
new_item = self.client.three_d.models.create(**item.dump(camel_case=False))
|
|
@@ -105,7 +101,7 @@ class ThreeDModelCRUD(ResourceContainerCRUD[str, ThreeDModelWrite, ThreeDModel,
|
|
|
105
101
|
break
|
|
106
102
|
return output
|
|
107
103
|
|
|
108
|
-
def update(self, items:
|
|
104
|
+
def update(self, items: Sequence[ThreeDModelWrite]) -> ThreeDModelList:
|
|
109
105
|
found = self.retrieve([item.name for item in items])
|
|
110
106
|
id_by_name = {model.name: model.id for model in found}
|
|
111
107
|
# 3D Model does not have an external identifier, only internal.
|
|
@@ -9,11 +9,9 @@ from cognite.client.data_classes import (
|
|
|
9
9
|
DatapointSubscriptionList,
|
|
10
10
|
DataPointSubscriptionUpdate,
|
|
11
11
|
DataPointSubscriptionWrite,
|
|
12
|
-
DatapointSubscriptionWriteList,
|
|
13
12
|
TimeSeries,
|
|
14
13
|
TimeSeriesList,
|
|
15
14
|
TimeSeriesWrite,
|
|
16
|
-
TimeSeriesWriteList,
|
|
17
15
|
)
|
|
18
16
|
from cognite.client.data_classes.capabilities import (
|
|
19
17
|
Capability,
|
|
@@ -43,14 +41,11 @@ from .data_organization import DataSetsCRUD
|
|
|
43
41
|
|
|
44
42
|
|
|
45
43
|
@final
|
|
46
|
-
class TimeSeriesCRUD(ResourceContainerCRUD[str, TimeSeriesWrite, TimeSeries
|
|
44
|
+
class TimeSeriesCRUD(ResourceContainerCRUD[str, TimeSeriesWrite, TimeSeries]):
|
|
47
45
|
item_name = "datapoints"
|
|
48
46
|
folder_name = "timeseries"
|
|
49
|
-
filename_pattern = r"^(?!.*DatapointSubscription$).*"
|
|
50
47
|
resource_cls = TimeSeries
|
|
51
48
|
resource_write_cls = TimeSeriesWrite
|
|
52
|
-
list_cls = TimeSeriesList
|
|
53
|
-
list_write_cls = TimeSeriesWriteList
|
|
54
49
|
yaml_cls = TimeSeriesYAML
|
|
55
50
|
kind = "TimeSeries"
|
|
56
51
|
dependencies = frozenset({DataSetsCRUD, GroupAllScopedCRUD, AssetCRUD})
|
|
@@ -125,7 +120,7 @@ class TimeSeriesCRUD(ResourceContainerCRUD[str, TimeSeriesWrite, TimeSeries, Tim
|
|
|
125
120
|
dumped["assetExternalId"] = self.client.lookup.assets.external_id(asset_id)
|
|
126
121
|
return dumped
|
|
127
122
|
|
|
128
|
-
def create(self, items:
|
|
123
|
+
def create(self, items: Sequence[TimeSeriesWrite]) -> TimeSeriesList:
|
|
129
124
|
return self.client.time_series.create(items)
|
|
130
125
|
|
|
131
126
|
def retrieve(self, ids: SequenceNotStr[str | int]) -> TimeSeriesList:
|
|
@@ -134,7 +129,7 @@ class TimeSeriesCRUD(ResourceContainerCRUD[str, TimeSeriesWrite, TimeSeries, Tim
|
|
|
134
129
|
ids=internal_ids, external_ids=external_ids, ignore_unknown_ids=True
|
|
135
130
|
)
|
|
136
131
|
|
|
137
|
-
def update(self, items:
|
|
132
|
+
def update(self, items: Sequence[TimeSeriesWrite]) -> TimeSeriesList:
|
|
138
133
|
return self.client.time_series.update(items, mode="replace")
|
|
139
134
|
|
|
140
135
|
def delete(self, ids: SequenceNotStr[str | int]) -> int:
|
|
@@ -182,16 +177,11 @@ class DatapointSubscriptionCRUD(
|
|
|
182
177
|
str,
|
|
183
178
|
DataPointSubscriptionWrite,
|
|
184
179
|
DatapointSubscription,
|
|
185
|
-
DatapointSubscriptionWriteList,
|
|
186
|
-
DatapointSubscriptionList,
|
|
187
180
|
]
|
|
188
181
|
):
|
|
189
182
|
folder_name = "timeseries"
|
|
190
|
-
filename_pattern = r"^.*DatapointSubscription$" # Matches all yaml files who end with *DatapointSubscription.
|
|
191
183
|
resource_cls = DatapointSubscription
|
|
192
184
|
resource_write_cls = DataPointSubscriptionWrite
|
|
193
|
-
list_cls = DatapointSubscriptionList
|
|
194
|
-
list_write_cls = DatapointSubscriptionWriteList
|
|
195
185
|
kind = "DatapointSubscription"
|
|
196
186
|
_doc_url = "Data-point-subscriptions/operation/postSubscriptions"
|
|
197
187
|
dependencies = frozenset(
|
|
@@ -253,7 +243,7 @@ class DatapointSubscriptionCRUD(
|
|
|
253
243
|
|
|
254
244
|
return TimeSeriesSubscriptionsAcl(actions, scope)
|
|
255
245
|
|
|
256
|
-
def create(self, items:
|
|
246
|
+
def create(self, items: Sequence[DataPointSubscriptionWrite]) -> DatapointSubscriptionList:
|
|
257
247
|
created_list = DatapointSubscriptionList([])
|
|
258
248
|
for item in items:
|
|
259
249
|
to_create, batches = self.create_split_timeseries_ids(item)
|
|
@@ -271,7 +261,7 @@ class DatapointSubscriptionCRUD(
|
|
|
271
261
|
items.append(retrieved)
|
|
272
262
|
return items
|
|
273
263
|
|
|
274
|
-
def update(self, items:
|
|
264
|
+
def update(self, items: Sequence[DataPointSubscriptionWrite]) -> DatapointSubscriptionList:
|
|
275
265
|
updated_list = DatapointSubscriptionList([])
|
|
276
266
|
for item in items:
|
|
277
267
|
current = self.client.time_series.subscriptions.list_member_time_series(item.external_id, limit=-1)
|