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,176 @@
|
|
|
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 (
|
|
7
|
+
HTTPClient,
|
|
8
|
+
ItemsSuccessResponse2,
|
|
9
|
+
RequestMessage2,
|
|
10
|
+
SuccessResponse2,
|
|
11
|
+
)
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.request_classes.filters import ClassicFilter
|
|
13
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.filemetadata import FileMetadataRequest, FileMetadataResponse
|
|
14
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import InternalOrExternalId
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FileMetadataAPI(CDFResourceAPI[InternalOrExternalId, FileMetadataRequest, FileMetadataResponse]):
|
|
18
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
19
|
+
super().__init__(
|
|
20
|
+
http_client=http_client,
|
|
21
|
+
method_endpoint_map={
|
|
22
|
+
"create": Endpoint(method="POST", path="/files", item_limit=1, concurrency_max_workers=1),
|
|
23
|
+
"retrieve": Endpoint(method="POST", path="/files/byids", item_limit=1000, concurrency_max_workers=1),
|
|
24
|
+
"update": Endpoint(method="POST", path="/files/update", item_limit=1000, concurrency_max_workers=1),
|
|
25
|
+
"delete": Endpoint(method="POST", path="/files/delete", item_limit=1000, concurrency_max_workers=1),
|
|
26
|
+
"list": Endpoint(method="POST", path="/files/list", item_limit=1000),
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
def _validate_page_response(
|
|
31
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
32
|
+
) -> PagedResponse[FileMetadataResponse]:
|
|
33
|
+
return PagedResponse[FileMetadataResponse].model_validate_json(response.body)
|
|
34
|
+
|
|
35
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[InternalOrExternalId]:
|
|
36
|
+
return ResponseItems[InternalOrExternalId].model_validate_json(response.body)
|
|
37
|
+
|
|
38
|
+
def create(self, items: Sequence[FileMetadataRequest], overwrite: bool = False) -> list[FileMetadataResponse]:
|
|
39
|
+
"""Upload file metadata to CDF.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
items: List of FileMetadataRequest objects to upload.
|
|
43
|
+
overwrite: Whether to overwrite existing file metadata with the same external ID.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
List of created FileMetadataResponse objects.
|
|
47
|
+
"""
|
|
48
|
+
# The Files API is different from other APIs, thus we have a custom implementation here.
|
|
49
|
+
# - It only allow one item per request that is not wrapped in a "items" field.
|
|
50
|
+
# - It uses a query parameter for "overwrite" instead of including it in the body
|
|
51
|
+
endpoint = self._method_endpoint_map["create"]
|
|
52
|
+
results: list[FileMetadataResponse] = []
|
|
53
|
+
for item in items:
|
|
54
|
+
request = RequestMessage2(
|
|
55
|
+
endpoint_url=self._make_url(endpoint.path),
|
|
56
|
+
method=endpoint.method,
|
|
57
|
+
body_content=item.dump(),
|
|
58
|
+
parameters={"overwrite": overwrite},
|
|
59
|
+
)
|
|
60
|
+
response = self._http_client.request_single_retries(request)
|
|
61
|
+
result = response.get_success_or_raise()
|
|
62
|
+
results.append(FileMetadataResponse.model_validate_json(result.body))
|
|
63
|
+
return results
|
|
64
|
+
|
|
65
|
+
def retrieve(
|
|
66
|
+
self, items: Sequence[InternalOrExternalId], ignore_unknown_ids: bool = False
|
|
67
|
+
) -> list[FileMetadataResponse]:
|
|
68
|
+
"""Retrieve file metadata from CDF.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
items: List of InternalOrExternalId objects to retrieve.
|
|
72
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
73
|
+
Returns:
|
|
74
|
+
List of retrieved FileMetadataResponse objects.
|
|
75
|
+
"""
|
|
76
|
+
return self._request_item_response(
|
|
77
|
+
items, method="retrieve", extra_body={"ignoreUnknownIds": ignore_unknown_ids}
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
def update(
|
|
81
|
+
self, items: Sequence[FileMetadataRequest], mode: Literal["patch", "replace"] = "replace"
|
|
82
|
+
) -> list[FileMetadataResponse]:
|
|
83
|
+
"""Update file metadata in CDF.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
items: List of FileMetadataRequest objects to update.
|
|
87
|
+
mode: Update mode, either "patch" or "replace".
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
List of updated FileMetadataResponse objects.
|
|
91
|
+
"""
|
|
92
|
+
return self._update(items, mode=mode)
|
|
93
|
+
|
|
94
|
+
def delete(self, items: Sequence[InternalOrExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
95
|
+
"""Delete file metadata from CDF.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
items: List of InternalOrExternalId objects to delete.
|
|
99
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
100
|
+
"""
|
|
101
|
+
self._request_no_response(items, "delete", extra_body={"ignoreUnknownIds": ignore_unknown_ids})
|
|
102
|
+
|
|
103
|
+
def paginate(
|
|
104
|
+
self,
|
|
105
|
+
filter: ClassicFilter | None = None,
|
|
106
|
+
directory_prefix: str | None = None,
|
|
107
|
+
uploaded: bool | None = None,
|
|
108
|
+
limit: int = 100,
|
|
109
|
+
cursor: str | None = None,
|
|
110
|
+
) -> PagedResponse[FileMetadataResponse]:
|
|
111
|
+
"""Iterate over file metadata in CDF.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
filter: Filter by data set IDs and/or asset subtree IDs.
|
|
115
|
+
directory_prefix: Filter by directory prefix.
|
|
116
|
+
uploaded: Filter by upload status.
|
|
117
|
+
limit: Maximum number of items to return per page.
|
|
118
|
+
cursor: Cursor for pagination.
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
PagedResponse of FileMetadataResponse objects.
|
|
122
|
+
"""
|
|
123
|
+
filter_: dict[str, Any] = filter.dump() if filter else {}
|
|
124
|
+
if directory_prefix is not None:
|
|
125
|
+
filter_["directoryPrefix"] = directory_prefix
|
|
126
|
+
if uploaded is not None:
|
|
127
|
+
filter_["uploaded"] = uploaded
|
|
128
|
+
|
|
129
|
+
return self._paginate(
|
|
130
|
+
cursor=cursor,
|
|
131
|
+
limit=limit,
|
|
132
|
+
body={"filter": filter_ or None},
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
def iterate(
|
|
136
|
+
self,
|
|
137
|
+
filter: ClassicFilter | None = None,
|
|
138
|
+
directory_prefix: str | None = None,
|
|
139
|
+
uploaded: bool | None = None,
|
|
140
|
+
limit: int | None = 100,
|
|
141
|
+
) -> Iterable[list[FileMetadataResponse]]:
|
|
142
|
+
"""Iterate over file metadata in CDF.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
filter: Filter by data set IDs and/or asset subtree IDs.
|
|
146
|
+
directory_prefix: Filter by directory prefix.
|
|
147
|
+
uploaded: Filter by upload status.
|
|
148
|
+
limit: Maximum number of items to return per page.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
Iterable of lists of FileMetadataResponse objects.
|
|
152
|
+
"""
|
|
153
|
+
filter_: dict[str, Any] = filter.dump() if filter else {}
|
|
154
|
+
if directory_prefix is not None:
|
|
155
|
+
filter_["directoryPrefix"] = directory_prefix
|
|
156
|
+
if uploaded is not None:
|
|
157
|
+
filter_["uploaded"] = uploaded
|
|
158
|
+
|
|
159
|
+
return self._iterate(
|
|
160
|
+
limit=limit,
|
|
161
|
+
body={"filter": filter_ or None},
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
def list(
|
|
165
|
+
self,
|
|
166
|
+
limit: int | None = 100,
|
|
167
|
+
) -> list[FileMetadataResponse]:
|
|
168
|
+
"""List all file metadata in CDF.
|
|
169
|
+
|
|
170
|
+
Args:
|
|
171
|
+
limit: Maximum number of items to return. None for all items.
|
|
172
|
+
|
|
173
|
+
Returns:
|
|
174
|
+
List of FileMetadataResponse objects.
|
|
175
|
+
"""
|
|
176
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Function Schedules API for managing CDF function schedules.
|
|
2
|
+
|
|
3
|
+
Based on the API specification at:
|
|
4
|
+
https://api-docs.cognite.com/20230101/tag/Function-schedules/operation/postFunctionSchedules
|
|
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.resource_classes.function_schedule import (
|
|
12
|
+
FunctionScheduleRequest,
|
|
13
|
+
FunctionScheduleResponse,
|
|
14
|
+
)
|
|
15
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import InternalId
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class FunctionSchedulesAPI(CDFResourceAPI[InternalId, FunctionScheduleRequest, FunctionScheduleResponse]):
|
|
19
|
+
"""API for managing CDF function schedules.
|
|
20
|
+
|
|
21
|
+
Note: Function schedules do not support update operations.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
25
|
+
super().__init__(
|
|
26
|
+
http_client=http_client,
|
|
27
|
+
method_endpoint_map={
|
|
28
|
+
"create": Endpoint(method="POST", path="/functions/schedules", item_limit=1),
|
|
29
|
+
"retrieve": Endpoint(method="POST", path="/functions/schedules/byids", item_limit=10_000),
|
|
30
|
+
"delete": Endpoint(method="POST", path="/functions/schedules/delete", item_limit=10_000),
|
|
31
|
+
"list": Endpoint(method="POST", path="/functions/schedules/list", item_limit=1000),
|
|
32
|
+
},
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def _validate_page_response(
|
|
36
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
37
|
+
) -> PagedResponse[FunctionScheduleResponse]:
|
|
38
|
+
return PagedResponse[FunctionScheduleResponse].model_validate_json(response.body)
|
|
39
|
+
|
|
40
|
+
def create(self, items: Sequence[FunctionScheduleRequest]) -> list[FunctionScheduleResponse]:
|
|
41
|
+
"""Create function schedules in CDF.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
items: List of FunctionScheduleRequest objects to create.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
List of created FunctionScheduleResponse objects.
|
|
48
|
+
"""
|
|
49
|
+
return self._request_item_response(items, "create")
|
|
50
|
+
|
|
51
|
+
def retrieve(self, items: Sequence[InternalId], ignore_unknown_ids: bool = False) -> list[FunctionScheduleResponse]:
|
|
52
|
+
"""Retrieve function schedules from CDF by ID.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
items: List of InternalId objects to retrieve.
|
|
56
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
List of retrieved FunctionScheduleResponse objects.
|
|
60
|
+
"""
|
|
61
|
+
return self._request_item_response(
|
|
62
|
+
items, method="retrieve", extra_body={"ignoreUnknownIds": ignore_unknown_ids}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
def delete(self, items: Sequence[InternalId]) -> None:
|
|
66
|
+
"""Delete function schedules from CDF.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
items: List of InternalId objects to delete.
|
|
70
|
+
"""
|
|
71
|
+
self._request_no_response(items, "delete")
|
|
72
|
+
|
|
73
|
+
def paginate(
|
|
74
|
+
self,
|
|
75
|
+
limit: int = 100,
|
|
76
|
+
cursor: str | None = None,
|
|
77
|
+
) -> PagedResponse[FunctionScheduleResponse]:
|
|
78
|
+
"""Get a page of function schedules from CDF.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
limit: Maximum number of function schedules to return.
|
|
82
|
+
cursor: Cursor for pagination.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
PagedResponse of FunctionScheduleResponse objects.
|
|
86
|
+
"""
|
|
87
|
+
return self._paginate(
|
|
88
|
+
cursor=cursor,
|
|
89
|
+
limit=limit,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
def iterate(
|
|
93
|
+
self,
|
|
94
|
+
limit: int | None = None,
|
|
95
|
+
) -> Iterable[list[FunctionScheduleResponse]]:
|
|
96
|
+
"""Iterate over all function schedules in CDF.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
limit: Maximum total number of function schedules to return.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
Iterable of lists of FunctionScheduleResponse objects.
|
|
103
|
+
"""
|
|
104
|
+
return self._iterate(limit=limit)
|
|
105
|
+
|
|
106
|
+
def list(self, limit: int | None = None) -> list[FunctionScheduleResponse]:
|
|
107
|
+
"""List all function schedules in CDF.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
limit: Maximum total number of function schedules to return.
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
List of FunctionScheduleResponse objects.
|
|
114
|
+
"""
|
|
115
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""Functions API for managing CDF functions.
|
|
2
|
+
|
|
3
|
+
Based on the API specification at:
|
|
4
|
+
https://api-docs.cognite.com/20230101/tag/Functions/operation/postFunctions
|
|
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.resource_classes.function import FunctionRequest, FunctionResponse
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import InternalId
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FunctionsAPI(CDFResourceAPI[InternalId, FunctionRequest, FunctionResponse]):
|
|
16
|
+
"""API for managing CDF functions.
|
|
17
|
+
|
|
18
|
+
Note: Functions do not support update operations.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
22
|
+
super().__init__(
|
|
23
|
+
http_client=http_client,
|
|
24
|
+
method_endpoint_map={
|
|
25
|
+
"create": Endpoint(method="POST", path="/functions", item_limit=1),
|
|
26
|
+
"retrieve": Endpoint(method="POST", path="/functions/byids", item_limit=10),
|
|
27
|
+
"delete": Endpoint(method="POST", path="/functions/delete", item_limit=10),
|
|
28
|
+
"list": Endpoint(method="POST", path="/functions/list", item_limit=1000),
|
|
29
|
+
},
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
def _validate_page_response(
|
|
33
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
34
|
+
) -> PagedResponse[FunctionResponse]:
|
|
35
|
+
return PagedResponse[FunctionResponse].model_validate_json(response.body)
|
|
36
|
+
|
|
37
|
+
def create(self, items: Sequence[FunctionRequest]) -> list[FunctionResponse]:
|
|
38
|
+
"""Create functions in CDF.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
items: List of FunctionRequest objects to create.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
List of created FunctionResponse objects.
|
|
45
|
+
"""
|
|
46
|
+
return self._request_item_response(items, "create")
|
|
47
|
+
|
|
48
|
+
def retrieve(self, items: Sequence[InternalId], ignore_unknown_ids: bool = False) -> list[FunctionResponse]:
|
|
49
|
+
"""Retrieve functions from CDF by ID.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
items: List of InternalId objects to retrieve.
|
|
53
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
List of retrieved FunctionResponse objects.
|
|
57
|
+
"""
|
|
58
|
+
return self._request_item_response(
|
|
59
|
+
items, method="retrieve", extra_body={"ignoreUnknownIds": ignore_unknown_ids}
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
def delete(self, items: Sequence[InternalId], ignore_unknown_ids: bool = False) -> None:
|
|
63
|
+
"""Delete functions from CDF.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
items: List of InternalId objects to delete.
|
|
67
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
68
|
+
"""
|
|
69
|
+
self._request_no_response(items, "delete", extra_body={"ignoreUnknownIds": ignore_unknown_ids})
|
|
70
|
+
|
|
71
|
+
def paginate(
|
|
72
|
+
self,
|
|
73
|
+
limit: int = 100,
|
|
74
|
+
cursor: str | None = None,
|
|
75
|
+
) -> PagedResponse[FunctionResponse]:
|
|
76
|
+
"""Get a page of functions from CDF.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
limit: Maximum number of functions to return.
|
|
80
|
+
cursor: Cursor for pagination.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
PagedResponse of FunctionResponse objects.
|
|
84
|
+
"""
|
|
85
|
+
return self._paginate(
|
|
86
|
+
cursor=cursor,
|
|
87
|
+
limit=limit,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
def iterate(
|
|
91
|
+
self,
|
|
92
|
+
limit: int | None = None,
|
|
93
|
+
) -> Iterable[list[FunctionResponse]]:
|
|
94
|
+
"""Iterate over all functions in CDF.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
limit: Maximum total number of functions to return.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
Iterable of lists of FunctionResponse objects.
|
|
101
|
+
"""
|
|
102
|
+
return self._iterate(limit=limit)
|
|
103
|
+
|
|
104
|
+
def list(self, limit: int | None = None) -> list[FunctionResponse]:
|
|
105
|
+
"""List all functions in CDF.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
limit: Maximum total number of functions to return.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
List of FunctionResponse objects.
|
|
112
|
+
"""
|
|
113
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""GraphQL Data Models API for managing CDF GraphQL/DML data models.
|
|
2
|
+
|
|
3
|
+
This API provides a wrapper around the legacy DML API for managing GraphQL data models.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from collections.abc import Iterable, Sequence
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, Endpoint, PagedResponse
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.cdf_client.responses import GraphQLUpsertResponse
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.http_client import (
|
|
12
|
+
HTTPClient,
|
|
13
|
+
ItemsSuccessResponse2,
|
|
14
|
+
RequestMessage2,
|
|
15
|
+
SuccessResponse2,
|
|
16
|
+
ToolkitAPIError,
|
|
17
|
+
)
|
|
18
|
+
from cognite_toolkit._cdf_tk.client.request_classes.filters import DataModelFilter
|
|
19
|
+
from cognite_toolkit._cdf_tk.client.request_classes.graphql import UPSERT_BODY
|
|
20
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.data_modeling import DataModelReference
|
|
21
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.graphql_data_model import (
|
|
22
|
+
GraphQLDataModelRequest,
|
|
23
|
+
GraphQLDataModelResponse,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class GraphQLDataModelsAPI(CDFResourceAPI[DataModelReference, GraphQLDataModelRequest, GraphQLDataModelResponse]):
|
|
28
|
+
"""API for managing CDF GraphQL/DML data models.
|
|
29
|
+
|
|
30
|
+
This API uses GraphQL mutations to manage data models with DML (Data Modeling Language).
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
34
|
+
super().__init__(
|
|
35
|
+
http_client=http_client,
|
|
36
|
+
method_endpoint_map={
|
|
37
|
+
"retrieve": Endpoint(method="POST", path="/models/datamodels/byids", item_limit=100),
|
|
38
|
+
"delete": Endpoint(method="POST", path="/models/datamodels/delete", item_limit=100),
|
|
39
|
+
"list": Endpoint(method="GET", path="/models/datamodels", item_limit=1000),
|
|
40
|
+
},
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def _validate_page_response(
|
|
44
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
45
|
+
) -> PagedResponse[GraphQLDataModelResponse]:
|
|
46
|
+
return PagedResponse[GraphQLDataModelResponse].model_validate_json(response.body)
|
|
47
|
+
|
|
48
|
+
def _post_graphql(self, payload: dict[str, Any]) -> GraphQLUpsertResponse:
|
|
49
|
+
"""Execute a GraphQL query against the DML endpoint."""
|
|
50
|
+
request = RequestMessage2(
|
|
51
|
+
endpoint_url=self._make_url("/dml/graphql"),
|
|
52
|
+
method="POST",
|
|
53
|
+
body_content=payload,
|
|
54
|
+
)
|
|
55
|
+
result = self._http_client.request_single_retries(request)
|
|
56
|
+
response = result.get_success_or_raise()
|
|
57
|
+
parsed = GraphQLUpsertResponse.model_validate_json(response.body)
|
|
58
|
+
if errors := parsed.upsert_graph_ql_dml_version.errors:
|
|
59
|
+
raise ToolkitAPIError(f"Failed GraphQL errors: {errors}")
|
|
60
|
+
return parsed
|
|
61
|
+
|
|
62
|
+
def create(self, items: Sequence[GraphQLDataModelRequest]) -> list[GraphQLDataModelResponse]:
|
|
63
|
+
"""Apply (create or update) GraphQL data models in CDF.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
items: List of GraphQLDataModelRequest objects to apply.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
List of applied GraphQLDataModelResponse objects.
|
|
70
|
+
"""
|
|
71
|
+
results: list[GraphQLDataModelResponse] = []
|
|
72
|
+
for item in items:
|
|
73
|
+
payload = {"query": UPSERT_BODY, "variables": {"dmCreate": item.dump()}}
|
|
74
|
+
response = self._post_graphql(payload)
|
|
75
|
+
|
|
76
|
+
results.append(response.upsert_graph_ql_dml_version.data)
|
|
77
|
+
|
|
78
|
+
return results
|
|
79
|
+
|
|
80
|
+
def update(self, items: Sequence[GraphQLDataModelRequest]) -> list[GraphQLDataModelResponse]:
|
|
81
|
+
"""Update GraphQL data models in CDF.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
items: List of GraphQLDataModelRequest objects to update.
|
|
85
|
+
Returns:
|
|
86
|
+
List of updated GraphQLDataModelResponse objects.
|
|
87
|
+
"""
|
|
88
|
+
return self.create(items)
|
|
89
|
+
|
|
90
|
+
def retrieve(
|
|
91
|
+
self, items: Sequence[DataModelReference], inline_views: bool = False
|
|
92
|
+
) -> list[GraphQLDataModelResponse]:
|
|
93
|
+
"""Retrieve GraphQL data models from CDF.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
items: List of DataModelReference objects to retrieve.
|
|
97
|
+
inline_views: Whether to include full view definitions in the response.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
List of retrieved GraphQLDataModelResponse objects.
|
|
101
|
+
"""
|
|
102
|
+
return self._request_item_response(items, method="retrieve", extra_body={"inlineViews": inline_views})
|
|
103
|
+
|
|
104
|
+
def delete(self, items: Sequence[DataModelReference]) -> None:
|
|
105
|
+
"""Delete GraphQL data models from CDF.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
items: List of DataModelReference objects to delete.
|
|
109
|
+
"""
|
|
110
|
+
self._request_no_response(items, "delete")
|
|
111
|
+
|
|
112
|
+
def paginate(
|
|
113
|
+
self,
|
|
114
|
+
filter: DataModelFilter | None = None,
|
|
115
|
+
limit: int = 100,
|
|
116
|
+
cursor: str | None = None,
|
|
117
|
+
) -> PagedResponse[GraphQLDataModelResponse]:
|
|
118
|
+
"""Get a page of GraphQL data models from CDF.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
filter: DataModelFilter to filter data models.
|
|
122
|
+
limit: Maximum number of data models to return.
|
|
123
|
+
cursor: Cursor for pagination.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
PagedResponse of GraphQLDataModelResponse objects.
|
|
127
|
+
"""
|
|
128
|
+
return self._paginate(
|
|
129
|
+
cursor=cursor,
|
|
130
|
+
limit=limit,
|
|
131
|
+
params=filter.dump() if filter else None,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
def iterate(
|
|
135
|
+
self,
|
|
136
|
+
filter: DataModelFilter | None = None,
|
|
137
|
+
limit: int | None = None,
|
|
138
|
+
) -> Iterable[list[GraphQLDataModelResponse]]:
|
|
139
|
+
"""Iterate over all GraphQL data models in CDF.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
filter: DataModelFilter to filter data models.
|
|
143
|
+
limit: Maximum total number of data models to return.
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
Iterable of lists of GraphQLDataModelResponse objects.
|
|
147
|
+
"""
|
|
148
|
+
return self._iterate(
|
|
149
|
+
limit=limit,
|
|
150
|
+
params=filter.dump() if filter else None,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
def list(
|
|
154
|
+
self,
|
|
155
|
+
filter: DataModelFilter | None = None,
|
|
156
|
+
limit: int | None = None,
|
|
157
|
+
) -> list[GraphQLDataModelResponse]:
|
|
158
|
+
"""List all GraphQL data models in CDF.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
filter: DataModelFilter to filter data models.
|
|
162
|
+
limit: Maximum total number of data models to return.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
List of GraphQLDataModelResponse objects.
|
|
166
|
+
"""
|
|
167
|
+
return self._list(limit=limit, params=filter.dump() if filter else None)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""Groups API for managing CDF access groups.
|
|
2
|
+
|
|
3
|
+
Based on the API specification at:
|
|
4
|
+
https://api-docs.cognite.com/20230101/tag/Groups/operation/createGroups
|
|
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 (
|
|
11
|
+
HTTPClient,
|
|
12
|
+
ItemsSuccessResponse2,
|
|
13
|
+
RequestMessage2,
|
|
14
|
+
SuccessResponse2,
|
|
15
|
+
)
|
|
16
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.group import GroupRequest, GroupResponse
|
|
17
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import InternalId
|
|
18
|
+
from cognite_toolkit._cdf_tk.utils.collection import chunker_sequence
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class GroupsAPI(CDFResourceAPI[InternalId, GroupRequest, GroupResponse]):
|
|
22
|
+
"""API for managing CDF access groups.
|
|
23
|
+
|
|
24
|
+
Note: Groups do not support update operations.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
28
|
+
super().__init__(
|
|
29
|
+
http_client=http_client,
|
|
30
|
+
method_endpoint_map={
|
|
31
|
+
"create": Endpoint(method="POST", path="/groups", item_limit=1000),
|
|
32
|
+
"delete": Endpoint(method="POST", path="/groups/delete", item_limit=1000),
|
|
33
|
+
"list": Endpoint(method="GET", path="/groups", item_limit=1000),
|
|
34
|
+
},
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
def _validate_page_response(
|
|
38
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
39
|
+
) -> PagedResponse[GroupResponse]:
|
|
40
|
+
return PagedResponse[GroupResponse].model_validate_json(response.body)
|
|
41
|
+
|
|
42
|
+
def create(self, items: Sequence[GroupRequest]) -> list[GroupResponse]:
|
|
43
|
+
"""Create groups in CDF.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
items: List of GroupRequest objects to create.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
List of created GroupResponse objects.
|
|
50
|
+
"""
|
|
51
|
+
return self._request_item_response(items, "create")
|
|
52
|
+
|
|
53
|
+
def delete(self, items: Sequence[InternalId]) -> None:
|
|
54
|
+
"""Delete groups from CDF.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
items: List of InternalId objects to delete.
|
|
58
|
+
"""
|
|
59
|
+
# Custom implementation since delete does not wrap the items in a {"id": ...} structure
|
|
60
|
+
endpoint = self._method_endpoint_map["delete"]
|
|
61
|
+
for chunk in chunker_sequence(items, endpoint.item_limit):
|
|
62
|
+
request = RequestMessage2(
|
|
63
|
+
endpoint_url=self._make_url(endpoint.path),
|
|
64
|
+
method=endpoint.method,
|
|
65
|
+
body_content={"items": [item.id for item in chunk]},
|
|
66
|
+
)
|
|
67
|
+
response = self._http_client.request_single_retries(request)
|
|
68
|
+
response.get_success_or_raise()
|
|
69
|
+
|
|
70
|
+
def paginate(
|
|
71
|
+
self,
|
|
72
|
+
all_groups: bool = False,
|
|
73
|
+
limit: int = 100,
|
|
74
|
+
cursor: str | None = None,
|
|
75
|
+
) -> PagedResponse[GroupResponse]:
|
|
76
|
+
"""Get a page of groups from CDF.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
all_groups: Whether to return all groups (requires admin permissions).
|
|
80
|
+
limit: Maximum number of groups to return.
|
|
81
|
+
cursor: Cursor for pagination.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
PagedResponse of GroupResponse objects.
|
|
85
|
+
"""
|
|
86
|
+
return self._paginate(
|
|
87
|
+
cursor=cursor,
|
|
88
|
+
limit=limit,
|
|
89
|
+
params={"all": all_groups} if all_groups else None,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
def iterate(
|
|
93
|
+
self,
|
|
94
|
+
all_groups: bool = False,
|
|
95
|
+
limit: int | None = None,
|
|
96
|
+
) -> Iterable[list[GroupResponse]]:
|
|
97
|
+
"""Iterate over all groups in CDF.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
all_groups: Whether to return all groups (requires admin permissions).
|
|
101
|
+
limit: Maximum total number of groups to return.
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
Iterable of lists of GroupResponse objects.
|
|
105
|
+
"""
|
|
106
|
+
return self._iterate(
|
|
107
|
+
limit=limit,
|
|
108
|
+
params={"all": all_groups} if all_groups else None,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
def list(self, all_groups: bool = False, limit: int | None = None) -> list[GroupResponse]:
|
|
112
|
+
"""List all groups in CDF.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
all_groups: Whether to return all groups (requires admin permissions).
|
|
116
|
+
limit: Maximum total number of groups to return.
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
List of GroupResponse objects.
|
|
120
|
+
"""
|
|
121
|
+
return self._list(limit=limit, params={"all": all_groups} if all_groups else None)
|