cognite-toolkit 0.7.39__py3-none-any.whl → 0.7.51__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cognite_toolkit/_cdf_tk/apps/_download_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_dump_app.py +1 -1
- cognite_toolkit/_cdf_tk/apps/_migrate_app.py +6 -6
- cognite_toolkit/_cdf_tk/builders/_function.py +81 -9
- cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/client/_resource_base.py +187 -0
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +37 -5
- cognite_toolkit/_cdf_tk/client/api/agents.py +107 -0
- cognite_toolkit/_cdf_tk/client/api/annotations.py +129 -0
- cognite_toolkit/_cdf_tk/client/api/assets.py +130 -0
- cognite_toolkit/_cdf_tk/client/api/containers.py +132 -0
- cognite_toolkit/_cdf_tk/client/api/data_models.py +137 -0
- cognite_toolkit/_cdf_tk/client/api/datasets.py +141 -0
- cognite_toolkit/_cdf_tk/client/api/events.py +129 -0
- cognite_toolkit/_cdf_tk/client/api/extraction_pipelines.py +148 -0
- cognite_toolkit/_cdf_tk/client/api/filemetadata.py +176 -0
- cognite_toolkit/_cdf_tk/client/api/function_schedules.py +115 -0
- cognite_toolkit/_cdf_tk/client/api/functions.py +113 -0
- cognite_toolkit/_cdf_tk/client/api/graphql_data_models.py +167 -0
- cognite_toolkit/_cdf_tk/client/api/groups.py +121 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_destinations.py +131 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_jobs.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_mappings.py +129 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractor_sources.py +136 -0
- cognite_toolkit/_cdf_tk/client/api/hosted_extractors.py +23 -0
- cognite_toolkit/_cdf_tk/client/api/infield.py +8 -8
- cognite_toolkit/_cdf_tk/client/api/instances.py +139 -0
- cognite_toolkit/_cdf_tk/client/api/labels.py +125 -0
- cognite_toolkit/_cdf_tk/client/api/legacy/canvas.py +3 -3
- cognite_toolkit/_cdf_tk/client/api/legacy/charts.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_data_modeling.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_files.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_functions.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_raw.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/extended_timeseries.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/legacy/location_filters.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/capabilities.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/data_postprocessing.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/frames.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/locations.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/maps.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/robots.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/legacy/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/location_filters.py +177 -0
- cognite_toolkit/_cdf_tk/client/api/migration.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/project.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/raw.py +204 -0
- cognite_toolkit/_cdf_tk/client/api/relationships.py +133 -0
- cognite_toolkit/_cdf_tk/client/api/robotics.py +19 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_capabilities.py +127 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_data_postprocessing.py +138 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_frames.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_locations.py +127 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_maps.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/robotics_robots.py +122 -0
- cognite_toolkit/_cdf_tk/client/api/search_config.py +101 -0
- cognite_toolkit/_cdf_tk/client/api/security_categories.py +94 -0
- cognite_toolkit/_cdf_tk/client/api/sequences.py +133 -0
- cognite_toolkit/_cdf_tk/client/api/simulator_models.py +154 -0
- cognite_toolkit/_cdf_tk/client/api/simulators.py +8 -0
- cognite_toolkit/_cdf_tk/client/api/spaces.py +117 -0
- cognite_toolkit/_cdf_tk/client/api/streams.py +65 -57
- cognite_toolkit/_cdf_tk/client/api/three_d.py +300 -283
- cognite_toolkit/_cdf_tk/client/api/timeseries.py +137 -0
- cognite_toolkit/_cdf_tk/client/api/token.py +1 -1
- cognite_toolkit/_cdf_tk/client/api/transformations.py +146 -0
- cognite_toolkit/_cdf_tk/client/api/views.py +139 -0
- cognite_toolkit/_cdf_tk/client/api/workflow_triggers.py +128 -0
- cognite_toolkit/_cdf_tk/client/api/workflow_versions.py +138 -0
- cognite_toolkit/_cdf_tk/client/api/workflows.py +119 -0
- cognite_toolkit/_cdf_tk/client/cdf_client/__init__.py +10 -0
- cognite_toolkit/_cdf_tk/client/cdf_client/api.py +358 -0
- cognite_toolkit/_cdf_tk/client/cdf_client/responses.py +38 -0
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/__init__.py +9 -7
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/_client.py +23 -14
- cognite_toolkit/_cdf_tk/{utils → client}/http_client/_data_classes.py +12 -2
- cognite_toolkit/_cdf_tk/client/http_client/_data_classes2.py +151 -0
- cognite_toolkit/_cdf_tk/client/http_client/_exception.py +13 -0
- cognite_toolkit/_cdf_tk/client/http_client/_item_classes.py +118 -0
- cognite_toolkit/_cdf_tk/client/request_classes/base.py +19 -0
- cognite_toolkit/_cdf_tk/client/request_classes/filters.py +113 -0
- cognite_toolkit/_cdf_tk/client/request_classes/graphql.py +28 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/agent.py +130 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/annotation.py +79 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/apm_config.py +128 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/asset.py +47 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/charts_data.py +1 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/cognite_file.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/__init__.py +168 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_constraints.py +37 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_container.py +50 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_data_model.py +73 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_data_types.py +116 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_indexes.py +26 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_instance.py +154 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_references.py +86 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_space.py +26 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_view.py +143 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_view_property.py +152 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/dataset.py +35 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/event.py +40 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/extraction_pipeline.py +59 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/filemetadata.py +52 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/function.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/function_schedule.py +65 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/graphql_data_model.py +40 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/__init__.py +187 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/_constants.py +2 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/acls.py +653 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/capability.py +56 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/group.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/group/scopes.py +166 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_destination.py +34 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_job.py +134 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_mapping.py +72 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/__init__.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_auth.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_base.py +26 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_certificate.py +20 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_eventhub.py +31 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_kafka.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_mqtt.py +36 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/hosted_extractor_source/_rest.py +49 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/identifiers.py +59 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/infield.py +1 -1
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/instance_api.py +35 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/label.py +27 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/legacy/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/canvas.py +48 -15
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/charts.py +1 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/location_filter.py +84 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/raw.py +44 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/relationship.py +49 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/resource_view_mapping.py +38 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/__init__.py +37 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_capability.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_common.py +34 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_data_post_processing.py +49 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_frame.py +46 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_location.py +36 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_map.py +65 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_robot.py +58 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/search_config.py +54 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/securitycategory.py +24 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/sequence.py +45 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/sequence_rows.py +56 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/simulator_model.py +50 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/streamlit_.py +71 -0
- cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/streams.py +9 -26
- cognite_toolkit/_cdf_tk/client/resource_classes/three_d.py +135 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/timeseries.py +52 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/transformation.py +140 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/workflow.py +27 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/workflow_trigger.py +63 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/workflow_version.py +155 -0
- cognite_toolkit/_cdf_tk/client/testing.py +31 -2
- cognite_toolkit/_cdf_tk/commands/_migrate/command.py +103 -108
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +22 -15
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +11 -10
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +148 -57
- cognite_toolkit/_cdf_tk/commands/_migrate/default_mappings.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +22 -39
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +29 -27
- cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_purge.py +8 -8
- cognite_toolkit/_cdf_tk/commands/_upload.py +1 -1
- cognite_toolkit/_cdf_tk/commands/build_cmd.py +12 -2
- cognite_toolkit/_cdf_tk/commands/build_v2/_module_parser.py +138 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/_modules_parser.py +163 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_cmd.py +83 -96
- cognite_toolkit/_cdf_tk/commands/build_v2/{build_input.py → build_parameters.py} +8 -22
- cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_modules.py +27 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/data_classes/_resource.py +22 -0
- cognite_toolkit/_cdf_tk/commands/dump_resource.py +4 -4
- cognite_toolkit/_cdf_tk/commands/pull.py +97 -2
- cognite_toolkit/_cdf_tk/commands/run.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/__init__.py +16 -6
- cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +9 -5
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +6 -2
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +70 -89
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/configuration.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/datamodel.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/extraction_pipeline.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +14 -7
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +50 -59
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/function.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/industrial_tool.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/location.py +4 -3
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +6 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +5 -4
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/simulators.py +122 -0
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +15 -31
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +42 -47
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +1 -1
- cognite_toolkit/_cdf_tk/data_classes/__init__.py +3 -0
- cognite_toolkit/_cdf_tk/data_classes/_issues.py +36 -0
- cognite_toolkit/_cdf_tk/data_classes/_module_directories.py +2 -1
- cognite_toolkit/_cdf_tk/data_classes/_tracking_info.py +4 -0
- cognite_toolkit/_cdf_tk/feature_flags.py +8 -0
- cognite_toolkit/_cdf_tk/resource_classes/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/resource_classes/capabilities.py +6 -0
- cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/resource_classes/simulator_model.py +17 -0
- cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +13 -4
- cognite_toolkit/_cdf_tk/storageio/_applications.py +53 -15
- cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +117 -107
- cognite_toolkit/_cdf_tk/storageio/_base.py +3 -1
- cognite_toolkit/_cdf_tk/storageio/_datapoints.py +7 -7
- cognite_toolkit/_cdf_tk/storageio/_file_content.py +64 -54
- cognite_toolkit/_cdf_tk/storageio/_instances.py +1 -1
- cognite_toolkit/_cdf_tk/storageio/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/storageio/logger.py +162 -0
- cognite_toolkit/_cdf_tk/tk_warnings/__init__.py +2 -0
- cognite_toolkit/_cdf_tk/tk_warnings/fileread.py +20 -0
- cognite_toolkit/_cdf_tk/utils/__init__.py +11 -1
- cognite_toolkit/_cdf_tk/utils/cdf.py +1 -1
- cognite_toolkit/_cdf_tk/utils/interactive_select.py +8 -6
- cognite_toolkit/_cdf_tk/utils/modules.py +7 -0
- cognite_toolkit/_cdf_tk/utils/pip_validator.py +96 -0
- cognite_toolkit/_cdf_tk/utils/useful_types.py +4 -7
- cognite_toolkit/_cdf_tk/utils/useful_types2.py +14 -0
- cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml +1 -1
- cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml +1 -1
- cognite_toolkit/_resources/cdf.toml +1 -1
- cognite_toolkit/_version.py +1 -1
- {cognite_toolkit-0.7.39.dist-info → cognite_toolkit-0.7.51.dist-info}/METADATA +13 -3
- cognite_toolkit-0.7.51.dist-info/RECORD +445 -0
- {cognite_toolkit-0.7.39.dist-info → cognite_toolkit-0.7.51.dist-info}/WHEEL +2 -2
- cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +0 -30
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +0 -67
- cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +0 -112
- cognite_toolkit/_cdf_tk/commands/build_v2/build_issues.py +0 -27
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +0 -247
- cognite_toolkit/_cdf_tk/utils/http_client/_exception.py +0 -4
- cognite_toolkit-0.7.39.dist-info/RECORD +0 -322
- /cognite_toolkit/_cdf_tk/{utils → client}/http_client/_tracker.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → request_classes}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes/legacy → resource_classes}/__init__.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/capabilities.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/apm_config_v1.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extendable_cognite_file.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_filemetadata.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_filemetdata.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/extended_timeseries.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/functions.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/graphql_data_models.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/instances.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/location_filters.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/migration.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/pending_instances_ids.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/project.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/raw.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/robotics.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/search_config.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/sequences.py +0 -0
- /cognite_toolkit/_cdf_tk/client/{data_classes → resource_classes}/legacy/streamlit_.py +0 -0
- {cognite_toolkit-0.7.39.dist-info → cognite_toolkit-0.7.51.dist-info}/entry_points.txt +0 -0
|
@@ -7,7 +7,7 @@ import typer
|
|
|
7
7
|
from questionary import Choice
|
|
8
8
|
from rich import print
|
|
9
9
|
|
|
10
|
-
from cognite_toolkit._cdf_tk.client.
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.raw import RawTable
|
|
11
11
|
from cognite_toolkit._cdf_tk.commands import DownloadCommand
|
|
12
12
|
from cognite_toolkit._cdf_tk.constants import DATA_DEFAULT_DIR
|
|
13
13
|
from cognite_toolkit._cdf_tk.feature_flags import Flags
|
|
@@ -6,7 +6,7 @@ from cognite.client.data_classes import WorkflowVersionId
|
|
|
6
6
|
from cognite.client.data_classes.data_modeling import DataModelId, ViewId
|
|
7
7
|
from rich import print
|
|
8
8
|
|
|
9
|
-
from cognite_toolkit._cdf_tk.client.
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.search_config import ViewId as SearchConfigViewId
|
|
10
10
|
from cognite_toolkit._cdf_tk.commands import DumpResourceCommand
|
|
11
11
|
from cognite_toolkit._cdf_tk.commands.dump_resource import (
|
|
12
12
|
AgentFinder,
|
|
@@ -868,13 +868,13 @@ class MigrateApp(typer.Typer):
|
|
|
868
868
|
"performed to select the Canvas to migrate."
|
|
869
869
|
),
|
|
870
870
|
] = None,
|
|
871
|
-
|
|
871
|
+
allow_missing_ref: Annotated[
|
|
872
872
|
bool,
|
|
873
873
|
typer.Option(
|
|
874
|
-
"--
|
|
875
|
-
"-
|
|
876
|
-
help="If set, the
|
|
877
|
-
"If not set, the migration will
|
|
874
|
+
"--allow-missing-ref",
|
|
875
|
+
"-a",
|
|
876
|
+
help="If set, the command will migrate Canvases that reference resources that have not been migrated to data modeling. "
|
|
877
|
+
"If not set, the migration will fail if any referenced resource are missing.",
|
|
878
878
|
),
|
|
879
879
|
] = False,
|
|
880
880
|
log_dir: Annotated[
|
|
@@ -926,7 +926,7 @@ class MigrateApp(typer.Typer):
|
|
|
926
926
|
lambda: cmd.migrate(
|
|
927
927
|
selected=selector,
|
|
928
928
|
data=CanvasIO(client, exclude_existing_version=True),
|
|
929
|
-
mapper=CanvasMapper(client, dry_run=dry_run, skip_on_missing_ref=
|
|
929
|
+
mapper=CanvasMapper(client, dry_run=dry_run, skip_on_missing_ref=not allow_missing_ref),
|
|
930
930
|
log_dir=log_dir,
|
|
931
931
|
dry_run=dry_run,
|
|
932
932
|
verbose=verbose,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import shutil
|
|
2
|
+
import time
|
|
2
3
|
from collections.abc import Callable, Iterable, Sequence
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Any
|
|
3
6
|
|
|
4
7
|
from cognite_toolkit._cdf_tk.builders import Builder
|
|
5
8
|
from cognite_toolkit._cdf_tk.cruds import FunctionCRUD
|
|
@@ -10,21 +13,74 @@ from cognite_toolkit._cdf_tk.data_classes import (
|
|
|
10
13
|
ModuleLocation,
|
|
11
14
|
)
|
|
12
15
|
from cognite_toolkit._cdf_tk.exceptions import ToolkitFileExistsError, ToolkitNotADirectoryError, ToolkitValueError
|
|
16
|
+
from cognite_toolkit._cdf_tk.feature_flags import Flags
|
|
13
17
|
from cognite_toolkit._cdf_tk.tk_warnings import (
|
|
14
18
|
FileReadWarning,
|
|
19
|
+
FunctionRequirementsValidationWarning,
|
|
15
20
|
HighSeverityWarning,
|
|
16
21
|
LowSeverityWarning,
|
|
17
22
|
MediumSeverityWarning,
|
|
18
23
|
ToolkitWarning,
|
|
19
24
|
WarningList,
|
|
20
25
|
)
|
|
26
|
+
from cognite_toolkit._cdf_tk.utils import validate_requirements_with_pip
|
|
27
|
+
|
|
28
|
+
# Maximum number of error lines to display in warnings
|
|
29
|
+
_MAX_ERROR_LINES = 3
|
|
21
30
|
|
|
22
31
|
|
|
23
32
|
class FunctionBuilder(Builder):
|
|
24
33
|
_resource_folder = FunctionCRUD.folder_name
|
|
25
34
|
|
|
35
|
+
def __init__(self, build_dir: Path, warn: Callable[[ToolkitWarning], None]) -> None:
|
|
36
|
+
super().__init__(build_dir, warn=warn)
|
|
37
|
+
# Metrics for telemetry
|
|
38
|
+
self.validation_count = 0
|
|
39
|
+
self.validation_failures = 0
|
|
40
|
+
self.validation_credential_errors = 0
|
|
41
|
+
self.validation_time_ms = 0
|
|
42
|
+
|
|
43
|
+
def _validate_function_requirements(
|
|
44
|
+
self,
|
|
45
|
+
requirements_txt: Path,
|
|
46
|
+
raw_function: dict[str, Any],
|
|
47
|
+
filepath: Path,
|
|
48
|
+
external_id: str,
|
|
49
|
+
) -> FunctionRequirementsValidationWarning | None:
|
|
50
|
+
"""Validate function requirements.txt using pip dry-run."""
|
|
51
|
+
start_time = time.time()
|
|
52
|
+
validation_result = validate_requirements_with_pip(
|
|
53
|
+
requirements_txt_path=requirements_txt,
|
|
54
|
+
index_url=raw_function.get("indexUrl"),
|
|
55
|
+
extra_index_urls=raw_function.get("extraIndexUrls"),
|
|
56
|
+
)
|
|
57
|
+
elapsed_ms = int((time.time() - start_time) * 1000)
|
|
58
|
+
self.validation_count += 1
|
|
59
|
+
self.validation_time_ms += elapsed_ms
|
|
60
|
+
|
|
61
|
+
if validation_result.success:
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
self.validation_failures += 1
|
|
65
|
+
if validation_result.is_credential_error:
|
|
66
|
+
self.validation_credential_errors += 1
|
|
67
|
+
|
|
68
|
+
error_detail = validation_result.error_message or "Unknown error"
|
|
69
|
+
relevant_lines = [line for line in error_detail.strip().split("\n") if line.strip()][-_MAX_ERROR_LINES:]
|
|
70
|
+
error_detail = "\n ".join(relevant_lines)
|
|
71
|
+
|
|
72
|
+
return FunctionRequirementsValidationWarning(
|
|
73
|
+
filepath=filepath,
|
|
74
|
+
function_external_id=external_id,
|
|
75
|
+
error_details=error_detail,
|
|
76
|
+
is_credential_error=validation_result.is_credential_error,
|
|
77
|
+
)
|
|
78
|
+
|
|
26
79
|
def build(
|
|
27
|
-
self,
|
|
80
|
+
self,
|
|
81
|
+
source_files: list[BuildSourceFile],
|
|
82
|
+
module: ModuleLocation,
|
|
83
|
+
console: Callable[[str], None] | None = None,
|
|
28
84
|
) -> Iterable[BuildDestinationFile | Sequence[ToolkitWarning]]:
|
|
29
85
|
for source_file in source_files:
|
|
30
86
|
if source_file.loaded is None:
|
|
@@ -55,7 +111,9 @@ class FunctionBuilder(Builder):
|
|
|
55
111
|
)
|
|
56
112
|
|
|
57
113
|
def validate_directory(
|
|
58
|
-
self,
|
|
114
|
+
self,
|
|
115
|
+
built_resources: BuiltResourceList,
|
|
116
|
+
module: ModuleLocation,
|
|
59
117
|
) -> WarningList[ToolkitWarning]:
|
|
60
118
|
warnings = WarningList[ToolkitWarning]()
|
|
61
119
|
has_config_files = any(resource.kind == FunctionCRUD.kind for resource in built_resources)
|
|
@@ -74,7 +132,7 @@ class FunctionBuilder(Builder):
|
|
|
74
132
|
f"was not found in {required_location.as_posix()!r}. "
|
|
75
133
|
f"The file {yaml_source_path.as_posix()!r} is currently "
|
|
76
134
|
f"considered part of the Function's artifacts and "
|
|
77
|
-
f"will not be processed by the Toolkit."
|
|
135
|
+
f"will not be processed by the Toolkit.",
|
|
78
136
|
)
|
|
79
137
|
warnings.append(warning)
|
|
80
138
|
return warnings
|
|
@@ -93,28 +151,42 @@ class FunctionBuilder(Builder):
|
|
|
93
151
|
warnings.append(
|
|
94
152
|
HighSeverityWarning(
|
|
95
153
|
f"Function in {source_file.source.path.as_posix()!r} has no externalId defined. "
|
|
96
|
-
f"This is used to match the function to the function directory."
|
|
97
|
-
)
|
|
154
|
+
f"This is used to match the function to the function directory.",
|
|
155
|
+
),
|
|
98
156
|
)
|
|
99
157
|
continue
|
|
100
158
|
if not function_path:
|
|
101
159
|
warnings.append(
|
|
102
160
|
MediumSeverityWarning(
|
|
103
|
-
f"Function {external_id} in {source_file.source.path.as_posix()!r} has no function_path defined."
|
|
104
|
-
)
|
|
161
|
+
f"Function {external_id} in {source_file.source.path.as_posix()!r} has no function_path defined.",
|
|
162
|
+
),
|
|
105
163
|
)
|
|
106
164
|
|
|
107
165
|
function_directory = source_file.source.path.with_name(external_id)
|
|
108
166
|
|
|
109
167
|
if not function_directory.is_dir():
|
|
110
168
|
raise ToolkitNotADirectoryError(
|
|
111
|
-
f"Function directory not found for externalId {external_id} defined in {source_file.source.path.as_posix()!r}."
|
|
169
|
+
f"Function directory not found for externalId {external_id} defined in {source_file.source.path.as_posix()!r}.",
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
# Validate requirements.txt if present and feature is enabled
|
|
173
|
+
if (
|
|
174
|
+
Flags.FUNCTION_REQUIREMENTS_VALIDATION.is_enabled()
|
|
175
|
+
and (requirements_txt := function_directory / "requirements.txt").exists()
|
|
176
|
+
):
|
|
177
|
+
warning = self._validate_function_requirements(
|
|
178
|
+
requirements_txt,
|
|
179
|
+
raw_function,
|
|
180
|
+
source_file.source.path,
|
|
181
|
+
external_id,
|
|
112
182
|
)
|
|
183
|
+
if warning:
|
|
184
|
+
warnings.append(warning)
|
|
113
185
|
|
|
114
186
|
destination = self.build_dir / self.resource_folder / external_id
|
|
115
187
|
if destination.exists():
|
|
116
188
|
raise ToolkitFileExistsError(
|
|
117
|
-
f"Function {external_id!r} is duplicated. If this is unexpected, ensure you have a clean build directory."
|
|
189
|
+
f"Function {external_id!r} is duplicated. If this is unexpected, ensure you have a clean build directory.",
|
|
118
190
|
)
|
|
119
191
|
shutil.copytree(function_directory, destination, ignore=shutil.ignore_patterns("__pycache__"))
|
|
120
192
|
|
|
@@ -3,7 +3,7 @@ from collections.abc import Callable, Iterable, Sequence
|
|
|
3
3
|
from typing import Any
|
|
4
4
|
|
|
5
5
|
from cognite_toolkit._cdf_tk.builders import Builder
|
|
6
|
-
from cognite_toolkit._cdf_tk.client.
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.legacy.raw import RawDatabase
|
|
7
7
|
from cognite_toolkit._cdf_tk.cruds import RawDatabaseCRUD, RawTableCRUD, ResourceCRUD
|
|
8
8
|
from cognite_toolkit._cdf_tk.data_classes import (
|
|
9
9
|
BuildDestinationFile,
|
|
@@ -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]
|
|
@@ -11,18 +11,34 @@ from cognite_toolkit._cdf_tk.client.api.legacy.extended_files import ExtendedFil
|
|
|
11
11
|
from cognite_toolkit._cdf_tk.client.api.legacy.extended_functions import ExtendedFunctionsAPI
|
|
12
12
|
from cognite_toolkit._cdf_tk.client.api.legacy.extended_raw import ExtendedRawAPI
|
|
13
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
|
|
15
|
-
from cognite_toolkit._cdf_tk.
|
|
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
|
|
16
16
|
|
|
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
|
|
17
23
|
from .api.infield import InfieldAPI
|
|
24
|
+
from .api.instances import InstancesAPI
|
|
25
|
+
from .api.labels import LabelsAPI
|
|
18
26
|
from .api.lookup import LookUpGroup
|
|
19
27
|
from .api.migration import MigrationAPI
|
|
20
28
|
from .api.project import ProjectAPI
|
|
29
|
+
from .api.raw import RawAPI
|
|
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)
|