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,187 @@
|
|
|
1
|
+
"""Base classes for Cognite Client resources and identifiers."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
import types
|
|
5
|
+
from abc import ABC, abstractmethod
|
|
6
|
+
from collections import UserList
|
|
7
|
+
from typing import Any, ClassVar, Generic, Literal, TypeVar, Union, get_args, get_origin
|
|
8
|
+
|
|
9
|
+
from cognite.client import CogniteClient
|
|
10
|
+
from pydantic import BaseModel, ConfigDict
|
|
11
|
+
from pydantic.alias_generators import to_camel
|
|
12
|
+
|
|
13
|
+
if sys.version_info >= (3, 11):
|
|
14
|
+
from typing import Self
|
|
15
|
+
else:
|
|
16
|
+
from typing_extensions import Self
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BaseModelObject(BaseModel):
|
|
20
|
+
"""Base class for all object. This includes resources and nested objects."""
|
|
21
|
+
|
|
22
|
+
# We allow extra fields to support forward compatibility.
|
|
23
|
+
model_config = ConfigDict(alias_generator=to_camel, extra="allow", populate_by_name=True)
|
|
24
|
+
|
|
25
|
+
def dump(self, camel_case: bool = True, exclude_extra: bool = False) -> dict[str, Any]:
|
|
26
|
+
"""Dump the resource to a dictionary.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
camel_case (bool): Whether to use camelCase for the keys. Default is True.
|
|
30
|
+
exclude_extra (bool): Whether to exclude extra fields not defined in the model. Default is False.
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
if exclude_extra:
|
|
34
|
+
return self.model_dump(
|
|
35
|
+
mode="json",
|
|
36
|
+
by_alias=camel_case,
|
|
37
|
+
exclude_unset=True,
|
|
38
|
+
exclude=set(self.__pydantic_extra__) if self.__pydantic_extra__ else None,
|
|
39
|
+
)
|
|
40
|
+
return self.model_dump(mode="json", by_alias=camel_case, exclude_unset=True)
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def _load(cls, resource: dict[str, Any]) -> Self:
|
|
44
|
+
"""Load method to match CogniteResource signature."""
|
|
45
|
+
return cls.model_validate(resource, by_alias=True)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class RequestItem(BaseModelObject, ABC):
|
|
49
|
+
"""A request item is any object that can be sent to the CDF API as part of a request."""
|
|
50
|
+
|
|
51
|
+
def __str__(self) -> str:
|
|
52
|
+
"""All request items must implement a string representation.
|
|
53
|
+
|
|
54
|
+
This is used to identify the item in error messages and logs.
|
|
55
|
+
"""
|
|
56
|
+
raise NotImplementedError()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
T_RequestItem = TypeVar("T_RequestItem", bound=RequestItem)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Identifier(RequestItem):
|
|
63
|
+
"""Base class for all identifier objects typically
|
|
64
|
+
{"externalId": "..."}, {"id": ...}, {"space": "...", "externalId: "..."}."""
|
|
65
|
+
|
|
66
|
+
model_config = ConfigDict(alias_generator=to_camel, extra="ignore", frozen=True)
|
|
67
|
+
|
|
68
|
+
def dump(self, camel_case: bool = True, exclude_extra: bool = False) -> dict[str, Any]:
|
|
69
|
+
"""Dump the resource to a dictionary.
|
|
70
|
+
|
|
71
|
+
This is the default serialization method for request resources.
|
|
72
|
+
"""
|
|
73
|
+
return self.model_dump(mode="json", by_alias=camel_case, exclude_unset=True)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
T_Identifier = TypeVar("T_Identifier", bound=Identifier)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class RequestResource(RequestItem, ABC):
|
|
80
|
+
@abstractmethod
|
|
81
|
+
def as_id(self) -> Identifier:
|
|
82
|
+
raise NotImplementedError()
|
|
83
|
+
|
|
84
|
+
def __str__(self) -> str:
|
|
85
|
+
return str(self.as_id())
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
T_RequestResource = TypeVar("T_RequestResource", bound=RequestResource)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class UpdatableRequestResource(RequestResource, ABC):
|
|
92
|
+
container_fields: ClassVar[frozenset[str]] = frozenset()
|
|
93
|
+
non_nullable_fields: ClassVar[frozenset[str]] = frozenset()
|
|
94
|
+
|
|
95
|
+
def as_update(self, mode: Literal["patch", "replace"]) -> dict[str, Any]:
|
|
96
|
+
"""Convert the request resource to an update item."""
|
|
97
|
+
update_item = self.as_id().dump(camel_case=True)
|
|
98
|
+
update: dict[str, Any] = {}
|
|
99
|
+
field_by_name = {info.alias or field_id: (field_id, info) for field_id, info in type(self).model_fields.items()}
|
|
100
|
+
# When mode is "patch", we only include fields that are set
|
|
101
|
+
exclude_unset = mode == "patch"
|
|
102
|
+
for key, value in self.model_dump(mode="json", by_alias=True, exclude_unset=exclude_unset).items():
|
|
103
|
+
if key in update_item:
|
|
104
|
+
# Skip identifier fields
|
|
105
|
+
continue
|
|
106
|
+
if key not in field_by_name:
|
|
107
|
+
# Skip unknown fields
|
|
108
|
+
continue
|
|
109
|
+
field_id, info = field_by_name[key]
|
|
110
|
+
if field_id in self.container_fields:
|
|
111
|
+
if mode == "patch":
|
|
112
|
+
update[key] = {"add": value}
|
|
113
|
+
elif mode == "replace":
|
|
114
|
+
if value is None:
|
|
115
|
+
origin = _get_annotation_origin(info.annotation)
|
|
116
|
+
if origin is list:
|
|
117
|
+
update[key] = {"set": []}
|
|
118
|
+
elif origin is dict:
|
|
119
|
+
update[key] = {"set": {}}
|
|
120
|
+
else:
|
|
121
|
+
raise NotImplementedError(
|
|
122
|
+
f'Cannot replace container field "{key}" with None when its type is unknown.'
|
|
123
|
+
)
|
|
124
|
+
else:
|
|
125
|
+
update[key] = {"set": value}
|
|
126
|
+
else:
|
|
127
|
+
raise NotImplementedError(f'Update mode "{mode}" is not supported for container fields.')
|
|
128
|
+
elif value is None:
|
|
129
|
+
if field_id not in self.non_nullable_fields:
|
|
130
|
+
update[key] = {"setNull": True}
|
|
131
|
+
else:
|
|
132
|
+
update[key] = {"set": value}
|
|
133
|
+
update_item["update"] = update
|
|
134
|
+
return update_item
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _get_annotation_origin(field_type: Any) -> Any:
|
|
138
|
+
origin = get_origin(field_type)
|
|
139
|
+
args = get_args(field_type)
|
|
140
|
+
|
|
141
|
+
# Check for Union type (both typing.Union and | syntax from Python 3.10+)
|
|
142
|
+
is_union = origin is Union or isinstance(field_type, getattr(types, "UnionType", ()))
|
|
143
|
+
|
|
144
|
+
if is_union:
|
|
145
|
+
# Handle Optional[T] by filtering out NoneType
|
|
146
|
+
none_types = (type(None), types.NoneType)
|
|
147
|
+
non_none_args = [arg for arg in args if arg not in none_types]
|
|
148
|
+
if len(non_none_args) == 1:
|
|
149
|
+
field_type = non_none_args[0]
|
|
150
|
+
origin = get_origin(field_type) or field_type
|
|
151
|
+
return origin
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class ResponseResource(BaseModelObject, Generic[T_RequestResource], ABC):
|
|
155
|
+
@abstractmethod
|
|
156
|
+
def as_request_resource(self) -> T_RequestResource:
|
|
157
|
+
"""Convert the response resource to a request resource."""
|
|
158
|
+
raise NotImplementedError()
|
|
159
|
+
|
|
160
|
+
# Todo remove when CogniteClient data classes are completely removed from the codebase
|
|
161
|
+
# and we only use the pydantic resource classes instead.from
|
|
162
|
+
def as_write(self) -> T_RequestResource:
|
|
163
|
+
"""Alias for as_request_resource to match protocol signature."""
|
|
164
|
+
return self.as_request_resource()
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
T_ResponseResource = TypeVar("T_ResponseResource", bound=ResponseResource)
|
|
168
|
+
|
|
169
|
+
# Todo: Delete this class and use list[T_Resource] directly
|
|
170
|
+
T_Resource = TypeVar("T_Resource", bound=RequestResource | ResponseResource)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class BaseResourceList(UserList[T_Resource]):
|
|
174
|
+
"""Base class for resource lists."""
|
|
175
|
+
|
|
176
|
+
_RESOURCE: type[T_Resource]
|
|
177
|
+
|
|
178
|
+
def __init__(self, initlist: list[T_Resource] | None = None, **_: Any) -> None:
|
|
179
|
+
super().__init__(initlist or [])
|
|
180
|
+
|
|
181
|
+
def dump(self, camel_case: bool = True) -> list[dict[str, Any]]:
|
|
182
|
+
return [item.dump(camel_case) for item in self.data]
|
|
183
|
+
|
|
184
|
+
@classmethod
|
|
185
|
+
def load(cls, data: list[dict[str, Any]], cognite_client: "CogniteClient | None" = None) -> Self:
|
|
186
|
+
items = [cls._RESOURCE.model_validate(item) for item in data]
|
|
187
|
+
return cls(items) # type: ignore[arg-type]
|
|
@@ -3,26 +3,42 @@ from typing import cast
|
|
|
3
3
|
from cognite.client import CogniteClient
|
|
4
4
|
from rich.console import Console
|
|
5
5
|
|
|
6
|
-
from cognite_toolkit._cdf_tk.
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.canvas import CanvasAPI
|
|
7
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.charts import ChartsAPI
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.dml import DMLAPI
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_data_modeling import ExtendedDataModelingAPI
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_files import ExtendedFileMetadataAPI
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_functions import ExtendedFunctionsAPI
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_raw import ExtendedRawAPI
|
|
13
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_timeseries import ExtendedTimeSeriesAPI
|
|
14
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.robotics import RoboticsAPI as RoboticsLegacyAPI
|
|
15
|
+
from cognite_toolkit._cdf_tk.client.http_client import HTTPClient
|
|
7
16
|
|
|
8
|
-
from .api.
|
|
9
|
-
from .api.
|
|
10
|
-
from .api.
|
|
11
|
-
from .api.
|
|
12
|
-
from .api.
|
|
13
|
-
from .api.
|
|
14
|
-
from .api.extended_raw import ExtendedRawAPI
|
|
15
|
-
from .api.extended_timeseries import ExtendedTimeSeriesAPI
|
|
17
|
+
from .api.assets import AssetsAPI
|
|
18
|
+
from .api.datasets import DataSetsAPI
|
|
19
|
+
from .api.events import EventsAPI
|
|
20
|
+
from .api.extraction_pipelines import ExtractionPipelinesAPI
|
|
21
|
+
from .api.filemetadata import FileMetadataAPI
|
|
22
|
+
from .api.hosted_extractors import HostedExtractorsAPI
|
|
16
23
|
from .api.infield import InfieldAPI
|
|
24
|
+
from .api.instances import InstancesAPI
|
|
25
|
+
from .api.labels import LabelsAPI
|
|
17
26
|
from .api.lookup import LookUpGroup
|
|
18
27
|
from .api.migration import MigrationAPI
|
|
19
28
|
from .api.project import ProjectAPI
|
|
29
|
+
from .api.raw import RawAPI
|
|
20
30
|
from .api.robotics import RoboticsAPI
|
|
21
31
|
from .api.search import SearchAPI
|
|
32
|
+
from .api.security_categories import SecurityCategoriesAPI
|
|
33
|
+
from .api.sequences import SequencesAPI
|
|
34
|
+
from .api.simulators import SimulatorsAPI
|
|
22
35
|
from .api.streams import StreamsAPI
|
|
23
36
|
from .api.three_d import ThreeDAPI
|
|
37
|
+
from .api.timeseries import TimeSeriesAPI
|
|
24
38
|
from .api.token import TokenAPI
|
|
39
|
+
from .api.transformations import TransformationsAPI
|
|
25
40
|
from .api.verify import VerifyAPI
|
|
41
|
+
from .api.workflows import WorkflowsAPI
|
|
26
42
|
from .config import ToolkitClientConfig
|
|
27
43
|
|
|
28
44
|
|
|
@@ -31,7 +47,23 @@ class ToolAPI:
|
|
|
31
47
|
|
|
32
48
|
def __init__(self, http_client: HTTPClient, console: Console) -> None:
|
|
33
49
|
self.http_client = http_client
|
|
34
|
-
self.
|
|
50
|
+
self.assets = AssetsAPI(http_client)
|
|
51
|
+
self.datasets = DataSetsAPI(http_client)
|
|
52
|
+
self.events = EventsAPI(http_client)
|
|
53
|
+
self.extraction_pipelines = ExtractionPipelinesAPI(http_client)
|
|
54
|
+
self.hosted_extractors = HostedExtractorsAPI(http_client)
|
|
55
|
+
self.instances = InstancesAPI(http_client)
|
|
56
|
+
self.labels = LabelsAPI(http_client)
|
|
57
|
+
self.filemetadata = FileMetadataAPI(http_client)
|
|
58
|
+
self.raw = RawAPI(http_client)
|
|
59
|
+
self.robotics = RoboticsAPI(http_client)
|
|
60
|
+
self.security_categories = SecurityCategoriesAPI(http_client)
|
|
61
|
+
self.sequences = SequencesAPI(http_client)
|
|
62
|
+
self.simulators = SimulatorsAPI(http_client)
|
|
63
|
+
self.three_d = ThreeDAPI(http_client)
|
|
64
|
+
self.timeseries = TimeSeriesAPI(http_client)
|
|
65
|
+
self.transformations = TransformationsAPI(http_client)
|
|
66
|
+
self.workflows = WorkflowsAPI(http_client)
|
|
35
67
|
|
|
36
68
|
|
|
37
69
|
class ToolkitClient(CogniteClient):
|
|
@@ -48,7 +80,7 @@ class ToolkitClient(CogniteClient):
|
|
|
48
80
|
self.console = console or Console()
|
|
49
81
|
self.tool = ToolAPI(http_client, self.console)
|
|
50
82
|
self.search = SearchAPI(self._config, self._API_VERSION, self)
|
|
51
|
-
self.robotics =
|
|
83
|
+
self.robotics = RoboticsLegacyAPI(self._config, self._API_VERSION, self)
|
|
52
84
|
self.dml = DMLAPI(self._config, self._API_VERSION, self)
|
|
53
85
|
self.verify = VerifyAPI(self._config, self._API_VERSION, self)
|
|
54
86
|
self.lookup = LookUpGroup(self._config, self._API_VERSION, self, self.console)
|
|
@@ -66,7 +98,7 @@ class ToolkitClient(CogniteClient):
|
|
|
66
98
|
self.charts = ChartsAPI(self._config, self._API_VERSION, self)
|
|
67
99
|
self.project = ProjectAPI(config=toolkit_config, cognite_client=self)
|
|
68
100
|
self.infield = InfieldAPI(http_client, self.console)
|
|
69
|
-
self.streams = StreamsAPI(http_client
|
|
101
|
+
self.streams = StreamsAPI(http_client)
|
|
70
102
|
|
|
71
103
|
@property
|
|
72
104
|
def config(self) -> ToolkitClientConfig:
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""Agents API for managing CDF AI agents.
|
|
2
|
+
|
|
3
|
+
Based on the API specification at:
|
|
4
|
+
https://api-docs.cognite.com/20230101-alpha/tag/Agents/operation/main_ai_agents_post
|
|
5
|
+
|
|
6
|
+
Note: This is an alpha API and may change in future releases.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from collections.abc import Iterable, Sequence
|
|
10
|
+
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, Endpoint, PagedResponse
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.http_client import HTTPClient, ItemsSuccessResponse2, SuccessResponse2
|
|
13
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.agent import AgentRequest, AgentResponse
|
|
14
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import ExternalId
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AgentsAPI(CDFResourceAPI[ExternalId, AgentRequest, AgentResponse]):
|
|
18
|
+
"""API for managing CDF AI agents.
|
|
19
|
+
|
|
20
|
+
Note: This is an alpha API and may change in future releases.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
24
|
+
super().__init__(
|
|
25
|
+
http_client=http_client,
|
|
26
|
+
method_endpoint_map={
|
|
27
|
+
"upsert": Endpoint(method="POST", path="/ai/agents", item_limit=1),
|
|
28
|
+
"retrieve": Endpoint(method="POST", path="/ai/agents/byids", item_limit=100),
|
|
29
|
+
"delete": Endpoint(method="POST", path="/ai/agents/delete", item_limit=1),
|
|
30
|
+
"list": Endpoint(method="GET", path="/ai/agents", item_limit=1000),
|
|
31
|
+
},
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
def _validate_page_response(
|
|
35
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
36
|
+
) -> PagedResponse[AgentResponse]:
|
|
37
|
+
return PagedResponse[AgentResponse].model_validate_json(response.body)
|
|
38
|
+
|
|
39
|
+
def create(self, items: Sequence[AgentRequest]) -> list[AgentResponse]:
|
|
40
|
+
"""Apply (create or update) agents in CDF.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
items: List of AgentRequest objects to apply.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
List of applied AgentResponse objects.
|
|
47
|
+
"""
|
|
48
|
+
return self._request_item_response(items, "upsert")
|
|
49
|
+
|
|
50
|
+
def update(self, items: Sequence[AgentRequest]) -> list[AgentResponse]:
|
|
51
|
+
"""Update agents in CDF.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
items: List of AgentRequest objects to update.
|
|
55
|
+
Returns:
|
|
56
|
+
List of updated AgentResponse objects.
|
|
57
|
+
"""
|
|
58
|
+
# Implemented as an alias to create (upsert) to have a standardized interface.
|
|
59
|
+
return self._request_item_response(items, "upsert")
|
|
60
|
+
|
|
61
|
+
def retrieve(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> list[AgentResponse]:
|
|
62
|
+
"""Retrieve agents from CDF by external ID.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
items: List of ExternalId objects to retrieve.
|
|
66
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
List of retrieved AgentResponse objects.
|
|
70
|
+
"""
|
|
71
|
+
return self._request_item_response(
|
|
72
|
+
items, method="retrieve", extra_body={"ignoreUnknownIds": ignore_unknown_ids}
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def delete(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
76
|
+
"""Delete agents from CDF.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
items: List of ExternalId objects to delete.
|
|
80
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
81
|
+
"""
|
|
82
|
+
self._request_no_response(items, "delete", extra_body={"ignoreUnknownIds": ignore_unknown_ids})
|
|
83
|
+
|
|
84
|
+
def iterate(
|
|
85
|
+
self,
|
|
86
|
+
limit: int | None = None,
|
|
87
|
+
) -> Iterable[list[AgentResponse]]:
|
|
88
|
+
"""Iterate over all agents in CDF.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
limit: Maximum total number of agents to return.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
Iterable of lists of AgentResponse objects.
|
|
95
|
+
"""
|
|
96
|
+
return self._iterate(limit=limit)
|
|
97
|
+
|
|
98
|
+
def list(self, limit: int | None = None) -> list[AgentResponse]:
|
|
99
|
+
"""List all agents in CDF.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
limit: Maximum total number of agents to return.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
List of AgentResponse objects.
|
|
106
|
+
"""
|
|
107
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""Annotations API for managing CDF annotations.
|
|
2
|
+
|
|
3
|
+
Based on the API specification at:
|
|
4
|
+
https://api-docs.cognite.com/20230101/tag/Annotations/operation/annotationsCreate
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from collections.abc import Iterable, Sequence
|
|
8
|
+
from typing import Literal
|
|
9
|
+
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, Endpoint, PagedResponse
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.http_client import HTTPClient, ItemsSuccessResponse2, SuccessResponse2
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.request_classes.filters import AnnotationFilter
|
|
13
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.annotation import AnnotationRequest, AnnotationResponse
|
|
14
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import InternalId
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AnnotationsAPI(CDFResourceAPI[InternalId, AnnotationRequest, AnnotationResponse]):
|
|
18
|
+
"""API for managing CDF annotations."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
21
|
+
super().__init__(
|
|
22
|
+
http_client=http_client,
|
|
23
|
+
method_endpoint_map={
|
|
24
|
+
"create": Endpoint(method="POST", path="/annotations", item_limit=1000),
|
|
25
|
+
"retrieve": Endpoint(method="POST", path="/annotations/byids", item_limit=1000),
|
|
26
|
+
"update": Endpoint(method="POST", path="/annotations/update", item_limit=1000),
|
|
27
|
+
"delete": Endpoint(method="POST", path="/annotations/delete", item_limit=1000),
|
|
28
|
+
"list": Endpoint(method="POST", path="/annotations/list", item_limit=1000),
|
|
29
|
+
},
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
def _validate_page_response(
|
|
33
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
34
|
+
) -> PagedResponse[AnnotationResponse]:
|
|
35
|
+
return PagedResponse[AnnotationResponse].model_validate_json(response.body)
|
|
36
|
+
|
|
37
|
+
def create(self, items: Sequence[AnnotationRequest]) -> list[AnnotationResponse]:
|
|
38
|
+
"""Create annotations in CDF.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
items: List of AnnotationRequest objects to create.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
List of created AnnotationResponse objects.
|
|
45
|
+
"""
|
|
46
|
+
return self._request_item_response(items, "create")
|
|
47
|
+
|
|
48
|
+
def retrieve(self, items: Sequence[InternalId]) -> list[AnnotationResponse]:
|
|
49
|
+
"""Retrieve annotations from CDF by ID.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
items: List of InternalId objects to retrieve.
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
List of retrieved AnnotationResponse objects.
|
|
56
|
+
"""
|
|
57
|
+
return self._request_item_response(items, method="retrieve")
|
|
58
|
+
|
|
59
|
+
def update(
|
|
60
|
+
self, items: Sequence[AnnotationRequest], mode: Literal["patch", "replace"] = "replace"
|
|
61
|
+
) -> list[AnnotationResponse]:
|
|
62
|
+
"""Update annotations in CDF.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
items: List of AnnotationRequest objects to update.
|
|
66
|
+
mode: Update mode, either "patch" or "replace".
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
List of updated AnnotationResponse objects.
|
|
70
|
+
"""
|
|
71
|
+
return self._update(items, mode=mode)
|
|
72
|
+
|
|
73
|
+
def delete(self, items: Sequence[InternalId]) -> None:
|
|
74
|
+
"""Delete annotations from CDF.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
items: List of InternalId objects to delete.
|
|
78
|
+
"""
|
|
79
|
+
self._request_no_response(items, "delete")
|
|
80
|
+
|
|
81
|
+
def paginate(
|
|
82
|
+
self,
|
|
83
|
+
filter: AnnotationFilter,
|
|
84
|
+
limit: int = 100,
|
|
85
|
+
cursor: str | None = None,
|
|
86
|
+
) -> PagedResponse[AnnotationResponse]:
|
|
87
|
+
"""Get a page of annotations from CDF.
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
filter: AnnotationFilter to filter annotations.
|
|
91
|
+
limit: Maximum number of annotations to return.
|
|
92
|
+
cursor: Cursor for pagination.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
PagedResponse of AnnotationResponse objects.
|
|
96
|
+
"""
|
|
97
|
+
return self._paginate(cursor=cursor, limit=limit, body=filter.dump())
|
|
98
|
+
|
|
99
|
+
def iterate(
|
|
100
|
+
self,
|
|
101
|
+
filter: AnnotationFilter,
|
|
102
|
+
limit: int | None = None,
|
|
103
|
+
) -> Iterable[list[AnnotationResponse]]:
|
|
104
|
+
"""Iterate over all annotations in CDF.
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
filter: AnnotationFilter to filter annotations.
|
|
108
|
+
limit: Maximum total number of annotations to return.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
Iterable of lists of AnnotationResponse objects.
|
|
112
|
+
"""
|
|
113
|
+
return self._iterate(limit=limit, body=filter.dump())
|
|
114
|
+
|
|
115
|
+
def list(
|
|
116
|
+
self,
|
|
117
|
+
filter: AnnotationFilter,
|
|
118
|
+
limit: int | None = None,
|
|
119
|
+
) -> list[AnnotationResponse]:
|
|
120
|
+
"""List all annotations in CDF.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
filter: AnnotationFilter to filter annotations.
|
|
124
|
+
limit: Maximum total number of annotations to return.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
List of AnnotationResponse objects.
|
|
128
|
+
"""
|
|
129
|
+
return self._list(limit=limit, body=filter.dump())
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
from collections.abc import Iterable, Sequence
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, PagedResponse, ResponseItems
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.cdf_client.api import Endpoint
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.http_client import HTTPClient, ItemsSuccessResponse2, SuccessResponse2
|
|
7
|
+
from cognite_toolkit._cdf_tk.client.request_classes.filters import ClassicFilter
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.asset import AssetRequest, AssetResponse
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import InternalOrExternalId
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AssetsAPI(CDFResourceAPI[InternalOrExternalId, AssetRequest, AssetResponse]):
|
|
13
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
14
|
+
super().__init__(
|
|
15
|
+
http_client=http_client,
|
|
16
|
+
method_endpoint_map={
|
|
17
|
+
"create": Endpoint(method="POST", path="/assets", item_limit=1000, concurrency_max_workers=1),
|
|
18
|
+
"retrieve": Endpoint(method="POST", path="/assets/byids", item_limit=1000, concurrency_max_workers=1),
|
|
19
|
+
"update": Endpoint(method="POST", path="/assets/update", item_limit=1000, concurrency_max_workers=1),
|
|
20
|
+
"delete": Endpoint(method="POST", path="/assets/delete", item_limit=1000, concurrency_max_workers=1),
|
|
21
|
+
"list": Endpoint(method="POST", path="/assets/list", item_limit=1000),
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def _validate_page_response(
|
|
26
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
27
|
+
) -> PagedResponse[AssetResponse]:
|
|
28
|
+
return PagedResponse[AssetResponse].model_validate_json(response.body)
|
|
29
|
+
|
|
30
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[InternalOrExternalId]:
|
|
31
|
+
return ResponseItems[InternalOrExternalId].model_validate_json(response.body)
|
|
32
|
+
|
|
33
|
+
def create(self, items: Sequence[AssetRequest]) -> list[AssetResponse]:
|
|
34
|
+
"""Create assets in CDF.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
items: List of AssetRequest objects to create.
|
|
38
|
+
Returns:
|
|
39
|
+
List of created AssetResponse objects.
|
|
40
|
+
"""
|
|
41
|
+
return self._request_item_response(items, "create")
|
|
42
|
+
|
|
43
|
+
def retrieve(self, items: Sequence[InternalOrExternalId], ignore_unknown_ids: bool = False) -> list[AssetResponse]:
|
|
44
|
+
"""Retrieve assets from CDF.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
items: List of InternalOrExternalId objects to retrieve.
|
|
48
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
49
|
+
Returns:
|
|
50
|
+
List of retrieved AssetResponse objects.
|
|
51
|
+
"""
|
|
52
|
+
return self._request_item_response(
|
|
53
|
+
items, method="retrieve", extra_body={"ignoreUnknownIds": ignore_unknown_ids}
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
def update(
|
|
57
|
+
self, items: Sequence[AssetRequest], mode: Literal["patch", "replace"] = "replace"
|
|
58
|
+
) -> list[AssetResponse]:
|
|
59
|
+
"""Update assets in CDF.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
items: List of AssetRequest objects to update.
|
|
63
|
+
mode: Update mode, either "patch" or "replace".
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
List of updated AssetResponse objects.
|
|
67
|
+
"""
|
|
68
|
+
return self._update(items, mode=mode)
|
|
69
|
+
|
|
70
|
+
def delete(
|
|
71
|
+
self, items: Sequence[InternalOrExternalId], recursive: bool = False, ignore_unknown_ids: bool = False
|
|
72
|
+
) -> None:
|
|
73
|
+
"""Delete assets from CDF.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
items: List of InternalOrExternalId objects to delete.
|
|
77
|
+
recursive: Whether to delete assets recursively.
|
|
78
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
79
|
+
"""
|
|
80
|
+
self._request_no_response(
|
|
81
|
+
items, "delete", extra_body={"recursive": recursive, "ignoreUnknownIds": ignore_unknown_ids}
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
def paginate(
|
|
85
|
+
self,
|
|
86
|
+
aggregated_properties: bool = False,
|
|
87
|
+
filter: ClassicFilter | None = None,
|
|
88
|
+
limit: int = 100,
|
|
89
|
+
cursor: str | None = None,
|
|
90
|
+
) -> PagedResponse[AssetResponse]:
|
|
91
|
+
"""Iterate over all assets in CDF.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
PagedResponse of AssetResponse objects.
|
|
95
|
+
"""
|
|
96
|
+
return self._paginate(
|
|
97
|
+
cursor=cursor,
|
|
98
|
+
limit=limit,
|
|
99
|
+
body={
|
|
100
|
+
"aggregatedProperties": ["childCount", "path", "depth"] if aggregated_properties else [],
|
|
101
|
+
"filter": filter.dump() if filter else None,
|
|
102
|
+
},
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
def iterate(
|
|
106
|
+
self,
|
|
107
|
+
aggregated_properties: bool = False,
|
|
108
|
+
filter: ClassicFilter | None = None,
|
|
109
|
+
limit: int | None = 100,
|
|
110
|
+
) -> Iterable[list[AssetResponse]]:
|
|
111
|
+
"""Iterate over all assets in CDF.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Sequence of AssetResponse objects.
|
|
115
|
+
"""
|
|
116
|
+
return self._iterate(
|
|
117
|
+
limit=limit,
|
|
118
|
+
body={
|
|
119
|
+
"aggregatedProperties": ["childCount", "path", "depth"] if aggregated_properties else [],
|
|
120
|
+
"filter": filter.dump() if filter else None,
|
|
121
|
+
},
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
def list(self, limit: int | None = 100) -> list[AssetResponse]:
|
|
125
|
+
"""List all asset references in CDF.
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
ResponseItems of T_Identifier objects.
|
|
129
|
+
"""
|
|
130
|
+
return self._list(limit=limit)
|