cognite-toolkit 0.7.10__py3-none-any.whl → 0.7.11__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_tk/commands/_purge.py +27 -28
- cognite_toolkit/_cdf_tk/commands/_upload.py +5 -1
- 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/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.11.dist-info}/METADATA +1 -1
- {cognite_toolkit-0.7.10.dist-info → cognite_toolkit-0.7.11.dist-info}/RECORD +43 -43
- {cognite_toolkit-0.7.10.dist-info → cognite_toolkit-0.7.11.dist-info}/WHEEL +0 -0
- {cognite_toolkit-0.7.10.dist-info → cognite_toolkit-0.7.11.dist-info}/entry_points.txt +0 -0
- {cognite_toolkit-0.7.10.dist-info → cognite_toolkit-0.7.11.dist-info}/licenses/LICENSE +0 -0
|
@@ -12,7 +12,6 @@ from cognite_toolkit._cdf_tk.client.data_classes.apm_config_v1 import (
|
|
|
12
12
|
APMConfig,
|
|
13
13
|
APMConfigList,
|
|
14
14
|
APMConfigWrite,
|
|
15
|
-
APMConfigWriteList,
|
|
16
15
|
)
|
|
17
16
|
from cognite_toolkit._cdf_tk.client.data_classes.infield import InfieldLocationConfig, InfieldLocationConfigList
|
|
18
17
|
from cognite_toolkit._cdf_tk.client.data_classes.instance_api import InstanceResult, NodeIdentifier
|
|
@@ -31,13 +30,11 @@ from .group_scoped import GroupResourceScopedCRUD
|
|
|
31
30
|
|
|
32
31
|
|
|
33
32
|
@final
|
|
34
|
-
class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig
|
|
33
|
+
class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig]):
|
|
35
34
|
folder_name = "cdf_applications"
|
|
36
35
|
filetypes = frozenset({"yaml", "yml"})
|
|
37
36
|
resource_cls = APMConfig
|
|
38
37
|
resource_write_cls = APMConfigWrite
|
|
39
|
-
list_cls = APMConfigList
|
|
40
|
-
list_write_cls = APMConfigWriteList
|
|
41
38
|
kind = "InfieldV1"
|
|
42
39
|
yaml_cls = InfieldV1YAML
|
|
43
40
|
dependencies = frozenset({DataSetsCRUD, AssetCRUD, SpaceCRUD, GroupAllScopedCRUD, GroupResourceScopedCRUD})
|
|
@@ -85,9 +82,9 @@ class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig, APMConfigWriteL
|
|
|
85
82
|
f"Install the infield options with cdf modules init/add to deploy it."
|
|
86
83
|
)
|
|
87
84
|
|
|
88
|
-
def create(self, items:
|
|
85
|
+
def create(self, items: Sequence[APMConfigWrite]) -> NodeApplyResultList:
|
|
89
86
|
result = self.client.data_modeling.instances.apply(
|
|
90
|
-
nodes=
|
|
87
|
+
nodes=[item.as_node() for item in items], auto_create_direct_relations=True, replace=False
|
|
91
88
|
)
|
|
92
89
|
return result.nodes
|
|
93
90
|
|
|
@@ -97,9 +94,9 @@ class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig, APMConfigWriteL
|
|
|
97
94
|
).nodes
|
|
98
95
|
return APMConfigList.from_nodes(result)
|
|
99
96
|
|
|
100
|
-
def update(self, items:
|
|
97
|
+
def update(self, items: Sequence[APMConfigWrite]) -> NodeApplyResultList:
|
|
101
98
|
result = self.client.data_modeling.instances.apply(
|
|
102
|
-
nodes=
|
|
99
|
+
nodes=[item.as_node() for item in items], auto_create_direct_relations=True, replace=True
|
|
103
100
|
)
|
|
104
101
|
return result.nodes
|
|
105
102
|
|
|
@@ -242,21 +239,11 @@ class InfieldV1CRUD(ResourceCRUD[str, APMConfigWrite, APMConfig, APMConfigWriteL
|
|
|
242
239
|
|
|
243
240
|
|
|
244
241
|
@final
|
|
245
|
-
class InFieldLocationConfigCRUD(
|
|
246
|
-
ResourceCRUD[
|
|
247
|
-
NodeIdentifier,
|
|
248
|
-
InfieldLocationConfig,
|
|
249
|
-
InfieldLocationConfig,
|
|
250
|
-
InfieldLocationConfigList,
|
|
251
|
-
InfieldLocationConfigList,
|
|
252
|
-
]
|
|
253
|
-
):
|
|
242
|
+
class InFieldLocationConfigCRUD(ResourceCRUD[NodeIdentifier, InfieldLocationConfig, InfieldLocationConfig]):
|
|
254
243
|
folder_name = "cdf_applications"
|
|
255
244
|
filetypes = frozenset({"yaml", "yml"})
|
|
256
245
|
resource_cls = InfieldLocationConfig
|
|
257
246
|
resource_write_cls = InfieldLocationConfig
|
|
258
|
-
list_cls = InfieldLocationConfigList
|
|
259
|
-
list_write_cls = InfieldLocationConfigList
|
|
260
247
|
kind = "InFieldLocationConfig"
|
|
261
248
|
yaml_cls = InfieldLocationConfigYAML
|
|
262
249
|
dependencies = frozenset({SpaceCRUD, GroupAllScopedCRUD, GroupResourceScopedCRUD})
|
|
@@ -304,7 +291,7 @@ class InFieldLocationConfigCRUD(
|
|
|
304
291
|
|
|
305
292
|
return dumped
|
|
306
293
|
|
|
307
|
-
def create(self, items:
|
|
294
|
+
def create(self, items: Sequence[InfieldLocationConfig]) -> list[InstanceResult]:
|
|
308
295
|
created = self.client.infield.config.apply(items)
|
|
309
296
|
config_ids = {config.as_id() for config in items}
|
|
310
297
|
# We filter out all the data exploration configs that were created along with the infield location configs
|
|
@@ -314,7 +301,7 @@ class InFieldLocationConfigCRUD(
|
|
|
314
301
|
def retrieve(self, ids: SequenceNotStr[NodeIdentifier]) -> InfieldLocationConfigList:
|
|
315
302
|
return InfieldLocationConfigList(self.client.infield.config.retrieve(list(ids)))
|
|
316
303
|
|
|
317
|
-
def update(self, items:
|
|
304
|
+
def update(self, items: Sequence[InfieldLocationConfig]) -> Sized:
|
|
318
305
|
return self.create(items)
|
|
319
306
|
|
|
320
307
|
def delete(self, ids: SequenceNotStr[NodeIdentifier]) -> int:
|
|
@@ -21,7 +21,6 @@ from cognite.client.data_classes import (
|
|
|
21
21
|
FileMetadata,
|
|
22
22
|
FileMetadataList,
|
|
23
23
|
FileMetadataWrite,
|
|
24
|
-
FileMetadataWriteList,
|
|
25
24
|
)
|
|
26
25
|
from cognite.client.data_classes.capabilities import (
|
|
27
26
|
Capability,
|
|
@@ -37,7 +36,6 @@ from rich import print
|
|
|
37
36
|
from cognite_toolkit._cdf_tk.client.data_classes.extendable_cognite_file import (
|
|
38
37
|
ExtendableCogniteFile,
|
|
39
38
|
ExtendableCogniteFileApply,
|
|
40
|
-
ExtendableCogniteFileApplyList,
|
|
41
39
|
ExtendableCogniteFileList,
|
|
42
40
|
)
|
|
43
41
|
from cognite_toolkit._cdf_tk.cruds._base_cruds import ResourceContainerCRUD, ResourceCRUD
|
|
@@ -57,15 +55,11 @@ from .datamodel import SpaceCRUD, ViewCRUD
|
|
|
57
55
|
|
|
58
56
|
|
|
59
57
|
@final
|
|
60
|
-
class FileMetadataCRUD(
|
|
61
|
-
ResourceContainerCRUD[str, FileMetadataWrite, FileMetadata, FileMetadataWriteList, FileMetadataList]
|
|
62
|
-
):
|
|
58
|
+
class FileMetadataCRUD(ResourceContainerCRUD[str, FileMetadataWrite, FileMetadata]):
|
|
63
59
|
item_name = "file contents"
|
|
64
60
|
folder_name = "files"
|
|
65
61
|
resource_cls = FileMetadata
|
|
66
62
|
resource_write_cls = FileMetadataWrite
|
|
67
|
-
list_cls = FileMetadataList
|
|
68
|
-
list_write_cls = FileMetadataWriteList
|
|
69
63
|
yaml_cls = FileMetadataYAML
|
|
70
64
|
kind = "FileMetadata"
|
|
71
65
|
dependencies = frozenset({DataSetsCRUD, GroupAllScopedCRUD, LabelCRUD, AssetCRUD})
|
|
@@ -147,7 +141,7 @@ class FileMetadataCRUD(
|
|
|
147
141
|
dumped["assetExternalIds"] = self.client.lookup.assets.external_id(asset_ids)
|
|
148
142
|
return dumped
|
|
149
143
|
|
|
150
|
-
def create(self, items:
|
|
144
|
+
def create(self, items: Sequence[FileMetadataWrite]) -> FileMetadataList:
|
|
151
145
|
created = FileMetadataList([])
|
|
152
146
|
for meta in items:
|
|
153
147
|
try:
|
|
@@ -160,7 +154,7 @@ class FileMetadataCRUD(
|
|
|
160
154
|
def retrieve(self, ids: SequenceNotStr[str]) -> FileMetadataList:
|
|
161
155
|
return self.client.files.retrieve_multiple(external_ids=ids, ignore_unknown_ids=True)
|
|
162
156
|
|
|
163
|
-
def update(self, items:
|
|
157
|
+
def update(self, items: Sequence[FileMetadataWrite]) -> FileMetadataList:
|
|
164
158
|
return self.client.files.update(items, mode="replace")
|
|
165
159
|
|
|
166
160
|
def delete(self, ids: str | int | SequenceNotStr[str | int] | None) -> int:
|
|
@@ -193,23 +187,13 @@ class FileMetadataCRUD(
|
|
|
193
187
|
|
|
194
188
|
|
|
195
189
|
@final
|
|
196
|
-
class CogniteFileCRUD(
|
|
197
|
-
ResourceContainerCRUD[
|
|
198
|
-
NodeId,
|
|
199
|
-
ExtendableCogniteFileApply,
|
|
200
|
-
ExtendableCogniteFile,
|
|
201
|
-
ExtendableCogniteFileApplyList,
|
|
202
|
-
ExtendableCogniteFileList,
|
|
203
|
-
]
|
|
204
|
-
):
|
|
190
|
+
class CogniteFileCRUD(ResourceContainerCRUD[NodeId, ExtendableCogniteFileApply, ExtendableCogniteFile]):
|
|
205
191
|
template_pattern = "$FILENAME"
|
|
206
192
|
item_name = "file contents"
|
|
207
193
|
folder_name = "files"
|
|
208
194
|
kind = "CogniteFile"
|
|
209
195
|
resource_cls = ExtendableCogniteFile
|
|
210
196
|
resource_write_cls = ExtendableCogniteFileApply
|
|
211
|
-
list_cls = ExtendableCogniteFileList
|
|
212
|
-
list_write_cls = ExtendableCogniteFileApplyList
|
|
213
197
|
yaml_cls = CogniteFileYAML
|
|
214
198
|
dependencies = frozenset({GroupAllScopedCRUD, SpaceCRUD, ViewCRUD})
|
|
215
199
|
|
|
@@ -289,7 +273,7 @@ class CogniteFileCRUD(
|
|
|
289
273
|
return diff_list_identifiable(local, cdf, get_identifier=dm_identifier)
|
|
290
274
|
return super().diff_list(local, cdf, json_path)
|
|
291
275
|
|
|
292
|
-
def create(self, items:
|
|
276
|
+
def create(self, items: Sequence[ExtendableCogniteFileApply]) -> NodeApplyResultList:
|
|
293
277
|
created = self.client.data_modeling.instances.apply(
|
|
294
278
|
nodes=items, replace=False, skip_on_version_conflict=True, auto_create_direct_relations=True
|
|
295
279
|
)
|
|
@@ -305,7 +289,7 @@ class CogniteFileCRUD(
|
|
|
305
289
|
)
|
|
306
290
|
return ExtendableCogniteFileList(items)
|
|
307
291
|
|
|
308
|
-
def update(self, items:
|
|
292
|
+
def update(self, items: Sequence[ExtendableCogniteFileApply]) -> NodeApplyResultList:
|
|
309
293
|
updated = self.client.data_modeling.instances.apply(nodes=items, replace=True)
|
|
310
294
|
return updated.nodes
|
|
311
295
|
|
|
@@ -12,9 +12,7 @@ from cognite.client.data_classes import (
|
|
|
12
12
|
FunctionSchedule,
|
|
13
13
|
FunctionSchedulesList,
|
|
14
14
|
FunctionScheduleWrite,
|
|
15
|
-
FunctionScheduleWriteList,
|
|
16
15
|
FunctionWrite,
|
|
17
|
-
FunctionWriteList,
|
|
18
16
|
)
|
|
19
17
|
from cognite.client.data_classes.capabilities import (
|
|
20
18
|
AllScope,
|
|
@@ -56,13 +54,11 @@ from .group_scoped import GroupResourceScopedCRUD
|
|
|
56
54
|
|
|
57
55
|
|
|
58
56
|
@final
|
|
59
|
-
class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function
|
|
57
|
+
class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function]):
|
|
60
58
|
support_drop = True
|
|
61
59
|
folder_name = "functions"
|
|
62
60
|
resource_cls = Function
|
|
63
61
|
resource_write_cls = FunctionWrite
|
|
64
|
-
list_cls = FunctionList
|
|
65
|
-
list_write_cls = FunctionWriteList
|
|
66
62
|
kind = "Function"
|
|
67
63
|
yaml_cls = FunctionsYAML
|
|
68
64
|
dependencies = frozenset({DataSetsCRUD, GroupAllScopedCRUD})
|
|
@@ -298,7 +294,7 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
298
294
|
self.client.functions.activate()
|
|
299
295
|
return False
|
|
300
296
|
|
|
301
|
-
def create(self, items:
|
|
297
|
+
def create(self, items: Sequence[FunctionWrite]) -> FunctionList:
|
|
302
298
|
created = FunctionList([], cognite_client=self.client)
|
|
303
299
|
if not self._is_activated("create"):
|
|
304
300
|
return created
|
|
@@ -423,16 +419,10 @@ class FunctionCRUD(ResourceCRUD[str, FunctionWrite, Function, FunctionWriteList,
|
|
|
423
419
|
|
|
424
420
|
|
|
425
421
|
@final
|
|
426
|
-
class FunctionScheduleCRUD(
|
|
427
|
-
ResourceCRUD[
|
|
428
|
-
FunctionScheduleID, FunctionScheduleWrite, FunctionSchedule, FunctionScheduleWriteList, FunctionSchedulesList
|
|
429
|
-
]
|
|
430
|
-
):
|
|
422
|
+
class FunctionScheduleCRUD(ResourceCRUD[FunctionScheduleID, FunctionScheduleWrite, FunctionSchedule]):
|
|
431
423
|
folder_name = "functions"
|
|
432
424
|
resource_cls = FunctionSchedule
|
|
433
425
|
resource_write_cls = FunctionScheduleWrite
|
|
434
|
-
list_cls = FunctionSchedulesList
|
|
435
|
-
list_write_cls = FunctionScheduleWriteList
|
|
436
426
|
kind = "Schedule"
|
|
437
427
|
yaml_cls = FunctionScheduleYAML
|
|
438
428
|
dependencies = frozenset({FunctionCRUD, GroupResourceScopedCRUD, GroupAllScopedCRUD})
|
|
@@ -553,7 +543,7 @@ class FunctionScheduleCRUD(
|
|
|
553
543
|
)
|
|
554
544
|
return schedules
|
|
555
545
|
|
|
556
|
-
def create(self, items:
|
|
546
|
+
def create(self, items: Sequence[FunctionScheduleWrite]) -> FunctionSchedulesList:
|
|
557
547
|
created_list = FunctionSchedulesList([], cognite_client=self.client)
|
|
558
548
|
function_id_by_external_id = self._get_function_ids_by_external_id(items)
|
|
559
549
|
|
|
@@ -582,7 +572,7 @@ class FunctionScheduleCRUD(
|
|
|
582
572
|
created_list.append(created)
|
|
583
573
|
return created_list
|
|
584
574
|
|
|
585
|
-
def _get_function_ids_by_external_id(self, items:
|
|
575
|
+
def _get_function_ids_by_external_id(self, items: Sequence[FunctionScheduleWrite]) -> dict[str, int]:
|
|
586
576
|
functions_to_lookup = list({item.function_external_id for item in items if item.function_external_id})
|
|
587
577
|
if not functions_to_lookup:
|
|
588
578
|
return {}
|
|
@@ -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:
|