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,146 @@
|
|
|
1
|
+
from collections.abc import Iterable, Sequence
|
|
2
|
+
from typing import Any, 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.identifiers import InternalOrExternalId
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.transformation import TransformationRequest, TransformationResponse
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TransformationsAPI(CDFResourceAPI[InternalOrExternalId, TransformationRequest, TransformationResponse]):
|
|
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="/transformations", item_limit=1000),
|
|
18
|
+
"retrieve": Endpoint(method="POST", path="/transformations/byids", item_limit=1000),
|
|
19
|
+
"update": Endpoint(method="POST", path="/transformations/update", item_limit=1000),
|
|
20
|
+
"delete": Endpoint(method="POST", path="/transformations/delete", item_limit=1000),
|
|
21
|
+
"list": Endpoint(method="POST", path="/transformations/filter", item_limit=1000),
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def _validate_page_response(
|
|
26
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
27
|
+
) -> PagedResponse[TransformationResponse]:
|
|
28
|
+
return PagedResponse[TransformationResponse].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[TransformationRequest]) -> list[TransformationResponse]:
|
|
34
|
+
"""Create transformations in CDF.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
items: List of TransformationRequest objects to create.
|
|
38
|
+
Returns:
|
|
39
|
+
List of created TransformationResponse objects.
|
|
40
|
+
"""
|
|
41
|
+
return self._request_item_response(items, "create")
|
|
42
|
+
|
|
43
|
+
def retrieve(
|
|
44
|
+
self, items: Sequence[InternalOrExternalId], ignore_unknown_ids: bool = False, with_job_details: bool = False
|
|
45
|
+
) -> list[TransformationResponse]:
|
|
46
|
+
"""Retrieve transformations from CDF.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
items: List of InternalOrExternalId objects to retrieve.
|
|
50
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
51
|
+
with_job_details: Whether the transformations will be returned with running job and last created job details.
|
|
52
|
+
Returns:
|
|
53
|
+
List of retrieved TransformationResponse objects.
|
|
54
|
+
"""
|
|
55
|
+
return self._request_item_response(
|
|
56
|
+
items,
|
|
57
|
+
method="retrieve",
|
|
58
|
+
extra_body={"ignoreUnknownIds": ignore_unknown_ids, "withJobDetails": with_job_details},
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
def update(
|
|
62
|
+
self, items: Sequence[TransformationRequest], mode: Literal["patch", "replace"] = "replace"
|
|
63
|
+
) -> list[TransformationResponse]:
|
|
64
|
+
"""Update transformations in CDF.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
items: List of TransformationRequest objects to update.
|
|
68
|
+
mode: Update mode, either "patch" or "replace".
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
List of updated TransformationResponse objects.
|
|
72
|
+
"""
|
|
73
|
+
return self._update(items, mode=mode)
|
|
74
|
+
|
|
75
|
+
def delete(self, items: Sequence[InternalOrExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
76
|
+
"""Delete transformations from CDF.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
items: List of InternalOrExternalId 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 paginate(
|
|
85
|
+
self,
|
|
86
|
+
filter: ClassicFilter | None = None,
|
|
87
|
+
is_public: bool | None = None,
|
|
88
|
+
limit: int = 100,
|
|
89
|
+
cursor: str | None = None,
|
|
90
|
+
) -> PagedResponse[TransformationResponse]:
|
|
91
|
+
"""Iterate over all transformations in CDF.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
filter: Filter by data set IDs.
|
|
95
|
+
is_public: Filter by public status.
|
|
96
|
+
limit: Maximum number of items to return.
|
|
97
|
+
cursor: Cursor for pagination.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
PagedResponse of TransformationResponse objects.
|
|
101
|
+
"""
|
|
102
|
+
filter_: dict[str, Any] = filter.dump() if filter else {}
|
|
103
|
+
if is_public is not None:
|
|
104
|
+
filter_["isPublic"] = is_public
|
|
105
|
+
|
|
106
|
+
return self._paginate(
|
|
107
|
+
cursor=cursor,
|
|
108
|
+
limit=limit,
|
|
109
|
+
body={"filter": filter_ or None},
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def iterate(
|
|
113
|
+
self,
|
|
114
|
+
filter: ClassicFilter | None = None,
|
|
115
|
+
is_public: bool | None = None,
|
|
116
|
+
limit: int = 100,
|
|
117
|
+
) -> Iterable[list[TransformationResponse]]:
|
|
118
|
+
"""Iterate over all transformations in CDF.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
filter: Filter by data set IDs.
|
|
122
|
+
is_public: Filter by public status.
|
|
123
|
+
limit: Maximum number of items to return per page.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
Iterable of lists of TransformationResponse objects.
|
|
127
|
+
"""
|
|
128
|
+
filter_: dict[str, Any] = filter.dump() if filter else {}
|
|
129
|
+
if is_public is not None:
|
|
130
|
+
filter_["isPublic"] = is_public
|
|
131
|
+
|
|
132
|
+
return self._iterate(
|
|
133
|
+
limit=limit,
|
|
134
|
+
body={"filter": filter_ or None},
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
def list(
|
|
138
|
+
self,
|
|
139
|
+
limit: int | None = 100,
|
|
140
|
+
) -> list[TransformationResponse]:
|
|
141
|
+
"""List all transformations in CDF.
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
List of TransformationResponse objects.
|
|
145
|
+
"""
|
|
146
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""Views API for managing CDF data modeling views.
|
|
2
|
+
|
|
3
|
+
Based on the API specification at:
|
|
4
|
+
https://api-docs.cognite.com/20230101/tag/Views/operation/ApplyViews
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from collections.abc import Iterable, Sequence
|
|
8
|
+
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, Endpoint, PagedResponse
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.http_client import HTTPClient, ItemsSuccessResponse2, SuccessResponse2
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.request_classes.filters import ViewFilter
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.data_modeling import (
|
|
13
|
+
ViewReference,
|
|
14
|
+
ViewRequest,
|
|
15
|
+
ViewResponse,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ViewsAPI(CDFResourceAPI[ViewReference, ViewRequest, ViewResponse]):
|
|
20
|
+
"""API for managing CDF data modeling views.
|
|
21
|
+
|
|
22
|
+
Views use an apply/upsert pattern for create and update operations.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
26
|
+
super().__init__(
|
|
27
|
+
http_client=http_client,
|
|
28
|
+
method_endpoint_map={
|
|
29
|
+
"upsert": Endpoint(method="POST", path="/models/views", item_limit=100),
|
|
30
|
+
"retrieve": Endpoint(method="POST", path="/models/views/byids", item_limit=100),
|
|
31
|
+
"delete": Endpoint(method="POST", path="/models/views/delete", item_limit=100),
|
|
32
|
+
"list": Endpoint(method="GET", path="/models/views", item_limit=1000),
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def _validate_page_response(
|
|
37
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
38
|
+
) -> PagedResponse[ViewResponse]:
|
|
39
|
+
return PagedResponse[ViewResponse].model_validate_json(response.body)
|
|
40
|
+
|
|
41
|
+
def create(self, items: Sequence[ViewRequest]) -> list[ViewResponse]:
|
|
42
|
+
"""Apply (create or update) views in CDF.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
items: List of ViewRequest objects to apply.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
List of applied ViewResponse objects.
|
|
49
|
+
"""
|
|
50
|
+
return self._request_item_response(items, "upsert")
|
|
51
|
+
|
|
52
|
+
def update(self, items: Sequence[ViewRequest]) -> list[ViewResponse]:
|
|
53
|
+
"""Apply (create or update) views in CDF.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
items: List of ViewRequest objects to apply.
|
|
57
|
+
Returns:
|
|
58
|
+
List of applied ViewResponse objects.
|
|
59
|
+
"""
|
|
60
|
+
return self._request_item_response(items, "upsert")
|
|
61
|
+
|
|
62
|
+
def retrieve(self, items: Sequence[ViewReference], include_inherited_properties: bool = True) -> list[ViewResponse]:
|
|
63
|
+
"""Retrieve views from CDF.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
items: List of ViewReference objects to retrieve.
|
|
67
|
+
include_inherited_properties: Whether to include inherited properties.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
List of retrieved ViewResponse objects.
|
|
71
|
+
"""
|
|
72
|
+
return self._request_item_response(
|
|
73
|
+
items, method="retrieve", extra_body={"includeInheritedProperties": include_inherited_properties}
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
def delete(self, items: Sequence[ViewReference]) -> None:
|
|
77
|
+
"""Delete views from CDF.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
items: List of ViewReference objects to delete.
|
|
81
|
+
"""
|
|
82
|
+
self._request_no_response(items, "delete")
|
|
83
|
+
|
|
84
|
+
def paginate(
|
|
85
|
+
self,
|
|
86
|
+
filter: ViewFilter | None = None,
|
|
87
|
+
limit: int = 100,
|
|
88
|
+
cursor: str | None = None,
|
|
89
|
+
) -> PagedResponse[ViewResponse]:
|
|
90
|
+
"""Get a page of views from CDF.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
filter: ViewFilter to filter views.
|
|
94
|
+
limit: Maximum number of views to return.
|
|
95
|
+
cursor: Cursor for pagination.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
PagedResponse of ViewResponse objects.
|
|
99
|
+
"""
|
|
100
|
+
return self._paginate(
|
|
101
|
+
cursor=cursor,
|
|
102
|
+
limit=limit,
|
|
103
|
+
params=filter.dump() if filter else None,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def iterate(
|
|
107
|
+
self,
|
|
108
|
+
filter: ViewFilter | None = None,
|
|
109
|
+
limit: int | None = None,
|
|
110
|
+
) -> Iterable[list[ViewResponse]]:
|
|
111
|
+
"""Iterate over all views in CDF.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
filter: ViewFilter to filter views.
|
|
115
|
+
limit: Maximum total number of views to return.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
Iterable of lists of ViewResponse objects.
|
|
119
|
+
"""
|
|
120
|
+
return self._iterate(
|
|
121
|
+
limit=limit,
|
|
122
|
+
params=filter.dump() if filter else None,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
def list(
|
|
126
|
+
self,
|
|
127
|
+
filter: ViewFilter | None = None,
|
|
128
|
+
limit: int | None = None,
|
|
129
|
+
) -> list[ViewResponse]:
|
|
130
|
+
"""List all views in CDF.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
filter: ViewFilter to filter views.
|
|
134
|
+
limit: Maximum total number of views to return.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
List of ViewResponse objects.
|
|
138
|
+
"""
|
|
139
|
+
return self._list(limit=limit, params=filter.dump() if filter else None)
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from collections.abc import Iterable, Sequence
|
|
2
|
+
from typing import Any
|
|
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.resource_classes.identifiers import ExternalId
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.workflow_trigger import (
|
|
9
|
+
WorkflowTriggerRequest,
|
|
10
|
+
WorkflowTriggerResponse,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class WorkflowTriggersAPI(CDFResourceAPI[ExternalId, WorkflowTriggerRequest, WorkflowTriggerResponse]):
|
|
15
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
16
|
+
super().__init__(
|
|
17
|
+
http_client=http_client,
|
|
18
|
+
method_endpoint_map={
|
|
19
|
+
"upsert": Endpoint(method="POST", path="/workflows/triggers", item_limit=1),
|
|
20
|
+
"delete": Endpoint(method="POST", path="/workflows/triggers/delete", item_limit=1),
|
|
21
|
+
"list": Endpoint(method="GET", path="/workflows/triggers", item_limit=1000),
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def _validate_page_response(
|
|
26
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
27
|
+
) -> PagedResponse[WorkflowTriggerResponse]:
|
|
28
|
+
return PagedResponse[WorkflowTriggerResponse].model_validate_json(response.body)
|
|
29
|
+
|
|
30
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[ExternalId]:
|
|
31
|
+
return ResponseItems[ExternalId].model_validate_json(response.body)
|
|
32
|
+
|
|
33
|
+
def create(self, items: Sequence[WorkflowTriggerRequest]) -> list[WorkflowTriggerResponse]:
|
|
34
|
+
"""Create or update workflow triggers in CDF.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
items: List of WorkflowTriggerRequest objects to create or update.
|
|
38
|
+
Returns:
|
|
39
|
+
List of created/updated WorkflowTriggerResponse objects.
|
|
40
|
+
"""
|
|
41
|
+
return self._request_item_response(items, "upsert")
|
|
42
|
+
|
|
43
|
+
# This is a duplicate of the create method, included to standardize the API interface.
|
|
44
|
+
def update(self, items: Sequence[WorkflowTriggerRequest]) -> list[WorkflowTriggerResponse]:
|
|
45
|
+
"""Create or update workflow triggers in CDF.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
items: List of WorkflowTriggerRequest objects to create or update.
|
|
49
|
+
Returns:
|
|
50
|
+
List of created/updated WorkflowTriggerResponse objects.
|
|
51
|
+
"""
|
|
52
|
+
return self.create(items)
|
|
53
|
+
|
|
54
|
+
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
55
|
+
"""Delete workflow triggers from CDF.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
items: List of ExternalId objects to delete.
|
|
59
|
+
"""
|
|
60
|
+
self._request_no_response(items, "delete")
|
|
61
|
+
|
|
62
|
+
def paginate(
|
|
63
|
+
self,
|
|
64
|
+
workflow_external_id: str | None = None,
|
|
65
|
+
workflow_version: str | None = None,
|
|
66
|
+
limit: int = 100,
|
|
67
|
+
cursor: str | None = None,
|
|
68
|
+
) -> PagedResponse[WorkflowTriggerResponse]:
|
|
69
|
+
"""Iterate over all workflow triggers in CDF.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
workflow_external_id: Filter by workflow external ID.
|
|
73
|
+
workflow_version: Filter by workflow version.
|
|
74
|
+
limit: Maximum number of items to return.
|
|
75
|
+
cursor: Cursor for pagination.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
PagedResponse of WorkflowTriggerResponse objects.
|
|
79
|
+
"""
|
|
80
|
+
params: dict[str, Any] = {}
|
|
81
|
+
if workflow_external_id:
|
|
82
|
+
params["workflowExternalId"] = workflow_external_id
|
|
83
|
+
if workflow_version:
|
|
84
|
+
params["workflowVersion"] = workflow_version
|
|
85
|
+
|
|
86
|
+
return self._paginate(
|
|
87
|
+
cursor=cursor,
|
|
88
|
+
limit=limit,
|
|
89
|
+
params=params,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
def iterate(
|
|
93
|
+
self,
|
|
94
|
+
workflow_external_id: str | None = None,
|
|
95
|
+
workflow_version: str | None = None,
|
|
96
|
+
limit: int = 100,
|
|
97
|
+
) -> Iterable[list[WorkflowTriggerResponse]]:
|
|
98
|
+
"""Iterate over all workflow triggers in CDF.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
workflow_external_id: Filter by workflow external ID.
|
|
102
|
+
workflow_version: Filter by workflow version.
|
|
103
|
+
limit: Maximum number of items to return per page.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
Iterable of lists of WorkflowTriggerResponse objects.
|
|
107
|
+
"""
|
|
108
|
+
params: dict[str, Any] = {}
|
|
109
|
+
if workflow_external_id:
|
|
110
|
+
params["workflowExternalId"] = workflow_external_id
|
|
111
|
+
if workflow_version:
|
|
112
|
+
params["workflowVersion"] = workflow_version
|
|
113
|
+
|
|
114
|
+
return self._iterate(
|
|
115
|
+
limit=limit,
|
|
116
|
+
params=params,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
def list(
|
|
120
|
+
self,
|
|
121
|
+
limit: int | None = 100,
|
|
122
|
+
) -> list[WorkflowTriggerResponse]:
|
|
123
|
+
"""List all workflow triggers in CDF.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
List of WorkflowTriggerResponse objects.
|
|
127
|
+
"""
|
|
128
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
from collections.abc import Iterable, Sequence
|
|
2
|
+
from typing import Any
|
|
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.resource_classes.identifiers import WorkflowVersionId
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.workflow_version import (
|
|
9
|
+
WorkflowVersionRequest,
|
|
10
|
+
WorkflowVersionResponse,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class WorkflowVersionsAPI(CDFResourceAPI[WorkflowVersionId, WorkflowVersionRequest, WorkflowVersionResponse]):
|
|
15
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
16
|
+
super().__init__(
|
|
17
|
+
http_client=http_client,
|
|
18
|
+
method_endpoint_map={
|
|
19
|
+
"upsert": Endpoint(method="POST", path="/workflows/versions", item_limit=1),
|
|
20
|
+
"retrieve": Endpoint(
|
|
21
|
+
method="GET", path="/workflow/{workflowExternalId}/versions/{version}", item_limit=1
|
|
22
|
+
),
|
|
23
|
+
"delete": Endpoint(method="POST", path="/workflows/versions/delete", item_limit=100),
|
|
24
|
+
"list": Endpoint(method="POST", path="/workflows/versions/list", item_limit=1000),
|
|
25
|
+
},
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
def _validate_page_response(
|
|
29
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
30
|
+
) -> PagedResponse[WorkflowVersionResponse]:
|
|
31
|
+
return PagedResponse[WorkflowVersionResponse].model_validate_json(response.body)
|
|
32
|
+
|
|
33
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[WorkflowVersionId]:
|
|
34
|
+
return ResponseItems[WorkflowVersionId].model_validate_json(response.body)
|
|
35
|
+
|
|
36
|
+
def create(self, items: Sequence[WorkflowVersionRequest]) -> list[WorkflowVersionResponse]:
|
|
37
|
+
"""Create or update workflow versions in CDF.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
items: List of WorkflowVersionRequest objects to create or update.
|
|
41
|
+
Returns:
|
|
42
|
+
List of created/updated WorkflowVersionResponse objects.
|
|
43
|
+
"""
|
|
44
|
+
return self._request_item_response(items, "upsert")
|
|
45
|
+
|
|
46
|
+
# This is a duplicate of the create method, included to standardize the API interface.
|
|
47
|
+
def update(self, items: Sequence[WorkflowVersionRequest]) -> list[WorkflowVersionResponse]:
|
|
48
|
+
"""Create or update workflow versions in CDF.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
items: List of WorkflowVersionRequest objects to create or update.
|
|
52
|
+
Returns:
|
|
53
|
+
List of created/updated WorkflowVersionResponse objects.
|
|
54
|
+
"""
|
|
55
|
+
return self.create(items)
|
|
56
|
+
|
|
57
|
+
def retrieve(self, items: Sequence[WorkflowVersionId]) -> list[WorkflowVersionResponse]:
|
|
58
|
+
"""Retrieve workflow versions from CDF.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
items: List of WorkflowVersionId objects to retrieve.
|
|
62
|
+
Returns:
|
|
63
|
+
List of retrieved WorkflowVersionResponse objects.
|
|
64
|
+
"""
|
|
65
|
+
result: list[WorkflowVersionResponse] = []
|
|
66
|
+
for item in items:
|
|
67
|
+
endpoint = f"/workflows/{item.workflow_external_id}/versions/{item.version}"
|
|
68
|
+
retrieved = self._request_item_response([item], "retrieve", endpoint=endpoint)
|
|
69
|
+
result.extend(retrieved)
|
|
70
|
+
return result
|
|
71
|
+
|
|
72
|
+
def delete(self, items: Sequence[WorkflowVersionId]) -> None:
|
|
73
|
+
"""Delete workflow versions from CDF.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
items: List of WorkflowVersionId objects to delete.
|
|
77
|
+
"""
|
|
78
|
+
self._request_no_response(items, "delete")
|
|
79
|
+
|
|
80
|
+
def paginate(
|
|
81
|
+
self,
|
|
82
|
+
workflow_external_id: str | None = None,
|
|
83
|
+
limit: int = 100,
|
|
84
|
+
cursor: str | None = None,
|
|
85
|
+
) -> PagedResponse[WorkflowVersionResponse]:
|
|
86
|
+
"""Iterate over all workflow versions in CDF.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
workflow_external_id: Filter by workflow external ID.
|
|
90
|
+
limit: Maximum number of items to return.
|
|
91
|
+
cursor: Cursor for pagination.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
PagedResponse of WorkflowVersionResponse objects.
|
|
95
|
+
"""
|
|
96
|
+
body: dict[str, Any] = {}
|
|
97
|
+
if workflow_external_id:
|
|
98
|
+
body["workflowExternalId"] = workflow_external_id
|
|
99
|
+
|
|
100
|
+
return self._paginate(
|
|
101
|
+
cursor=cursor,
|
|
102
|
+
limit=limit,
|
|
103
|
+
body=body,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def iterate(
|
|
107
|
+
self,
|
|
108
|
+
workflow_external_id: str | None = None,
|
|
109
|
+
limit: int = 100,
|
|
110
|
+
) -> Iterable[list[WorkflowVersionResponse]]:
|
|
111
|
+
"""Iterate over all workflow versions in CDF.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
workflow_external_id: Filter by workflow external ID.
|
|
115
|
+
limit: Maximum number of items to return per page.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
Iterable of lists of WorkflowVersionResponse objects.
|
|
119
|
+
"""
|
|
120
|
+
body: dict[str, Any] = {}
|
|
121
|
+
if workflow_external_id:
|
|
122
|
+
body["workflowExternalId"] = workflow_external_id
|
|
123
|
+
|
|
124
|
+
return self._iterate(
|
|
125
|
+
limit=limit,
|
|
126
|
+
body=body,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
def list(
|
|
130
|
+
self,
|
|
131
|
+
limit: int | None = 100,
|
|
132
|
+
) -> list[WorkflowVersionResponse]:
|
|
133
|
+
"""List all workflow versions in CDF.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
List of WorkflowVersionResponse objects.
|
|
137
|
+
"""
|
|
138
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
from collections.abc import Iterable, Sequence
|
|
2
|
+
|
|
3
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, PagedResponse, ResponseItems
|
|
4
|
+
from cognite_toolkit._cdf_tk.client.cdf_client.api import Endpoint
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.http_client import HTTPClient, ItemsSuccessResponse2, SuccessResponse2
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import ExternalId
|
|
7
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.workflow import WorkflowRequest, WorkflowResponse
|
|
8
|
+
|
|
9
|
+
from .workflow_triggers import WorkflowTriggersAPI
|
|
10
|
+
from .workflow_versions import WorkflowVersionsAPI
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class WorkflowsAPI(CDFResourceAPI[ExternalId, WorkflowRequest, WorkflowResponse]):
|
|
14
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
15
|
+
super().__init__(
|
|
16
|
+
http_client=http_client,
|
|
17
|
+
method_endpoint_map={
|
|
18
|
+
"upsert": Endpoint(method="POST", path="/workflows", item_limit=1),
|
|
19
|
+
"retrieve": Endpoint(method="GET", path="/workflows/{workflowExternalId}", item_limit=1),
|
|
20
|
+
"delete": Endpoint(method="POST", path="/workflows/delete", item_limit=100),
|
|
21
|
+
"list": Endpoint(method="GET", path="/workflows", item_limit=100),
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
self.versions = WorkflowVersionsAPI(http_client)
|
|
25
|
+
self.triggers = WorkflowTriggersAPI(http_client)
|
|
26
|
+
|
|
27
|
+
def _validate_page_response(
|
|
28
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
29
|
+
) -> PagedResponse[WorkflowResponse]:
|
|
30
|
+
return PagedResponse[WorkflowResponse].model_validate_json(response.body)
|
|
31
|
+
|
|
32
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[ExternalId]:
|
|
33
|
+
return ResponseItems[ExternalId].model_validate_json(response.body)
|
|
34
|
+
|
|
35
|
+
def create(self, items: Sequence[WorkflowRequest]) -> list[WorkflowResponse]:
|
|
36
|
+
"""Create or update workflows in CDF.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
items: List of WorkflowRequest objects to create or update.
|
|
40
|
+
Returns:
|
|
41
|
+
List of created/updated WorkflowResponse objects.
|
|
42
|
+
"""
|
|
43
|
+
return self._request_item_response(items, "upsert")
|
|
44
|
+
|
|
45
|
+
# This is a duplicate of the create method, included to standardize the API interface.
|
|
46
|
+
def update(self, items: Sequence[WorkflowRequest]) -> list[WorkflowResponse]:
|
|
47
|
+
"""Create or update workflows in CDF.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
items: List of WorkflowRequest objects to create or update.
|
|
51
|
+
Returns:
|
|
52
|
+
List of created/updated WorkflowResponse objects.
|
|
53
|
+
"""
|
|
54
|
+
return self.create(items)
|
|
55
|
+
|
|
56
|
+
def retrieve(self, items: Sequence[ExternalId]) -> list[WorkflowResponse]:
|
|
57
|
+
"""Retrieve a workflow from CDF by external ID.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
items: List of ExternalId objects to retrieve.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
The retrieved WorkflowResponse object, or None if not found.
|
|
64
|
+
"""
|
|
65
|
+
result: list[WorkflowResponse] = []
|
|
66
|
+
for item in items:
|
|
67
|
+
endpoint = f"/workflows/{item.external_id}"
|
|
68
|
+
retrieved = self._request_item_response([item], "retrieve", endpoint=endpoint)
|
|
69
|
+
result.extend(retrieved)
|
|
70
|
+
return result
|
|
71
|
+
|
|
72
|
+
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
73
|
+
"""Delete workflows from CDF.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
items: List of ExternalId objects to delete.
|
|
77
|
+
"""
|
|
78
|
+
self._request_no_response(items, "delete")
|
|
79
|
+
|
|
80
|
+
def paginate(
|
|
81
|
+
self,
|
|
82
|
+
limit: int = 100,
|
|
83
|
+
cursor: str | None = None,
|
|
84
|
+
) -> PagedResponse[WorkflowResponse]:
|
|
85
|
+
"""Iterate over all workflows in CDF.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
limit: Maximum number of items to return.
|
|
89
|
+
cursor: Cursor for pagination.
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
PagedResponse of WorkflowResponse objects.
|
|
93
|
+
"""
|
|
94
|
+
return self._paginate(cursor=cursor, limit=limit)
|
|
95
|
+
|
|
96
|
+
def iterate(
|
|
97
|
+
self,
|
|
98
|
+
limit: int = 100,
|
|
99
|
+
) -> Iterable[list[WorkflowResponse]]:
|
|
100
|
+
"""Iterate over all workflows in CDF.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
limit: Maximum number of items to return per page.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
Iterable of lists of WorkflowResponse objects.
|
|
107
|
+
"""
|
|
108
|
+
return self._iterate(limit=limit)
|
|
109
|
+
|
|
110
|
+
def list(
|
|
111
|
+
self,
|
|
112
|
+
limit: int | None = 100,
|
|
113
|
+
) -> list[WorkflowResponse]:
|
|
114
|
+
"""List all workflows in CDF.
|
|
115
|
+
|
|
116
|
+
Returns:
|
|
117
|
+
List of WorkflowResponse objects.
|
|
118
|
+
"""
|
|
119
|
+
return self._list(limit=limit)
|