cognite-toolkit 0.7.47__py3-none-any.whl → 0.7.49__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_tk/apps/_migrate_app.py +6 -6
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +6 -4
- cognite_toolkit/_cdf_tk/client/api/instances.py +139 -0
- cognite_toolkit/_cdf_tk/client/api/location_filters.py +177 -0
- cognite_toolkit/_cdf_tk/client/api/raw.py +2 -2
- 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_config.py +101 -0
- cognite_toolkit/_cdf_tk/client/api/streams.py +63 -55
- cognite_toolkit/_cdf_tk/client/api/three_d.py +293 -277
- cognite_toolkit/_cdf_tk/client/cdf_client/api.py +34 -5
- cognite_toolkit/_cdf_tk/client/http_client/_client.py +5 -2
- cognite_toolkit/_cdf_tk/client/http_client/_data_classes2.py +4 -3
- cognite_toolkit/_cdf_tk/client/request_classes/filters.py +45 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/apm_config.py +128 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/cognite_file.py +53 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/__init__.py +4 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/data_modeling/_instance.py +22 -11
- cognite_toolkit/_cdf_tk/client/resource_classes/identifiers.py +7 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/location_filter.py +9 -2
- cognite_toolkit/_cdf_tk/client/resource_classes/resource_view_mapping.py +38 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_map.py +6 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/robotics/_robot.py +10 -5
- cognite_toolkit/_cdf_tk/client/resource_classes/streams.py +1 -20
- cognite_toolkit/_cdf_tk/client/resource_classes/three_d.py +30 -9
- cognite_toolkit/_cdf_tk/client/testing.py +2 -2
- cognite_toolkit/_cdf_tk/commands/_migrate/command.py +103 -108
- cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +6 -1
- cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +119 -41
- cognite_toolkit/_cdf_tk/commands/_migrate/issues.py +21 -38
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +14 -12
- 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 +83 -96
- cognite_toolkit/_cdf_tk/commands/build_v2/{build_input.py → build_parameters.py} +8 -22
- 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/cruds/__init__.py +11 -5
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/streams.py +14 -30
- 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/storageio/_base.py +2 -0
- cognite_toolkit/_cdf_tk/storageio/logger.py +162 -0
- cognite_toolkit/_cdf_tk/utils/__init__.py +8 -1
- cognite_toolkit/_cdf_tk/utils/interactive_select.py +3 -1
- cognite_toolkit/_cdf_tk/utils/modules.py +7 -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.47.dist-info → cognite_toolkit-0.7.49.dist-info}/METADATA +1 -1
- {cognite_toolkit-0.7.47.dist-info → cognite_toolkit-0.7.49.dist-info}/RECORD +61 -43
- cognite_toolkit/_cdf_tk/commands/build_v2/build_issues.py +0 -27
- /cognite_toolkit/_cdf_tk/client/resource_classes/{search_config_resource.py → search_config.py} +0 -0
- {cognite_toolkit-0.7.47.dist-info → cognite_toolkit-0.7.49.dist-info}/WHEEL +0 -0
- {cognite_toolkit-0.7.47.dist-info → cognite_toolkit-0.7.49.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
from collections.abc import Iterable, Sequence
|
|
2
|
+
|
|
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.search_config import (
|
|
12
|
+
SearchConfigRequest,
|
|
13
|
+
SearchConfigResponse,
|
|
14
|
+
SearchConfigViewId,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class SearchConfigurationsAPI(CDFResourceAPI[SearchConfigViewId, SearchConfigRequest, SearchConfigResponse]):
|
|
19
|
+
"""API for managing Search Configurations using the CDFResourceAPI pattern.
|
|
20
|
+
|
|
21
|
+
This API manages search view configurations at:
|
|
22
|
+
/apps/v1/projects/{project}/storage/config/apps/search/views
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
BASE_PATH = "/storage/config/apps/search/views"
|
|
26
|
+
|
|
27
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
28
|
+
super().__init__(
|
|
29
|
+
http_client=http_client,
|
|
30
|
+
method_endpoint_map={
|
|
31
|
+
"upsert": Endpoint(method="POST", path=f"{self.BASE_PATH}/upsert", item_limit=1),
|
|
32
|
+
"list": Endpoint(method="POST", path=f"{self.BASE_PATH}/list", item_limit=1000),
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def _make_url(self, path: str = "") -> str:
|
|
37
|
+
"""Create the full URL for this resource endpoint using the apps URL format."""
|
|
38
|
+
return self._http_client.config.create_app_url(path)
|
|
39
|
+
|
|
40
|
+
def _validate_page_response(
|
|
41
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
42
|
+
) -> PagedResponse[SearchConfigResponse]:
|
|
43
|
+
return PagedResponse[SearchConfigResponse].model_validate_json(response.body)
|
|
44
|
+
|
|
45
|
+
def create(self, items: Sequence[SearchConfigRequest]) -> list[SearchConfigResponse]:
|
|
46
|
+
"""Create or update a search configurations.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
items: The search configuration to create or update.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
The created or updated search configurations.
|
|
53
|
+
"""
|
|
54
|
+
endpoint = self._method_endpoint_map["upsert"]
|
|
55
|
+
results: list[SearchConfigResponse] = []
|
|
56
|
+
for item in items:
|
|
57
|
+
request = RequestMessage2(
|
|
58
|
+
endpoint_url=self._make_url(endpoint.path),
|
|
59
|
+
method=endpoint.method,
|
|
60
|
+
body_content=item.model_dump(mode="json", by_alias=True),
|
|
61
|
+
)
|
|
62
|
+
result = self._http_client.request_single_retries(request)
|
|
63
|
+
response = result.get_success_or_raise()
|
|
64
|
+
results.append(SearchConfigResponse.model_validate_json(response.body))
|
|
65
|
+
return results
|
|
66
|
+
|
|
67
|
+
def update(self, items: Sequence[SearchConfigRequest]) -> list[SearchConfigResponse]:
|
|
68
|
+
"""Update a search configurations.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
items: The search configuration to update.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
The updated search configurations.
|
|
75
|
+
"""
|
|
76
|
+
return self.create(items)
|
|
77
|
+
|
|
78
|
+
def paginate(self) -> PagedResponse[SearchConfigResponse]:
|
|
79
|
+
"""Get a single page of search configurations.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
PagedResponse of SearchConfigResponse objects.
|
|
83
|
+
"""
|
|
84
|
+
return self._paginate(cursor=None, limit=100)
|
|
85
|
+
|
|
86
|
+
def iterate(self) -> Iterable[list[SearchConfigResponse]]:
|
|
87
|
+
"""Iterate over all search configurations.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
Iterable of lists of SearchConfigResponse objects.
|
|
91
|
+
"""
|
|
92
|
+
return self._iterate(limit=None)
|
|
93
|
+
|
|
94
|
+
def list(self) -> list[SearchConfigResponse]:
|
|
95
|
+
"""List all search configurations.
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
List of SearchConfigResponse objects.
|
|
100
|
+
"""
|
|
101
|
+
return self._list(limit=None)
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
from collections.abc import Sequence
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
|
|
6
|
-
from cognite_toolkit._cdf_tk.client.cdf_client.responses import PagedResponse
|
|
3
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, PagedResponse
|
|
4
|
+
from cognite_toolkit._cdf_tk.client.cdf_client.api import Endpoint
|
|
7
5
|
from cognite_toolkit._cdf_tk.client.http_client import (
|
|
8
6
|
HTTPClient,
|
|
9
|
-
|
|
7
|
+
ItemsSuccessResponse2,
|
|
10
8
|
RequestMessage2,
|
|
9
|
+
SuccessResponse2,
|
|
11
10
|
)
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import ExternalId
|
|
12
12
|
from cognite_toolkit._cdf_tk.client.resource_classes.streams import StreamRequest, StreamResponse
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
class StreamsAPI:
|
|
16
|
-
|
|
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
|
+
)
|
|
17
26
|
|
|
18
|
-
def
|
|
19
|
-
self
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
def _validate_page_response(
|
|
28
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
29
|
+
) -> PagedResponse[StreamResponse]:
|
|
30
|
+
return PagedResponse[StreamResponse].model_validate_json(response.body)
|
|
22
31
|
|
|
23
32
|
def create(self, items: Sequence[StreamRequest]) -> list[StreamResponse]:
|
|
24
33
|
"""Create one or more streams.
|
|
@@ -29,60 +38,59 @@ class StreamsAPI:
|
|
|
29
38
|
Returns:
|
|
30
39
|
List of created StreamResponse items.
|
|
31
40
|
"""
|
|
32
|
-
|
|
33
|
-
ItemsRequest2(
|
|
34
|
-
endpoint_url=self._config.create_api_url(self.ENDPOINT),
|
|
35
|
-
method="POST",
|
|
36
|
-
items=items,
|
|
37
|
-
)
|
|
38
|
-
)
|
|
39
|
-
responses.raise_for_status()
|
|
40
|
-
return TypeAdapter(list[StreamResponse]).validate_python(responses.get_items())
|
|
41
|
+
return self._request_item_response(items, "create")
|
|
41
42
|
|
|
42
|
-
def delete(self,
|
|
43
|
-
"""Delete
|
|
43
|
+
def delete(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
44
|
+
"""Delete streams using their external IDs.
|
|
44
45
|
|
|
45
46
|
Args:
|
|
46
|
-
|
|
47
|
+
items: Sequence of ExternalId objects to delete.
|
|
48
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
47
49
|
"""
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
53
|
-
)
|
|
54
|
-
_ = response.get_success_or_raise()
|
|
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")
|
|
55
55
|
|
|
56
|
-
def
|
|
57
|
-
|
|
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.
|
|
58
67
|
|
|
59
68
|
Returns:
|
|
60
|
-
|
|
69
|
+
List of StreamResponse items.
|
|
61
70
|
"""
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
+
)
|
|
66
80
|
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
|
70
87
|
|
|
71
|
-
def
|
|
72
|
-
"""
|
|
88
|
+
def list(self) -> list[StreamResponse]:
|
|
89
|
+
"""List all streams.
|
|
90
|
+
|
|
91
|
+
Note: The streams API does not support pagination.
|
|
73
92
|
|
|
74
|
-
Args:
|
|
75
|
-
external_id: External ID of the stream to retrieve.
|
|
76
|
-
include_statistics: Whether to include usage statistics in the response.
|
|
77
93
|
Returns:
|
|
78
|
-
StreamResponse
|
|
94
|
+
List of StreamResponse items.
|
|
79
95
|
"""
|
|
80
|
-
|
|
81
|
-
RequestMessage2(
|
|
82
|
-
endpoint_url=self._config.create_api_url(f"{self.ENDPOINT}/{external_id}"),
|
|
83
|
-
method="GET",
|
|
84
|
-
parameters={"includeStatistics": include_statistics},
|
|
85
|
-
)
|
|
86
|
-
)
|
|
87
|
-
success = response.get_success_or_raise()
|
|
88
|
-
return StreamResponse.model_validate(success.body_json)
|
|
96
|
+
return self._list(limit=None)
|