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,358 @@
|
|
|
1
|
+
"""Base classes for resource clients.
|
|
2
|
+
|
|
3
|
+
This module provides the base infrastructure for resource-specific clients
|
|
4
|
+
that handle CRUD operations for CDF Data Modeling API resources.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from abc import ABC, abstractmethod
|
|
8
|
+
from collections import defaultdict
|
|
9
|
+
from collections.abc import Callable, Iterable, Sequence
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from functools import partial
|
|
12
|
+
from typing import Any, Generic, Literal, TypeAlias
|
|
13
|
+
|
|
14
|
+
from pydantic import JsonValue
|
|
15
|
+
|
|
16
|
+
from cognite_toolkit._cdf_tk.client._resource_base import (
|
|
17
|
+
RequestItem,
|
|
18
|
+
T_Identifier,
|
|
19
|
+
T_RequestResource,
|
|
20
|
+
T_ResponseResource,
|
|
21
|
+
UpdatableRequestResource,
|
|
22
|
+
)
|
|
23
|
+
from cognite_toolkit._cdf_tk.client.http_client import (
|
|
24
|
+
HTTPClient,
|
|
25
|
+
ItemsRequest2,
|
|
26
|
+
ItemsSuccessResponse2,
|
|
27
|
+
RequestMessage2,
|
|
28
|
+
SuccessResponse2,
|
|
29
|
+
)
|
|
30
|
+
from cognite_toolkit._cdf_tk.utils.collection import chunker_sequence
|
|
31
|
+
|
|
32
|
+
from .responses import PagedResponse
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass(frozen=True)
|
|
36
|
+
class Endpoint:
|
|
37
|
+
method: Literal["GET", "POST", "PUT", "PATCH", "DELETE"]
|
|
38
|
+
path: str
|
|
39
|
+
item_limit: int
|
|
40
|
+
concurrency_max_workers: int = 1
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
APIMethod: TypeAlias = Literal["create", "retrieve", "update", "delete", "list", "upsert"]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class CDFResourceAPI(Generic[T_Identifier, T_RequestResource, T_ResponseResource], ABC):
|
|
47
|
+
"""Generic resource API for CDF APIs
|
|
48
|
+
|
|
49
|
+
This class provides the logic for working with CDF resources,
|
|
50
|
+
including creating, retrieving, deleting, and listing resources.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def __init__(
|
|
54
|
+
self, http_client: HTTPClient, method_endpoint_map: dict[APIMethod, Endpoint], disable_gzip: bool = False
|
|
55
|
+
) -> None:
|
|
56
|
+
"""Initialize the resource API.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
http_client: The HTTP client to use for API requests.
|
|
60
|
+
method_endpoint_map: A mapping of endpoint suffixes to their properties.
|
|
61
|
+
disable_gzip: Whether to disable gzip compression for requests. Defaults to False.
|
|
62
|
+
This is only used by the robotics API. If that API is dropped, this parameter can be removed.
|
|
63
|
+
"""
|
|
64
|
+
self._http_client = http_client
|
|
65
|
+
self._method_endpoint_map = method_endpoint_map
|
|
66
|
+
self._disable_gzip = disable_gzip
|
|
67
|
+
|
|
68
|
+
@classmethod
|
|
69
|
+
def _serialize_items(cls, items: Sequence[RequestItem]) -> list[dict[str, JsonValue]]:
|
|
70
|
+
"""Serialize reference objects to JSON-compatible dicts."""
|
|
71
|
+
return [item.dump() for item in items]
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def _serialize_updates(
|
|
75
|
+
cls, items: Sequence[UpdatableRequestResource], mode: Literal["patch", "replace"]
|
|
76
|
+
) -> list[dict[str, JsonValue]]:
|
|
77
|
+
"""Serialize updateable objects to JSON-compatible dicts."""
|
|
78
|
+
return [item.as_update(mode=mode) for item in items]
|
|
79
|
+
|
|
80
|
+
@abstractmethod
|
|
81
|
+
def _validate_page_response(
|
|
82
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
83
|
+
) -> PagedResponse[T_ResponseResource]:
|
|
84
|
+
"""Parse a single item response."""
|
|
85
|
+
raise NotImplementedError()
|
|
86
|
+
|
|
87
|
+
def _make_url(self, path: str = "") -> str:
|
|
88
|
+
"""Create the full URL for this resource endpoint."""
|
|
89
|
+
return self._http_client.config.create_api_url(path)
|
|
90
|
+
|
|
91
|
+
def _update(
|
|
92
|
+
self, items: Sequence[UpdatableRequestResource], mode: Literal["patch", "replace"]
|
|
93
|
+
) -> list[T_ResponseResource]:
|
|
94
|
+
"""Update resources in chunks."""
|
|
95
|
+
response_items: list[T_ResponseResource] = []
|
|
96
|
+
for response in self._chunk_requests(
|
|
97
|
+
items, "update", serialization=partial(self._serialize_updates, mode=mode)
|
|
98
|
+
):
|
|
99
|
+
response_items.extend(self._validate_page_response(response).items)
|
|
100
|
+
return response_items
|
|
101
|
+
|
|
102
|
+
def _request_item_response(
|
|
103
|
+
self,
|
|
104
|
+
items: Sequence[RequestItem],
|
|
105
|
+
method: APIMethod,
|
|
106
|
+
params: dict[str, Any] | None = None,
|
|
107
|
+
extra_body: dict[str, Any] | None = None,
|
|
108
|
+
endpoint: str | None = None,
|
|
109
|
+
) -> list[T_ResponseResource]:
|
|
110
|
+
response_items: list[T_ResponseResource] = []
|
|
111
|
+
for response in self._chunk_requests(items, method, self._serialize_items, params, extra_body, endpoint):
|
|
112
|
+
response_items.extend(self._validate_page_response(response).items)
|
|
113
|
+
return response_items
|
|
114
|
+
|
|
115
|
+
def _request_no_response(
|
|
116
|
+
self,
|
|
117
|
+
items: Sequence[RequestItem],
|
|
118
|
+
method: APIMethod,
|
|
119
|
+
params: dict[str, Any] | None = None,
|
|
120
|
+
extra_body: dict[str, Any] | None = None,
|
|
121
|
+
endpoint: str | None = None,
|
|
122
|
+
) -> None:
|
|
123
|
+
list(self._chunk_requests(items, method, self._serialize_items, params, extra_body, endpoint))
|
|
124
|
+
return None
|
|
125
|
+
|
|
126
|
+
def _chunk_requests(
|
|
127
|
+
self,
|
|
128
|
+
items: Sequence[RequestItem],
|
|
129
|
+
method: APIMethod,
|
|
130
|
+
serialization: Callable[[Sequence[RequestItem]], list[dict[str, JsonValue]]],
|
|
131
|
+
params: dict[str, Any] | None = None,
|
|
132
|
+
extra_body: dict[str, Any] | None = None,
|
|
133
|
+
endpoint_path: str | None = None,
|
|
134
|
+
) -> Iterable[SuccessResponse2]:
|
|
135
|
+
"""Send requests in chunks and yield responses.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
items: The items to process.
|
|
139
|
+
method: The API method to use. This is used ot look the up the endpoint.
|
|
140
|
+
serialization: A function to serialize the items to JSON-compatible dicts.
|
|
141
|
+
params: Optional query parameters for the request.
|
|
142
|
+
extra_body: Optional extra body content to include in the request.
|
|
143
|
+
endpoint_path: Optional override for the endpoint path.
|
|
144
|
+
|
|
145
|
+
Yields:
|
|
146
|
+
The successful responses from the API.
|
|
147
|
+
"""
|
|
148
|
+
# Filter out None
|
|
149
|
+
request_params = self._filter_out_none_values(params)
|
|
150
|
+
endpoint = self._method_endpoint_map[method]
|
|
151
|
+
|
|
152
|
+
for chunk in chunker_sequence(items, endpoint.item_limit):
|
|
153
|
+
request = RequestMessage2(
|
|
154
|
+
endpoint_url=f"{self._make_url(endpoint_path or endpoint.path)}",
|
|
155
|
+
method=endpoint.method,
|
|
156
|
+
body_content={"items": serialization(chunk), **(extra_body or {})}, # type: ignore[dict-item]
|
|
157
|
+
parameters=request_params,
|
|
158
|
+
disable_gzip=self._disable_gzip,
|
|
159
|
+
)
|
|
160
|
+
response = self._http_client.request_single_retries(request)
|
|
161
|
+
yield response.get_success_or_raise()
|
|
162
|
+
|
|
163
|
+
def _request_item_split_retries(
|
|
164
|
+
self,
|
|
165
|
+
items: Sequence[RequestItem],
|
|
166
|
+
method: APIMethod,
|
|
167
|
+
params: dict[str, Any] | None = None,
|
|
168
|
+
extra_body: dict[str, Any] | None = None,
|
|
169
|
+
) -> list[T_ResponseResource]:
|
|
170
|
+
"""Request items with retries, splitting on failures.
|
|
171
|
+
|
|
172
|
+
This method handles large batches of items by chunking them according to the endpoint's item limit.
|
|
173
|
+
If a single item fails, it splits the request into individual item requests to isolate the failure.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
items: Sequence of items to request.
|
|
177
|
+
method: API method to use for the request.
|
|
178
|
+
params: Optional query parameters for the request.
|
|
179
|
+
extra_body: Optional additional body fields for the request.
|
|
180
|
+
Returns:
|
|
181
|
+
List of response items.
|
|
182
|
+
"""
|
|
183
|
+
response_items: list[T_ResponseResource] = []
|
|
184
|
+
for response in self._chunk_requests_items_split_retries(items, method, params, extra_body):
|
|
185
|
+
response_items.extend(self._validate_page_response(response).items)
|
|
186
|
+
return response_items
|
|
187
|
+
|
|
188
|
+
def _request_item_split_retries_no_response(
|
|
189
|
+
self,
|
|
190
|
+
items: Sequence[RequestItem],
|
|
191
|
+
method: APIMethod,
|
|
192
|
+
params: dict[str, Any] | None = None,
|
|
193
|
+
extra_body: dict[str, Any] | None = None,
|
|
194
|
+
) -> None:
|
|
195
|
+
"""Request items with retries, splitting on failures, without returning any response.
|
|
196
|
+
|
|
197
|
+
This method handles large batches of items by chunking them according to the endpoint's item limit.
|
|
198
|
+
If a single item fails, it splits the request into individual item requests to isolate the failure.
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
items: Sequence of items to request.
|
|
202
|
+
method: API method to use for the request.
|
|
203
|
+
params: Optional query parameters for the request.
|
|
204
|
+
extra_body: Optional additional body fields for the request.
|
|
205
|
+
"""
|
|
206
|
+
list(self._chunk_requests_items_split_retries(items, method, params, extra_body))
|
|
207
|
+
return None
|
|
208
|
+
|
|
209
|
+
def _chunk_requests_items_split_retries(
|
|
210
|
+
self,
|
|
211
|
+
items: Sequence[RequestItem],
|
|
212
|
+
method: APIMethod,
|
|
213
|
+
params: dict[str, Any] | None = None,
|
|
214
|
+
extra_body: dict[str, Any] | None = None,
|
|
215
|
+
) -> Iterable[ItemsSuccessResponse2]:
|
|
216
|
+
"""Request items with retries and splitting on failures.
|
|
217
|
+
|
|
218
|
+
This method handles large batches of items by chunking them according to the endpoint's item limit.
|
|
219
|
+
If a single item fails, it splits the request into individual item requests to isolate the failure.
|
|
220
|
+
|
|
221
|
+
This can be useful to create ignore unknown IDs behavior when retrieving items for API endpoints that
|
|
222
|
+
do not support it natively.
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
items: Sequence of items to request.
|
|
226
|
+
method: API method to use for the request.
|
|
227
|
+
params: Optional query parameters for the request.
|
|
228
|
+
extra_body: Optional additional body fields for the request.
|
|
229
|
+
Yields
|
|
230
|
+
SuccessResponse2: Successful responses from the API. All failed items are skipped.
|
|
231
|
+
|
|
232
|
+
"""
|
|
233
|
+
# Filter out None
|
|
234
|
+
request_params = self._filter_out_none_values(params)
|
|
235
|
+
endpoint = self._method_endpoint_map[method]
|
|
236
|
+
|
|
237
|
+
for chunk in chunker_sequence(items, endpoint.item_limit):
|
|
238
|
+
request = ItemsRequest2(
|
|
239
|
+
endpoint_url=f"{self._make_url(endpoint.path)}",
|
|
240
|
+
method=endpoint.method,
|
|
241
|
+
parameters=request_params,
|
|
242
|
+
items=chunk,
|
|
243
|
+
extra_body_fields=extra_body,
|
|
244
|
+
disable_gzip=self._disable_gzip,
|
|
245
|
+
)
|
|
246
|
+
responses = self._http_client.request_items_retries(request)
|
|
247
|
+
for response in responses:
|
|
248
|
+
if isinstance(response, ItemsSuccessResponse2):
|
|
249
|
+
yield response
|
|
250
|
+
|
|
251
|
+
@classmethod
|
|
252
|
+
def _filter_out_none_values(cls, params: dict[str, Any] | None) -> dict[str, Any] | None:
|
|
253
|
+
request_params: dict[str, Any] | None = None
|
|
254
|
+
if params:
|
|
255
|
+
request_params = {k: v for k, v in params.items() if v is not None}
|
|
256
|
+
return request_params
|
|
257
|
+
|
|
258
|
+
@classmethod
|
|
259
|
+
def _group_items_by_text_field(
|
|
260
|
+
cls, items: Sequence[RequestItem], *field_names: str
|
|
261
|
+
) -> dict[tuple[str, ...], list[RequestItem]]:
|
|
262
|
+
"""Group items by a text field."""
|
|
263
|
+
grouped_items: dict[tuple[str, ...], list[RequestItem]] = defaultdict(list)
|
|
264
|
+
for item in items:
|
|
265
|
+
key = tuple(str(getattr(item, field_name)) for field_name in field_names)
|
|
266
|
+
grouped_items[key].append(item)
|
|
267
|
+
return grouped_items
|
|
268
|
+
|
|
269
|
+
def _paginate(
|
|
270
|
+
self,
|
|
271
|
+
limit: int,
|
|
272
|
+
cursor: str | None = None,
|
|
273
|
+
params: dict[str, Any] | None = None,
|
|
274
|
+
body: dict[str, Any] | None = None,
|
|
275
|
+
endpoint_path: str | None = None,
|
|
276
|
+
) -> PagedResponse[T_ResponseResource]:
|
|
277
|
+
"""Fetch a single page of resources.
|
|
278
|
+
|
|
279
|
+
Args:
|
|
280
|
+
params: Query parameters for the request. Supported parameters depend on
|
|
281
|
+
the resource type but typically include:
|
|
282
|
+
- cursor: Cursor for pagination
|
|
283
|
+
- limit: Maximum number of items (defaults to list limit)
|
|
284
|
+
- space: Filter by space
|
|
285
|
+
- includeGlobal: Whether to include global resources
|
|
286
|
+
body : Body content for the request, if applicable.
|
|
287
|
+
limit: Maximum number of items to return in the page.
|
|
288
|
+
cursor: Cursor for pagination.
|
|
289
|
+
limit: Maximum number of items to return in the page.
|
|
290
|
+
cursor: Cursor for pagination.
|
|
291
|
+
|
|
292
|
+
Returns:
|
|
293
|
+
A Page containing the items and the cursor for the next page.
|
|
294
|
+
"""
|
|
295
|
+
endpoint = self._method_endpoint_map["list"]
|
|
296
|
+
if not (0 < limit <= endpoint.item_limit):
|
|
297
|
+
raise ValueError(f"Limit must be between 1 and {endpoint.item_limit}, got {limit}.")
|
|
298
|
+
|
|
299
|
+
request_params = self._filter_out_none_values(params) or {}
|
|
300
|
+
body = self._filter_out_none_values(body) or {}
|
|
301
|
+
if endpoint.method == "GET":
|
|
302
|
+
request_params["limit"] = limit
|
|
303
|
+
if cursor is not None:
|
|
304
|
+
request_params["cursor"] = cursor
|
|
305
|
+
elif endpoint.method in {"POST", "PUT", "PATCH"}:
|
|
306
|
+
body["limit"] = limit
|
|
307
|
+
if cursor is not None:
|
|
308
|
+
body["cursor"] = cursor
|
|
309
|
+
else:
|
|
310
|
+
raise NotImplementedError(f"Unsupported method {endpoint.method} for pagination.")
|
|
311
|
+
|
|
312
|
+
request = RequestMessage2(
|
|
313
|
+
endpoint_url=self._make_url(endpoint_path or endpoint.path),
|
|
314
|
+
method=endpoint.method,
|
|
315
|
+
parameters=request_params,
|
|
316
|
+
body_content=body,
|
|
317
|
+
disable_gzip=self._disable_gzip,
|
|
318
|
+
)
|
|
319
|
+
result = self._http_client.request_single_retries(request)
|
|
320
|
+
response = result.get_success_or_raise()
|
|
321
|
+
return self._validate_page_response(response)
|
|
322
|
+
|
|
323
|
+
def _iterate(
|
|
324
|
+
self,
|
|
325
|
+
limit: int | None = None,
|
|
326
|
+
cursor: str | None = None,
|
|
327
|
+
params: dict[str, Any] | None = None,
|
|
328
|
+
body: dict[str, Any] | None = None,
|
|
329
|
+
endpoint_path: str | None = None,
|
|
330
|
+
) -> Iterable[list[T_ResponseResource]]:
|
|
331
|
+
"""Iterate over all resources, handling pagination automatically."""
|
|
332
|
+
next_cursor = cursor
|
|
333
|
+
total = 0
|
|
334
|
+
endpoint = self._method_endpoint_map["list"]
|
|
335
|
+
while True:
|
|
336
|
+
page_limit = endpoint.item_limit if limit is None else min(limit - total, endpoint.item_limit)
|
|
337
|
+
page = self._paginate(
|
|
338
|
+
limit=page_limit, cursor=next_cursor, params=params, body=body, endpoint_path=endpoint_path
|
|
339
|
+
)
|
|
340
|
+
yield page.items
|
|
341
|
+
total += len(page.items)
|
|
342
|
+
if page.next_cursor is None or (limit is not None and total >= limit):
|
|
343
|
+
break
|
|
344
|
+
next_cursor = page.next_cursor
|
|
345
|
+
|
|
346
|
+
def _list(
|
|
347
|
+
self,
|
|
348
|
+
limit: int | None = None,
|
|
349
|
+
params: dict[str, Any] | None = None,
|
|
350
|
+
endpoint_path: str | None = None,
|
|
351
|
+
body: dict[str, Any] | None = None,
|
|
352
|
+
) -> list[T_ResponseResource]:
|
|
353
|
+
"""List all resources, handling pagination automatically."""
|
|
354
|
+
return [
|
|
355
|
+
item
|
|
356
|
+
for batch in self._iterate(limit=limit, params=params, endpoint_path=endpoint_path, body=body)
|
|
357
|
+
for item in batch
|
|
358
|
+
]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import Generic, TypeVar
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field, JsonValue
|
|
4
|
+
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.graphql_data_model import GraphQLDataModelResponse
|
|
6
|
+
|
|
7
|
+
T = TypeVar("T", bound=BaseModel)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ResponseItems(BaseModel, Generic[T]):
|
|
11
|
+
"""A page of reference items from a paginated API response.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
items: The list of reference items in this page.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
items: list[T]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class PagedResponse(BaseModel, Generic[T]):
|
|
21
|
+
items: list[T]
|
|
22
|
+
next_cursor: str | None = Field(None, alias="nextCursor")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class QueryResponse(BaseModel, Generic[T]):
|
|
26
|
+
items: dict[str, list[T]]
|
|
27
|
+
typing: dict[str, JsonValue] | None = None
|
|
28
|
+
next_cursor: dict[str, str] = Field(alias="nextCursor")
|
|
29
|
+
debug: dict[str, JsonValue] | None = None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class GraphQLResponse(BaseModel):
|
|
33
|
+
data: GraphQLDataModelResponse
|
|
34
|
+
errors: list[dict[str, JsonValue]] | None = None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class GraphQLUpsertResponse(BaseModel):
|
|
38
|
+
upsert_graph_ql_dml_version: GraphQLResponse = Field(alias="upsertGraphQlDmlVersion")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from ._client import HTTPClient
|
|
2
2
|
from ._data_classes import (
|
|
3
|
+
T_COVARIANT_ID,
|
|
3
4
|
DataBodyRequest,
|
|
4
5
|
ErrorDetails,
|
|
5
6
|
FailedRequestItems,
|
|
@@ -10,6 +11,7 @@ from ._data_classes import (
|
|
|
10
11
|
ItemMessage,
|
|
11
12
|
ItemsRequest,
|
|
12
13
|
ParamRequest,
|
|
14
|
+
RequestItem,
|
|
13
15
|
RequestMessage,
|
|
14
16
|
ResponseList,
|
|
15
17
|
ResponseMessage,
|
|
@@ -17,25 +19,53 @@ from ._data_classes import (
|
|
|
17
19
|
SuccessResponse,
|
|
18
20
|
SuccessResponseItems,
|
|
19
21
|
)
|
|
22
|
+
from ._data_classes2 import (
|
|
23
|
+
ErrorDetails2,
|
|
24
|
+
FailedRequest2,
|
|
25
|
+
FailedResponse2,
|
|
26
|
+
HTTPResult2,
|
|
27
|
+
RequestMessage2,
|
|
28
|
+
SuccessResponse2,
|
|
29
|
+
)
|
|
20
30
|
from ._exception import ToolkitAPIError
|
|
31
|
+
from ._item_classes import (
|
|
32
|
+
ItemsFailedRequest2,
|
|
33
|
+
ItemsFailedResponse2,
|
|
34
|
+
ItemsRequest2,
|
|
35
|
+
ItemsResultMessage2,
|
|
36
|
+
ItemsSuccessResponse2,
|
|
37
|
+
)
|
|
21
38
|
|
|
22
39
|
__all__ = [
|
|
40
|
+
"T_COVARIANT_ID",
|
|
23
41
|
"DataBodyRequest",
|
|
24
42
|
"ErrorDetails",
|
|
43
|
+
"ErrorDetails2",
|
|
44
|
+
"FailedRequest2",
|
|
25
45
|
"FailedRequestItems",
|
|
26
46
|
"FailedRequestMessage",
|
|
27
47
|
"FailedResponse",
|
|
48
|
+
"FailedResponse2",
|
|
28
49
|
"FailedResponseItems",
|
|
29
50
|
"HTTPClient",
|
|
30
51
|
"HTTPMessage",
|
|
52
|
+
"HTTPResult2",
|
|
31
53
|
"ItemMessage",
|
|
54
|
+
"ItemsFailedRequest2",
|
|
55
|
+
"ItemsFailedResponse2",
|
|
32
56
|
"ItemsRequest",
|
|
57
|
+
"ItemsRequest2",
|
|
58
|
+
"ItemsResultMessage2",
|
|
59
|
+
"ItemsSuccessResponse2",
|
|
33
60
|
"ParamRequest",
|
|
61
|
+
"RequestItem",
|
|
34
62
|
"RequestMessage",
|
|
63
|
+
"RequestMessage2",
|
|
35
64
|
"ResponseList",
|
|
36
65
|
"ResponseMessage",
|
|
37
66
|
"SimpleBodyRequest",
|
|
38
67
|
"SuccessResponse",
|
|
68
|
+
"SuccessResponse2",
|
|
39
69
|
"SuccessResponseItems",
|
|
40
70
|
"ToolkitAPIError",
|
|
41
71
|
]
|
|
@@ -10,9 +10,7 @@ import httpx
|
|
|
10
10
|
from cognite.client import global_config
|
|
11
11
|
from rich.console import Console
|
|
12
12
|
|
|
13
|
-
from cognite_toolkit._cdf_tk.
|
|
14
|
-
from cognite_toolkit._cdf_tk.utils.auxiliary import get_current_toolkit_version, get_user_agent
|
|
15
|
-
from cognite_toolkit._cdf_tk.utils.http_client._data_classes import (
|
|
13
|
+
from cognite_toolkit._cdf_tk.client.http_client._data_classes import (
|
|
16
14
|
BodyRequest,
|
|
17
15
|
DataBodyRequest,
|
|
18
16
|
FailedRequestMessage,
|
|
@@ -23,20 +21,25 @@ from cognite_toolkit._cdf_tk.utils.http_client._data_classes import (
|
|
|
23
21
|
ResponseList,
|
|
24
22
|
ResponseMessage,
|
|
25
23
|
)
|
|
26
|
-
from cognite_toolkit._cdf_tk.
|
|
24
|
+
from cognite_toolkit._cdf_tk.client.http_client._data_classes2 import (
|
|
27
25
|
BaseRequestMessage,
|
|
28
26
|
ErrorDetails2,
|
|
29
27
|
FailedRequest2,
|
|
30
28
|
FailedResponse2,
|
|
31
29
|
HTTPResult2,
|
|
30
|
+
RequestMessage2,
|
|
31
|
+
SuccessResponse2,
|
|
32
|
+
)
|
|
33
|
+
from cognite_toolkit._cdf_tk.client.http_client._item_classes import (
|
|
32
34
|
ItemsFailedRequest2,
|
|
33
35
|
ItemsFailedResponse2,
|
|
34
36
|
ItemsRequest2,
|
|
37
|
+
ItemsResultList,
|
|
35
38
|
ItemsResultMessage2,
|
|
36
39
|
ItemsSuccessResponse2,
|
|
37
|
-
RequestMessage2,
|
|
38
|
-
SuccessResponse2,
|
|
39
40
|
)
|
|
41
|
+
from cognite_toolkit._cdf_tk.tk_warnings import HighSeverityWarning
|
|
42
|
+
from cognite_toolkit._cdf_tk.utils.auxiliary import get_current_toolkit_version, get_user_agent
|
|
40
43
|
from cognite_toolkit._cdf_tk.utils.useful_types import PrimitiveType
|
|
41
44
|
|
|
42
45
|
if sys.version_info >= (3, 11):
|
|
@@ -171,6 +174,7 @@ class HTTPClient:
|
|
|
171
174
|
content_type: str = "application/json",
|
|
172
175
|
accept: str = "application/json",
|
|
173
176
|
content_length: int | None = None,
|
|
177
|
+
disable_gzip: bool = False,
|
|
174
178
|
) -> MutableMapping[str, str]:
|
|
175
179
|
headers: MutableMapping[str, str] = {}
|
|
176
180
|
headers["User-Agent"] = f"httpx/{httpx.__version__} {get_user_agent()}"
|
|
@@ -183,7 +187,7 @@ class HTTPClient:
|
|
|
183
187
|
headers["x-cdp-sdk"] = f"CogniteToolkit:{get_current_toolkit_version()}"
|
|
184
188
|
headers["x-cdp-app"] = self.config.client_name
|
|
185
189
|
headers["cdf-version"] = api_version or self.config.api_subversion
|
|
186
|
-
if not global_config.disable_gzip and content_length is None:
|
|
190
|
+
if not global_config.disable_gzip and content_length is None and not disable_gzip:
|
|
187
191
|
headers["Content-Encoding"] = "gzip"
|
|
188
192
|
return headers
|
|
189
193
|
|
|
@@ -331,7 +335,13 @@ class HTTPClient:
|
|
|
331
335
|
raise TypeError(f"Unexpected result type: {type(result)}")
|
|
332
336
|
|
|
333
337
|
def _make_request2(self, message: BaseRequestMessage) -> httpx.Response:
|
|
334
|
-
headers = self._create_headers(
|
|
338
|
+
headers = self._create_headers(
|
|
339
|
+
message.api_version,
|
|
340
|
+
message.content_type,
|
|
341
|
+
message.accept,
|
|
342
|
+
content_length=message.content_length,
|
|
343
|
+
disable_gzip=message.disable_gzip,
|
|
344
|
+
)
|
|
335
345
|
return self.session.request(
|
|
336
346
|
method=message.method,
|
|
337
347
|
url=message.endpoint_url,
|
|
@@ -413,7 +423,7 @@ class HTTPClient:
|
|
|
413
423
|
if message.tracker and message.tracker.limit_reached():
|
|
414
424
|
return [
|
|
415
425
|
ItemsFailedRequest2(
|
|
416
|
-
ids=[item
|
|
426
|
+
ids=[str(item) for item in message.items],
|
|
417
427
|
error_message=f"Aborting further splitting of requests after {message.tracker.failed_split_count} failed attempts.",
|
|
418
428
|
)
|
|
419
429
|
]
|
|
@@ -424,7 +434,7 @@ class HTTPClient:
|
|
|
424
434
|
results = self._handle_items_error(e, message)
|
|
425
435
|
return results
|
|
426
436
|
|
|
427
|
-
def request_items_retries(self, message: ItemsRequest2) ->
|
|
437
|
+
def request_items_retries(self, message: ItemsRequest2) -> ItemsResultList:
|
|
428
438
|
"""Send an HTTP request with multiple items and handle retries.
|
|
429
439
|
|
|
430
440
|
This method will keep retrying the request until it either succeeds or
|
|
@@ -442,7 +452,7 @@ class HTTPClient:
|
|
|
442
452
|
raise RuntimeError(f"ItemsRequest2 has already been attempted {message.total_attempts} times.")
|
|
443
453
|
pending_requests: deque[ItemsRequest2] = deque()
|
|
444
454
|
pending_requests.append(message)
|
|
445
|
-
final_responses
|
|
455
|
+
final_responses = ItemsResultList([])
|
|
446
456
|
while pending_requests:
|
|
447
457
|
current_request = pending_requests.popleft()
|
|
448
458
|
results = self.request_items(current_request)
|
|
@@ -463,7 +473,7 @@ class HTTPClient:
|
|
|
463
473
|
if 200 <= response.status_code < 300:
|
|
464
474
|
return [
|
|
465
475
|
ItemsSuccessResponse2(
|
|
466
|
-
ids=[item
|
|
476
|
+
ids=[str(item) for item in request.items],
|
|
467
477
|
status_code=response.status_code,
|
|
468
478
|
body=response.text,
|
|
469
479
|
content=response.content,
|
|
@@ -479,7 +489,7 @@ class HTTPClient:
|
|
|
479
489
|
if splits[0].tracker and splits[0].tracker.limit_reached():
|
|
480
490
|
return [
|
|
481
491
|
ItemsFailedResponse2(
|
|
482
|
-
ids=[item
|
|
492
|
+
ids=[str(item) for item in request.items],
|
|
483
493
|
status_code=response.status_code,
|
|
484
494
|
body=response.text,
|
|
485
495
|
error=ErrorDetails2.from_response(response),
|
|
@@ -493,7 +503,7 @@ class HTTPClient:
|
|
|
493
503
|
# Permanent failure
|
|
494
504
|
return [
|
|
495
505
|
ItemsFailedResponse2(
|
|
496
|
-
ids=[item
|
|
506
|
+
ids=[str(item) for item in request.items],
|
|
497
507
|
status_code=response.status_code,
|
|
498
508
|
body=response.text,
|
|
499
509
|
error=ErrorDetails2.from_response(response),
|
|
@@ -515,7 +525,7 @@ class HTTPClient:
|
|
|
515
525
|
error_msg = f"Unexpected exception: {e!s}"
|
|
516
526
|
return [
|
|
517
527
|
ItemsFailedRequest2(
|
|
518
|
-
ids=[item
|
|
528
|
+
ids=[str(item) for item in request.items],
|
|
519
529
|
error_message=error_msg,
|
|
520
530
|
)
|
|
521
531
|
]
|
|
@@ -529,7 +539,7 @@ class HTTPClient:
|
|
|
529
539
|
|
|
530
540
|
return [
|
|
531
541
|
ItemsFailedRequest2(
|
|
532
|
-
ids=[item
|
|
542
|
+
ids=[str(item) for item in request.items],
|
|
533
543
|
error_message=error_msg,
|
|
534
544
|
)
|
|
535
545
|
]
|
|
@@ -7,8 +7,8 @@ from typing import Generic, Literal, Protocol, TypeAlias, TypeVar
|
|
|
7
7
|
import httpx
|
|
8
8
|
from cognite.client.utils import _json
|
|
9
9
|
|
|
10
|
-
from cognite_toolkit._cdf_tk.
|
|
11
|
-
from cognite_toolkit._cdf_tk.
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.http_client._exception import ToolkitAPIError
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.http_client._tracker import ItemsRequestTracker
|
|
12
12
|
from cognite_toolkit._cdf_tk.utils.useful_types import JsonVal, PrimitiveType
|
|
13
13
|
|
|
14
14
|
StatusCode: TypeAlias = int
|
|
@@ -76,6 +76,9 @@ class ErrorDetails:
|
|
|
76
76
|
class FailedRequestMessage(HTTPMessage):
|
|
77
77
|
error: str
|
|
78
78
|
|
|
79
|
+
def __str__(self) -> str:
|
|
80
|
+
return self.error
|
|
81
|
+
|
|
79
82
|
|
|
80
83
|
@dataclass
|
|
81
84
|
class ResponseMessage(HTTPMessage):
|
|
@@ -135,6 +138,9 @@ class FailedResponse(ResponseMessage):
|
|
|
135
138
|
output["error"] = self.error.dump()
|
|
136
139
|
return output
|
|
137
140
|
|
|
141
|
+
def __str__(self) -> str:
|
|
142
|
+
return f"{self.error.code} | {self.error.message}"
|
|
143
|
+
|
|
138
144
|
|
|
139
145
|
@dataclass
|
|
140
146
|
class SimpleRequest(RequestMessage):
|
|
@@ -301,6 +307,11 @@ class ItemsRequest(Generic[T_COVARIANT_ID], BodyRequest):
|
|
|
301
307
|
connect_attempt=self.connect_attempt,
|
|
302
308
|
read_attempt=self.read_attempt,
|
|
303
309
|
status_attempt=status_attempts,
|
|
310
|
+
api_version=self.api_version,
|
|
311
|
+
content_type=self.content_type,
|
|
312
|
+
accept=self.accept,
|
|
313
|
+
content_length=self.content_length,
|
|
314
|
+
max_failures_before_abort=self.max_failures_before_abort,
|
|
304
315
|
)
|
|
305
316
|
first_half.tracker = tracker
|
|
306
317
|
second_half = ItemsRequest[T_COVARIANT_ID](
|
|
@@ -311,6 +322,11 @@ class ItemsRequest(Generic[T_COVARIANT_ID], BodyRequest):
|
|
|
311
322
|
connect_attempt=self.connect_attempt,
|
|
312
323
|
read_attempt=self.read_attempt,
|
|
313
324
|
status_attempt=status_attempts,
|
|
325
|
+
api_version=self.api_version,
|
|
326
|
+
content_type=self.content_type,
|
|
327
|
+
accept=self.accept,
|
|
328
|
+
content_length=self.content_length,
|
|
329
|
+
max_failures_before_abort=self.max_failures_before_abort,
|
|
314
330
|
)
|
|
315
331
|
second_half.tracker = tracker
|
|
316
332
|
return [first_half, second_half]
|