cognite-toolkit 0.7.30__py3-none-any.whl → 0.7.39__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 +177 -2
- cognite_toolkit/_cdf_tk/builders/_raw.py +1 -1
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +9 -9
- cognite_toolkit/_cdf_tk/client/api/infield.py +38 -33
- cognite_toolkit/_cdf_tk/client/api/{canvas.py → legacy/canvas.py} +15 -7
- 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/{location_filters.py → legacy/location_filters.py} +1 -1
- 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/{search_config.py → legacy/search_config.py} +5 -1
- 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/search.py +2 -2
- cognite_toolkit/_cdf_tk/client/api/streams.py +21 -17
- cognite_toolkit/_cdf_tk/client/api/three_d.py +343 -9
- cognite_toolkit/_cdf_tk/client/data_classes/api_classes.py +13 -0
- cognite_toolkit/_cdf_tk/client/data_classes/base.py +12 -32
- cognite_toolkit/_cdf_tk/client/data_classes/instance_api.py +18 -13
- cognite_toolkit/_cdf_tk/client/data_classes/legacy/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/client/data_classes/{canvas.py → legacy/canvas.py} +1 -1
- cognite_toolkit/_cdf_tk/client/data_classes/three_d.py +65 -0
- cognite_toolkit/_cdf_tk/client/testing.py +24 -16
- cognite_toolkit/_cdf_tk/commands/__init__.py +1 -0
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +8 -2
- cognite_toolkit/_cdf_tk/commands/_migrate/creators.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_classes.py +35 -4
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +149 -14
- 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 +19 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +220 -3
- cognite_toolkit/_cdf_tk/commands/_profile.py +1 -1
- cognite_toolkit/_cdf_tk/commands/_purge.py +9 -11
- cognite_toolkit/_cdf_tk/commands/build_cmd.py +1 -1
- cognite_toolkit/_cdf_tk/commands/build_v2/__init__.py +0 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_cmd.py +241 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_input.py +85 -0
- cognite_toolkit/_cdf_tk/commands/build_v2/build_issues.py +27 -0
- cognite_toolkit/_cdf_tk/commands/dump_resource.py +4 -4
- cognite_toolkit/_cdf_tk/commands/run.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +2 -2
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +1 -1
- 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 +22 -20
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +1 -1
- 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 +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/migration.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/raw.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +1 -1
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/transformation.py +49 -14
- cognite_toolkit/_cdf_tk/data_classes/_module_toml.py +1 -0
- cognite_toolkit/_cdf_tk/resource_classes/search_config.py +1 -1
- cognite_toolkit/_cdf_tk/resource_classes/workflow_version.py +164 -5
- cognite_toolkit/_cdf_tk/storageio/_applications.py +2 -2
- cognite_toolkit/_cdf_tk/storageio/_file_content.py +1 -2
- cognite_toolkit/_cdf_tk/storageio/_instances.py +1 -1
- 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/utils/cdf.py +1 -1
- cognite_toolkit/_cdf_tk/utils/http_client/__init__.py +28 -0
- cognite_toolkit/_cdf_tk/utils/http_client/_client.py +3 -2
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes.py +6 -0
- cognite_toolkit/_cdf_tk/utils/http_client/_data_classes2.py +67 -7
- cognite_toolkit/_cdf_tk/utils/http_client/_tracker.py +5 -2
- cognite_toolkit/_cdf_tk/utils/interactive_select.py +51 -4
- 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.39.dist-info}/METADATA +1 -1
- {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.39.dist-info}/RECORD +119 -113
- {cognite_toolkit-0.7.30.dist-info → cognite_toolkit-0.7.39.dist-info}/WHEEL +1 -1
- cognite_toolkit/_cdf_tk/client/api/robotics/__init__.py +0 -3
- cognite_toolkit/_cdf_tk/prototypes/import_app.py +0 -41
- /cognite_toolkit/_cdf_tk/{prototypes/commands → client/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/client/data_classes/{apm_config_v1.py → legacy/apm_config_v1.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{charts.py → legacy/charts.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extendable_cognite_file.py → legacy/extendable_cognite_file.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_filemetadata.py → legacy/extended_filemetadata.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_filemetdata.py → legacy/extended_filemetdata.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{extended_timeseries.py → legacy/extended_timeseries.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{functions.py → legacy/functions.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{graphql_data_models.py → legacy/graphql_data_models.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{instances.py → legacy/instances.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{location_filters.py → legacy/location_filters.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{migration.py → legacy/migration.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{pending_instances_ids.py → legacy/pending_instances_ids.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{project.py → legacy/project.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{raw.py → legacy/raw.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{robotics.py → legacy/robotics.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{search_config.py → legacy/search_config.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{sequences.py → legacy/sequences.py} +0 -0
- /cognite_toolkit/_cdf_tk/client/data_classes/{streamlit_.py → 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.39.dist-info}/entry_points.txt +0 -0
|
@@ -9,11 +9,11 @@ from cognite.client.utils._concurrency import execute_tasks
|
|
|
9
9
|
from cognite.client.utils._identifier import IdentifierSequence
|
|
10
10
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
11
11
|
|
|
12
|
-
from cognite_toolkit._cdf_tk.client.data_classes.extended_filemetadata import (
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.extended_filemetadata import (
|
|
13
13
|
ExtendedFileMetadata,
|
|
14
14
|
ExtendedFileMetadataList,
|
|
15
15
|
)
|
|
16
|
-
from cognite_toolkit._cdf_tk.client.data_classes.pending_instances_ids import PendingInstanceId
|
|
16
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.pending_instances_ids import PendingInstanceId
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class ExtendedFileMetadataAPI(FilesAPI):
|
|
@@ -7,7 +7,7 @@ from rich.console import Console
|
|
|
7
7
|
|
|
8
8
|
from cognite_toolkit._cdf_tk.client.config import ToolkitClientConfig
|
|
9
9
|
from cognite_toolkit._cdf_tk.utils.collection import chunker
|
|
10
|
-
from cognite_toolkit._cdf_tk.utils.http_client import HTTPClient,
|
|
10
|
+
from cognite_toolkit._cdf_tk.utils.http_client import HTTPClient, RequestMessage2
|
|
11
11
|
from cognite_toolkit._cdf_tk.utils.useful_types import JsonVal
|
|
12
12
|
|
|
13
13
|
|
|
@@ -34,21 +34,20 @@ class ExtendedFunctionsAPI(FunctionsAPI):
|
|
|
34
34
|
|
|
35
35
|
Args:
|
|
36
36
|
function (FunctionWrite): The function to create.
|
|
37
|
-
console (Console | None): The rich console to use for printing warnings.
|
|
38
37
|
|
|
39
38
|
Returns:
|
|
40
39
|
Function: The created function object.
|
|
41
40
|
"""
|
|
42
|
-
result = self._toolkit_http_client.
|
|
43
|
-
message=
|
|
41
|
+
result = self._toolkit_http_client.request_single_retries(
|
|
42
|
+
message=RequestMessage2(
|
|
44
43
|
endpoint_url=self._toolkit_config.create_api_url("/functions"),
|
|
45
44
|
method="POST",
|
|
46
45
|
body_content={"items": [function.dump(camel_case=True)]},
|
|
47
46
|
)
|
|
48
47
|
)
|
|
49
|
-
result.
|
|
48
|
+
success = result.get_success_or_raise()
|
|
50
49
|
# We assume the API response is one item on a successful creation
|
|
51
|
-
return Function._load(
|
|
50
|
+
return Function._load(success.body_json["items"][0], cognite_client=self._cognite_client)
|
|
52
51
|
|
|
53
52
|
def delete_with_429_retry(self, external_id: SequenceNotStr[str], ignore_unknown_ids: bool = False) -> None:
|
|
54
53
|
"""Delete one or more functions with retry handling for 429 Too Many Requests responses.
|
|
@@ -70,11 +69,12 @@ class ExtendedFunctionsAPI(FunctionsAPI):
|
|
|
70
69
|
}
|
|
71
70
|
if ignore_unknown_ids:
|
|
72
71
|
body_content["ignoreUnknownIds"] = True
|
|
73
|
-
self._toolkit_http_client.
|
|
74
|
-
message=
|
|
72
|
+
result = self._toolkit_http_client.request_single_retries(
|
|
73
|
+
message=RequestMessage2(
|
|
75
74
|
endpoint_url=self._toolkit_config.create_api_url("/functions/delete"),
|
|
76
75
|
method="POST",
|
|
77
76
|
body_content=body_content,
|
|
78
77
|
)
|
|
79
|
-
)
|
|
78
|
+
)
|
|
79
|
+
result.get_success_or_raise()
|
|
80
80
|
return None
|
|
@@ -13,8 +13,11 @@ from cognite.client.utils._identifier import IdentifierSequence
|
|
|
13
13
|
from cognite.client.utils._validation import prepare_filter_sort, process_asset_subtree_ids, process_data_set_ids
|
|
14
14
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
15
15
|
|
|
16
|
-
from cognite_toolkit._cdf_tk.client.data_classes.extended_timeseries import
|
|
17
|
-
|
|
16
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.extended_timeseries import (
|
|
17
|
+
ExtendedTimeSeries,
|
|
18
|
+
ExtendedTimeSeriesList,
|
|
19
|
+
)
|
|
20
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.pending_instances_ids import PendingInstanceId
|
|
18
21
|
|
|
19
22
|
|
|
20
23
|
class ExtendedTimeSeriesAPI(TimeSeriesAPI):
|
|
@@ -6,7 +6,7 @@ from cognite.client._api_client import APIClient
|
|
|
6
6
|
from cognite.client.config import ClientConfig
|
|
7
7
|
from cognite.client.utils._identifier import IdentifierSequence
|
|
8
8
|
|
|
9
|
-
from cognite_toolkit._cdf_tk.client.data_classes.location_filters import (
|
|
9
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.location_filters import (
|
|
10
10
|
LocationFilter,
|
|
11
11
|
LocationFilterList,
|
|
12
12
|
LocationFilterWrite,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from .api import RoboticsAPI
|
|
2
|
+
from .capabilities import CapabilitiesAPI
|
|
3
|
+
from .data_postprocessing import DataPostProcessingAPI
|
|
4
|
+
from .frames import FramesAPI
|
|
5
|
+
from .locations import LocationsAPI
|
|
6
|
+
from .maps import MapsAPI
|
|
7
|
+
|
|
8
|
+
__all__ = ["CapabilitiesAPI", "DataPostProcessingAPI", "FramesAPI", "LocationsAPI", "MapsAPI", "RoboticsAPI"]
|
|
@@ -5,7 +5,7 @@ from cognite.client._api_client import APIClient
|
|
|
5
5
|
from cognite.client.utils._identifier import IdentifierSequence
|
|
6
6
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
7
7
|
|
|
8
|
-
from cognite_toolkit._cdf_tk.client.data_classes.robotics import (
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.robotics import (
|
|
9
9
|
RobotCapability,
|
|
10
10
|
RobotCapabilityList,
|
|
11
11
|
RobotCapabilityWrite,
|
|
@@ -5,7 +5,7 @@ from cognite.client._api_client import APIClient
|
|
|
5
5
|
from cognite.client.utils._identifier import IdentifierSequence
|
|
6
6
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
7
7
|
|
|
8
|
-
from cognite_toolkit._cdf_tk.client.data_classes.robotics import (
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.robotics import (
|
|
9
9
|
DataPostProcessing,
|
|
10
10
|
DataPostProcessingList,
|
|
11
11
|
DataPostProcessingWrite,
|
|
@@ -5,7 +5,7 @@ from cognite.client._api_client import APIClient
|
|
|
5
5
|
from cognite.client.utils._identifier import IdentifierSequence
|
|
6
6
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
7
7
|
|
|
8
|
-
from cognite_toolkit._cdf_tk.client.data_classes.robotics import (
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.robotics import (
|
|
9
9
|
Frame,
|
|
10
10
|
FrameList,
|
|
11
11
|
FrameWrite,
|
|
@@ -5,7 +5,7 @@ from cognite.client._api_client import APIClient
|
|
|
5
5
|
from cognite.client.utils._identifier import IdentifierSequence
|
|
6
6
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
7
7
|
|
|
8
|
-
from cognite_toolkit._cdf_tk.client.data_classes.robotics import (
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.robotics import (
|
|
9
9
|
Location,
|
|
10
10
|
LocationList,
|
|
11
11
|
LocationWrite,
|
|
@@ -5,7 +5,7 @@ from cognite.client._api_client import APIClient
|
|
|
5
5
|
from cognite.client.utils._identifier import IdentifierSequence
|
|
6
6
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
7
7
|
|
|
8
|
-
from cognite_toolkit._cdf_tk.client.data_classes.robotics import (
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.robotics import (
|
|
9
9
|
Map,
|
|
10
10
|
MapList,
|
|
11
11
|
MapWrite,
|
|
@@ -3,8 +3,8 @@ from typing import overload
|
|
|
3
3
|
|
|
4
4
|
from cognite.client._api_client import APIClient
|
|
5
5
|
|
|
6
|
-
from cognite_toolkit._cdf_tk.client.api.robotics.utlis import tmp_disable_gzip
|
|
7
|
-
from cognite_toolkit._cdf_tk.client.data_classes.robotics import Robot, RobotList, RobotWrite, _RobotUpdate
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.robotics.utlis import tmp_disable_gzip
|
|
7
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.robotics import Robot, RobotList, RobotWrite, _RobotUpdate
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class RobotsAPI(APIClient):
|
|
@@ -4,7 +4,11 @@ from cognite.client import CogniteClient
|
|
|
4
4
|
from cognite.client._api_client import APIClient
|
|
5
5
|
from cognite.client.config import ClientConfig
|
|
6
6
|
|
|
7
|
-
from cognite_toolkit._cdf_tk.client.data_classes.search_config import
|
|
7
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.search_config import (
|
|
8
|
+
SearchConfig,
|
|
9
|
+
SearchConfigList,
|
|
10
|
+
SearchConfigWrite,
|
|
11
|
+
)
|
|
8
12
|
|
|
9
13
|
|
|
10
14
|
class SearchConfigurationsAPI(APIClient):
|
|
@@ -16,7 +16,8 @@ from cognite.client.data_classes.data_modeling import (
|
|
|
16
16
|
)
|
|
17
17
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
18
18
|
|
|
19
|
-
from cognite_toolkit._cdf_tk.client.
|
|
19
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.extended_data_modeling import ExtendedInstancesAPI
|
|
20
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.migration import (
|
|
20
21
|
AssetCentricId,
|
|
21
22
|
CreatedSourceSystem,
|
|
22
23
|
InstanceSource,
|
|
@@ -29,8 +30,6 @@ from cognite_toolkit._cdf_tk.tk_warnings import HighSeverityWarning
|
|
|
29
30
|
from cognite_toolkit._cdf_tk.utils.collection import chunker_sequence
|
|
30
31
|
from cognite_toolkit._cdf_tk.utils.useful_types import AssetCentricType
|
|
31
32
|
|
|
32
|
-
from .extended_data_modeling import ExtendedInstancesAPI
|
|
33
|
-
|
|
34
33
|
|
|
35
34
|
class InstanceSourceAPI:
|
|
36
35
|
def __init__(self, instance_api: ExtendedInstancesAPI) -> None:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from cognite.client import CogniteClient
|
|
2
2
|
|
|
3
3
|
from cognite_toolkit._cdf_tk.client.config import ToolkitClientConfig
|
|
4
|
-
from cognite_toolkit._cdf_tk.client.data_classes.project import ProjectStatusList
|
|
5
|
-
from cognite_toolkit._cdf_tk.utils.http_client import HTTPClient,
|
|
4
|
+
from cognite_toolkit._cdf_tk.client.data_classes.legacy.project import ProjectStatusList
|
|
5
|
+
from cognite_toolkit._cdf_tk.utils.http_client import HTTPClient, RequestMessage2
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class ProjectAPI:
|
|
@@ -13,11 +13,12 @@ class ProjectAPI:
|
|
|
13
13
|
|
|
14
14
|
def status(self) -> ProjectStatusList:
|
|
15
15
|
"""Retrieve information about the current project."""
|
|
16
|
-
response = self._http_client.
|
|
17
|
-
|
|
18
|
-
endpoint_url=f"{self._config.base_url}/api/v1/projects
|
|
16
|
+
response = self._http_client.request_single_retries(
|
|
17
|
+
RequestMessage2(
|
|
18
|
+
endpoint_url=f"{self._config.base_url}/api/v1/projects",
|
|
19
|
+
method="GET",
|
|
20
|
+
parameters={"withDataModelingStatus": True},
|
|
19
21
|
)
|
|
20
22
|
)
|
|
21
|
-
response.
|
|
22
|
-
|
|
23
|
-
return ProjectStatusList._load(body["items"], cognite_client=self._cognite_client) # type: ignore[arg-type]
|
|
23
|
+
success = response.get_success_or_raise()
|
|
24
|
+
return ProjectStatusList._load(success.body_json["items"], cognite_client=self._cognite_client)
|
|
@@ -2,8 +2,8 @@ from cognite.client import CogniteClient
|
|
|
2
2
|
from cognite.client._api_client import APIClient
|
|
3
3
|
from cognite.client.config import ClientConfig
|
|
4
4
|
|
|
5
|
-
from .location_filters import LocationFiltersAPI
|
|
6
|
-
from .search_config import SearchConfigurationsAPI
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.location_filters import LocationFiltersAPI
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.api.legacy.search_config import SearchConfigurationsAPI
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class SearchAPI(APIClient):
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
from collections.abc import Sequence
|
|
2
2
|
|
|
3
|
+
from pydantic import TypeAdapter
|
|
3
4
|
from rich.console import Console
|
|
4
5
|
|
|
5
6
|
from cognite_toolkit._cdf_tk.client.data_classes.api_classes import PagedResponse
|
|
6
7
|
from cognite_toolkit._cdf_tk.client.data_classes.streams import StreamRequest, StreamResponse
|
|
7
|
-
from cognite_toolkit._cdf_tk.utils.http_client import
|
|
8
|
+
from cognite_toolkit._cdf_tk.utils.http_client import (
|
|
9
|
+
HTTPClient,
|
|
10
|
+
ItemsRequest2,
|
|
11
|
+
RequestMessage2,
|
|
12
|
+
)
|
|
8
13
|
|
|
9
14
|
|
|
10
15
|
class StreamsAPI:
|
|
@@ -24,15 +29,15 @@ class StreamsAPI:
|
|
|
24
29
|
Returns:
|
|
25
30
|
List of created StreamResponse items.
|
|
26
31
|
"""
|
|
27
|
-
responses = self._http_client.
|
|
28
|
-
|
|
32
|
+
responses = self._http_client.request_items_retries(
|
|
33
|
+
ItemsRequest2(
|
|
29
34
|
endpoint_url=self._config.create_api_url(self.ENDPOINT),
|
|
30
35
|
method="POST",
|
|
31
|
-
items=
|
|
36
|
+
items=items,
|
|
32
37
|
)
|
|
33
38
|
)
|
|
34
39
|
responses.raise_for_status()
|
|
35
|
-
return
|
|
40
|
+
return TypeAdapter(list[StreamResponse]).validate_python(responses.get_items())
|
|
36
41
|
|
|
37
42
|
def delete(self, external_id: str) -> None:
|
|
38
43
|
"""Delete stream using its external ID.
|
|
@@ -40,13 +45,13 @@ class StreamsAPI:
|
|
|
40
45
|
Args:
|
|
41
46
|
external_id: External ID of the stream to delete.
|
|
42
47
|
"""
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
response = self._http_client.request_single_retries(
|
|
49
|
+
RequestMessage2(
|
|
45
50
|
endpoint_url=self._config.create_api_url(f"{self.ENDPOINT}/{external_id}"),
|
|
46
51
|
method="DELETE",
|
|
47
52
|
)
|
|
48
53
|
)
|
|
49
|
-
|
|
54
|
+
_ = response.get_success_or_raise()
|
|
50
55
|
|
|
51
56
|
def list(self) -> list[StreamResponse]:
|
|
52
57
|
"""List streams.
|
|
@@ -54,14 +59,14 @@ class StreamsAPI:
|
|
|
54
59
|
Returns:
|
|
55
60
|
StreamResponseList containing the listed streams.
|
|
56
61
|
"""
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
response = self._http_client.request_single_retries(
|
|
63
|
+
RequestMessage2(
|
|
59
64
|
endpoint_url=self._config.create_api_url(self.ENDPOINT),
|
|
60
65
|
method="GET",
|
|
61
66
|
)
|
|
62
67
|
)
|
|
63
|
-
|
|
64
|
-
return PagedResponse[StreamResponse].model_validate(
|
|
68
|
+
success = response.get_success_or_raise()
|
|
69
|
+
return PagedResponse[StreamResponse].model_validate(success.body_json).items
|
|
65
70
|
|
|
66
71
|
def retrieve(self, external_id: str, include_statistics: bool = True) -> StreamResponse:
|
|
67
72
|
"""Retrieve a stream by its external ID.
|
|
@@ -72,13 +77,12 @@ class StreamsAPI:
|
|
|
72
77
|
Returns:
|
|
73
78
|
StreamResponse item.
|
|
74
79
|
"""
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
response = self._http_client.request_single_retries(
|
|
81
|
+
RequestMessage2(
|
|
77
82
|
endpoint_url=self._config.create_api_url(f"{self.ENDPOINT}/{external_id}"),
|
|
78
83
|
method="GET",
|
|
79
84
|
parameters={"includeStatistics": include_statistics},
|
|
80
85
|
)
|
|
81
86
|
)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return StreamResponse.model_validate(response_body)
|
|
87
|
+
success = response.get_success_or_raise()
|
|
88
|
+
return StreamResponse.model_validate(success.body_json)
|