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,94 @@
|
|
|
1
|
+
from collections.abc import Iterable, Sequence
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, PagedResponse, ResponseItems
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.cdf_client.api import Endpoint
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.http_client import HTTPClient, ItemsSuccessResponse2, SuccessResponse2
|
|
7
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import InternalId
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.securitycategory import (
|
|
9
|
+
SecurityCategoryRequest,
|
|
10
|
+
SecurityCategoryResponse,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SecurityCategoriesAPI(CDFResourceAPI[InternalId, SecurityCategoryRequest, SecurityCategoryResponse]):
|
|
15
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
16
|
+
super().__init__(
|
|
17
|
+
http_client=http_client,
|
|
18
|
+
method_endpoint_map={
|
|
19
|
+
"create": Endpoint(method="POST", path="/securitycategories", item_limit=1000),
|
|
20
|
+
"delete": Endpoint(method="POST", path="/securitycategories/delete", item_limit=1000),
|
|
21
|
+
"list": Endpoint(method="GET", path="/securitycategories", item_limit=1000),
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def _validate_page_response(
|
|
26
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
27
|
+
) -> PagedResponse[SecurityCategoryResponse]:
|
|
28
|
+
return PagedResponse[SecurityCategoryResponse].model_validate_json(response.body)
|
|
29
|
+
|
|
30
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[InternalId]:
|
|
31
|
+
return ResponseItems[InternalId].model_validate_json(response.body)
|
|
32
|
+
|
|
33
|
+
def create(self, items: Sequence[SecurityCategoryRequest]) -> list[SecurityCategoryResponse]:
|
|
34
|
+
"""Create security categories in CDF.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
items: List of SecurityCategoryRequest objects to create.
|
|
38
|
+
Returns:
|
|
39
|
+
List of created SecurityCategoryResponse objects.
|
|
40
|
+
"""
|
|
41
|
+
return self._request_item_response(items, "create")
|
|
42
|
+
|
|
43
|
+
def delete(self, items: Sequence[InternalId]) -> None:
|
|
44
|
+
"""Delete security categories from CDF.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
items: List of InternalId objects to delete.
|
|
48
|
+
"""
|
|
49
|
+
self._request_no_response(items, "delete")
|
|
50
|
+
|
|
51
|
+
def paginate(
|
|
52
|
+
self,
|
|
53
|
+
sort: Literal["ASC", "DESC"] = "ASC",
|
|
54
|
+
limit: int = 100,
|
|
55
|
+
cursor: str | None = None,
|
|
56
|
+
) -> PagedResponse[SecurityCategoryResponse]:
|
|
57
|
+
"""Iterate over all security categories in CDF.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
sort: Sort descending or ascending.
|
|
61
|
+
limit: Maximum number of items to return.
|
|
62
|
+
cursor: Cursor for pagination.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
PagedResponse of SecurityCategoryResponse objects.
|
|
66
|
+
"""
|
|
67
|
+
return self._paginate(cursor=cursor, limit=limit, params={"sort": sort})
|
|
68
|
+
|
|
69
|
+
def iterate(
|
|
70
|
+
self,
|
|
71
|
+
sort: Literal["ASC", "DESC"] = "ASC",
|
|
72
|
+
limit: int = 100,
|
|
73
|
+
) -> Iterable[list[SecurityCategoryResponse]]:
|
|
74
|
+
"""Iterate over all security categories in CDF.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
sort: Sort descending or ascending.
|
|
78
|
+
limit: Maximum number of items to return per page.
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
Iterable of lists of SecurityCategoryResponse objects.
|
|
82
|
+
"""
|
|
83
|
+
return self._iterate(limit=limit, params={"sort": sort})
|
|
84
|
+
|
|
85
|
+
def list(
|
|
86
|
+
self,
|
|
87
|
+
limit: int | None = 100,
|
|
88
|
+
) -> list[SecurityCategoryResponse]:
|
|
89
|
+
"""List all security categories in CDF.
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
List of SecurityCategoryResponse objects.
|
|
93
|
+
"""
|
|
94
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
from collections.abc import Iterable, Sequence
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, PagedResponse, ResponseItems
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.cdf_client.api import Endpoint
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.http_client import HTTPClient, ItemsSuccessResponse2, SuccessResponse2
|
|
7
|
+
from cognite_toolkit._cdf_tk.client.request_classes.filters import ClassicFilter
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import InternalOrExternalId
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.sequence import SequenceRequest, SequenceResponse
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class SequencesAPI(CDFResourceAPI[InternalOrExternalId, SequenceRequest, SequenceResponse]):
|
|
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="/sequences", item_limit=1000, concurrency_max_workers=1),
|
|
18
|
+
"retrieve": Endpoint(
|
|
19
|
+
method="POST", path="/sequences/byids", item_limit=1000, concurrency_max_workers=1
|
|
20
|
+
),
|
|
21
|
+
"update": Endpoint(method="POST", path="/sequences/update", item_limit=1000, concurrency_max_workers=1),
|
|
22
|
+
"delete": Endpoint(method="POST", path="/sequences/delete", item_limit=1000, concurrency_max_workers=1),
|
|
23
|
+
"list": Endpoint(method="POST", path="/sequences/list", item_limit=1000),
|
|
24
|
+
},
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
def _validate_page_response(
|
|
28
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
29
|
+
) -> PagedResponse[SequenceResponse]:
|
|
30
|
+
return PagedResponse[SequenceResponse].model_validate_json(response.body)
|
|
31
|
+
|
|
32
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[InternalOrExternalId]:
|
|
33
|
+
return ResponseItems[InternalOrExternalId].model_validate_json(response.body)
|
|
34
|
+
|
|
35
|
+
def create(self, items: Sequence[SequenceRequest]) -> list[SequenceResponse]:
|
|
36
|
+
"""Create sequences in CDF.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
items: List of SequenceRequest objects to create.
|
|
40
|
+
Returns:
|
|
41
|
+
List of created SequenceResponse objects.
|
|
42
|
+
"""
|
|
43
|
+
return self._request_item_response(items, "create")
|
|
44
|
+
|
|
45
|
+
def retrieve(
|
|
46
|
+
self, items: Sequence[InternalOrExternalId], ignore_unknown_ids: bool = False
|
|
47
|
+
) -> list[SequenceResponse]:
|
|
48
|
+
"""Retrieve sequences from CDF.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
items: List of InternalOrExternalId objects to retrieve.
|
|
52
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
53
|
+
Returns:
|
|
54
|
+
List of retrieved SequenceResponse objects.
|
|
55
|
+
"""
|
|
56
|
+
return self._request_item_response(
|
|
57
|
+
items, method="retrieve", extra_body={"ignoreUnknownIds": ignore_unknown_ids}
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
def update(
|
|
61
|
+
self, items: Sequence[SequenceRequest], mode: Literal["patch", "replace"] = "replace"
|
|
62
|
+
) -> list[SequenceResponse]:
|
|
63
|
+
"""Update sequences in CDF.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
items: List of SequenceRequest objects to update.
|
|
67
|
+
mode: Update mode, either "patch" or "replace".
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
List of updated SequenceResponse objects.
|
|
71
|
+
"""
|
|
72
|
+
return self._update(items, mode=mode)
|
|
73
|
+
|
|
74
|
+
def delete(self, items: Sequence[InternalOrExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
75
|
+
"""Delete sequences from CDF.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
items: List of InternalOrExternalId objects to delete.
|
|
79
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
80
|
+
"""
|
|
81
|
+
self._request_no_response(items, "delete", extra_body={"ignoreUnknownIds": ignore_unknown_ids})
|
|
82
|
+
|
|
83
|
+
def paginate(
|
|
84
|
+
self,
|
|
85
|
+
filter: ClassicFilter | None = None,
|
|
86
|
+
limit: int = 100,
|
|
87
|
+
cursor: str | None = None,
|
|
88
|
+
) -> PagedResponse[SequenceResponse]:
|
|
89
|
+
"""Iterate over all sequences in CDF.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
filter: Filter by data set IDs and/or asset subtree IDs.
|
|
93
|
+
limit: Maximum number of items to return.
|
|
94
|
+
cursor: Cursor for pagination.
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
PagedResponse of SequenceResponse objects.
|
|
98
|
+
"""
|
|
99
|
+
return self._paginate(
|
|
100
|
+
cursor=cursor,
|
|
101
|
+
limit=limit,
|
|
102
|
+
body={"filter": filter.dump() if filter else None},
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
def iterate(
|
|
106
|
+
self,
|
|
107
|
+
filter: ClassicFilter | None = None,
|
|
108
|
+
limit: int = 100,
|
|
109
|
+
) -> Iterable[list[SequenceResponse]]:
|
|
110
|
+
"""Iterate over all sequences in CDF.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
filter: Filter by data set IDs and/or asset subtree IDs.
|
|
114
|
+
limit: Maximum number of items to return per page.
|
|
115
|
+
|
|
116
|
+
Returns:
|
|
117
|
+
Iterable of lists of SequenceResponse objects.
|
|
118
|
+
"""
|
|
119
|
+
return self._iterate(
|
|
120
|
+
limit=limit,
|
|
121
|
+
body={"filter": filter.dump() if filter else None},
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
def list(
|
|
125
|
+
self,
|
|
126
|
+
limit: int | None = 100,
|
|
127
|
+
) -> list[SequenceResponse]:
|
|
128
|
+
"""List all sequences in CDF.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
List of SequenceResponse objects.
|
|
132
|
+
"""
|
|
133
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,154 @@
|
|
|
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.resource_classes.identifiers import InternalOrExternalId
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.simulator_model import (
|
|
9
|
+
SimulatorModelRequest,
|
|
10
|
+
SimulatorModelResponse,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SimulatorModelsAPI(CDFResourceAPI[InternalOrExternalId, SimulatorModelRequest, SimulatorModelResponse]):
|
|
15
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
16
|
+
super().__init__(
|
|
17
|
+
http_client=http_client,
|
|
18
|
+
method_endpoint_map={
|
|
19
|
+
"create": Endpoint(method="POST", path="/simulators/models", item_limit=1, concurrency_max_workers=1),
|
|
20
|
+
"retrieve": Endpoint(
|
|
21
|
+
method="POST", path="/simulators/models/byids", item_limit=1, concurrency_max_workers=1
|
|
22
|
+
),
|
|
23
|
+
"update": Endpoint(
|
|
24
|
+
method="POST", path="/simulators/models/update", item_limit=1, concurrency_max_workers=1
|
|
25
|
+
),
|
|
26
|
+
"delete": Endpoint(
|
|
27
|
+
method="POST", path="/simulators/models/delete", item_limit=1, concurrency_max_workers=1
|
|
28
|
+
),
|
|
29
|
+
"list": Endpoint(method="POST", path="/simulators/models/list", item_limit=1000),
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def _validate_page_response(
|
|
34
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
35
|
+
) -> PagedResponse[SimulatorModelResponse]:
|
|
36
|
+
return PagedResponse[SimulatorModelResponse].model_validate_json(response.body)
|
|
37
|
+
|
|
38
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[InternalOrExternalId]:
|
|
39
|
+
return ResponseItems[InternalOrExternalId].model_validate_json(response.body)
|
|
40
|
+
|
|
41
|
+
def create(self, items: Sequence[SimulatorModelRequest]) -> list[SimulatorModelResponse]:
|
|
42
|
+
"""Create simulator models in CDF.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
items: List of SimulatorModelRequest objects to create.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
List of created SimulatorModelResponse objects.
|
|
49
|
+
"""
|
|
50
|
+
return self._request_item_response(items, "create")
|
|
51
|
+
|
|
52
|
+
def retrieve(
|
|
53
|
+
self, items: Sequence[InternalOrExternalId], ignore_unknown_ids: bool = False
|
|
54
|
+
) -> list[SimulatorModelResponse]:
|
|
55
|
+
"""Retrieve simulator models from CDF.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
items: List of InternalOrExternalId objects to retrieve.
|
|
59
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
List of retrieved SimulatorModelResponse objects.
|
|
63
|
+
"""
|
|
64
|
+
if ignore_unknown_ids:
|
|
65
|
+
# The CDF API does not support ignore_unknown_ids for simulator models,
|
|
66
|
+
# so we implement it with retries here.
|
|
67
|
+
return self._request_item_split_retries(items, method="retrieve")
|
|
68
|
+
else:
|
|
69
|
+
return self._request_item_response(items, method="retrieve")
|
|
70
|
+
|
|
71
|
+
def update(
|
|
72
|
+
self, items: Sequence[SimulatorModelRequest], mode: Literal["patch", "replace"] = "replace"
|
|
73
|
+
) -> list[SimulatorModelResponse]:
|
|
74
|
+
"""Update simulator models in CDF.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
items: List of SimulatorModelRequest objects to update.
|
|
78
|
+
mode: Update mode, either "patch" or "replace".
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
List of updated SimulatorModelResponse objects.
|
|
82
|
+
"""
|
|
83
|
+
return self._update(items, mode=mode)
|
|
84
|
+
|
|
85
|
+
def delete(self, items: Sequence[InternalOrExternalId]) -> None:
|
|
86
|
+
"""Delete simulator models from CDF.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
items: List of InternalOrExternalId objects to delete.
|
|
90
|
+
"""
|
|
91
|
+
self._request_no_response(items, "delete")
|
|
92
|
+
|
|
93
|
+
def paginate(
|
|
94
|
+
self,
|
|
95
|
+
simulator_external_ids: list[str] | None = None,
|
|
96
|
+
limit: int = 100,
|
|
97
|
+
cursor: str | None = None,
|
|
98
|
+
) -> PagedResponse[SimulatorModelResponse]:
|
|
99
|
+
"""Iterate over simulator models in CDF.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
simulator_external_ids: Filter by simulator external IDs.
|
|
103
|
+
limit: Maximum number of items to return per page.
|
|
104
|
+
cursor: Cursor for pagination.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
PagedResponse of SimulatorModelResponse objects.
|
|
108
|
+
"""
|
|
109
|
+
filter_: dict[str, Any] = {}
|
|
110
|
+
if simulator_external_ids:
|
|
111
|
+
filter_["simulatorExternalIds"] = simulator_external_ids
|
|
112
|
+
|
|
113
|
+
return self._paginate(
|
|
114
|
+
cursor=cursor,
|
|
115
|
+
limit=limit,
|
|
116
|
+
body={"filter": filter_ or None},
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
def iterate(
|
|
120
|
+
self,
|
|
121
|
+
simulator_external_ids: list[str] | None = None,
|
|
122
|
+
limit: int = 100,
|
|
123
|
+
) -> Iterable[list[SimulatorModelResponse]]:
|
|
124
|
+
"""Iterate over simulator models in CDF.
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
simulator_external_ids: Filter by simulator external IDs.
|
|
128
|
+
limit: Maximum number of items to return per page.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
Iterable of lists of SimulatorModelResponse objects.
|
|
132
|
+
"""
|
|
133
|
+
filter_: dict[str, Any] = {}
|
|
134
|
+
if simulator_external_ids:
|
|
135
|
+
filter_["simulatorExternalIds"] = simulator_external_ids
|
|
136
|
+
|
|
137
|
+
return self._iterate(
|
|
138
|
+
limit=limit,
|
|
139
|
+
body={"filter": filter_ or None},
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
def list(
|
|
143
|
+
self,
|
|
144
|
+
limit: int | None = 100,
|
|
145
|
+
) -> list[SimulatorModelResponse]:
|
|
146
|
+
"""List all simulator models in CDF.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
limit: Maximum number of items to return. None for all items.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
List of SimulatorModelResponse objects.
|
|
153
|
+
"""
|
|
154
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Spaces API for managing CDF data modeling spaces.
|
|
2
|
+
|
|
3
|
+
Based on the API specification at:
|
|
4
|
+
https://api-docs.cognite.com/20230101/tag/Spaces/operation/ApplySpaces
|
|
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.data_modeling import SpaceReference, SpaceRequest, SpaceResponse
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SpacesAPI(CDFResourceAPI[SpaceReference, SpaceRequest, SpaceResponse]):
|
|
15
|
+
"""API for managing CDF data modeling spaces.
|
|
16
|
+
|
|
17
|
+
Spaces use an apply/upsert pattern for create and update operations.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
21
|
+
super().__init__(
|
|
22
|
+
http_client=http_client,
|
|
23
|
+
method_endpoint_map={
|
|
24
|
+
"upsert": Endpoint(method="POST", path="/models/spaces", item_limit=100),
|
|
25
|
+
"retrieve": Endpoint(method="POST", path="/models/spaces/byids", item_limit=100),
|
|
26
|
+
"delete": Endpoint(method="POST", path="/models/spaces/delete", item_limit=100),
|
|
27
|
+
"list": Endpoint(method="GET", path="/models/spaces", item_limit=1000),
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
def _validate_page_response(
|
|
32
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
33
|
+
) -> PagedResponse[SpaceResponse]:
|
|
34
|
+
return PagedResponse[SpaceResponse].model_validate_json(response.body)
|
|
35
|
+
|
|
36
|
+
def apply(self, items: Sequence[SpaceRequest]) -> list[SpaceResponse]:
|
|
37
|
+
"""Apply (create or update) spaces in CDF.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
items: List of SpaceRequest objects to apply.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
List of applied SpaceResponse objects.
|
|
44
|
+
"""
|
|
45
|
+
return self._request_item_response(items, "upsert")
|
|
46
|
+
|
|
47
|
+
def retrieve(self, items: Sequence[SpaceReference]) -> list[SpaceResponse]:
|
|
48
|
+
"""Retrieve spaces from CDF.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
items: List of SpaceReference objects to retrieve.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
List of retrieved SpaceResponse objects.
|
|
55
|
+
"""
|
|
56
|
+
return self._request_item_response(items, method="retrieve")
|
|
57
|
+
|
|
58
|
+
def delete(self, items: Sequence[SpaceReference]) -> None:
|
|
59
|
+
"""Delete spaces from CDF.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
items: List of SpaceReference objects to delete.
|
|
63
|
+
"""
|
|
64
|
+
self._request_no_response(items, "delete")
|
|
65
|
+
|
|
66
|
+
def paginate(
|
|
67
|
+
self,
|
|
68
|
+
include_global: bool = False,
|
|
69
|
+
limit: int = 100,
|
|
70
|
+
cursor: str | None = None,
|
|
71
|
+
) -> PagedResponse[SpaceResponse]:
|
|
72
|
+
"""Get a page of spaces from CDF.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
include_global: Whether to include global spaces.
|
|
76
|
+
limit: Maximum number of spaces to return.
|
|
77
|
+
cursor: Cursor for pagination.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
PagedResponse of SpaceResponse objects.
|
|
81
|
+
"""
|
|
82
|
+
return self._paginate(
|
|
83
|
+
cursor=cursor,
|
|
84
|
+
limit=limit,
|
|
85
|
+
params={"includeGlobal": include_global},
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
def iterate(
|
|
89
|
+
self,
|
|
90
|
+
include_global: bool = False,
|
|
91
|
+
limit: int | None = None,
|
|
92
|
+
) -> Iterable[list[SpaceResponse]]:
|
|
93
|
+
"""Iterate over all spaces in CDF.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
include_global: Whether to include global spaces.
|
|
97
|
+
limit: Maximum total number of spaces to return.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
Iterable of lists of SpaceResponse objects.
|
|
101
|
+
"""
|
|
102
|
+
return self._iterate(
|
|
103
|
+
limit=limit,
|
|
104
|
+
params={"includeGlobal": include_global},
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
def list(self, include_global: bool = False, limit: int | None = None) -> list[SpaceResponse]:
|
|
108
|
+
"""List all spaces in CDF.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
include_global: Whether to include global spaces.
|
|
112
|
+
limit: Maximum total number of spaces to return.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
List of SpaceResponse objects.
|
|
116
|
+
"""
|
|
117
|
+
return self._list(limit=limit, params={"includeGlobal": include_global})
|
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
from collections.abc import Sequence
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, PagedResponse
|
|
4
|
+
from cognite_toolkit._cdf_tk.client.cdf_client.api import Endpoint
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.http_client import (
|
|
6
|
+
HTTPClient,
|
|
7
|
+
ItemsSuccessResponse2,
|
|
8
|
+
RequestMessage2,
|
|
9
|
+
SuccessResponse2,
|
|
10
|
+
)
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import ExternalId
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.streams import StreamRequest, StreamResponse
|
|
4
13
|
|
|
5
|
-
from cognite_toolkit._cdf_tk.client.data_classes.api_classes import PagedResponse
|
|
6
|
-
from cognite_toolkit._cdf_tk.client.data_classes.streams import StreamRequest, StreamResponse
|
|
7
|
-
from cognite_toolkit._cdf_tk.utils.http_client import HTTPClient, ItemsRequest, ParamRequest
|
|
8
14
|
|
|
15
|
+
class StreamsAPI(CDFResourceAPI[ExternalId, StreamRequest, StreamResponse]):
|
|
16
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
17
|
+
super().__init__(
|
|
18
|
+
http_client=http_client,
|
|
19
|
+
method_endpoint_map={
|
|
20
|
+
"create": Endpoint(method="POST", path="/streams", item_limit=1),
|
|
21
|
+
"delete": Endpoint(method="POST", path="/streams/delete", item_limit=1),
|
|
22
|
+
"retrieve": Endpoint(method="GET", path="/streams/{streamId}", item_limit=1),
|
|
23
|
+
"list": Endpoint(method="GET", path="/streams", item_limit=1000),
|
|
24
|
+
},
|
|
25
|
+
)
|
|
9
26
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
self._http_client = http_client
|
|
15
|
-
self._console = console
|
|
16
|
-
self._config = http_client.config
|
|
27
|
+
def _validate_page_response(
|
|
28
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
29
|
+
) -> PagedResponse[StreamResponse]:
|
|
30
|
+
return PagedResponse[StreamResponse].model_validate_json(response.body)
|
|
17
31
|
|
|
18
32
|
def create(self, items: Sequence[StreamRequest]) -> list[StreamResponse]:
|
|
19
33
|
"""Create one or more streams.
|
|
@@ -24,61 +38,59 @@ class StreamsAPI:
|
|
|
24
38
|
Returns:
|
|
25
39
|
List of created StreamResponse items.
|
|
26
40
|
"""
|
|
27
|
-
|
|
28
|
-
ItemsRequest(
|
|
29
|
-
endpoint_url=self._config.create_api_url(self.ENDPOINT),
|
|
30
|
-
method="POST",
|
|
31
|
-
items=list(items),
|
|
32
|
-
)
|
|
33
|
-
)
|
|
34
|
-
responses.raise_for_status()
|
|
35
|
-
return PagedResponse[StreamResponse].model_validate(responses.get_first_body()).items
|
|
41
|
+
return self._request_item_response(items, "create")
|
|
36
42
|
|
|
37
|
-
def delete(self,
|
|
38
|
-
"""Delete
|
|
43
|
+
def delete(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
44
|
+
"""Delete streams using their external IDs.
|
|
39
45
|
|
|
40
46
|
Args:
|
|
41
|
-
|
|
47
|
+
items: Sequence of ExternalId objects to delete.
|
|
48
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
42
49
|
"""
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
)
|
|
48
|
-
)
|
|
49
|
-
responses.raise_for_status()
|
|
50
|
+
if ignore_unknown_ids:
|
|
51
|
+
# The endpoint does not support ignoreUnknownIds, so we have to do it on the client side
|
|
52
|
+
return self._request_item_split_retries_no_response(items, "delete")
|
|
53
|
+
else:
|
|
54
|
+
return self._request_no_response(items, "delete")
|
|
50
55
|
|
|
51
|
-
def
|
|
52
|
-
|
|
56
|
+
def retrieve(
|
|
57
|
+
self, items: Sequence[ExternalId], include_statistics: bool = False, ignore_unknown_ids: bool = False
|
|
58
|
+
) -> list[StreamResponse]:
|
|
59
|
+
"""Retrieve streams by their external IDs.
|
|
60
|
+
|
|
61
|
+
Note: The streams API only supports retrieving one stream at a time via path parameter.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
items: Sequence of ExternalId objects to retrieve.
|
|
65
|
+
include_statistics: Whether to include usage statistics in the response.
|
|
66
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
53
67
|
|
|
54
68
|
Returns:
|
|
55
|
-
|
|
69
|
+
List of StreamResponse items.
|
|
56
70
|
"""
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
results: list[StreamResponse] = []
|
|
72
|
+
endpoint = self._method_endpoint_map["retrieve"]
|
|
73
|
+
for item in items:
|
|
74
|
+
response = self._http_client.request_single_retries(
|
|
75
|
+
RequestMessage2(
|
|
76
|
+
endpoint_url=self._make_url(endpoint.path.format(streamId=item.external_id)),
|
|
77
|
+
method=endpoint.method,
|
|
78
|
+
parameters={"includeStatistics": include_statistics},
|
|
79
|
+
)
|
|
61
80
|
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
81
|
+
if isinstance(response, SuccessResponse2):
|
|
82
|
+
results.append(StreamResponse.model_validate(response.body_json))
|
|
83
|
+
elif ignore_unknown_ids:
|
|
84
|
+
continue
|
|
85
|
+
_ = response.get_success_or_raise()
|
|
86
|
+
return results
|
|
65
87
|
|
|
66
|
-
def
|
|
67
|
-
"""
|
|
88
|
+
def list(self) -> list[StreamResponse]:
|
|
89
|
+
"""List all streams.
|
|
90
|
+
|
|
91
|
+
Note: The streams API does not support pagination.
|
|
68
92
|
|
|
69
|
-
Args:
|
|
70
|
-
external_id: External ID of the stream to retrieve.
|
|
71
|
-
include_statistics: Whether to include usage statistics in the response.
|
|
72
93
|
Returns:
|
|
73
|
-
StreamResponse
|
|
94
|
+
List of StreamResponse items.
|
|
74
95
|
"""
|
|
75
|
-
|
|
76
|
-
ParamRequest(
|
|
77
|
-
endpoint_url=self._config.create_api_url(f"{self.ENDPOINT}/{external_id}"),
|
|
78
|
-
method="GET",
|
|
79
|
-
parameters={"includeStatistics": include_statistics},
|
|
80
|
-
)
|
|
81
|
-
)
|
|
82
|
-
responses.raise_for_status()
|
|
83
|
-
response_body = responses.get_first_body()
|
|
84
|
-
return StreamResponse.model_validate(response_body)
|
|
96
|
+
return self._list(limit=None)
|