cognite-toolkit 0.7.46__py3-none-any.whl → 0.7.48__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/agents.py +107 -0
- cognite_toolkit/_cdf_tk/client/api/annotations.py +129 -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/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/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/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_config.py +101 -0
- cognite_toolkit/_cdf_tk/client/api/spaces.py +117 -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/api/views.py +139 -0
- cognite_toolkit/_cdf_tk/client/cdf_client/api.py +42 -7
- cognite_toolkit/_cdf_tk/client/cdf_client/responses.py +11 -0
- cognite_toolkit/_cdf_tk/client/http_client/_client.py +5 -2
- cognite_toolkit/_cdf_tk/client/http_client/_data_classes.py +10 -0
- cognite_toolkit/_cdf_tk/client/http_client/_data_classes2.py +4 -3
- cognite_toolkit/_cdf_tk/client/request_classes/filters.py +75 -0
- cognite_toolkit/_cdf_tk/client/request_classes/graphql.py +28 -0
- cognite_toolkit/_cdf_tk/client/resource_classes/agent.py +8 -2
- 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/function_schedule.py +8 -4
- cognite_toolkit/_cdf_tk/client/resource_classes/group/group.py +9 -5
- 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/relationship.py +9 -3
- 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/data_mapper.py +5 -5
- cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py +11 -7
- 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 +163 -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.46.dist-info → cognite_toolkit-0.7.48.dist-info}/METADATA +1 -1
- {cognite_toolkit-0.7.46.dist-info → cognite_toolkit-0.7.48.dist-info}/RECORD +76 -46
- 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.46.dist-info → cognite_toolkit-0.7.48.dist-info}/WHEEL +0 -0
- {cognite_toolkit-0.7.46.dist-info → cognite_toolkit-0.7.48.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
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.identifiers import InternalId
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.location_filter import (
|
|
13
|
+
LocationFilterRequest,
|
|
14
|
+
LocationFilterResponse,
|
|
15
|
+
)
|
|
16
|
+
from cognite_toolkit._cdf_tk.utils.collection import chunker_sequence
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class LocationFiltersAPI(CDFResourceAPI[InternalId, LocationFilterRequest, LocationFilterResponse]):
|
|
20
|
+
"""API for managing Location Filters using the CDFResourceAPI pattern.
|
|
21
|
+
|
|
22
|
+
This API manages location filter configurations at:
|
|
23
|
+
/apps/v1/projects/{project}/storage/config/locationfilters
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
BASE_PATH = "/storage/config/locationfilters"
|
|
27
|
+
|
|
28
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
29
|
+
super().__init__(
|
|
30
|
+
http_client=http_client,
|
|
31
|
+
method_endpoint_map={
|
|
32
|
+
"create": Endpoint(method="POST", path=self.BASE_PATH, item_limit=1),
|
|
33
|
+
"retrieve": Endpoint(method="POST", path=f"{self.BASE_PATH}/byids", item_limit=1000),
|
|
34
|
+
"update": Endpoint(method="PUT", path=f"{self.BASE_PATH}/{{id}}", item_limit=1),
|
|
35
|
+
"delete": Endpoint(method="DELETE", path=f"{self.BASE_PATH}/{{id}}", item_limit=1),
|
|
36
|
+
"list": Endpoint(method="POST", path=f"{self.BASE_PATH}/list", item_limit=1000),
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def _make_url(self, path: str = "") -> str:
|
|
41
|
+
"""Create the full URL for this resource endpoint using the apps URL format."""
|
|
42
|
+
return self._http_client.config.create_app_url(path)
|
|
43
|
+
|
|
44
|
+
def _validate_page_response(
|
|
45
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
46
|
+
) -> PagedResponse[LocationFilterResponse]:
|
|
47
|
+
return PagedResponse[LocationFilterResponse].model_validate_json(response.body)
|
|
48
|
+
|
|
49
|
+
def create(self, items: Sequence[LocationFilterRequest]) -> list[LocationFilterResponse]:
|
|
50
|
+
"""Create a new location filter.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
items: The location filter to create.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
The created location filter.
|
|
57
|
+
"""
|
|
58
|
+
endpoint = self._method_endpoint_map["create"]
|
|
59
|
+
results: list[LocationFilterResponse] = []
|
|
60
|
+
for item in items:
|
|
61
|
+
request = RequestMessage2(
|
|
62
|
+
endpoint_url=self._make_url(endpoint.path),
|
|
63
|
+
method=endpoint.method,
|
|
64
|
+
body_content=item.model_dump(mode="json", by_alias=True),
|
|
65
|
+
)
|
|
66
|
+
result = self._http_client.request_single_retries(request)
|
|
67
|
+
response = result.get_success_or_raise()
|
|
68
|
+
results.append(LocationFilterResponse.model_validate_json(response.body))
|
|
69
|
+
return results
|
|
70
|
+
|
|
71
|
+
def retrieve(self, items: Sequence[InternalId]) -> list[LocationFilterResponse]:
|
|
72
|
+
"""Retrieve a single location filter by ID.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
items: The ID of the location filter to retrieve.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
The retrieved location filter.
|
|
79
|
+
"""
|
|
80
|
+
endpoint = self._method_endpoint_map["retrieve"]
|
|
81
|
+
results: list[LocationFilterResponse] = []
|
|
82
|
+
for chunk in chunker_sequence(items, endpoint.item_limit):
|
|
83
|
+
request = RequestMessage2(
|
|
84
|
+
endpoint_url=self._make_url(endpoint.path),
|
|
85
|
+
method=endpoint.method,
|
|
86
|
+
body_content={"ids": [item.id for item in chunk]},
|
|
87
|
+
)
|
|
88
|
+
result = self._http_client.request_single_retries(request)
|
|
89
|
+
response = result.get_success_or_raise()
|
|
90
|
+
results.extend(self._validate_page_response(response).items)
|
|
91
|
+
return results
|
|
92
|
+
|
|
93
|
+
def update(self, items: Sequence[LocationFilterRequest]) -> list[LocationFilterResponse]:
|
|
94
|
+
"""Update an existing location filter.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
items: The updated location filter data.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
The updated location filter.
|
|
101
|
+
"""
|
|
102
|
+
endpoint = self._method_endpoint_map["update"]
|
|
103
|
+
results: list[LocationFilterResponse] = []
|
|
104
|
+
for item in items:
|
|
105
|
+
if item.id is None:
|
|
106
|
+
raise ValueError("Item must have an ID for update operation.")
|
|
107
|
+
request = RequestMessage2(
|
|
108
|
+
endpoint_url=self._make_url(endpoint.path.format(id=item.id)),
|
|
109
|
+
method=endpoint.method,
|
|
110
|
+
body_content=item.model_dump(mode="json", by_alias=True),
|
|
111
|
+
)
|
|
112
|
+
result = self._http_client.request_single_retries(request)
|
|
113
|
+
response = result.get_success_or_raise()
|
|
114
|
+
parsed = LocationFilterResponse.model_validate_json(response.body)
|
|
115
|
+
parsed.id = item.id
|
|
116
|
+
results.append(parsed)
|
|
117
|
+
return results
|
|
118
|
+
|
|
119
|
+
def delete(self, items: Sequence[InternalId]) -> list[LocationFilterResponse]:
|
|
120
|
+
"""Delete a location filter.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
items: The ID of the location filter to delete.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
list[LocationFilterResponse]: The deleted location filters.
|
|
127
|
+
"""
|
|
128
|
+
endpoint = self._method_endpoint_map["delete"]
|
|
129
|
+
results: list[LocationFilterResponse] = []
|
|
130
|
+
for item in items:
|
|
131
|
+
request = RequestMessage2(
|
|
132
|
+
endpoint_url=self._make_url(endpoint.path.format(id=item.id)),
|
|
133
|
+
method=endpoint.method,
|
|
134
|
+
)
|
|
135
|
+
result = self._http_client.request_single_retries(request)
|
|
136
|
+
response = result.get_success_or_raise()
|
|
137
|
+
results.append(LocationFilterResponse.model_validate_json(response.body))
|
|
138
|
+
return results
|
|
139
|
+
|
|
140
|
+
def paginate(
|
|
141
|
+
self,
|
|
142
|
+
flat: bool = True,
|
|
143
|
+
) -> PagedResponse[LocationFilterResponse]:
|
|
144
|
+
"""Get a single page of location filters.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
flat: Whether to return a flat list (default True).
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
PagedResponse of LocationFilterResponse objects.
|
|
151
|
+
"""
|
|
152
|
+
return self._paginate(cursor=None, limit=100, body={"flat": flat})
|
|
153
|
+
|
|
154
|
+
def iterate(
|
|
155
|
+
self,
|
|
156
|
+
flat: bool = True,
|
|
157
|
+
) -> Iterable[list[LocationFilterResponse]]:
|
|
158
|
+
"""Iterate over all location filters.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
flat: Whether to return a flat list (default True).
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
Iterable of lists of LocationFilterResponse objects.
|
|
165
|
+
"""
|
|
166
|
+
return self._iterate(limit=None, body={"flat": flat})
|
|
167
|
+
|
|
168
|
+
def list(self, flat: bool = True) -> list[LocationFilterResponse]:
|
|
169
|
+
"""List all location filters.
|
|
170
|
+
|
|
171
|
+
Args:
|
|
172
|
+
flat: Whether to return a flat list (default True).
|
|
173
|
+
|
|
174
|
+
Returns:
|
|
175
|
+
List of LocationFilterResponse objects.
|
|
176
|
+
"""
|
|
177
|
+
return self._list(limit=None, body={"flat": flat})
|
|
@@ -128,7 +128,7 @@ class RawTablesAPI(CDFResourceAPI[RAWTable, RAWTable, RAWTable]):
|
|
|
128
128
|
List of created RAWTable objects.
|
|
129
129
|
"""
|
|
130
130
|
result: list[RAWTable] = []
|
|
131
|
-
for db_name, group in self._group_items_by_text_field(items, "db_name").items():
|
|
131
|
+
for (db_name,), group in self._group_items_by_text_field(items, "db_name").items():
|
|
132
132
|
if not db_name:
|
|
133
133
|
raise ValueError("db_name must be set on all RAWTable items for creation.")
|
|
134
134
|
endpoint = f"/raw/dbs/{db_name}/tables"
|
|
@@ -145,7 +145,7 @@ class RawTablesAPI(CDFResourceAPI[RAWTable, RAWTable, RAWTable]):
|
|
|
145
145
|
Args:
|
|
146
146
|
items: List of RAWTable objects to delete.
|
|
147
147
|
"""
|
|
148
|
-
for db_name, group in self._group_items_by_text_field(items, "db_name").items():
|
|
148
|
+
for (db_name,), group in self._group_items_by_text_field(items, "db_name").items():
|
|
149
149
|
if not db_name:
|
|
150
150
|
raise ValueError("db_name must be set on all RAWTable items for deletion.")
|
|
151
151
|
endpoint = f"/raw/dbs/{db_name}/tables/delete"
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Relationships API for managing CDF relationships.
|
|
2
|
+
|
|
3
|
+
Based on the API specification at:
|
|
4
|
+
https://api-docs.cognite.com/20230101/tag/Relationships/operation/createRelationships
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from collections.abc import Iterable, Sequence
|
|
8
|
+
from typing import Literal
|
|
9
|
+
|
|
10
|
+
from cognite_toolkit._cdf_tk.client.cdf_client import CDFResourceAPI, Endpoint, PagedResponse
|
|
11
|
+
from cognite_toolkit._cdf_tk.client.http_client import HTTPClient, ItemsSuccessResponse2, SuccessResponse2
|
|
12
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.identifiers import ExternalId
|
|
13
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.relationship import RelationshipRequest, RelationshipResponse
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class RelationshipsAPI(CDFResourceAPI[ExternalId, RelationshipRequest, RelationshipResponse]):
|
|
17
|
+
"""API for managing CDF relationships."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
20
|
+
super().__init__(
|
|
21
|
+
http_client=http_client,
|
|
22
|
+
method_endpoint_map={
|
|
23
|
+
"create": Endpoint(method="POST", path="/relationships", item_limit=1000),
|
|
24
|
+
"retrieve": Endpoint(method="POST", path="/relationships/byids", item_limit=1000),
|
|
25
|
+
"update": Endpoint(method="POST", path="/relationships/update", item_limit=1000),
|
|
26
|
+
"delete": Endpoint(method="POST", path="/relationships/delete", item_limit=1000),
|
|
27
|
+
"list": Endpoint(method="POST", path="/relationships/list", item_limit=1000),
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
def _validate_page_response(
|
|
32
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
33
|
+
) -> PagedResponse[RelationshipResponse]:
|
|
34
|
+
return PagedResponse[RelationshipResponse].model_validate_json(response.body)
|
|
35
|
+
|
|
36
|
+
def create(self, items: Sequence[RelationshipRequest]) -> list[RelationshipResponse]:
|
|
37
|
+
"""Create relationships in CDF.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
items: List of RelationshipRequest objects to create.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
List of created RelationshipResponse objects.
|
|
44
|
+
"""
|
|
45
|
+
return self._request_item_response(items, "create")
|
|
46
|
+
|
|
47
|
+
def retrieve(
|
|
48
|
+
self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False, fetch_resources: bool = False
|
|
49
|
+
) -> list[RelationshipResponse]:
|
|
50
|
+
"""Retrieve relationships from CDF.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
items: List of ExternalId objects to retrieve.
|
|
54
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
55
|
+
fetch_resources: If true, will try to fetch the resources referred to in the relationship,
|
|
56
|
+
based on the users access rights. Will silently fail to attach the resources
|
|
57
|
+
if the user lacks access to some of them.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
List of retrieved RelationshipResponse objects.
|
|
61
|
+
"""
|
|
62
|
+
return self._request_item_response(
|
|
63
|
+
items,
|
|
64
|
+
method="retrieve",
|
|
65
|
+
extra_body={"ignoreUnknownIds": ignore_unknown_ids, "fetchResources": fetch_resources},
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
def update(
|
|
69
|
+
self, items: Sequence[RelationshipRequest], mode: Literal["patch", "replace"] = "replace"
|
|
70
|
+
) -> list[RelationshipResponse]:
|
|
71
|
+
"""Update relationships in CDF.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
items: List of RelationshipRequest objects to update.
|
|
75
|
+
mode: Update mode, either "patch" or "replace".
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
List of updated RelationshipResponse objects.
|
|
79
|
+
"""
|
|
80
|
+
return self._update(items, mode=mode)
|
|
81
|
+
|
|
82
|
+
def delete(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
83
|
+
"""Delete relationships from CDF.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
items: List of ExternalId objects to delete.
|
|
87
|
+
ignore_unknown_ids: Whether to ignore unknown IDs.
|
|
88
|
+
"""
|
|
89
|
+
self._request_no_response(items, "delete", extra_body={"ignoreUnknownIds": ignore_unknown_ids})
|
|
90
|
+
|
|
91
|
+
def paginate(
|
|
92
|
+
self,
|
|
93
|
+
limit: int = 100,
|
|
94
|
+
cursor: str | None = None,
|
|
95
|
+
) -> PagedResponse[RelationshipResponse]:
|
|
96
|
+
"""Get a page of relationships from CDF.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
limit: Maximum number of relationships to return.
|
|
100
|
+
cursor: Cursor for pagination.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
PagedResponse of RelationshipResponse objects.
|
|
104
|
+
"""
|
|
105
|
+
return self._paginate(
|
|
106
|
+
cursor=cursor,
|
|
107
|
+
limit=limit,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
def iterate(
|
|
111
|
+
self,
|
|
112
|
+
limit: int | None = None,
|
|
113
|
+
) -> Iterable[list[RelationshipResponse]]:
|
|
114
|
+
"""Iterate over all relationships in CDF.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
limit: Maximum total number of relationships to return.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
Iterable of lists of RelationshipResponse objects.
|
|
121
|
+
"""
|
|
122
|
+
return self._iterate(limit=limit)
|
|
123
|
+
|
|
124
|
+
def list(self, limit: int | None = None) -> list[RelationshipResponse]:
|
|
125
|
+
"""List all relationships in CDF.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
limit: Maximum total number of relationships to return.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
List of RelationshipResponse objects.
|
|
132
|
+
"""
|
|
133
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from cognite_toolkit._cdf_tk.client.api.robotics_capabilities import CapabilitiesAPI
|
|
2
|
+
from cognite_toolkit._cdf_tk.client.api.robotics_data_postprocessing import DataPostProcessingAPI
|
|
3
|
+
from cognite_toolkit._cdf_tk.client.api.robotics_frames import FramesAPI
|
|
4
|
+
from cognite_toolkit._cdf_tk.client.api.robotics_locations import LocationsAPI
|
|
5
|
+
from cognite_toolkit._cdf_tk.client.api.robotics_maps import MapsAPI
|
|
6
|
+
from cognite_toolkit._cdf_tk.client.api.robotics_robots import RobotsAPI
|
|
7
|
+
from cognite_toolkit._cdf_tk.client.http_client import HTTPClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RoboticsAPI:
|
|
11
|
+
"""API for Robotics resources."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
14
|
+
self.capabilities = CapabilitiesAPI(http_client)
|
|
15
|
+
self.data_postprocessing = DataPostProcessingAPI(http_client)
|
|
16
|
+
self.frames = FramesAPI(http_client)
|
|
17
|
+
self.locations = LocationsAPI(http_client)
|
|
18
|
+
self.maps = MapsAPI(http_client)
|
|
19
|
+
self.robots = RobotsAPI(http_client)
|
|
@@ -0,0 +1,127 @@
|
|
|
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 ExternalId
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.robotics._capability import (
|
|
9
|
+
RobotCapabilityRequest,
|
|
10
|
+
RobotCapabilityResponse,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CapabilitiesAPI(CDFResourceAPI[ExternalId, RobotCapabilityRequest, RobotCapabilityResponse]):
|
|
15
|
+
"""API for managing Capability resources in CDF."""
|
|
16
|
+
|
|
17
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
18
|
+
super().__init__(
|
|
19
|
+
http_client=http_client,
|
|
20
|
+
method_endpoint_map={
|
|
21
|
+
"create": Endpoint(
|
|
22
|
+
method="POST", path="/robotics/capabilities", item_limit=1000, concurrency_max_workers=1
|
|
23
|
+
),
|
|
24
|
+
"retrieve": Endpoint(
|
|
25
|
+
method="POST", path="/robotics/capabilities/byids", item_limit=1000, concurrency_max_workers=1
|
|
26
|
+
),
|
|
27
|
+
"update": Endpoint(
|
|
28
|
+
method="POST", path="/robotics/capabilities/update", item_limit=1000, concurrency_max_workers=1
|
|
29
|
+
),
|
|
30
|
+
"delete": Endpoint(
|
|
31
|
+
method="POST", path="/robotics/capabilities/delete", item_limit=1000, concurrency_max_workers=1
|
|
32
|
+
),
|
|
33
|
+
"list": Endpoint(method="GET", path="/robotics/capabilities", item_limit=1000),
|
|
34
|
+
},
|
|
35
|
+
disable_gzip=True,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
def _validate_page_response(
|
|
39
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
40
|
+
) -> PagedResponse[RobotCapabilityResponse]:
|
|
41
|
+
return PagedResponse[RobotCapabilityResponse].model_validate_json(response.body)
|
|
42
|
+
|
|
43
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[ExternalId]:
|
|
44
|
+
return ResponseItems[ExternalId].model_validate_json(response.body)
|
|
45
|
+
|
|
46
|
+
def create(self, items: Sequence[RobotCapabilityRequest]) -> list[RobotCapabilityResponse]:
|
|
47
|
+
"""Create capabilities in CDF.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
items: List of RobotCapabilityRequest objects to create.
|
|
51
|
+
Returns:
|
|
52
|
+
List of created RobotCapabilityResponse objects.
|
|
53
|
+
"""
|
|
54
|
+
return self._request_item_response(items, "create")
|
|
55
|
+
|
|
56
|
+
def retrieve(self, items: Sequence[ExternalId]) -> list[RobotCapabilityResponse]:
|
|
57
|
+
"""Retrieve capabilities from CDF.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
items: List of ExternalId objects to retrieve.
|
|
61
|
+
Returns:
|
|
62
|
+
List of retrieved RobotCapabilityResponse objects.
|
|
63
|
+
"""
|
|
64
|
+
return self._request_item_response(items, method="retrieve")
|
|
65
|
+
|
|
66
|
+
def update(
|
|
67
|
+
self, items: Sequence[RobotCapabilityRequest], mode: Literal["patch", "replace"] = "replace"
|
|
68
|
+
) -> list[RobotCapabilityResponse]:
|
|
69
|
+
"""Update capabilities in CDF.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
items: List of RobotCapabilityRequest objects to update.
|
|
73
|
+
mode: Update mode, either "patch" or "replace".
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
List of updated RobotCapabilityResponse objects.
|
|
77
|
+
"""
|
|
78
|
+
return self._update(items, mode=mode)
|
|
79
|
+
|
|
80
|
+
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
81
|
+
"""Delete capabilities from CDF.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
items: List of ExternalId objects to delete.
|
|
85
|
+
"""
|
|
86
|
+
self._request_no_response(items, "delete")
|
|
87
|
+
|
|
88
|
+
def paginate(
|
|
89
|
+
self,
|
|
90
|
+
limit: int = 100,
|
|
91
|
+
cursor: str | None = None,
|
|
92
|
+
) -> PagedResponse[RobotCapabilityResponse]:
|
|
93
|
+
"""Paginate over capabilities in CDF.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
limit: Maximum number of items per page.
|
|
97
|
+
cursor: Cursor for pagination.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
PagedResponse of RobotCapabilityResponse objects.
|
|
101
|
+
"""
|
|
102
|
+
return self._paginate(cursor=cursor, limit=limit)
|
|
103
|
+
|
|
104
|
+
def iterate(
|
|
105
|
+
self,
|
|
106
|
+
limit: int | None = 100,
|
|
107
|
+
) -> Iterable[list[RobotCapabilityResponse]]:
|
|
108
|
+
"""Iterate over all capabilities in CDF.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
limit: Maximum number of items to return. None returns all.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Iterable of lists of RobotCapabilityResponse objects.
|
|
115
|
+
"""
|
|
116
|
+
return self._iterate(limit=limit)
|
|
117
|
+
|
|
118
|
+
def list(self, limit: int | None = 100) -> list[RobotCapabilityResponse]:
|
|
119
|
+
"""List all capabilities in CDF.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
limit: Maximum number of items to return. None returns all.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
List of RobotCapabilityResponse objects.
|
|
126
|
+
"""
|
|
127
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,138 @@
|
|
|
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 ExternalId
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.robotics._data_post_processing import (
|
|
9
|
+
RobotDataPostProcessingRequest,
|
|
10
|
+
RobotDataPostProcessingResponse,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class DataPostProcessingAPI(
|
|
15
|
+
CDFResourceAPI[ExternalId, RobotDataPostProcessingRequest, RobotDataPostProcessingResponse]
|
|
16
|
+
):
|
|
17
|
+
"""API for managing DataPostProcessing resources in CDF."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
20
|
+
super().__init__(
|
|
21
|
+
http_client=http_client,
|
|
22
|
+
method_endpoint_map={
|
|
23
|
+
"create": Endpoint(
|
|
24
|
+
method="POST", path="/robotics/data_postprocessing", item_limit=1000, concurrency_max_workers=1
|
|
25
|
+
),
|
|
26
|
+
"retrieve": Endpoint(
|
|
27
|
+
method="POST",
|
|
28
|
+
path="/robotics/data_postprocessing/byids",
|
|
29
|
+
item_limit=1000,
|
|
30
|
+
concurrency_max_workers=1,
|
|
31
|
+
),
|
|
32
|
+
"update": Endpoint(
|
|
33
|
+
method="POST",
|
|
34
|
+
path="/robotics/data_postprocessing/update",
|
|
35
|
+
item_limit=1000,
|
|
36
|
+
concurrency_max_workers=1,
|
|
37
|
+
),
|
|
38
|
+
"delete": Endpoint(
|
|
39
|
+
method="POST",
|
|
40
|
+
path="/robotics/data_postprocessing/delete",
|
|
41
|
+
item_limit=1000,
|
|
42
|
+
concurrency_max_workers=1,
|
|
43
|
+
),
|
|
44
|
+
"list": Endpoint(method="GET", path="/robotics/data_postprocessing", item_limit=1000),
|
|
45
|
+
},
|
|
46
|
+
disable_gzip=True,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def _validate_page_response(
|
|
50
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
51
|
+
) -> PagedResponse[RobotDataPostProcessingResponse]:
|
|
52
|
+
return PagedResponse[RobotDataPostProcessingResponse].model_validate_json(response.body)
|
|
53
|
+
|
|
54
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[ExternalId]:
|
|
55
|
+
return ResponseItems[ExternalId].model_validate_json(response.body)
|
|
56
|
+
|
|
57
|
+
def create(self, items: Sequence[RobotDataPostProcessingRequest]) -> list[RobotDataPostProcessingResponse]:
|
|
58
|
+
"""Create data post-processing configurations in CDF.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
items: List of RobotDataPostProcessingRequest objects to create.
|
|
62
|
+
Returns:
|
|
63
|
+
List of created RobotDataPostProcessingResponse objects.
|
|
64
|
+
"""
|
|
65
|
+
return self._request_item_response(items, "create")
|
|
66
|
+
|
|
67
|
+
def retrieve(self, items: Sequence[ExternalId]) -> list[RobotDataPostProcessingResponse]:
|
|
68
|
+
"""Retrieve data post-processing configurations from CDF.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
items: List of ExternalId objects to retrieve.
|
|
72
|
+
Returns:
|
|
73
|
+
List of retrieved RobotDataPostProcessingResponse objects.
|
|
74
|
+
"""
|
|
75
|
+
return self._request_item_response(items, method="retrieve")
|
|
76
|
+
|
|
77
|
+
def update(
|
|
78
|
+
self, items: Sequence[RobotDataPostProcessingRequest], mode: Literal["patch", "replace"] = "replace"
|
|
79
|
+
) -> list[RobotDataPostProcessingResponse]:
|
|
80
|
+
"""Update data post-processing configurations in CDF.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
items: List of RobotDataPostProcessingRequest objects to update.
|
|
84
|
+
mode: Update mode, either "patch" or "replace".
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
List of updated RobotDataPostProcessingResponse objects.
|
|
88
|
+
"""
|
|
89
|
+
return self._update(items, mode=mode)
|
|
90
|
+
|
|
91
|
+
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
92
|
+
"""Delete data post-processing configurations from CDF.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
items: List of ExternalId objects to delete.
|
|
96
|
+
"""
|
|
97
|
+
self._request_no_response(items, "delete")
|
|
98
|
+
|
|
99
|
+
def paginate(
|
|
100
|
+
self,
|
|
101
|
+
limit: int = 100,
|
|
102
|
+
cursor: str | None = None,
|
|
103
|
+
) -> PagedResponse[RobotDataPostProcessingResponse]:
|
|
104
|
+
"""Paginate over data post-processing configurations in CDF.
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
limit: Maximum number of items per page.
|
|
108
|
+
cursor: Cursor for pagination.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
PagedResponse of RobotDataPostProcessingResponse objects.
|
|
112
|
+
"""
|
|
113
|
+
return self._paginate(cursor=cursor, limit=limit)
|
|
114
|
+
|
|
115
|
+
def iterate(
|
|
116
|
+
self,
|
|
117
|
+
limit: int | None = 100,
|
|
118
|
+
) -> Iterable[list[RobotDataPostProcessingResponse]]:
|
|
119
|
+
"""Iterate over all data post-processing configurations in CDF.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
limit: Maximum number of items to return. None returns all.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
Iterable of lists of RobotDataPostProcessingResponse objects.
|
|
126
|
+
"""
|
|
127
|
+
return self._iterate(limit=limit)
|
|
128
|
+
|
|
129
|
+
def list(self, limit: int | None = 100) -> list[RobotDataPostProcessingResponse]:
|
|
130
|
+
"""List all data post-processing configurations in CDF.
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
limit: Maximum number of items to return. None returns all.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
List of RobotDataPostProcessingResponse objects.
|
|
137
|
+
"""
|
|
138
|
+
return self._list(limit=limit)
|