cognite-toolkit 0.7.10__py3-none-any.whl → 0.7.12__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 +8 -0
- cognite_toolkit/_cdf_tk/commands/__init__.py +2 -2
- cognite_toolkit/_cdf_tk/commands/_purge.py +27 -28
- cognite_toolkit/_cdf_tk/commands/_upload.py +5 -1
- cognite_toolkit/_cdf_tk/commands/about.py +221 -0
- cognite_toolkit/_cdf_tk/commands/clean.py +11 -13
- cognite_toolkit/_cdf_tk/commands/deploy.py +9 -17
- cognite_toolkit/_cdf_tk/commands/dump_resource.py +6 -4
- cognite_toolkit/_cdf_tk/commands/pull.py +6 -19
- cognite_toolkit/_cdf_tk/cruds/_base_cruds.py +7 -25
- cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +3 -6
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/agent.py +4 -6
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +4 -12
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +19 -36
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +4 -10
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/data_organization.py +4 -12
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +16 -41
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +5 -15
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +8 -21
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +6 -22
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +5 -15
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/hosted_extractors.py +12 -26
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +3 -6
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +3 -14
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +4 -8
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +4 -8
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +3 -6
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +15 -34
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +2 -5
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/three_d_model.py +3 -6
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +5 -13
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +4 -19
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/workflow.py +20 -37
- cognite_toolkit/_cdf_tk/cruds/_worker.py +13 -30
- cognite_toolkit/_cdf_tk/feature_flags.py +1 -1
- cognite_toolkit/_cdf_tk/storageio/_base.py +23 -0
- cognite_toolkit/_cdf_tk/storageio/_file_content.py +4 -0
- cognite_toolkit/_cdf_tk/utils/fileio/_readers.py +42 -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 +1 -1
- cognite_toolkit/_version.py +1 -1
- {cognite_toolkit-0.7.10.dist-info → cognite_toolkit-0.7.12.dist-info}/METADATA +1 -1
- {cognite_toolkit-0.7.10.dist-info → cognite_toolkit-0.7.12.dist-info}/RECORD +47 -47
- cognite_toolkit/_cdf_tk/commands/featureflag.py +0 -27
- {cognite_toolkit-0.7.10.dist-info → cognite_toolkit-0.7.12.dist-info}/WHEEL +0 -0
- {cognite_toolkit-0.7.10.dist-info → cognite_toolkit-0.7.12.dist-info}/entry_points.txt +0 -0
- {cognite_toolkit-0.7.10.dist-info → cognite_toolkit-0.7.12.dist-info}/licenses/LICENSE +0 -0
|
@@ -8,21 +8,17 @@ from cognite.client.data_classes.hosted_extractors import (
|
|
|
8
8
|
Destination,
|
|
9
9
|
DestinationList,
|
|
10
10
|
DestinationWrite,
|
|
11
|
-
DestinationWriteList,
|
|
12
11
|
EventHubSourceWrite,
|
|
13
12
|
Job,
|
|
14
13
|
JobList,
|
|
15
14
|
JobWrite,
|
|
16
|
-
JobWriteList,
|
|
17
15
|
KafkaSourceWrite,
|
|
18
16
|
Mapping,
|
|
19
17
|
MappingList,
|
|
20
18
|
MappingWrite,
|
|
21
|
-
MappingWriteList,
|
|
22
19
|
Source,
|
|
23
20
|
SourceList,
|
|
24
21
|
SourceWrite,
|
|
25
|
-
SourceWriteList,
|
|
26
22
|
)
|
|
27
23
|
from cognite.client.data_classes.hosted_extractors.sources import (
|
|
28
24
|
AuthenticationWrite,
|
|
@@ -48,12 +44,10 @@ from cognite_toolkit._cdf_tk.tk_warnings import HighSeverityWarning
|
|
|
48
44
|
from .data_organization import DataSetsCRUD
|
|
49
45
|
|
|
50
46
|
|
|
51
|
-
class HostedExtractorSourceCRUD(ResourceCRUD[str, SourceWrite, Source
|
|
47
|
+
class HostedExtractorSourceCRUD(ResourceCRUD[str, SourceWrite, Source]):
|
|
52
48
|
folder_name = "hosted_extractors"
|
|
53
49
|
resource_cls = Source
|
|
54
50
|
resource_write_cls = SourceWrite
|
|
55
|
-
list_cls = SourceList
|
|
56
|
-
list_write_cls = SourceWriteList
|
|
57
51
|
kind = "Source"
|
|
58
52
|
yaml_cls = HostedExtractorSourceYAML
|
|
59
53
|
_doc_base_url = "https://api-docs.cognite.com/20230101-alpha/tag/"
|
|
@@ -92,13 +86,13 @@ class HostedExtractorSourceCRUD(ResourceCRUD[str, SourceWrite, Source, SourceWri
|
|
|
92
86
|
HostedExtractorsAcl.Scope.All(),
|
|
93
87
|
)
|
|
94
88
|
|
|
95
|
-
def create(self, items:
|
|
89
|
+
def create(self, items: Sequence[SourceWrite]) -> SourceList:
|
|
96
90
|
return self.client.hosted_extractors.sources.create(items)
|
|
97
91
|
|
|
98
92
|
def retrieve(self, ids: SequenceNotStr[str]) -> SourceList:
|
|
99
93
|
return self.client.hosted_extractors.sources.retrieve(external_ids=ids, ignore_unknown_ids=True)
|
|
100
94
|
|
|
101
|
-
def update(self, items:
|
|
95
|
+
def update(self, items: Sequence[SourceWrite]) -> SourceList:
|
|
102
96
|
return self.client.hosted_extractors.sources.update(items, mode="replace")
|
|
103
97
|
|
|
104
98
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -150,14 +144,10 @@ class HostedExtractorSourceCRUD(ResourceCRUD[str, SourceWrite, Source, SourceWri
|
|
|
150
144
|
yield auth.client_secret
|
|
151
145
|
|
|
152
146
|
|
|
153
|
-
class HostedExtractorDestinationCRUD(
|
|
154
|
-
ResourceCRUD[str, DestinationWrite, Destination, DestinationWriteList, DestinationList]
|
|
155
|
-
):
|
|
147
|
+
class HostedExtractorDestinationCRUD(ResourceCRUD[str, DestinationWrite, Destination]):
|
|
156
148
|
folder_name = "hosted_extractors"
|
|
157
149
|
resource_cls = Destination
|
|
158
150
|
resource_write_cls = DestinationWrite
|
|
159
|
-
list_cls = DestinationList
|
|
160
|
-
list_write_cls = DestinationWriteList
|
|
161
151
|
dependencies = frozenset({DataSetsCRUD})
|
|
162
152
|
kind = "Destination"
|
|
163
153
|
_doc_base_url = "https://api-docs.cognite.com/20230101-alpha/tag/"
|
|
@@ -200,13 +190,13 @@ class HostedExtractorDestinationCRUD(
|
|
|
200
190
|
HostedExtractorsAcl.Scope.All(),
|
|
201
191
|
)
|
|
202
192
|
|
|
203
|
-
def create(self, items:
|
|
193
|
+
def create(self, items: Sequence[DestinationWrite]) -> DestinationList:
|
|
204
194
|
return self.client.hosted_extractors.destinations.create(items)
|
|
205
195
|
|
|
206
196
|
def retrieve(self, ids: SequenceNotStr[str]) -> DestinationList:
|
|
207
197
|
return self.client.hosted_extractors.destinations.retrieve(external_ids=ids, ignore_unknown_ids=True)
|
|
208
198
|
|
|
209
|
-
def update(self, items:
|
|
199
|
+
def update(self, items: Sequence[DestinationWrite]) -> DestinationList:
|
|
210
200
|
return self.client.hosted_extractors.destinations.update(items, mode="replace")
|
|
211
201
|
|
|
212
202
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -252,12 +242,10 @@ class HostedExtractorDestinationCRUD(
|
|
|
252
242
|
yield self._authentication_by_id[id_].client_secret
|
|
253
243
|
|
|
254
244
|
|
|
255
|
-
class HostedExtractorJobCRUD(ResourceCRUD[str, JobWrite, Job
|
|
245
|
+
class HostedExtractorJobCRUD(ResourceCRUD[str, JobWrite, Job]):
|
|
256
246
|
folder_name = "hosted_extractors"
|
|
257
247
|
resource_cls = Job
|
|
258
248
|
resource_write_cls = JobWrite
|
|
259
|
-
list_cls = JobList
|
|
260
|
-
list_write_cls = JobWriteList
|
|
261
249
|
dependencies = frozenset({HostedExtractorSourceCRUD, HostedExtractorDestinationCRUD})
|
|
262
250
|
kind = "Job"
|
|
263
251
|
yaml_cls = HostedExtractorJobYAML
|
|
@@ -303,13 +291,13 @@ class HostedExtractorJobCRUD(ResourceCRUD[str, JobWrite, Job, JobWriteList, JobL
|
|
|
303
291
|
dumped.pop("config", None)
|
|
304
292
|
return dumped
|
|
305
293
|
|
|
306
|
-
def create(self, items:
|
|
294
|
+
def create(self, items: Sequence[JobWrite]) -> JobList:
|
|
307
295
|
return self.client.hosted_extractors.jobs.create(items)
|
|
308
296
|
|
|
309
297
|
def retrieve(self, ids: SequenceNotStr[str]) -> JobList:
|
|
310
298
|
return self.client.hosted_extractors.jobs.retrieve(external_ids=ids, ignore_unknown_ids=True)
|
|
311
299
|
|
|
312
|
-
def update(self, items:
|
|
300
|
+
def update(self, items: Sequence[JobWrite]) -> JobList:
|
|
313
301
|
return self.client.hosted_extractors.jobs.update(items, mode="replace")
|
|
314
302
|
|
|
315
303
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -332,12 +320,10 @@ class HostedExtractorJobCRUD(ResourceCRUD[str, JobWrite, Job, JobWriteList, JobL
|
|
|
332
320
|
yield HostedExtractorDestinationCRUD, item["destinationId"]
|
|
333
321
|
|
|
334
322
|
|
|
335
|
-
class HostedExtractorMappingCRUD(ResourceCRUD[str, MappingWrite, Mapping
|
|
323
|
+
class HostedExtractorMappingCRUD(ResourceCRUD[str, MappingWrite, Mapping]):
|
|
336
324
|
folder_name = "hosted_extractors"
|
|
337
325
|
resource_cls = Mapping
|
|
338
326
|
resource_write_cls = MappingWrite
|
|
339
|
-
list_cls = MappingList
|
|
340
|
-
list_write_cls = MappingWriteList
|
|
341
327
|
# This is not an explicit dependency, however, adding it here as mapping will should be deployed after source.
|
|
342
328
|
dependencies = frozenset({HostedExtractorSourceCRUD})
|
|
343
329
|
kind = "Mapping"
|
|
@@ -377,13 +363,13 @@ class HostedExtractorMappingCRUD(ResourceCRUD[str, MappingWrite, Mapping, Mappin
|
|
|
377
363
|
HostedExtractorsAcl.Scope.All(),
|
|
378
364
|
)
|
|
379
365
|
|
|
380
|
-
def create(self, items:
|
|
366
|
+
def create(self, items: Sequence[MappingWrite]) -> MappingList:
|
|
381
367
|
return self.client.hosted_extractors.mappings.create(items)
|
|
382
368
|
|
|
383
369
|
def retrieve(self, ids: SequenceNotStr[str]) -> MappingList:
|
|
384
370
|
return self.client.hosted_extractors.mappings.retrieve(external_ids=ids, ignore_unknown_ids=True)
|
|
385
371
|
|
|
386
|
-
def update(self, items:
|
|
372
|
+
def update(self, items: Sequence[MappingWrite]) -> MappingList:
|
|
387
373
|
return self.client.hosted_extractors.mappings.update(items)
|
|
388
374
|
|
|
389
375
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -18,7 +18,6 @@ from cognite_toolkit._cdf_tk.client.data_classes.streamlit_ import (
|
|
|
18
18
|
Streamlit,
|
|
19
19
|
StreamlitList,
|
|
20
20
|
StreamlitWrite,
|
|
21
|
-
StreamlitWriteList,
|
|
22
21
|
)
|
|
23
22
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceCRUD
|
|
24
23
|
from cognite_toolkit._cdf_tk.exceptions import ToolkitNotADirectoryError, ToolkitRequiredValueError
|
|
@@ -34,12 +33,10 @@ from .data_organization import DataSetsCRUD
|
|
|
34
33
|
|
|
35
34
|
|
|
36
35
|
@final
|
|
37
|
-
class StreamlitCRUD(ResourceCRUD[str, StreamlitWrite, Streamlit
|
|
36
|
+
class StreamlitCRUD(ResourceCRUD[str, StreamlitWrite, Streamlit]):
|
|
38
37
|
folder_name = "streamlit"
|
|
39
38
|
resource_cls = Streamlit
|
|
40
39
|
resource_write_cls = StreamlitWrite
|
|
41
|
-
list_cls = StreamlitList
|
|
42
|
-
list_write_cls = StreamlitWriteList
|
|
43
40
|
kind = "Streamlit"
|
|
44
41
|
dependencies = frozenset({DataSetsCRUD, GroupAllScopedCRUD})
|
|
45
42
|
_doc_url = "Files/operation/initFileUpload"
|
|
@@ -156,7 +153,7 @@ class StreamlitCRUD(ResourceCRUD[str, StreamlitWrite, Streamlit, StreamlitWriteL
|
|
|
156
153
|
missing.append(recommended.name)
|
|
157
154
|
return missing
|
|
158
155
|
|
|
159
|
-
def create(self, items:
|
|
156
|
+
def create(self, items: Sequence[StreamlitWrite]) -> StreamlitList:
|
|
160
157
|
created = StreamlitList([])
|
|
161
158
|
for item in items:
|
|
162
159
|
content = self._as_json_string(item.external_id, item.entrypoint)
|
|
@@ -171,7 +168,7 @@ class StreamlitCRUD(ResourceCRUD[str, StreamlitWrite, Streamlit, StreamlitWriteL
|
|
|
171
168
|
files = self.client.files.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
172
169
|
return StreamlitList([Streamlit.from_file(file) for file in files])
|
|
173
170
|
|
|
174
|
-
def update(self, items:
|
|
171
|
+
def update(self, items: Sequence[StreamlitWrite]) -> StreamlitList:
|
|
175
172
|
files = []
|
|
176
173
|
for item in items:
|
|
177
174
|
content = self._as_json_string(item.external_id, item.entrypoint)
|
|
@@ -11,7 +11,6 @@ from cognite_toolkit._cdf_tk.client.data_classes.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,14 +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
32
|
resource_cls = LocationFilter
|
|
36
33
|
resource_write_cls = LocationFilterWrite
|
|
37
|
-
list_cls = LocationFilterList
|
|
38
|
-
list_write_cls = LocationFilterWriteList
|
|
39
34
|
yaml_cls = LocationYAML
|
|
40
35
|
dependencies = frozenset(
|
|
41
36
|
{
|
|
@@ -181,10 +176,7 @@ class LocationFilterCRUD(
|
|
|
181
176
|
*e.args[1:],
|
|
182
177
|
) from None
|
|
183
178
|
|
|
184
|
-
def create(self, items: LocationFilterWrite
|
|
185
|
-
if isinstance(items, LocationFilterWrite):
|
|
186
|
-
items = LocationFilterWriteList([items])
|
|
187
|
-
|
|
179
|
+
def create(self, items: Sequence[LocationFilterWrite]) -> LocationFilterList:
|
|
188
180
|
created: list[LocationFilter] = []
|
|
189
181
|
# Note: the Location API does not support batch creation, so we need to do this one by one.
|
|
190
182
|
# Furthermore, we could not do the parentExternalId->parentId lookup before the parent was created,
|
|
@@ -212,10 +204,7 @@ class LocationFilterCRUD(
|
|
|
212
204
|
_recursive_find(all_locations)
|
|
213
205
|
return LocationFilterList(found_locations)
|
|
214
206
|
|
|
215
|
-
def update(self, items: LocationFilterWrite
|
|
216
|
-
if isinstance(items, LocationFilterWrite):
|
|
217
|
-
items = LocationFilterWriteList([items])
|
|
218
|
-
|
|
207
|
+
def update(self, items: Sequence[LocationFilterWrite]) -> LocationFilterList:
|
|
219
208
|
updated = []
|
|
220
209
|
ids = {item.external_id: item.id for item in self.retrieve([item.external_id for item in items])}
|
|
221
210
|
for update in items:
|
|
@@ -3,7 +3,7 @@ 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
9
|
from cognite_toolkit._cdf_tk.client.data_classes.migration import (
|
|
@@ -19,15 +19,11 @@ 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
24
|
filetypes = frozenset({"yaml", "yml"})
|
|
27
25
|
resource_cls = ResourceViewMapping
|
|
28
26
|
resource_write_cls = ResourceViewMappingApply
|
|
29
|
-
list_cls = NodeList[ResourceViewMapping]
|
|
30
|
-
list_write_cls = NodeApplyList
|
|
31
27
|
kind = "ResourceViewMapping"
|
|
32
28
|
dependencies = frozenset({SpaceCRUD, ViewCRUD})
|
|
33
29
|
_doc_url = "Instances/operation/applyNodeAndEdges"
|
|
@@ -71,10 +67,10 @@ class ResourceViewMappingCRUD(
|
|
|
71
67
|
return None
|
|
72
68
|
return f"{self.display_name} requires the {view_id!r} to be deployed. run `cdf migrate prepare` to deploy it."
|
|
73
69
|
|
|
74
|
-
def create(self, items:
|
|
70
|
+
def create(self, items: Sequence[ResourceViewMappingApply]) -> Sized:
|
|
75
71
|
return self.client.migration.resource_view_mapping.upsert(items)
|
|
76
72
|
|
|
77
|
-
def update(self, items:
|
|
73
|
+
def update(self, items: Sequence[ResourceViewMappingApply]) -> Sized:
|
|
78
74
|
return self.client.migration.resource_view_mapping.upsert(items)
|
|
79
75
|
|
|
80
76
|
def retrieve(self, ids: SequenceNotStr[str]) -> NodeList[ResourceViewMapping]:
|
|
@@ -37,13 +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
43
|
resource_cls = RawDatabase
|
|
44
44
|
resource_write_cls = RawDatabase
|
|
45
|
-
list_cls = RawDatabaseList
|
|
46
|
-
list_write_cls = RawDatabaseList
|
|
47
45
|
kind = "Database"
|
|
48
46
|
yaml_cls = DatabaseYAML
|
|
49
47
|
dependencies = frozenset({GroupAllScopedCRUD})
|
|
@@ -91,7 +89,7 @@ class RawDatabaseCRUD(ResourceContainerCRUD[RawDatabase, RawDatabase, RawDatabas
|
|
|
91
89
|
def dump_id(cls, id: RawDatabase) -> dict[str, Any]:
|
|
92
90
|
return {"dbName": id.db_name}
|
|
93
91
|
|
|
94
|
-
def create(self, items:
|
|
92
|
+
def create(self, items: Sequence[RawDatabase]) -> RawDatabaseList:
|
|
95
93
|
database_list = self.client.raw.databases.create([db.db_name for db in items])
|
|
96
94
|
return RawDatabaseList([RawDatabase(db_name=db.name) for db in database_list if db.name])
|
|
97
95
|
|
|
@@ -150,13 +148,11 @@ class RawDatabaseCRUD(ResourceContainerCRUD[RawDatabase, RawDatabase, RawDatabas
|
|
|
150
148
|
|
|
151
149
|
|
|
152
150
|
@final
|
|
153
|
-
class RawTableCRUD(ResourceContainerCRUD[RawTable, RawTable, RawTable
|
|
151
|
+
class RawTableCRUD(ResourceContainerCRUD[RawTable, RawTable, RawTable]):
|
|
154
152
|
item_name = "raw rows"
|
|
155
153
|
folder_name = "raw"
|
|
156
154
|
resource_cls = RawTable
|
|
157
155
|
resource_write_cls = RawTable
|
|
158
|
-
list_cls = RawTableList
|
|
159
|
-
list_write_cls = RawTableList
|
|
160
156
|
kind = "Table"
|
|
161
157
|
yaml_cls = TableYAML
|
|
162
158
|
support_update = False
|
|
@@ -213,7 +209,7 @@ class RawTableCRUD(ResourceContainerCRUD[RawTable, RawTable, RawTable, RawTableL
|
|
|
213
209
|
if "dbName" in item:
|
|
214
210
|
yield RawDatabaseCRUD, RawDatabase(item["dbName"])
|
|
215
211
|
|
|
216
|
-
def create(self, items:
|
|
212
|
+
def create(self, items: Sequence[RawTable]) -> RawTableList:
|
|
217
213
|
created = RawTableList([])
|
|
218
214
|
for db_name, raw_tables in itertools.groupby(sorted(items, key=lambda x: x.db_name), key=lambda x: x.db_name):
|
|
219
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,13 +21,11 @@ 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
26
|
filetypes = frozenset({"yaml", "yml"})
|
|
28
27
|
resource_cls = Relationship
|
|
29
28
|
resource_write_cls = RelationshipWrite
|
|
30
|
-
list_cls = RelationshipList
|
|
31
|
-
list_write_cls = RelationshipWriteList
|
|
32
29
|
kind = "Relationship"
|
|
33
30
|
yaml_cls = RelationshipYAML
|
|
34
31
|
dependencies = frozenset(
|
|
@@ -74,13 +71,13 @@ class RelationshipCRUD(ResourceCRUD[str, RelationshipWrite, Relationship, Relati
|
|
|
74
71
|
|
|
75
72
|
return capabilities.RelationshipsAcl(actions, scope)
|
|
76
73
|
|
|
77
|
-
def create(self, items:
|
|
74
|
+
def create(self, items: Sequence[RelationshipWrite]) -> RelationshipList:
|
|
78
75
|
return self.client.relationships.create(items)
|
|
79
76
|
|
|
80
77
|
def retrieve(self, ids: SequenceNotStr[str]) -> RelationshipList:
|
|
81
78
|
return self.client.relationships.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
82
79
|
|
|
83
|
-
def update(self, items:
|
|
80
|
+
def update(self, items: Sequence[RelationshipWrite]) -> RelationshipList:
|
|
84
81
|
return self.client.relationships.update(items)
|
|
85
82
|
|
|
86
83
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -13,23 +13,18 @@ from cognite_toolkit._cdf_tk.client.data_classes.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,12 +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
42
|
resource_cls = Frame
|
|
48
43
|
resource_write_cls = FrameWrite
|
|
49
|
-
list_cls = FrameList
|
|
50
|
-
list_write_cls = FrameWriteList
|
|
51
44
|
kind = "Frame"
|
|
52
45
|
yaml_cls = RobotFrameYAML
|
|
53
46
|
_doc_url = "Frames/operation/createFrames"
|
|
@@ -84,13 +77,13 @@ class RoboticFrameCRUD(ResourceCRUD[str, FrameWrite, Frame, FrameWriteList, Fram
|
|
|
84
77
|
capabilities.RoboticsAcl.Scope.All(),
|
|
85
78
|
)
|
|
86
79
|
|
|
87
|
-
def create(self, items:
|
|
80
|
+
def create(self, items: Sequence[FrameWrite]) -> FrameList:
|
|
88
81
|
return self.client.robotics.frames.create(items)
|
|
89
82
|
|
|
90
83
|
def retrieve(self, ids: SequenceNotStr[str]) -> FrameList:
|
|
91
84
|
return _fallback_to_one_by_one(self.client.robotics.frames.retrieve, ids, FrameList)
|
|
92
85
|
|
|
93
|
-
def update(self, items:
|
|
86
|
+
def update(self, items: Sequence[FrameWrite]) -> FrameList:
|
|
94
87
|
return self.client.robotics.frames.update(items)
|
|
95
88
|
|
|
96
89
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -109,12 +102,10 @@ class RoboticFrameCRUD(ResourceCRUD[str, FrameWrite, Frame, FrameWriteList, Fram
|
|
|
109
102
|
return iter(self.client.robotics.frames)
|
|
110
103
|
|
|
111
104
|
|
|
112
|
-
class RoboticLocationCRUD(ResourceCRUD[str, LocationWrite, Location
|
|
105
|
+
class RoboticLocationCRUD(ResourceCRUD[str, LocationWrite, Location]):
|
|
113
106
|
folder_name = "robotics"
|
|
114
107
|
resource_cls = Location
|
|
115
108
|
resource_write_cls = LocationWrite
|
|
116
|
-
list_cls = LocationList
|
|
117
|
-
list_write_cls = LocationWriteList
|
|
118
109
|
kind = "Location"
|
|
119
110
|
yaml_cls = RobotLocationYAML
|
|
120
111
|
_doc_url = "Locations/operation/createLocations"
|
|
@@ -156,13 +147,13 @@ class RoboticLocationCRUD(ResourceCRUD[str, LocationWrite, Location, LocationWri
|
|
|
156
147
|
|
|
157
148
|
return capabilities.RoboticsAcl(actions, capabilities.RoboticsAcl.Scope.All())
|
|
158
149
|
|
|
159
|
-
def create(self, items:
|
|
150
|
+
def create(self, items: Sequence[LocationWrite]) -> LocationList:
|
|
160
151
|
return self.client.robotics.locations.create(items)
|
|
161
152
|
|
|
162
153
|
def retrieve(self, ids: SequenceNotStr[str]) -> LocationList:
|
|
163
154
|
return _fallback_to_one_by_one(self.client.robotics.locations.retrieve, ids, LocationList)
|
|
164
155
|
|
|
165
|
-
def update(self, items:
|
|
156
|
+
def update(self, items: Sequence[LocationWrite]) -> LocationList:
|
|
166
157
|
return self.client.robotics.locations.update(items)
|
|
167
158
|
|
|
168
159
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -181,14 +172,10 @@ class RoboticLocationCRUD(ResourceCRUD[str, LocationWrite, Location, LocationWri
|
|
|
181
172
|
return iter(self.client.robotics.locations)
|
|
182
173
|
|
|
183
174
|
|
|
184
|
-
class RoboticsDataPostProcessingCRUD(
|
|
185
|
-
ResourceCRUD[str, DataPostProcessingWrite, DataPostProcessing, DataPostProcessingWriteList, DataPostProcessingList]
|
|
186
|
-
):
|
|
175
|
+
class RoboticsDataPostProcessingCRUD(ResourceCRUD[str, DataPostProcessingWrite, DataPostProcessing]):
|
|
187
176
|
folder_name = "robotics"
|
|
188
177
|
resource_cls = DataPostProcessing
|
|
189
178
|
resource_write_cls = DataPostProcessingWrite
|
|
190
|
-
list_cls = DataPostProcessingList
|
|
191
|
-
list_write_cls = DataPostProcessingWriteList
|
|
192
179
|
kind = "DataPostProcessing"
|
|
193
180
|
yaml_cls = RobotDataPostProcessingYAML
|
|
194
181
|
_doc_url = "DataPostProcessing/operation/createDataPostProcessing"
|
|
@@ -230,13 +217,13 @@ class RoboticsDataPostProcessingCRUD(
|
|
|
230
217
|
|
|
231
218
|
return capabilities.RoboticsAcl(actions, capabilities.RoboticsAcl.Scope.All())
|
|
232
219
|
|
|
233
|
-
def create(self, items:
|
|
220
|
+
def create(self, items: Sequence[DataPostProcessingWrite]) -> DataPostProcessingList:
|
|
234
221
|
return self.client.robotics.data_postprocessing.create(items)
|
|
235
222
|
|
|
236
223
|
def retrieve(self, ids: SequenceNotStr[str]) -> DataPostProcessingList:
|
|
237
224
|
return _fallback_to_one_by_one(self.client.robotics.data_postprocessing.retrieve, ids, DataPostProcessingList)
|
|
238
225
|
|
|
239
|
-
def update(self, items:
|
|
226
|
+
def update(self, items: Sequence[DataPostProcessingWrite]) -> DataPostProcessingList:
|
|
240
227
|
# There is a bug in the /update endpoint that requires the input_schema to be a string
|
|
241
228
|
# and not an object. This is a workaround until the bug is fixed.
|
|
242
229
|
# We do the serialization to avoid modifying the original object.
|
|
@@ -274,14 +261,10 @@ class RoboticsDataPostProcessingCRUD(
|
|
|
274
261
|
return super().diff_list(local, cdf, json_path)
|
|
275
262
|
|
|
276
263
|
|
|
277
|
-
class RobotCapabilityCRUD(
|
|
278
|
-
ResourceCRUD[str, RobotCapabilityWrite, RobotCapability, RobotCapabilityWriteList, RobotCapabilityList]
|
|
279
|
-
):
|
|
264
|
+
class RobotCapabilityCRUD(ResourceCRUD[str, RobotCapabilityWrite, RobotCapability]):
|
|
280
265
|
folder_name = "robotics"
|
|
281
266
|
resource_cls = RobotCapability
|
|
282
267
|
resource_write_cls = RobotCapabilityWrite
|
|
283
|
-
list_cls = RobotCapabilityList
|
|
284
|
-
list_write_cls = RobotCapabilityWriteList
|
|
285
268
|
kind = "RobotCapability"
|
|
286
269
|
yaml_cls = RobotCapabilityYAML
|
|
287
270
|
_doc_url = "RobotCapabilities/operation/createRobotCapabilities"
|
|
@@ -323,13 +306,13 @@ class RobotCapabilityCRUD(
|
|
|
323
306
|
|
|
324
307
|
return capabilities.RoboticsAcl(actions, capabilities.RoboticsAcl.Scope.All())
|
|
325
308
|
|
|
326
|
-
def create(self, items:
|
|
309
|
+
def create(self, items: Sequence[RobotCapabilityWrite]) -> RobotCapabilityList:
|
|
327
310
|
return self.client.robotics.capabilities.create(items)
|
|
328
311
|
|
|
329
312
|
def retrieve(self, ids: SequenceNotStr[str]) -> RobotCapabilityList:
|
|
330
313
|
return _fallback_to_one_by_one(self.client.robotics.capabilities.retrieve, ids, RobotCapabilityList)
|
|
331
314
|
|
|
332
|
-
def update(self, items:
|
|
315
|
+
def update(self, items: Sequence[RobotCapabilityWrite]) -> RobotCapabilityList:
|
|
333
316
|
# There is a bug in the /update endpoint that requires the input_schema to be a string
|
|
334
317
|
# and not an object. This is a workaround until the bug is fixed.
|
|
335
318
|
# We do the serialization to avoid modifying the original object.
|
|
@@ -370,12 +353,10 @@ class RobotCapabilityCRUD(
|
|
|
370
353
|
return super().diff_list(local, cdf, json_path)
|
|
371
354
|
|
|
372
355
|
|
|
373
|
-
class RoboticMapCRUD(ResourceCRUD[str, MapWrite, Map
|
|
356
|
+
class RoboticMapCRUD(ResourceCRUD[str, MapWrite, Map]):
|
|
374
357
|
folder_name = "robotics"
|
|
375
358
|
resource_cls = Map
|
|
376
359
|
resource_write_cls = MapWrite
|
|
377
|
-
list_cls = MapList
|
|
378
|
-
list_write_cls = MapWriteList
|
|
379
360
|
kind = "Map"
|
|
380
361
|
dependencies = frozenset({RoboticFrameCRUD, RoboticLocationCRUD})
|
|
381
362
|
yaml_cls = RobotMapYAML
|
|
@@ -427,13 +408,13 @@ class RoboticMapCRUD(ResourceCRUD[str, MapWrite, Map, MapWriteList, MapList]):
|
|
|
427
408
|
del dump["scale"]
|
|
428
409
|
return dump
|
|
429
410
|
|
|
430
|
-
def create(self, items:
|
|
411
|
+
def create(self, items: Sequence[MapWrite]) -> MapList:
|
|
431
412
|
return self.client.robotics.maps.create(items)
|
|
432
413
|
|
|
433
414
|
def retrieve(self, ids: SequenceNotStr[str]) -> MapList:
|
|
434
415
|
return _fallback_to_one_by_one(self.client.robotics.maps.retrieve, ids, MapList)
|
|
435
416
|
|
|
436
|
-
def update(self, items:
|
|
417
|
+
def update(self, items: Sequence[MapWrite]) -> MapList:
|
|
437
418
|
return self.client.robotics.maps.update(items)
|
|
438
419
|
|
|
439
420
|
def delete(self, ids: SequenceNotStr[str]) -> int:
|
|
@@ -6,7 +6,6 @@ from cognite.client.utils.useful_types import SequenceNotStr
|
|
|
6
6
|
|
|
7
7
|
from cognite_toolkit._cdf_tk.client.data_classes.streams import (
|
|
8
8
|
StreamRequest,
|
|
9
|
-
StreamRequestList,
|
|
10
9
|
StreamResponse,
|
|
11
10
|
StreamResponseList,
|
|
12
11
|
)
|
|
@@ -18,13 +17,11 @@ from .datamodel import ContainerCRUD
|
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
@final
|
|
21
|
-
class StreamCRUD(ResourceCRUD[str, StreamRequest, StreamResponse
|
|
20
|
+
class StreamCRUD(ResourceCRUD[str, StreamRequest, StreamResponse]):
|
|
22
21
|
folder_name = "streams"
|
|
23
22
|
filetypes = frozenset({"yaml", "yml"})
|
|
24
23
|
resource_cls = StreamResponse
|
|
25
24
|
resource_write_cls = StreamRequest
|
|
26
|
-
list_cls = StreamResponseList
|
|
27
|
-
list_write_cls = StreamRequestList
|
|
28
25
|
kind = "Streams"
|
|
29
26
|
yaml_cls = StreamYAML
|
|
30
27
|
dependencies = frozenset({ContainerCRUD})
|
|
@@ -59,7 +56,7 @@ class StreamCRUD(ResourceCRUD[str, StreamRequest, StreamResponse, StreamRequestL
|
|
|
59
56
|
)
|
|
60
57
|
return StreamsAcl(actions, StreamsAcl.Scope.All())
|
|
61
58
|
|
|
62
|
-
def create(self, items:
|
|
59
|
+
def create(self, items: Sequence[StreamRequest]) -> StreamResponseList:
|
|
63
60
|
created = self.client.streams.create(list(items))
|
|
64
61
|
return StreamResponseList(created)
|
|
65
62
|
|
|
@@ -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,12 +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
24
|
resource_cls = ThreeDModel
|
|
26
25
|
resource_write_cls = ThreeDModelWrite
|
|
27
|
-
list_cls = ThreeDModelList
|
|
28
|
-
list_write_cls = ThreeDModelWriteList
|
|
29
26
|
kind = "3DModel"
|
|
30
27
|
yaml_cls = ThreeDModelYAML
|
|
31
28
|
dependencies = frozenset({DataSetsCRUD})
|
|
@@ -82,7 +79,7 @@ class ThreeDModelCRUD(ResourceContainerCRUD[str, ThreeDModelWrite, ThreeDModel,
|
|
|
82
79
|
|
|
83
80
|
return capabilities.ThreeDAcl(actions, scope)
|
|
84
81
|
|
|
85
|
-
def create(self, items:
|
|
82
|
+
def create(self, items: Sequence[ThreeDModelWrite]) -> ThreeDModelList:
|
|
86
83
|
created = ThreeDModelList([])
|
|
87
84
|
for item in items:
|
|
88
85
|
new_item = self.client.three_d.models.create(**item.dump(camel_case=False))
|
|
@@ -104,7 +101,7 @@ class ThreeDModelCRUD(ResourceContainerCRUD[str, ThreeDModelWrite, ThreeDModel,
|
|
|
104
101
|
break
|
|
105
102
|
return output
|
|
106
103
|
|
|
107
|
-
def update(self, items:
|
|
104
|
+
def update(self, items: Sequence[ThreeDModelWrite]) -> ThreeDModelList:
|
|
108
105
|
found = self.retrieve([item.name for item in items])
|
|
109
106
|
id_by_name = {model.name: model.id for model in found}
|
|
110
107
|
# 3D Model does not have an external identifier, only internal.
|