cognite-toolkit 0.7.39__py3-none-any.whl → 0.7.51__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/apps/_download_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_dump_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_migrate_app.py +6 -6
- cognite_toolkit/_cdf_tk/builders/_function.py +81 -9
- cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/client/_resource_base.py +187 -0
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +37 -5
- cognite_toolkit/_cdf_tk/client/api/agents.py +107 -0
- cognite_toolkit/_cdf_tk/client/api/annotations.py +129 -0
- cognite_toolkit/_cdf_tk/client/api/assets.py +130 -0
- cognite_toolkit/_cdf_tk/client/api/containers.py +132 -0
- cognite_toolkit/_cdf_tk/client/api/data_models.py +137 -0
- cognite_toolkit/_cdf_tk/client/api/datasets.py +141 -0
- cognite_toolkit/_cdf_tk/client/api/events.py +129 -0
- cognite_toolkit/_cdf_tk/client/api/extraction_pipelines.py +148 -0
- cognite_toolkit/_cdf_tk/client/api/filemetadata.py +176 -0
- cognite_toolkit/_cdf_tk/client/api/function_schedules.py +115 -0
- cognite_toolkit/_cdf_tk/client/api/functions.py +113 -0
- cognite_toolkit/_cdf_tk/client/api/graphql_data_models.py +167 -0
- cognite_toolkit/_cdf_tk/client/api/groups.py +121 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_destinations.py +131 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_jobs.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_mappings.py +129 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_sources.py +136 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractors.py +23 -0
- cognite_toolkit/_cdf_tk/client/api/infield.py +8 -8
- cognite_toolkit/_cdf_tk/client/api/instances.py +139 -0
- cognite_toolkit/_cdf_tk/client/api/labels.py +125 -0
- cognite_toolkit/_cdf_tk/client/api/legacy/canvas.py +3 -3
- cognite_toolkit/_cdf_tk/client/api/legacy/charts.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_data_modeling.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_files.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_functions.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_raw.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_timeseries.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/legacy/location_filters.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/capabilities.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/data_postprocessing.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/frames.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/locations.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/maps.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/robots.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/location_filters.py +177 -0
- cognite_toolkit/_cdf_tk/client/api/migration.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/project.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/raw.py +204 -0
- cognite_toolkit/_cdf_tk/client/api/relationships.py +133 -0
- cognite_toolkit/_cdf_tk/client/api/robotics.py +19 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_capabilities.py +127 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_data_postprocessing.py +138 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_frames.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_locations.py +127 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_maps.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_robots.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/search_config.py +101 -0
- cognite_toolkit/_cdf_tk/client/api/security_categories.py +94 -0
- cognite_toolkit/_cdf_tk/client/api/sequences.py +133 -0
- cognite_toolkit/_cdf_tk/client/api/simulator_models.py +154 -0
- cognite_toolkit/_cdf_tk/client/api/simulators.py +8 -0
- cognite_toolkit/_cdf_tk/client/api/spaces.py +117 -0
- cognite_toolkit/_cdf_tk/client/api/streams.py +65 -57
- cognite_toolkit/_cdf_tk/client/api/three_d.py +300 -283
- cognite_toolkit/_cdf_tk/client/api/timeseries.py +137 -0
- cognite_toolkit/_cdf_tk/client/api/token.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/transformations.py +146 -0
- cognite_toolkit/_cdf_tk/client/api/views.py +139 -0
- cognite_toolkit/_cdf_tk/client/api/workflow_triggers.py +128 -0
- cognite_toolkit/_cdf_tk/client/api/workflow_versions.py +138 -0
- cognite_toolkit/_cdf_tk/client/api/workflows.py +119 -0
- cognite_toolkit/_cdf_tk/client/cdf_client/__init__.py +10 -0
- cognite_toolkit/_cdf_tk/client/cdf_client/api.py +358 -0
- cognite_toolkit/_cdf_tk/client/cdf_client/responses.py +38 -0
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/__init__.py +9 -7
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/_client.py +23 -14
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/_data_classes.py +12 -2
- cognite_toolkit/_cdf_tk/client/http_client/_data_classes2.py +151 -0
- cognite_toolkit/_cdf_tk/client/http_client/_exception.py +13 -0
- cognite_toolkit/_cdf_tk/client/http_client/_item_classes.py +118 -0
- cognite_toolkit/_cdf_tk/client/request_classes/base.py +19 -0
- cognite_toolkit/_cdf_tk/client/request_classes/filters.py +113 -0
- cognite_toolkit/_cdf_tk/client/request_classes/graphql.py +28 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/agent.py +130 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/annotation.py +79 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/apm_config.py +128 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/asset.py +47 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/charts_data.py +1 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/cognite_file.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/__init__.py +168 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_constraints.py +37 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_container.py +50 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_data_model.py +73 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_data_types.py +116 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_indexes.py +26 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_instance.py +154 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_references.py +86 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_space.py +26 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_view.py +143 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_view_property.py +152 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/dataset.py +35 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/event.py +40 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/extraction_pipeline.py +59 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/filemetadata.py +52 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/function.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/function_schedule.py +65 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/graphql_data_model.py +40 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/__init__.py +187 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/_constants.py +2 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/acls.py +653 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/capability.py +56 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/group.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/scopes.py +166 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_destination.py +34 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_job.py +134 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_mapping.py +72 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/__init__.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_auth.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_base.py +26 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_certificate.py +20 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_eventhub.py +31 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_kafka.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_mqtt.py +36 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_rest.py +49 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/identifiers.py +59 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/infield.py +1 -1
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/instance_api.py +35 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/label.py +27 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/legacy/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/canvas.py +48 -15
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/charts.py +1 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/location_filter.py +84 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/raw.py +44 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/relationship.py +49 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/resource_view_mapping.py +38 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/__init__.py +37 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_capability.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_common.py +34 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_data_post_processing.py +49 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_frame.py +46 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_location.py +36 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_map.py +65 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_robot.py +58 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/search_config.py +54 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/securitycategory.py +24 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/sequence.py +45 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/sequence_rows.py +56 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/simulator_model.py +50 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/streamlit_.py +71 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/streams.py +9 -26
- cognite_toolkit/_cdf_tk/client/resource_classes/three_d.py +135 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/timeseries.py +52 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/transformation.py +140 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/workflow.py +27 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/workflow_trigger.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/workflow_version.py +155 -0
- cognite_toolkit/_cdf_tk/client/testing.py +31 -2
- cognite_toolkit/_cdf_tk/commands/_migrate/command.py +103 -108
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +22 -15
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +11 -10
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +148 -57
- cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +22 -39
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +29 -27
- cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_purge.py +8 -8
- cognite_toolkit/_cdf_tk/commands/_upload.py +1 -1
- cognite_toolkit/_cdf_tk/commands/build_cmd.py +12 -2
- cognite_toolkit/_cdf_tk/commands/build_v2/_module_parser.py +138 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/_modules_parser.py +163 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_cmd.py +83 -96
- cognite_toolkit/_cdf_tk/commands/build_v2/{build_input.py → build_parameters.py} +8 -22
- cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_modules.py +27 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_resource.py +22 -0
- cognite_toolkit/_cdf_tk/commands/dump_resource.py +4 -4
- cognite_toolkit/_cdf_tk/commands/pull.py +97 -2
- cognite_toolkit/_cdf_tk/commands/run.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/__init__.py +16 -6
- cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +9 -5
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +6 -2
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +70 -89
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +14 -7
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +50 -59
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +4 -3
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +6 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +5 -4
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/simulators.py +122 -0
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +15 -31
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +42 -47
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +1 -1
- cognite_toolkit/_cdf_tk/data_classes/__init__.py +3 -0
- cognite_toolkit/_cdf_tk/data_classes/_issues.py +36 -0
- cognite_toolkit/_cdf_tk/data_classes/_module_directories.py +2 -1
- cognite_toolkit/_cdf_tk/data_classes/_tracking_info.py +4 -0
- cognite_toolkit/_cdf_tk/feature_flags.py +8 -0
- cognite_toolkit/_cdf_tk/resource_classes/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/resource_classes/capabilities.py +6 -0
- cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/resource_classes/simulator_model.py +17 -0
- cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +13 -4
- cognite_toolkit/_cdf_tk/storageio/_applications.py +53 -15
- cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +117 -107
- cognite_toolkit/_cdf_tk/storageio/_base.py +3 -1
- cognite_toolkit/_cdf_tk/storageio/_datapoints.py +7 -7
- cognite_toolkit/_cdf_tk/storageio/_file_content.py +64 -54
- cognite_toolkit/_cdf_tk/storageio/_instances.py +1 -1
- cognite_toolkit/_cdf_tk/storageio/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/storageio/logger.py +162 -0
- cognite_toolkit/_cdf_tk/tk_warnings/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/tk_warnings/fileread.py +20 -0
- cognite_toolkit/_cdf_tk/utils/__init__.py +11 -1
- cognite_toolkit/_cdf_tk/utils/cdf.py +1 -1
- cognite_toolkit/_cdf_tk/utils/interactive_select.py +8 -6
- cognite_toolkit/_cdf_tk/utils/modules.py +7 -0
- cognite_toolkit/_cdf_tk/utils/pip_validator.py +96 -0
- cognite_toolkit/_cdf_tk/utils/useful_types.py +4 -7
- cognite_toolkit/_cdf_tk/utils/useful_types2.py +14 -0
- 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.39.dist-info → cognite_toolkit-0.7.51.dist-info}/METADATA +13 -3
- cognite_toolkit-0.7.51.dist-info/RECORD +445 -0
- {cognite_toolkit-0.7.39.dist-info → cognite_toolkit-0.7.51.dist-info}/WHEEL +2 -2
- cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +0 -30
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +0 -67
- cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +0 -112
- cognite_toolkit/_cdf_tk/commands/build_v2/build_issues.py +0 -27
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +0 -247
- cognite_toolkit/_cdf_tk/utils/http_client/_exception.py +0 -4
- cognite_toolkit-0.7.39.dist-info/RECORD +0 -322
- /cognite_toolkit/_cdf_tk/{utils → client}/http_client/_tracker.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → request_classes}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes/legacy → resource_classes}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/capabilities.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/apm_config_v1.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extendable_cognite_file.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_filemetadata.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_filemetdata.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_timeseries.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/functions.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/graphql_data_models.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/instances.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/location_filters.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/migration.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/pending_instances_ids.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/project.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/raw.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/robotics.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/search_config.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/sequences.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/streamlit_.py +0 -0
- {cognite_toolkit-0.7.39.dist-info → cognite_toolkit-0.7.51.dist-info}/entry_points.txt +0 -0
|
@@ -1,156 +1,151 @@
|
|
|
1
|
-
from collections import defaultdict
|
|
2
1
|
from collections.abc import Iterable, Sequence
|
|
3
|
-
from typing import
|
|
2
|
+
from typing import TypeVar
|
|
4
3
|
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, PagedResponse
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.cdf_client.api import Endpoint
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.http_client import (
|
|
7
|
+
HTTPClient,
|
|
8
|
+
ItemsSuccessResponse2,
|
|
9
|
+
SuccessResponse2,
|
|
10
|
+
)
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.request_classes.filters import ThreeDAssetMappingFilter
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import InternalId
|
|
13
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.three_d import (
|
|
10
14
|
AssetMappingClassicRequest,
|
|
15
|
+
AssetMappingClassicResponse,
|
|
11
16
|
AssetMappingDMRequest,
|
|
12
|
-
|
|
17
|
+
AssetMappingDMResponse,
|
|
13
18
|
ThreeDModelClassicRequest,
|
|
14
19
|
ThreeDModelResponse,
|
|
15
20
|
)
|
|
16
|
-
from cognite_toolkit._cdf_tk.utils.collection import chunker_sequence
|
|
17
|
-
from cognite_toolkit._cdf_tk.utils.http_client import (
|
|
18
|
-
HTTPClient,
|
|
19
|
-
ItemsRequest2,
|
|
20
|
-
RequestMessage2,
|
|
21
|
-
)
|
|
22
|
-
from cognite_toolkit._cdf_tk.utils.useful_types import PrimitiveType
|
|
23
21
|
|
|
24
22
|
|
|
25
|
-
class
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
class ThreeDClassicModelsAPI(CDFResourceAPI[InternalId, ThreeDModelClassicRequest, ThreeDModelResponse]):
|
|
24
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
25
|
+
super().__init__(
|
|
26
|
+
http_client=http_client,
|
|
27
|
+
method_endpoint_map={
|
|
28
|
+
"create": Endpoint(method="POST", path="/3d/models", item_limit=1000),
|
|
29
|
+
"delete": Endpoint(method="POST", path="/3d/models/delete", item_limit=1000),
|
|
30
|
+
"update": Endpoint(method="POST", path="/3d/models/update", item_limit=1000),
|
|
31
|
+
"retrieve": Endpoint(method="GET", path="/3d/models/{modelId}", item_limit=1000),
|
|
32
|
+
"list": Endpoint(method="GET", path="/3d/models", item_limit=1000),
|
|
33
|
+
},
|
|
34
|
+
)
|
|
30
35
|
|
|
31
|
-
def
|
|
32
|
-
self
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
def _validate_page_response(
|
|
37
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
38
|
+
) -> PagedResponse[ThreeDModelResponse]:
|
|
39
|
+
return PagedResponse[ThreeDModelResponse].model_validate_json(response.body)
|
|
35
40
|
|
|
36
|
-
def create(self,
|
|
41
|
+
def create(self, items: Sequence[ThreeDModelClassicRequest]) -> list[ThreeDModelResponse]:
|
|
37
42
|
"""Create 3D models in classic format.
|
|
38
43
|
|
|
39
44
|
Args:
|
|
40
|
-
|
|
45
|
+
items (Sequence[ThreeDModelClassicRequest]): The 3D model(s) to create.
|
|
41
46
|
|
|
42
47
|
Returns:
|
|
43
48
|
list[ThreeDModelResponse]: The created 3D model(s).
|
|
44
49
|
"""
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
return self._request_item_response(items, "create")
|
|
51
|
+
|
|
52
|
+
def retrieve(self, ids: Sequence[InternalId]) -> list[ThreeDModelResponse]:
|
|
53
|
+
"""Retrieve 3D models by their IDs.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
ids (Sequence[int]): The IDs of the 3D models to retrieve.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
list[ThreeDModelResponse]: The retrieved 3D model(s).
|
|
60
|
+
"""
|
|
61
|
+
return self._request_item_response(ids, "retrieve")
|
|
62
|
+
|
|
63
|
+
def update(self, items: Sequence[ThreeDModelClassicRequest]) -> list[ThreeDModelResponse]:
|
|
64
|
+
"""Update 3D models in classic format.
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
Args:
|
|
67
|
+
items (Sequence[ThreeDModelClassicRequest]): The 3D model(s) to update.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
list[ThreeDModelResponse]: The updated 3D model(s).
|
|
71
|
+
"""
|
|
72
|
+
return self._request_item_response(items, "update")
|
|
73
|
+
|
|
74
|
+
def delete(self, ids: Sequence[InternalId]) -> None:
|
|
60
75
|
"""Delete 3D models by their IDs.
|
|
61
76
|
|
|
62
77
|
Args:
|
|
63
78
|
ids (Sequence[int]): The IDs of the 3D models to delete.
|
|
64
79
|
"""
|
|
65
|
-
|
|
66
|
-
return None
|
|
67
|
-
if len(ids) > self.MAX_MODELS_PER_DELETE_REQUEST:
|
|
68
|
-
raise ValueError("Cannot delete more than 1000 3D models in a single request.")
|
|
69
|
-
responses = self._http_client.request_items_retries(
|
|
70
|
-
ItemsRequest2(
|
|
71
|
-
endpoint_url=self._config.create_api_url(self.ENDPOINT + "/delete"),
|
|
72
|
-
method="POST",
|
|
73
|
-
items=InternalIdRequest.from_ids(list(ids)),
|
|
74
|
-
)
|
|
75
|
-
)
|
|
76
|
-
responses.raise_for_status()
|
|
80
|
+
self._request_no_response(ids, "delete")
|
|
77
81
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
include_revision_info: bool = False,
|
|
82
|
-
limit: int = 100,
|
|
83
|
-
cursor: str | None = None,
|
|
84
|
-
) -> PagedResponse[ThreeDModelResponse]:
|
|
85
|
-
if not (0 < limit <= self._LIST_REQUEST_MAX_LIMIT):
|
|
86
|
-
raise ValueError(f"Limit must be between 1 and {self._LIST_REQUEST_MAX_LIMIT}, got {limit}.")
|
|
87
|
-
parameters: dict[str, PrimitiveType] = {
|
|
82
|
+
@staticmethod
|
|
83
|
+
def _create_list_filter(include_revision_info: bool, published: bool | None) -> dict[str, bool]:
|
|
84
|
+
params = {
|
|
88
85
|
# There is a bug in the API. The parameter includeRevisionInfo is expected to be lower case and not
|
|
89
86
|
# camel case as documented. You get error message: Unrecognized query parameter includeRevisionInfo,
|
|
90
87
|
# did you mean includerevisioninfo?
|
|
91
88
|
"includerevisioninfo": include_revision_info,
|
|
92
|
-
"limit": limit,
|
|
93
89
|
}
|
|
94
90
|
if published is not None:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return
|
|
91
|
+
params["published"] = published
|
|
92
|
+
return params
|
|
93
|
+
|
|
94
|
+
def paginate(
|
|
95
|
+
self,
|
|
96
|
+
published: bool | None = None,
|
|
97
|
+
include_revision_info: bool = False,
|
|
98
|
+
limit: int = 100,
|
|
99
|
+
cursor: str | None = None,
|
|
100
|
+
) -> PagedResponse[ThreeDModelResponse]:
|
|
101
|
+
params = self._create_list_filter(include_revision_info, published)
|
|
102
|
+
return self._paginate(limit=limit, cursor=cursor, params=params)
|
|
103
|
+
|
|
104
|
+
def iterate(
|
|
105
|
+
self,
|
|
106
|
+
published: bool | None = None,
|
|
107
|
+
include_revision_info: bool = False,
|
|
108
|
+
limit: int = 100,
|
|
109
|
+
cursor: str | None = None,
|
|
110
|
+
) -> Iterable[list[ThreeDModelResponse]]:
|
|
111
|
+
params = self._create_list_filter(include_revision_info, published)
|
|
112
|
+
return self._iterate(limit=limit, cursor=cursor, params=params)
|
|
107
113
|
|
|
108
114
|
def list(
|
|
109
115
|
self,
|
|
110
116
|
published: bool | None = None,
|
|
111
117
|
include_revision_info: bool = False,
|
|
112
118
|
limit: int | None = 100,
|
|
113
|
-
cursor: str | None = None,
|
|
114
119
|
) -> list[ThreeDModelResponse]:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
request_limit = (
|
|
118
|
-
self._LIST_REQUEST_MAX_LIMIT
|
|
119
|
-
if limit is None
|
|
120
|
-
else min(limit - len(results), self._LIST_REQUEST_MAX_LIMIT)
|
|
121
|
-
)
|
|
122
|
-
if request_limit <= 0:
|
|
123
|
-
break
|
|
124
|
-
page = self.iterate(
|
|
125
|
-
published=published,
|
|
126
|
-
include_revision_info=include_revision_info,
|
|
127
|
-
limit=request_limit,
|
|
128
|
-
cursor=cursor,
|
|
129
|
-
)
|
|
130
|
-
results.extend(page.items)
|
|
131
|
-
if page.next_cursor is None:
|
|
132
|
-
break
|
|
133
|
-
cursor = page.next_cursor
|
|
134
|
-
return results
|
|
120
|
+
params = self._create_list_filter(include_revision_info, published)
|
|
121
|
+
return self._list(limit=limit, params=params)
|
|
135
122
|
|
|
136
123
|
|
|
137
124
|
T_RequestMapping = TypeVar("T_RequestMapping", bound=AssetMappingClassicRequest | AssetMappingDMRequest)
|
|
138
125
|
|
|
139
126
|
|
|
140
|
-
class
|
|
127
|
+
class ThreeDClassicAssetMappingAPI(
|
|
128
|
+
CDFResourceAPI[AssetMappingClassicRequest, AssetMappingClassicRequest, AssetMappingClassicResponse]
|
|
129
|
+
):
|
|
141
130
|
ENDPOINT = "/3d/models/{modelId}/revisions/{revisionId}/mappings"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
131
|
+
|
|
132
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
133
|
+
super().__init__(
|
|
134
|
+
http_client=http_client,
|
|
135
|
+
method_endpoint_map={
|
|
136
|
+
# These endpoints are parameterized, so the paths are templates
|
|
137
|
+
"create": Endpoint(method="POST", path=self.ENDPOINT, item_limit=1000),
|
|
138
|
+
"delete": Endpoint(method="POST", path=f"{self.ENDPOINT}/delete", item_limit=1000),
|
|
139
|
+
"list": Endpoint(method="POST", path=f"{self.ENDPOINT}/list", item_limit=1000),
|
|
140
|
+
},
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
def _validate_page_response(
|
|
144
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
145
|
+
) -> PagedResponse[AssetMappingClassicResponse]:
|
|
146
|
+
return PagedResponse[AssetMappingClassicResponse].model_validate_json(response.body)
|
|
147
|
+
|
|
148
|
+
def create(self, mappings: Sequence[AssetMappingClassicRequest]) -> list[AssetMappingClassicResponse]:
|
|
154
149
|
"""Create 3D asset mappings.
|
|
155
150
|
|
|
156
151
|
Args:
|
|
@@ -158,32 +153,123 @@ class ThreeDAssetMappingAPI:
|
|
|
158
153
|
The 3D asset mapping(s) to create.
|
|
159
154
|
|
|
160
155
|
Returns:
|
|
161
|
-
list[
|
|
156
|
+
list[AssetMappingClassicResponse]: The created 3D asset mapping(s).
|
|
162
157
|
"""
|
|
163
|
-
results: list[
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
items=revision_mappings,
|
|
172
|
-
)
|
|
173
|
-
)
|
|
174
|
-
responses.raise_for_status()
|
|
175
|
-
items = responses.get_items()
|
|
176
|
-
for item in items:
|
|
158
|
+
results: list[AssetMappingClassicResponse] = []
|
|
159
|
+
endpoint = self._method_endpoint_map["create"]
|
|
160
|
+
for (model_id, revision_id), group in self._group_items_by_text_field(
|
|
161
|
+
mappings, "model_id", "revision_id"
|
|
162
|
+
).items():
|
|
163
|
+
path = endpoint.path.format(modelId=model_id, revisionId=revision_id)
|
|
164
|
+
result = self._request_item_response(group, "create", endpoint=path)
|
|
165
|
+
for item in result:
|
|
177
166
|
# We append modelId and revisionId to each item since the API does not return them
|
|
178
167
|
# this is needed to fully populate the AssetMappingResponse data class
|
|
179
|
-
item
|
|
180
|
-
item
|
|
181
|
-
results.extend(
|
|
168
|
+
object.__setattr__(item, "model_id", int(model_id))
|
|
169
|
+
object.__setattr__(item, "revision_id", int(revision_id))
|
|
170
|
+
results.extend(result)
|
|
182
171
|
return results
|
|
183
172
|
|
|
184
|
-
def
|
|
173
|
+
def delete(self, mappings: Sequence[AssetMappingClassicRequest]) -> None:
|
|
174
|
+
"""Delete 3D asset mappings.
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
mappings (Sequence[AssetMappingClassicRequest]):
|
|
178
|
+
The 3D asset mapping(s) to delete.
|
|
179
|
+
"""
|
|
180
|
+
endpoint = self._method_endpoint_map["delete"]
|
|
181
|
+
for (model_id, revision_id), group in self._group_items_by_text_field(
|
|
182
|
+
mappings, "model_id", "revision_id"
|
|
183
|
+
).items():
|
|
184
|
+
path = endpoint.path.format(modelId=model_id, revisionId=revision_id)
|
|
185
|
+
self._request_no_response(group, "delete", endpoint=path)
|
|
186
|
+
return None
|
|
187
|
+
|
|
188
|
+
def paginate(
|
|
189
|
+
self,
|
|
190
|
+
model_id: int,
|
|
191
|
+
revision_id: int,
|
|
192
|
+
filter: ThreeDAssetMappingFilter | None = None,
|
|
193
|
+
limit: int = 100,
|
|
194
|
+
cursor: str | None = None,
|
|
195
|
+
) -> PagedResponse[AssetMappingClassicResponse]:
|
|
196
|
+
endpoint = self._method_endpoint_map["list"]
|
|
197
|
+
path = endpoint.path.format(modelId=model_id, revisionId=revision_id)
|
|
198
|
+
page = self._paginate(
|
|
199
|
+
limit=limit,
|
|
200
|
+
cursor=cursor,
|
|
201
|
+
body={"filter": filter.dump() if filter else None, "getDmsInstances": False},
|
|
202
|
+
endpoint_path=path,
|
|
203
|
+
)
|
|
204
|
+
# Add modelId and revisionId to items since the API does not return them
|
|
205
|
+
for item in page.items:
|
|
206
|
+
object.__setattr__(item, "model_id", model_id)
|
|
207
|
+
object.__setattr__(item, "revision_id", revision_id)
|
|
208
|
+
return page
|
|
209
|
+
|
|
210
|
+
def iterate(
|
|
211
|
+
self,
|
|
212
|
+
model_id: int,
|
|
213
|
+
revision_id: int,
|
|
214
|
+
filter: ThreeDAssetMappingFilter | None = None,
|
|
215
|
+
limit: int = 100,
|
|
216
|
+
) -> Iterable[list[AssetMappingClassicResponse]]:
|
|
217
|
+
endpoint = self._method_endpoint_map["list"]
|
|
218
|
+
path = endpoint.path.format(modelId=model_id, revisionId=revision_id)
|
|
219
|
+
for items in self._iterate(
|
|
220
|
+
body={"filter": filter.dump() if filter else None, "getDmsInstances": False},
|
|
221
|
+
limit=limit,
|
|
222
|
+
endpoint_path=path,
|
|
223
|
+
):
|
|
224
|
+
# Add modelId and revisionId to items since the API does not return them
|
|
225
|
+
for item in items:
|
|
226
|
+
object.__setattr__(item, "model_id", model_id)
|
|
227
|
+
object.__setattr__(item, "revision_id", revision_id)
|
|
228
|
+
yield items
|
|
229
|
+
|
|
230
|
+
def list(
|
|
231
|
+
self,
|
|
232
|
+
model_id: int,
|
|
233
|
+
revision_id: int,
|
|
234
|
+
filter: ThreeDAssetMappingFilter | None = None,
|
|
235
|
+
limit: int | None = 100,
|
|
236
|
+
) -> list[AssetMappingClassicResponse]:
|
|
237
|
+
endpoint = self._method_endpoint_map["list"]
|
|
238
|
+
path = endpoint.path.format(modelId=model_id, revisionId=revision_id)
|
|
239
|
+
items = self._list(
|
|
240
|
+
body={"filter": filter.dump() if filter else None, "getDmsInstances": False},
|
|
241
|
+
limit=limit,
|
|
242
|
+
endpoint_path=path,
|
|
243
|
+
)
|
|
244
|
+
# Add modelId and revisionId to items since the API does not return them
|
|
245
|
+
for item in items:
|
|
246
|
+
object.__setattr__(item, "model_id", model_id)
|
|
247
|
+
object.__setattr__(item, "revision_id", revision_id)
|
|
248
|
+
return items
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class ThreeDDMAssetMappingAPI(CDFResourceAPI[AssetMappingDMRequest, AssetMappingDMRequest, AssetMappingDMResponse]):
|
|
252
|
+
ENDPOINT = "/3d/models/{modelId}/revisions/{revisionId}/mappings"
|
|
253
|
+
|
|
254
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
255
|
+
super().__init__(
|
|
256
|
+
http_client=http_client,
|
|
257
|
+
method_endpoint_map={
|
|
258
|
+
# These endpoints are parameterized, so the paths are templates
|
|
259
|
+
"create": Endpoint(method="POST", path=self.ENDPOINT, item_limit=100),
|
|
260
|
+
"delete": Endpoint(method="POST", path=f"{self.ENDPOINT}/delete", item_limit=100),
|
|
261
|
+
"list": Endpoint(method="POST", path=f"{self.ENDPOINT}/list", item_limit=1000),
|
|
262
|
+
},
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
def _validate_page_response(
|
|
266
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
267
|
+
) -> PagedResponse[AssetMappingDMResponse]:
|
|
268
|
+
return PagedResponse[AssetMappingDMResponse].model_validate_json(response.body)
|
|
269
|
+
|
|
270
|
+
def create(
|
|
185
271
|
self, mappings: Sequence[AssetMappingDMRequest], object_3d_space: str, cad_node_space: str
|
|
186
|
-
) -> list[
|
|
272
|
+
) -> list[AssetMappingDMResponse]:
|
|
187
273
|
"""Create 3D asset mappings in Data Modeling format.
|
|
188
274
|
|
|
189
275
|
Args:
|
|
@@ -194,69 +280,33 @@ class ThreeDAssetMappingAPI:
|
|
|
194
280
|
cad_node_space (str):
|
|
195
281
|
The instance space where the CogniteCADNode are located.
|
|
196
282
|
Returns:
|
|
197
|
-
list[
|
|
283
|
+
list[AssetMappingDMResponse]: The created 3D asset mapping(s).
|
|
198
284
|
"""
|
|
199
|
-
results: list[
|
|
200
|
-
for
|
|
201
|
-
mappings,
|
|
202
|
-
):
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
)
|
|
285
|
+
results: list[AssetMappingDMResponse] = []
|
|
286
|
+
for (model_id, revision_id), group in self._group_items_by_text_field(
|
|
287
|
+
mappings, "model_id", "revision_id"
|
|
288
|
+
).items():
|
|
289
|
+
path = self.ENDPOINT.format(modelId=model_id, revisionId=revision_id)
|
|
290
|
+
result = self._request_item_response(
|
|
291
|
+
group,
|
|
292
|
+
"create",
|
|
293
|
+
endpoint=path,
|
|
294
|
+
extra_body={
|
|
295
|
+
"dmsContextualizationConfig": {
|
|
296
|
+
"object3DSpace": object_3d_space,
|
|
297
|
+
"cadNodeSpace": cad_node_space,
|
|
298
|
+
}
|
|
299
|
+
},
|
|
215
300
|
)
|
|
216
|
-
|
|
217
|
-
items = responses.get_items()
|
|
218
|
-
for item in items:
|
|
301
|
+
for item in result:
|
|
219
302
|
# We append modelId and revisionId to each item since the API does not return them
|
|
220
|
-
# this is needed to fully populate the
|
|
221
|
-
item
|
|
222
|
-
item
|
|
223
|
-
results.extend(
|
|
303
|
+
# this is needed to fully populate the AssetMappingDMResponse data class
|
|
304
|
+
object.__setattr__(item, "model_id", int(model_id))
|
|
305
|
+
object.__setattr__(item, "revision_id", int(revision_id))
|
|
306
|
+
results.extend(result)
|
|
224
307
|
return results
|
|
225
308
|
|
|
226
|
-
|
|
227
|
-
def _chunk_mappings_by_endpoint(
|
|
228
|
-
cls, mappings: Sequence[T_RequestMapping], chunk_size: int
|
|
229
|
-
) -> Iterable[tuple[str, int, int, list[T_RequestMapping]]]:
|
|
230
|
-
chunked_mappings: dict[tuple[int, int], list[T_RequestMapping]] = defaultdict(list)
|
|
231
|
-
for mapping in mappings:
|
|
232
|
-
key = mapping.model_id, mapping.revision_id
|
|
233
|
-
chunked_mappings[key].append(mapping)
|
|
234
|
-
for (model_id, revision_id), revision_mappings in chunked_mappings.items():
|
|
235
|
-
endpoint = cls.ENDPOINT.format(modelId=model_id, revisionId=revision_id)
|
|
236
|
-
for chunk in chunker_sequence(revision_mappings, chunk_size):
|
|
237
|
-
yield endpoint, model_id, revision_id, chunk
|
|
238
|
-
|
|
239
|
-
def delete(self, mappings: Sequence[AssetMappingClassicRequest]) -> None:
|
|
240
|
-
"""Delete 3D asset mappings.
|
|
241
|
-
|
|
242
|
-
Args:
|
|
243
|
-
mappings (Sequence[AssetMappingClassicRequest]):
|
|
244
|
-
The 3D asset mapping(s) to delete.
|
|
245
|
-
"""
|
|
246
|
-
for endpoint, *_, revision_mappings in self._chunk_mappings_by_endpoint(
|
|
247
|
-
mappings, self.DELETE_CLASSIC_MAX_MAPPINGS_PER_REQUEST
|
|
248
|
-
):
|
|
249
|
-
responses = self._http_client.request_items_retries(
|
|
250
|
-
ItemsRequest2(
|
|
251
|
-
endpoint_url=self._config.create_api_url(f"{endpoint}/delete"),
|
|
252
|
-
method="DELETE",
|
|
253
|
-
items=revision_mappings,
|
|
254
|
-
)
|
|
255
|
-
)
|
|
256
|
-
responses.raise_for_status()
|
|
257
|
-
return None
|
|
258
|
-
|
|
259
|
-
def delete_dm(self, mappings: Sequence[AssetMappingDMRequest], object_3d_space: str, cad_node_space: str) -> None:
|
|
309
|
+
def delete(self, mappings: Sequence[AssetMappingDMRequest], object_3d_space: str, cad_node_space: str) -> None:
|
|
260
310
|
"""Delete 3D asset mappings in Data Modeling format.
|
|
261
311
|
|
|
262
312
|
Args:
|
|
@@ -267,118 +317,85 @@ class ThreeDAssetMappingAPI:
|
|
|
267
317
|
cad_node_space (str):
|
|
268
318
|
The instance space where the CogniteCADNode are located.
|
|
269
319
|
"""
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
320
|
+
endpoint = self._method_endpoint_map["delete"]
|
|
321
|
+
for (model_id, revision_id), group in self._group_items_by_text_field(
|
|
322
|
+
mappings, "model_id", "revision_id"
|
|
323
|
+
).items():
|
|
324
|
+
path = endpoint.path.format(modelId=model_id, revisionId=revision_id)
|
|
325
|
+
self._request_no_response(
|
|
326
|
+
group,
|
|
327
|
+
"delete",
|
|
328
|
+
endpoint=path,
|
|
329
|
+
extra_body={
|
|
330
|
+
"dmsContextualizationConfig": {
|
|
331
|
+
"object3DSpace": object_3d_space,
|
|
332
|
+
"cadNodeSpace": cad_node_space,
|
|
333
|
+
}
|
|
334
|
+
},
|
|
285
335
|
)
|
|
286
|
-
responses.raise_for_status()
|
|
287
336
|
return None
|
|
288
337
|
|
|
289
|
-
def
|
|
338
|
+
def paginate(
|
|
290
339
|
self,
|
|
291
340
|
model_id: int,
|
|
292
341
|
revision_id: int,
|
|
293
|
-
|
|
294
|
-
asset_instance_ids: list[str] | None = None,
|
|
295
|
-
node_ids: list[int] | None = None,
|
|
296
|
-
tree_indexes: list[int] | None = None,
|
|
297
|
-
get_dms_instances: bool = False,
|
|
342
|
+
filter: ThreeDAssetMappingFilter | None = None,
|
|
298
343
|
limit: int = 100,
|
|
299
344
|
cursor: str | None = None,
|
|
300
|
-
) -> PagedResponse[
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
"getDmsInstances":
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
if asset_ids is not None:
|
|
310
|
-
if not (0 < len(asset_ids) <= 100):
|
|
311
|
-
raise ValueError("asset_ids must contain between 1 and 100 IDs.")
|
|
312
|
-
body["filter"] = {"assetIds": asset_ids}
|
|
313
|
-
elif asset_instance_ids is not None:
|
|
314
|
-
if not (0 < len(asset_instance_ids) <= 100):
|
|
315
|
-
raise ValueError("asset_instance_ids must contain between 1 and 100 IDs.")
|
|
316
|
-
body["filter"] = {"assetInstanceIds": asset_instance_ids}
|
|
317
|
-
elif node_ids is not None:
|
|
318
|
-
if not (0 < len(node_ids) <= 100):
|
|
319
|
-
raise ValueError("node_ids must contain between 1 and 100 IDs.")
|
|
320
|
-
body["filter"] = {"nodeIds": node_ids}
|
|
321
|
-
elif tree_indexes is not None:
|
|
322
|
-
if not (0 < len(tree_indexes) <= 100):
|
|
323
|
-
raise ValueError("tree_indexes must contain between 1 and 100 indexes.")
|
|
324
|
-
body["filter"] = {"treeIndexes": tree_indexes}
|
|
325
|
-
if cursor is not None:
|
|
326
|
-
body["cursor"] = cursor
|
|
327
|
-
|
|
328
|
-
endpoint = self.ENDPOINT.format(modelId=model_id, revisionId=revision_id)
|
|
329
|
-
responses = self._http_client.request_single_retries(
|
|
330
|
-
RequestMessage2(
|
|
331
|
-
endpoint_url=self._config.create_api_url(f"{endpoint}/list"),
|
|
332
|
-
method="POST",
|
|
333
|
-
body_content=body,
|
|
334
|
-
)
|
|
345
|
+
) -> PagedResponse[AssetMappingDMResponse]:
|
|
346
|
+
endpoint = self._method_endpoint_map["list"]
|
|
347
|
+
path = endpoint.path.format(modelId=model_id, revisionId=revision_id)
|
|
348
|
+
page = self._paginate(
|
|
349
|
+
limit=limit,
|
|
350
|
+
cursor=cursor,
|
|
351
|
+
body={"filter": filter.dump() if filter else None, "getDmsInstances": True},
|
|
352
|
+
endpoint_path=path,
|
|
335
353
|
)
|
|
336
|
-
success_response = responses.get_success_or_raise()
|
|
337
|
-
body_json = success_response.body_json
|
|
338
354
|
# Add modelId and revisionId to items since the API does not return them
|
|
339
|
-
for item in
|
|
340
|
-
item
|
|
341
|
-
item
|
|
342
|
-
return
|
|
355
|
+
for item in page.items:
|
|
356
|
+
object.__setattr__(item, "model_id", model_id)
|
|
357
|
+
object.__setattr__(item, "revision_id", revision_id)
|
|
358
|
+
return page
|
|
359
|
+
|
|
360
|
+
def iterate(
|
|
361
|
+
self,
|
|
362
|
+
model_id: int,
|
|
363
|
+
revision_id: int,
|
|
364
|
+
filter: ThreeDAssetMappingFilter | None = None,
|
|
365
|
+
limit: int = 100,
|
|
366
|
+
) -> Iterable[list[AssetMappingDMResponse]]:
|
|
367
|
+
endpoint = self._method_endpoint_map["list"]
|
|
368
|
+
path = endpoint.path.format(modelId=model_id, revisionId=revision_id)
|
|
369
|
+
for items in self._iterate(
|
|
370
|
+
body={"filter": filter.dump() if filter else None, "getDmsInstances": True}, limit=limit, endpoint_path=path
|
|
371
|
+
):
|
|
372
|
+
# Add modelId and revisionId to items since the API does not return them
|
|
373
|
+
for item in items:
|
|
374
|
+
object.__setattr__(item, "model_id", model_id)
|
|
375
|
+
object.__setattr__(item, "revision_id", revision_id)
|
|
376
|
+
yield items
|
|
343
377
|
|
|
344
378
|
def list(
|
|
345
379
|
self,
|
|
346
380
|
model_id: int,
|
|
347
381
|
revision_id: int,
|
|
348
|
-
|
|
349
|
-
asset_instance_ids: list[str] | None = None,
|
|
350
|
-
node_ids: list[int] | None = None,
|
|
351
|
-
tree_indexes: list[int] | None = None,
|
|
352
|
-
get_dms_instances: bool = False,
|
|
382
|
+
filter: ThreeDAssetMappingFilter | None = None,
|
|
353
383
|
limit: int | None = 100,
|
|
354
|
-
) -> list[
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
revision_id=revision_id,
|
|
366
|
-
asset_ids=asset_ids,
|
|
367
|
-
asset_instance_ids=asset_instance_ids,
|
|
368
|
-
node_ids=node_ids,
|
|
369
|
-
tree_indexes=tree_indexes,
|
|
370
|
-
get_dms_instances=get_dms_instances,
|
|
371
|
-
limit=request_limit,
|
|
372
|
-
cursor=cursor,
|
|
373
|
-
)
|
|
374
|
-
results.extend(page.items)
|
|
375
|
-
if page.next_cursor is None:
|
|
376
|
-
break
|
|
377
|
-
cursor = page.next_cursor
|
|
378
|
-
return results
|
|
384
|
+
) -> list[AssetMappingDMResponse]:
|
|
385
|
+
endpoint = self._method_endpoint_map["list"]
|
|
386
|
+
path = endpoint.path.format(modelId=model_id, revisionId=revision_id)
|
|
387
|
+
items = self._list(
|
|
388
|
+
body={"filter": filter.dump() if filter else None, "getDmsInstances": True}, limit=limit, endpoint_path=path
|
|
389
|
+
)
|
|
390
|
+
# Add modelId and revisionId to items since the API does not return them
|
|
391
|
+
for item in items:
|
|
392
|
+
object.__setattr__(item, "model_id", model_id)
|
|
393
|
+
object.__setattr__(item, "revision_id", revision_id)
|
|
394
|
+
return items
|
|
379
395
|
|
|
380
396
|
|
|
381
397
|
class ThreeDAPI:
|
|
382
|
-
def __init__(self, http_client: HTTPClient
|
|
383
|
-
self.
|
|
384
|
-
self.
|
|
398
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
399
|
+
self.models_classic = ThreeDClassicModelsAPI(http_client)
|
|
400
|
+
self.asset_mappings_classic = ThreeDClassicAssetMappingAPI(http_client)
|
|
401
|
+
self.asset_mappings_dm = ThreeDDMAssetMappingAPI(http_client)
|