cognite-toolkit 0.7.30__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.py +5 -6
- cognite_toolkit/_cdf_tk/apps/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/apps/_core_app.py +7 -1
- cognite_toolkit/_cdf_tk/apps/_download_app.py +2 -2
- cognite_toolkit/_cdf_tk/apps/_dump_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_import_app.py +41 -0
- cognite_toolkit/_cdf_tk/apps/_migrate_app.py +183 -8
- 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 +44 -12
- 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 +40 -35
- 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/{canvas.py → legacy/canvas.py} +16 -8
- cognite_toolkit/_cdf_tk/client/api/{charts.py → legacy/charts.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_data_modeling.py → legacy/extended_data_modeling.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_files.py → legacy/extended_files.py} +2 -2
- cognite_toolkit/_cdf_tk/client/api/{extended_functions.py → legacy/extended_functions.py} +9 -9
- cognite_toolkit/_cdf_tk/client/api/{extended_raw.py → legacy/extended_raw.py} +1 -1
- cognite_toolkit/_cdf_tk/client/api/{extended_timeseries.py → legacy/extended_timeseries.py} +5 -2
- cognite_toolkit/_cdf_tk/client/api/legacy/location_filters.py +112 -0
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/__init__.py +8 -0
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/capabilities.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/data_postprocessing.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/frames.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/locations.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/maps.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/robots.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/legacy/search_config.py +53 -0
- cognite_toolkit/_cdf_tk/client/api/location_filters.py +140 -75
- cognite_toolkit/_cdf_tk/client/api/migration.py +2 -3
- cognite_toolkit/_cdf_tk/client/api/project.py +9 -8
- 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.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/search_config.py +83 -31
- 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 +68 -56
- cognite_toolkit/_cdf_tk/client/api/three_d.py +385 -34
- 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 +30 -0
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/_client.py +26 -16
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/_data_classes.py +18 -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/{utils → client}/http_client/_tracker.py +5 -2
- 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/__init__.py +0 -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 +53 -14
- 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 +54 -17
- cognite_toolkit/_cdf_tk/commands/__init__.py +1 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/command.py +103 -108
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +29 -16
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +38 -6
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +262 -36
- cognite_toolkit/_cdf_tk/commands/_migrate/data_model.py +1 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +39 -38
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +227 -8
- cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_purge.py +14 -16
- 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/__init__.py +0 -0
- 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 +228 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_parameters.py +71 -0
- 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 +34 -25
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +50 -59
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +14 -2
- 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 +49 -14
- 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/_module_toml.py +1 -0
- 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 +173 -5
- 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 +65 -56
- 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/storageio/selectors/__init__.py +10 -1
- cognite_toolkit/_cdf_tk/storageio/selectors/_three_d.py +34 -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 +53 -4
- 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/_cdf_tk/validation.py +4 -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.30.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.30.dist-info → cognite_toolkit-0.7.51.dist-info}/WHEEL +2 -2
- cognite_toolkit/_cdf_tk/client/api/robotics/__init__.py +0 -3
- cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +0 -17
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +0 -87
- cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +0 -47
- cognite_toolkit/_cdf_tk/prototypes/import_app.py +0 -41
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +0 -187
- cognite_toolkit/_cdf_tk/utils/http_client/_exception.py +0 -4
- cognite_toolkit-0.7.30.dist-info/RECORD +0 -316
- /cognite_toolkit/_cdf_tk/client/{data_classes → api/legacy}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{dml.py → legacy/dml.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{fixed_transformations.py → legacy/fixed_transformations.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/api.py +0 -0
- /cognite_toolkit/_cdf_tk/client/api/{robotics → legacy/robotics}/utlis.py +0 -0
- /cognite_toolkit/_cdf_tk/{prototypes/commands → client/request_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/_cdf_tk/{prototypes/commands/import_.py → commands/_import_cmd.py} +0 -0
- {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.51.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import gzip
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
from collections.abc import Hashable
|
|
4
|
+
from typing import Any, Literal
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
from cognite.client import global_config
|
|
8
|
+
from pydantic import BaseModel, JsonValue, TypeAdapter, model_validator
|
|
9
|
+
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.http_client._data_classes import (
|
|
11
|
+
ErrorDetails,
|
|
12
|
+
FailedRequestItems,
|
|
13
|
+
FailedRequestMessage,
|
|
14
|
+
FailedResponseItems,
|
|
15
|
+
ResponseMessage,
|
|
16
|
+
SuccessResponseItems,
|
|
17
|
+
)
|
|
18
|
+
from cognite_toolkit._cdf_tk.client.http_client._exception import ToolkitAPIError
|
|
19
|
+
from cognite_toolkit._cdf_tk.utils.useful_types import PrimitiveType
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class HTTPResult2(BaseModel):
|
|
23
|
+
def get_success_or_raise(self) -> "SuccessResponse2":
|
|
24
|
+
"""Raises an exception if any response in the list indicates a failure."""
|
|
25
|
+
if isinstance(self, SuccessResponse2):
|
|
26
|
+
return self
|
|
27
|
+
elif isinstance(self, FailedResponse2):
|
|
28
|
+
raise ToolkitAPIError(
|
|
29
|
+
f"Request failed with status code {self.status_code}: {self.error.message}",
|
|
30
|
+
missing=self.error.missing, # type: ignore[arg-type]
|
|
31
|
+
duplicated=self.error.duplicated, # type: ignore[arg-type]
|
|
32
|
+
)
|
|
33
|
+
elif isinstance(self, FailedRequest2):
|
|
34
|
+
raise ToolkitAPIError(f"Request failed with error: {self.error}")
|
|
35
|
+
else:
|
|
36
|
+
raise ToolkitAPIError("Unknown HTTPResult2 type")
|
|
37
|
+
|
|
38
|
+
# Todo: Remove when HTTPResult2 is renamed to HTTPResponse and the old HTTPResponse is deleted
|
|
39
|
+
def as_item_response(self, item_id: Hashable) -> ResponseMessage | FailedRequestMessage:
|
|
40
|
+
if isinstance(self, SuccessResponse2):
|
|
41
|
+
return SuccessResponseItems(
|
|
42
|
+
status_code=self.status_code, content=self.content, ids=[item_id], body=self.body
|
|
43
|
+
)
|
|
44
|
+
elif isinstance(self, FailedResponse2):
|
|
45
|
+
return FailedResponseItems(
|
|
46
|
+
status_code=self.status_code,
|
|
47
|
+
ids=[item_id],
|
|
48
|
+
body=self.body,
|
|
49
|
+
error=ErrorDetails(
|
|
50
|
+
code=self.error.code,
|
|
51
|
+
message=self.error.message,
|
|
52
|
+
missing=self.error.missing,
|
|
53
|
+
duplicated=self.error.duplicated,
|
|
54
|
+
),
|
|
55
|
+
)
|
|
56
|
+
elif isinstance(self, FailedRequest2):
|
|
57
|
+
return FailedRequestItems(ids=[item_id], error=self.error)
|
|
58
|
+
else:
|
|
59
|
+
raise ToolkitAPIError("Unknown HTTPResult2 type")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class FailedRequest2(HTTPResult2):
|
|
63
|
+
error: str
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class SuccessResponse2(HTTPResult2):
|
|
67
|
+
status_code: int
|
|
68
|
+
body: str
|
|
69
|
+
content: bytes
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def body_json(self) -> dict[str, Any]:
|
|
73
|
+
"""Parse the response body as JSON."""
|
|
74
|
+
return TypeAdapter(dict[str, JsonValue]).validate_json(self.body)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class ErrorDetails2(BaseModel):
|
|
78
|
+
"""This is the expected structure of error details in the CDF API"""
|
|
79
|
+
|
|
80
|
+
code: int
|
|
81
|
+
message: str
|
|
82
|
+
missing: list[JsonValue] | None = None
|
|
83
|
+
duplicated: list[JsonValue] | None = None
|
|
84
|
+
is_auto_retryable: bool | None = None
|
|
85
|
+
|
|
86
|
+
@classmethod
|
|
87
|
+
def from_response(cls, response: httpx.Response) -> "ErrorDetails2":
|
|
88
|
+
"""Populate the error details from a httpx response."""
|
|
89
|
+
try:
|
|
90
|
+
res = TypeAdapter(dict[Literal["error"], ErrorDetails2]).validate_json(response.text)
|
|
91
|
+
except ValueError:
|
|
92
|
+
return cls(code=response.status_code, message=response.text)
|
|
93
|
+
return res["error"]
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class FailedResponse2(HTTPResult2):
|
|
97
|
+
status_code: int
|
|
98
|
+
body: str
|
|
99
|
+
error: ErrorDetails2
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class BaseRequestMessage(BaseModel, ABC):
|
|
103
|
+
endpoint_url: str
|
|
104
|
+
method: Literal["GET", "POST", "PATCH", "DELETE", "PUT"]
|
|
105
|
+
connect_attempt: int = 0
|
|
106
|
+
read_attempt: int = 0
|
|
107
|
+
status_attempt: int = 0
|
|
108
|
+
api_version: str | None = None
|
|
109
|
+
disable_gzip: bool = False
|
|
110
|
+
content_length: int | None = None
|
|
111
|
+
content_type: str = "application/json"
|
|
112
|
+
accept: str = "application/json"
|
|
113
|
+
|
|
114
|
+
parameters: dict[str, PrimitiveType] | None = None
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def total_attempts(self) -> int:
|
|
118
|
+
return self.connect_attempt + self.read_attempt + self.status_attempt
|
|
119
|
+
|
|
120
|
+
@property
|
|
121
|
+
@abstractmethod
|
|
122
|
+
def content(self) -> str | bytes | None: ...
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class RequestMessage2(BaseRequestMessage):
|
|
126
|
+
data_content: bytes | None = None
|
|
127
|
+
body_content: dict[str, JsonValue] | None = None
|
|
128
|
+
|
|
129
|
+
@model_validator(mode="before")
|
|
130
|
+
def check_data_or_body(cls, values: dict[str, Any]) -> dict[str, Any]:
|
|
131
|
+
if values.get("data_content") is not None and values.get("body_content") is not None:
|
|
132
|
+
raise ValueError("Only one of data_content or body_content can be set.")
|
|
133
|
+
return values
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def content(self) -> str | bytes | None:
|
|
137
|
+
data: str | bytes | None = None
|
|
138
|
+
if self.data_content is not None:
|
|
139
|
+
data = self.data_content
|
|
140
|
+
if not global_config.disable_gzip and not self.disable_gzip:
|
|
141
|
+
data = gzip.compress(data)
|
|
142
|
+
elif self.body_content is not None:
|
|
143
|
+
# We serialize using pydantic instead of json.dumps. This is because pydantic is faster
|
|
144
|
+
# and handles more complex types such as datetime, float('nan'), etc.
|
|
145
|
+
data = _BODY_SERIALIZER.dump_json(self.body_content)
|
|
146
|
+
if not global_config.disable_gzip and not self.disable_gzip and isinstance(data, bytes):
|
|
147
|
+
data = gzip.compress(data)
|
|
148
|
+
return data
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
_BODY_SERIALIZER = TypeAdapter(dict[str, JsonValue])
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ToolkitAPIError(Exception):
|
|
5
|
+
"""Base class for all exceptions raised by the Cognite Toolkit API client."""
|
|
6
|
+
|
|
7
|
+
def __init__(
|
|
8
|
+
self, message: str, missing: list[dict[str, Any]] | None = None, duplicated: list[dict[str, Any]] | None = None
|
|
9
|
+
) -> None:
|
|
10
|
+
super().__init__(message)
|
|
11
|
+
self.message = message
|
|
12
|
+
self.missing = missing
|
|
13
|
+
self.duplicated = duplicated
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""Data classes for handling item-based requests and responses in the Cognite Toolkit HTTP client."""
|
|
2
|
+
|
|
3
|
+
import gzip
|
|
4
|
+
from collections import UserList
|
|
5
|
+
from collections.abc import Sequence
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from cognite.client import global_config
|
|
9
|
+
from pydantic import BaseModel, ConfigDict, Field, JsonValue
|
|
10
|
+
|
|
11
|
+
from cognite_toolkit._cdf_tk.client._resource_base import RequestItem
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.http_client._data_classes2 import (
|
|
13
|
+
_BODY_SERIALIZER,
|
|
14
|
+
BaseRequestMessage,
|
|
15
|
+
ErrorDetails2,
|
|
16
|
+
)
|
|
17
|
+
from cognite_toolkit._cdf_tk.client.http_client._exception import ToolkitAPIError
|
|
18
|
+
from cognite_toolkit._cdf_tk.client.http_client._tracker import ItemsRequestTracker
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ItemsResultMessage2(BaseModel):
|
|
22
|
+
ids: list[str]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ItemsFailedRequest2(ItemsResultMessage2):
|
|
26
|
+
error_message: str
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ItemsSuccessResponse2(ItemsResultMessage2):
|
|
30
|
+
status_code: int
|
|
31
|
+
body: str
|
|
32
|
+
content: bytes
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ItemsFailedResponse2(ItemsResultMessage2):
|
|
36
|
+
status_code: int
|
|
37
|
+
error: ErrorDetails2
|
|
38
|
+
body: str
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _set_default_tracker(data: dict[str, Any]) -> ItemsRequestTracker:
|
|
42
|
+
if "tracker" not in data or data["tracker"] is None:
|
|
43
|
+
return ItemsRequestTracker(data.get("max_failures_before_abort", 50))
|
|
44
|
+
return data["tracker"]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ItemsRequest2(BaseRequestMessage):
|
|
48
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
49
|
+
items: Sequence[RequestItem]
|
|
50
|
+
extra_body_fields: dict[str, JsonValue] | None = None
|
|
51
|
+
max_failures_before_abort: int = 50
|
|
52
|
+
tracker: ItemsRequestTracker = Field(init=False, default_factory=_set_default_tracker, exclude=True)
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def content(self) -> str | bytes | None:
|
|
56
|
+
body: dict[str, JsonValue] = {"items": [item.dump(camel_case=True) for item in self.items]}
|
|
57
|
+
if self.extra_body_fields:
|
|
58
|
+
body.update(self.extra_body_fields)
|
|
59
|
+
res = _BODY_SERIALIZER.dump_json(body)
|
|
60
|
+
if not global_config.disable_gzip and not self.disable_gzip and isinstance(res, bytes):
|
|
61
|
+
return gzip.compress(res)
|
|
62
|
+
return res
|
|
63
|
+
|
|
64
|
+
def split(self, status_attempts: int) -> list["ItemsRequest2"]:
|
|
65
|
+
"""Split the request into multiple requests with a single item each."""
|
|
66
|
+
mid = len(self.items) // 2
|
|
67
|
+
if mid == 0:
|
|
68
|
+
return [self]
|
|
69
|
+
self.tracker.register_failure()
|
|
70
|
+
messages: list[ItemsRequest2] = []
|
|
71
|
+
for part in (self.items[:mid], self.items[mid:]):
|
|
72
|
+
new_request = self.model_copy(update={"items": part, "status_attempt": status_attempts})
|
|
73
|
+
new_request.tracker = self.tracker
|
|
74
|
+
messages.append(new_request)
|
|
75
|
+
return messages
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class ItemResponse(BaseModel):
|
|
79
|
+
items: list[dict[str, JsonValue]]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class ItemsResultList(UserList[ItemsResultMessage2]):
|
|
83
|
+
def __init__(self, collection: Sequence[ItemsResultMessage2] | None = None) -> None:
|
|
84
|
+
super().__init__(collection or [])
|
|
85
|
+
|
|
86
|
+
def raise_for_status(self) -> None:
|
|
87
|
+
"""Raises an exception if any response in the list indicates a failure."""
|
|
88
|
+
failed_responses = [resp for resp in self.data if isinstance(resp, ItemsFailedResponse2)]
|
|
89
|
+
failed_requests = [resp for resp in self.data if isinstance(resp, ItemsFailedRequest2)]
|
|
90
|
+
if not failed_responses and not failed_requests:
|
|
91
|
+
return
|
|
92
|
+
error_messages = "; ".join(f"Status {err.status_code}: {err.error.message}" for err in failed_responses)
|
|
93
|
+
if failed_requests:
|
|
94
|
+
if error_messages:
|
|
95
|
+
error_messages += "; "
|
|
96
|
+
error_messages += "; ".join(f"Request error: {err.error_message}" for err in failed_requests)
|
|
97
|
+
raise ToolkitAPIError(f"One or more requests failed: {error_messages}")
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def has_failed(self) -> bool:
|
|
101
|
+
"""Indicates whether any response in the list indicates a failure.
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
bool: True if there are any failed responses or requests, False otherwise.
|
|
105
|
+
"""
|
|
106
|
+
for resp in self.data:
|
|
107
|
+
if isinstance(resp, ItemsFailedResponse2 | ItemsFailedRequest2):
|
|
108
|
+
return True
|
|
109
|
+
return False
|
|
110
|
+
|
|
111
|
+
def get_items(self) -> list[dict[str, JsonValue]]:
|
|
112
|
+
"""Get the items from all successful responses."""
|
|
113
|
+
items: list[dict[str, JsonValue]] = []
|
|
114
|
+
for resp in self.data:
|
|
115
|
+
if isinstance(resp, ItemsSuccessResponse2):
|
|
116
|
+
body_json = ItemResponse.model_validate_json(resp.body)
|
|
117
|
+
items.extend(body_json.items)
|
|
118
|
+
return items
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import threading
|
|
2
2
|
from dataclasses import dataclass, field
|
|
3
|
+
from typing import Any
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
@dataclass
|
|
@@ -9,13 +10,15 @@ class ItemsRequestTracker:
|
|
|
9
10
|
Attributes:
|
|
10
11
|
max_failures_before_abort (int): Maximum number of allowed failed split requests before aborting
|
|
11
12
|
the entire operation. A value of -1 indicates no early abort.
|
|
12
|
-
lock (
|
|
13
|
+
lock (Any): A lock to ensure thread-safe updates to the failure count.
|
|
13
14
|
failed_split_count (int): The current count of failed split requests.
|
|
14
15
|
|
|
15
16
|
"""
|
|
16
17
|
|
|
17
18
|
max_failures_before_abort: int = -1 # -1 means no early abort
|
|
18
|
-
|
|
19
|
+
# NOTE: `threading.Lock` is a factory function (backed by `_thread.allocate_lock`), not a type.
|
|
20
|
+
# Annotate as `Any` so Pydantic won't attempt to generate a schema for the lock field.
|
|
21
|
+
lock: Any = field(default_factory=threading.Lock, init=False)
|
|
19
22
|
failed_split_count: int = field(default=0, init=False)
|
|
20
23
|
|
|
21
24
|
def register_failure(self) -> None:
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, ConfigDict
|
|
4
|
+
from pydantic.alias_generators import to_camel
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class BaseModelRequest(BaseModel):
|
|
8
|
+
"""Base class for all object. This includes resources and nested objects."""
|
|
9
|
+
|
|
10
|
+
model_config = ConfigDict(alias_generator=to_camel, extra="ignore", populate_by_name=True)
|
|
11
|
+
|
|
12
|
+
def dump(self, camel_case: bool = True) -> dict[str, Any]:
|
|
13
|
+
"""Dump the object to a dictionary.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
camel_case (bool): Whether to use camelCase for the keys. Default is True.
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
return self.model_dump(mode="json", by_alias=camel_case, exclude_unset=True)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from typing import Any, Literal
|
|
3
|
+
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.annotation import AnnotationStatus, AnnotationType
|
|
7
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.data_modeling import NodeReference, ViewReference
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import ExternalId, InternalId
|
|
9
|
+
|
|
10
|
+
from .base import BaseModelRequest
|
|
11
|
+
|
|
12
|
+
if sys.version_info >= (3, 11):
|
|
13
|
+
from typing import Self
|
|
14
|
+
else:
|
|
15
|
+
from typing_extensions import Self
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Filter(BaseModelRequest): ...
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ClassicFilter(Filter):
|
|
22
|
+
asset_subtree_ids: list[ExternalId | InternalId] | None = None
|
|
23
|
+
data_set_ids: list[ExternalId | InternalId] | None = None
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def from_asset_subtree_and_data_sets(
|
|
27
|
+
cls,
|
|
28
|
+
asset_subtree_id: str | int | list[str | int] | None = None,
|
|
29
|
+
data_set_id: str | int | list[str | int] | None = None,
|
|
30
|
+
) -> Self:
|
|
31
|
+
return cls(
|
|
32
|
+
asset_subtree_ids=cls._as_internal_or_external_id_list(asset_subtree_id),
|
|
33
|
+
data_set_ids=cls._as_internal_or_external_id_list(data_set_id),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def _as_internal_or_external_id_list(
|
|
38
|
+
cls, id: str | int | list[str | int] | None
|
|
39
|
+
) -> list[ExternalId | InternalId] | None:
|
|
40
|
+
if id is None:
|
|
41
|
+
return None
|
|
42
|
+
ids = id if isinstance(id, list) else [id]
|
|
43
|
+
return [ExternalId(external_id=item) if isinstance(item, str) else InternalId(id=item) for item in ids]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class DataModelingFilter(Filter):
|
|
47
|
+
space: str | None = None
|
|
48
|
+
include_global: bool | None = None
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ContainerFilter(DataModelingFilter):
|
|
52
|
+
used_for: Literal["node", "edge", "record", "all"] | None
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class ViewFilter(DataModelingFilter):
|
|
56
|
+
include_inherited_properties: bool | None = None
|
|
57
|
+
all_versions: bool | None = None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class DataModelFilter(DataModelingFilter):
|
|
61
|
+
inline_views: bool | None = None
|
|
62
|
+
all_versions: bool | None = None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class InstanceFilter(Filter):
|
|
66
|
+
instance_type: Literal["node", "edge"] | None = None
|
|
67
|
+
source: ViewReference | None = None
|
|
68
|
+
space: list[str] | None = None
|
|
69
|
+
|
|
70
|
+
def dump(self, camel_case: bool = True) -> dict[str, Any]:
|
|
71
|
+
body: dict[str, Any] = {}
|
|
72
|
+
if self.instance_type is not None:
|
|
73
|
+
body["instanceType"] = self.instance_type
|
|
74
|
+
if self.source is not None:
|
|
75
|
+
body["sources"] = [{"source": self.source.dump()}]
|
|
76
|
+
if self.space is not None:
|
|
77
|
+
instance_type = self.instance_type or "node"
|
|
78
|
+
body["filter"] = {
|
|
79
|
+
"in": {
|
|
80
|
+
"property": [instance_type, "space"],
|
|
81
|
+
"values": self.space,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return body
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class AnnotationFilter(Filter):
|
|
88
|
+
annotated_resource_type: Literal["file", "threedmodel"]
|
|
89
|
+
annotated_resource_ids: list[ExternalId | InternalId]
|
|
90
|
+
annotation_type: AnnotationType | None = None
|
|
91
|
+
created_app: str | None = None
|
|
92
|
+
creating_app_version: str | None = None
|
|
93
|
+
creating_user: str | None = None
|
|
94
|
+
status: AnnotationStatus | None = None
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class ThreeDAssetMappingFilter(Filter): ...
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class ThreeDAssetMappingAssetIdFilter(ThreeDAssetMappingFilter):
|
|
101
|
+
asset_ids: list[int] = Field(max_length=100)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class ThreeDAssetMappingAssetInstanceIdFilter(ThreeDAssetMappingFilter):
|
|
105
|
+
asset_instance_ids: list[NodeReference] = Field(max_length=100)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class ThreeDAssetMapping3DNodeFilter(ThreeDAssetMappingFilter):
|
|
109
|
+
node_ids: list[int] = Field(max_length=100)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class ThreeDAssetMappingTreeIndexFilter(ThreeDAssetMappingFilter):
|
|
113
|
+
tree_indexes: list[int] = Field(max_length=100)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
UPSERT_BODY = """
|
|
2
|
+
mutation UpsertGraphQlDmlVersion($dmCreate: GraphQlDmlVersionUpsert!) {
|
|
3
|
+
upsertGraphQlDmlVersion(graphQlDmlVersion: $dmCreate) {
|
|
4
|
+
errors {
|
|
5
|
+
kind
|
|
6
|
+
message
|
|
7
|
+
hint
|
|
8
|
+
location {
|
|
9
|
+
start {
|
|
10
|
+
line
|
|
11
|
+
column
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
result {
|
|
16
|
+
space
|
|
17
|
+
externalId
|
|
18
|
+
version
|
|
19
|
+
name
|
|
20
|
+
description
|
|
21
|
+
graphQlDml
|
|
22
|
+
isGlobal
|
|
23
|
+
createdTime
|
|
24
|
+
lastUpdatedTime
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
"""
|
|
File without changes
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
from typing import Annotated, Any, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import BeforeValidator, Field
|
|
4
|
+
|
|
5
|
+
from cognite_toolkit._cdf_tk.client._resource_base import BaseModelObject, RequestResource, ResponseResource
|
|
6
|
+
|
|
7
|
+
from .identifiers import ExternalId
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AgentToolDefinition(BaseModelObject):
|
|
11
|
+
type: str
|
|
12
|
+
name: str
|
|
13
|
+
description: str
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AskDocument(AgentToolDefinition):
|
|
17
|
+
type: Literal["askDocument"] = "askDocument"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ExamineDataSemantically(AgentToolDefinition):
|
|
21
|
+
type: Literal["examineDataSemantically"] = "examineDataSemantically"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class AgentDataModel(BaseModelObject):
|
|
25
|
+
space: str
|
|
26
|
+
external_id: str
|
|
27
|
+
version: str
|
|
28
|
+
view_external_ids: list[str] | None = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AgentInstanceSpacesDefinition(BaseModelObject):
|
|
32
|
+
type: str
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class AllInstanceSpaces(AgentInstanceSpacesDefinition):
|
|
36
|
+
type: Literal["all"] = "all"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ManualInstanceSpaces(AgentInstanceSpacesDefinition):
|
|
40
|
+
type: Literal["manual"] = "manual"
|
|
41
|
+
spaces: list[str]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
AgentInstanceSpaces = Annotated[
|
|
45
|
+
AllInstanceSpaces | ManualInstanceSpaces,
|
|
46
|
+
Field(discriminator="type"),
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class QueryKnowledgeGraphConfig(BaseModelObject):
|
|
51
|
+
data_models: list[AgentDataModel]
|
|
52
|
+
instance_spaces: AgentInstanceSpaces | None = None
|
|
53
|
+
# This is deviating from the API documentation, but the Atlas team has confirmed that "v2" is the default
|
|
54
|
+
version: Literal["v1", "v2"] = "v2"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class QueryKnowledgeGraph(AgentToolDefinition):
|
|
58
|
+
type: Literal["queryKnowledgeGraph"] = "queryKnowledgeGraph"
|
|
59
|
+
configuration: QueryKnowledgeGraphConfig
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class QueryTimeSeriesDatapoints(AgentToolDefinition):
|
|
63
|
+
type: Literal["queryTimeSeriesDatapoints"] = "queryTimeSeriesDatapoints"
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class SummarizeDocument(AgentToolDefinition):
|
|
67
|
+
type: Literal["summarizeDocument"] = "summarizeDocument"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class UnknownAgentTool(AgentToolDefinition):
|
|
71
|
+
"""Fallback for unknown tool types."""
|
|
72
|
+
|
|
73
|
+
...
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# Mapping of known agent tool types to their classes
|
|
77
|
+
KNOWN_TOOLS: dict[str, type[AgentToolDefinition]] = {
|
|
78
|
+
"askDocument": AskDocument,
|
|
79
|
+
"examineDataSemantically": ExamineDataSemantically,
|
|
80
|
+
"queryKnowledgeGraph": QueryKnowledgeGraph,
|
|
81
|
+
"queryTimeSeriesDatapoints": QueryTimeSeriesDatapoints,
|
|
82
|
+
"summarizeDocument": SummarizeDocument,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _handle_unknown_tool(value: Any) -> Any:
|
|
87
|
+
if isinstance(value, dict):
|
|
88
|
+
tool_type = value.get("type")
|
|
89
|
+
if tool_type not in KNOWN_TOOLS:
|
|
90
|
+
return UnknownAgentTool(**value)
|
|
91
|
+
else:
|
|
92
|
+
return KNOWN_TOOLS[tool_type].model_validate(value)
|
|
93
|
+
return value
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
AgentTool = Annotated[
|
|
97
|
+
AskDocument
|
|
98
|
+
| QueryKnowledgeGraph
|
|
99
|
+
| QueryTimeSeriesDatapoints
|
|
100
|
+
| SummarizeDocument
|
|
101
|
+
| ExamineDataSemantically
|
|
102
|
+
| UnknownAgentTool,
|
|
103
|
+
BeforeValidator(_handle_unknown_tool),
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class Agent(BaseModelObject):
|
|
108
|
+
external_id: str
|
|
109
|
+
name: str
|
|
110
|
+
description: str | None = None
|
|
111
|
+
instructions: str | None = None
|
|
112
|
+
model: str = "azure/gpt-4o-mini"
|
|
113
|
+
tools: list[AgentTool] | None = None
|
|
114
|
+
|
|
115
|
+
def as_id(self) -> ExternalId:
|
|
116
|
+
return ExternalId(external_id=self.external_id)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class AgentRequest(Agent, RequestResource):
|
|
120
|
+
runtime_version: str | None = None
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class AgentResponse(Agent, ResponseResource[AgentRequest]):
|
|
124
|
+
created_time: int
|
|
125
|
+
last_updated_time: int
|
|
126
|
+
owner_id: str
|
|
127
|
+
runtime_version: str
|
|
128
|
+
|
|
129
|
+
def as_request_resource(self) -> AgentRequest:
|
|
130
|
+
return AgentRequest.model_validate(self.dump(), extra="ignore")
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from typing import Any, Literal, TypeAlias
|
|
2
|
+
|
|
3
|
+
from pydantic import Field, JsonValue
|
|
4
|
+
|
|
5
|
+
from cognite_toolkit._cdf_tk.client._resource_base import BaseModelObject, ResponseResource, UpdatableRequestResource
|
|
6
|
+
|
|
7
|
+
from .identifiers import InternalId
|
|
8
|
+
|
|
9
|
+
AnnotationStatus: TypeAlias = Literal["suggested", "rejected", "approved"]
|
|
10
|
+
AnnotationType: TypeAlias = Literal[
|
|
11
|
+
"diagrams.AssetLink",
|
|
12
|
+
"diagrams.FileLink",
|
|
13
|
+
"diagrams.InstanceLink",
|
|
14
|
+
"diagrams.Junction",
|
|
15
|
+
"diagrams.Line",
|
|
16
|
+
"diagrams.UnhandledSymbolObject",
|
|
17
|
+
"diagrams.UnhandledTextObject",
|
|
18
|
+
"documents.ExtractedText",
|
|
19
|
+
"forms.Detection",
|
|
20
|
+
"images.AssetLink",
|
|
21
|
+
"images.Classification",
|
|
22
|
+
"images.InstanceLink",
|
|
23
|
+
"images.KeypointCollection",
|
|
24
|
+
"images.ObjectDetection",
|
|
25
|
+
"images.TextRegion",
|
|
26
|
+
"isoplan.IsoPlanAnnotation",
|
|
27
|
+
"pointcloud.BoundingVolume",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Annotation(BaseModelObject):
|
|
32
|
+
annotated_resource_type: str
|
|
33
|
+
annotated_resource_id: int
|
|
34
|
+
annotation_type: AnnotationType
|
|
35
|
+
creating_app: str
|
|
36
|
+
creating_app_version: str
|
|
37
|
+
creating_user: str | None
|
|
38
|
+
data: dict[str, JsonValue]
|
|
39
|
+
status: AnnotationStatus
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class AnnotationRequest(Annotation, UpdatableRequestResource):
|
|
43
|
+
"""Request data class for annotations."""
|
|
44
|
+
|
|
45
|
+
# The 'id' field is not part of the request when creating a new resource,
|
|
46
|
+
# but is needed when updating an existing resource.
|
|
47
|
+
id: int | None = Field(default=None, exclude=True)
|
|
48
|
+
|
|
49
|
+
def as_id(self) -> InternalId:
|
|
50
|
+
if self.id is None:
|
|
51
|
+
raise ValueError("Cannot convert AnnotationRequest to InternalId when id is None")
|
|
52
|
+
return InternalId(id=self.id)
|
|
53
|
+
|
|
54
|
+
def as_update(self, mode: Literal["patch", "replace"]) -> dict[str, Any]:
|
|
55
|
+
"""Converts the request to an update payload for the API."""
|
|
56
|
+
if self.id is None:
|
|
57
|
+
raise ValueError("id must be provided to create an update dictionary")
|
|
58
|
+
return {
|
|
59
|
+
"id": self.id,
|
|
60
|
+
"update": {
|
|
61
|
+
"annotationType": {"set": self.annotation_type},
|
|
62
|
+
"data": {"set": self.data},
|
|
63
|
+
"status": {"set": self.status},
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class AnnotationResponse(Annotation, ResponseResource[AnnotationRequest]):
|
|
69
|
+
"""Response data class for annotations."""
|
|
70
|
+
|
|
71
|
+
id: int
|
|
72
|
+
created_time: int
|
|
73
|
+
last_updated_time: int
|
|
74
|
+
|
|
75
|
+
def as_id(self) -> InternalId:
|
|
76
|
+
return InternalId(id=self.id)
|
|
77
|
+
|
|
78
|
+
def as_request_resource(self) -> AnnotationRequest:
|
|
79
|
+
return AnnotationRequest.model_validate(self.dump(), extra="ignore")
|