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,122 @@
|
|
|
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._frame import RobotFrameRequest, RobotFrameResponse
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class FramesAPI(CDFResourceAPI[ExternalId, RobotFrameRequest, RobotFrameResponse]):
|
|
12
|
+
"""API for managing Frame resources in CDF."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
15
|
+
super().__init__(
|
|
16
|
+
http_client=http_client,
|
|
17
|
+
method_endpoint_map={
|
|
18
|
+
"create": Endpoint(method="POST", path="/robotics/frames", item_limit=1000, concurrency_max_workers=1),
|
|
19
|
+
"retrieve": Endpoint(
|
|
20
|
+
method="POST", path="/robotics/frames/byids", item_limit=1000, concurrency_max_workers=1
|
|
21
|
+
),
|
|
22
|
+
"update": Endpoint(
|
|
23
|
+
method="POST", path="/robotics/frames/update", item_limit=1000, concurrency_max_workers=1
|
|
24
|
+
),
|
|
25
|
+
"delete": Endpoint(
|
|
26
|
+
method="POST", path="/robotics/frames/delete", item_limit=1000, concurrency_max_workers=1
|
|
27
|
+
),
|
|
28
|
+
"list": Endpoint(method="GET", path="/robotics/frames", item_limit=1000),
|
|
29
|
+
},
|
|
30
|
+
disable_gzip=True,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def _validate_page_response(
|
|
34
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
35
|
+
) -> PagedResponse[RobotFrameResponse]:
|
|
36
|
+
return PagedResponse[RobotFrameResponse].model_validate_json(response.body)
|
|
37
|
+
|
|
38
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[ExternalId]:
|
|
39
|
+
return ResponseItems[ExternalId].model_validate_json(response.body)
|
|
40
|
+
|
|
41
|
+
def create(self, items: Sequence[RobotFrameRequest]) -> list[RobotFrameResponse]:
|
|
42
|
+
"""Create frames in CDF.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
items: List of RobotFrameRequest objects to create.
|
|
46
|
+
Returns:
|
|
47
|
+
List of created RobotFrameResponse objects.
|
|
48
|
+
"""
|
|
49
|
+
return self._request_item_response(items, "create")
|
|
50
|
+
|
|
51
|
+
def retrieve(self, items: Sequence[ExternalId]) -> list[RobotFrameResponse]:
|
|
52
|
+
"""Retrieve frames from CDF.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
items: List of ExternalId objects to retrieve.
|
|
56
|
+
Returns:
|
|
57
|
+
List of retrieved RobotFrameResponse objects.
|
|
58
|
+
"""
|
|
59
|
+
return self._request_item_response(items, method="retrieve")
|
|
60
|
+
|
|
61
|
+
def update(
|
|
62
|
+
self, items: Sequence[RobotFrameRequest], mode: Literal["patch", "replace"] = "replace"
|
|
63
|
+
) -> list[RobotFrameResponse]:
|
|
64
|
+
"""Update frames in CDF.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
items: List of RobotFrameRequest objects to update.
|
|
68
|
+
mode: Update mode, either "patch" or "replace".
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
List of updated RobotFrameResponse objects.
|
|
72
|
+
"""
|
|
73
|
+
return self._update(items, mode=mode)
|
|
74
|
+
|
|
75
|
+
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
76
|
+
"""Delete frames from CDF.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
items: List of ExternalId objects to delete.
|
|
80
|
+
"""
|
|
81
|
+
self._request_no_response(items, "delete")
|
|
82
|
+
|
|
83
|
+
def paginate(
|
|
84
|
+
self,
|
|
85
|
+
limit: int = 100,
|
|
86
|
+
cursor: str | None = None,
|
|
87
|
+
) -> PagedResponse[RobotFrameResponse]:
|
|
88
|
+
"""Paginate over frames in CDF.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
limit: Maximum number of items per page.
|
|
92
|
+
cursor: Cursor for pagination.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
PagedResponse of RobotFrameResponse objects.
|
|
96
|
+
"""
|
|
97
|
+
return self._paginate(cursor=cursor, limit=limit)
|
|
98
|
+
|
|
99
|
+
def iterate(
|
|
100
|
+
self,
|
|
101
|
+
limit: int | None = 100,
|
|
102
|
+
) -> Iterable[list[RobotFrameResponse]]:
|
|
103
|
+
"""Iterate over all frames in CDF.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
limit: Maximum number of items to return. None returns all.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
Iterable of lists of RobotFrameResponse objects.
|
|
110
|
+
"""
|
|
111
|
+
return self._iterate(limit=limit)
|
|
112
|
+
|
|
113
|
+
def list(self, limit: int | None = 100) -> list[RobotFrameResponse]:
|
|
114
|
+
"""List all frames in CDF.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
limit: Maximum number of items to return. None returns all.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
List of RobotFrameResponse objects.
|
|
121
|
+
"""
|
|
122
|
+
return self._list(limit=limit)
|
|
@@ -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._location import (
|
|
9
|
+
RobotLocationRequest,
|
|
10
|
+
RobotLocationResponse,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class LocationsAPI(CDFResourceAPI[ExternalId, RobotLocationRequest, RobotLocationResponse]):
|
|
15
|
+
"""API for managing Location 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/locations", item_limit=1000, concurrency_max_workers=1
|
|
23
|
+
),
|
|
24
|
+
"retrieve": Endpoint(
|
|
25
|
+
method="POST", path="/robotics/locations/byids", item_limit=1000, concurrency_max_workers=1
|
|
26
|
+
),
|
|
27
|
+
"update": Endpoint(
|
|
28
|
+
method="POST", path="/robotics/locations/update", item_limit=1000, concurrency_max_workers=1
|
|
29
|
+
),
|
|
30
|
+
"delete": Endpoint(
|
|
31
|
+
method="POST", path="/robotics/locations/delete", item_limit=1000, concurrency_max_workers=1
|
|
32
|
+
),
|
|
33
|
+
"list": Endpoint(method="GET", path="/robotics/locations", item_limit=1000),
|
|
34
|
+
},
|
|
35
|
+
disable_gzip=True,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
def _validate_page_response(
|
|
39
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
40
|
+
) -> PagedResponse[RobotLocationResponse]:
|
|
41
|
+
return PagedResponse[RobotLocationResponse].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[RobotLocationRequest]) -> list[RobotLocationResponse]:
|
|
47
|
+
"""Create locations in CDF.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
items: List of RobotLocationRequest objects to create.
|
|
51
|
+
Returns:
|
|
52
|
+
List of created RobotLocationResponse objects.
|
|
53
|
+
"""
|
|
54
|
+
return self._request_item_response(items, "create")
|
|
55
|
+
|
|
56
|
+
def retrieve(self, items: Sequence[ExternalId]) -> list[RobotLocationResponse]:
|
|
57
|
+
"""Retrieve locations from CDF.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
items: List of ExternalId objects to retrieve.
|
|
61
|
+
Returns:
|
|
62
|
+
List of retrieved RobotLocationResponse objects.
|
|
63
|
+
"""
|
|
64
|
+
return self._request_item_response(items, method="retrieve")
|
|
65
|
+
|
|
66
|
+
def update(
|
|
67
|
+
self, items: Sequence[RobotLocationRequest], mode: Literal["patch", "replace"] = "replace"
|
|
68
|
+
) -> list[RobotLocationResponse]:
|
|
69
|
+
"""Update locations in CDF.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
items: List of RobotLocationRequest objects to update.
|
|
73
|
+
mode: Update mode, either "patch" or "replace".
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
List of updated RobotLocationResponse objects.
|
|
77
|
+
"""
|
|
78
|
+
return self._update(items, mode=mode)
|
|
79
|
+
|
|
80
|
+
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
81
|
+
"""Delete locations 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[RobotLocationResponse]:
|
|
93
|
+
"""Paginate over locations in CDF.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
limit: Maximum number of items per page.
|
|
97
|
+
cursor: Cursor for pagination.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
PagedResponse of RobotLocationResponse objects.
|
|
101
|
+
"""
|
|
102
|
+
return self._paginate(cursor=cursor, limit=limit)
|
|
103
|
+
|
|
104
|
+
def iterate(
|
|
105
|
+
self,
|
|
106
|
+
limit: int | None = 100,
|
|
107
|
+
) -> Iterable[list[RobotLocationResponse]]:
|
|
108
|
+
"""Iterate over all locations in CDF.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
limit: Maximum number of items to return. None returns all.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Iterable of lists of RobotLocationResponse objects.
|
|
115
|
+
"""
|
|
116
|
+
return self._iterate(limit=limit)
|
|
117
|
+
|
|
118
|
+
def list(self, limit: int | None = 100) -> list[RobotLocationResponse]:
|
|
119
|
+
"""List all locations in CDF.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
limit: Maximum number of items to return. None returns all.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
List of RobotLocationResponse objects.
|
|
126
|
+
"""
|
|
127
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,122 @@
|
|
|
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._map import RobotMapRequest, RobotMapResponse
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MapsAPI(CDFResourceAPI[ExternalId, RobotMapRequest, RobotMapResponse]):
|
|
12
|
+
"""API for managing Map resources in CDF."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
15
|
+
super().__init__(
|
|
16
|
+
http_client=http_client,
|
|
17
|
+
method_endpoint_map={
|
|
18
|
+
"create": Endpoint(method="POST", path="/robotics/maps", item_limit=1000, concurrency_max_workers=1),
|
|
19
|
+
"retrieve": Endpoint(
|
|
20
|
+
method="POST", path="/robotics/maps/byids", item_limit=1000, concurrency_max_workers=1
|
|
21
|
+
),
|
|
22
|
+
"update": Endpoint(
|
|
23
|
+
method="POST", path="/robotics/maps/update", item_limit=1000, concurrency_max_workers=1
|
|
24
|
+
),
|
|
25
|
+
"delete": Endpoint(
|
|
26
|
+
method="POST", path="/robotics/maps/delete", item_limit=1000, concurrency_max_workers=1
|
|
27
|
+
),
|
|
28
|
+
"list": Endpoint(method="GET", path="/robotics/maps", item_limit=1000),
|
|
29
|
+
},
|
|
30
|
+
disable_gzip=True,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def _validate_page_response(
|
|
34
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
35
|
+
) -> PagedResponse[RobotMapResponse]:
|
|
36
|
+
return PagedResponse[RobotMapResponse].model_validate_json(response.body)
|
|
37
|
+
|
|
38
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[ExternalId]:
|
|
39
|
+
return ResponseItems[ExternalId].model_validate_json(response.body)
|
|
40
|
+
|
|
41
|
+
def create(self, items: Sequence[RobotMapRequest]) -> list[RobotMapResponse]:
|
|
42
|
+
"""Create maps in CDF.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
items: List of RobotMapRequest objects to create.
|
|
46
|
+
Returns:
|
|
47
|
+
List of created RobotMapResponse objects.
|
|
48
|
+
"""
|
|
49
|
+
return self._request_item_response(items, "create")
|
|
50
|
+
|
|
51
|
+
def retrieve(self, items: Sequence[ExternalId]) -> list[RobotMapResponse]:
|
|
52
|
+
"""Retrieve maps from CDF.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
items: List of ExternalId objects to retrieve.
|
|
56
|
+
Returns:
|
|
57
|
+
List of retrieved RobotMapResponse objects.
|
|
58
|
+
"""
|
|
59
|
+
return self._request_item_response(items, method="retrieve")
|
|
60
|
+
|
|
61
|
+
def update(
|
|
62
|
+
self, items: Sequence[RobotMapRequest], mode: Literal["patch", "replace"] = "replace"
|
|
63
|
+
) -> list[RobotMapResponse]:
|
|
64
|
+
"""Update maps in CDF.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
items: List of RobotMapRequest objects to update.
|
|
68
|
+
mode: Update mode, either "patch" or "replace".
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
List of updated RobotMapResponse objects.
|
|
72
|
+
"""
|
|
73
|
+
return self._update(items, mode=mode)
|
|
74
|
+
|
|
75
|
+
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
76
|
+
"""Delete maps from CDF.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
items: List of ExternalId objects to delete.
|
|
80
|
+
"""
|
|
81
|
+
self._request_no_response(items, "delete")
|
|
82
|
+
|
|
83
|
+
def paginate(
|
|
84
|
+
self,
|
|
85
|
+
limit: int = 100,
|
|
86
|
+
cursor: str | None = None,
|
|
87
|
+
) -> PagedResponse[RobotMapResponse]:
|
|
88
|
+
"""Paginate over maps in CDF.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
limit: Maximum number of items per page.
|
|
92
|
+
cursor: Cursor for pagination.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
PagedResponse of RobotMapResponse objects.
|
|
96
|
+
"""
|
|
97
|
+
return self._paginate(cursor=cursor, limit=limit)
|
|
98
|
+
|
|
99
|
+
def iterate(
|
|
100
|
+
self,
|
|
101
|
+
limit: int | None = 100,
|
|
102
|
+
) -> Iterable[list[RobotMapResponse]]:
|
|
103
|
+
"""Iterate over all maps in CDF.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
limit: Maximum number of items to return. None returns all.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
Iterable of lists of RobotMapResponse objects.
|
|
110
|
+
"""
|
|
111
|
+
return self._iterate(limit=limit)
|
|
112
|
+
|
|
113
|
+
def list(self, limit: int | None = 100) -> list[RobotMapResponse]:
|
|
114
|
+
"""List all maps in CDF.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
limit: Maximum number of items to return. None returns all.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
List of RobotMapResponse objects.
|
|
121
|
+
"""
|
|
122
|
+
return self._list(limit=limit)
|
|
@@ -0,0 +1,122 @@
|
|
|
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 DataSetId
|
|
8
|
+
from cognite_toolkit._cdf_tk.client.resource_classes.robotics._robot import RobotRequest, RobotResponse
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RobotsAPI(CDFResourceAPI[DataSetId, RobotRequest, RobotResponse]):
|
|
12
|
+
"""API for managing Robot resources in CDF."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, http_client: HTTPClient) -> None:
|
|
15
|
+
super().__init__(
|
|
16
|
+
http_client=http_client,
|
|
17
|
+
method_endpoint_map={
|
|
18
|
+
"create": Endpoint(method="POST", path="/robotics/robots", item_limit=1000, concurrency_max_workers=1),
|
|
19
|
+
"retrieve": Endpoint(
|
|
20
|
+
method="POST", path="/robotics/robots/byids", item_limit=1000, concurrency_max_workers=1
|
|
21
|
+
),
|
|
22
|
+
"update": Endpoint(
|
|
23
|
+
method="POST", path="/robotics/robots/update", item_limit=1000, concurrency_max_workers=1
|
|
24
|
+
),
|
|
25
|
+
"delete": Endpoint(
|
|
26
|
+
method="POST", path="/robotics/robots/delete", item_limit=1000, concurrency_max_workers=1
|
|
27
|
+
),
|
|
28
|
+
"list": Endpoint(method="GET", path="/robotics/robots", item_limit=1000),
|
|
29
|
+
},
|
|
30
|
+
disable_gzip=True,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def _validate_page_response(
|
|
34
|
+
self, response: SuccessResponse2 | ItemsSuccessResponse2
|
|
35
|
+
) -> PagedResponse[RobotResponse]:
|
|
36
|
+
return PagedResponse[RobotResponse].model_validate_json(response.body)
|
|
37
|
+
|
|
38
|
+
def _reference_response(self, response: SuccessResponse2) -> ResponseItems[DataSetId]:
|
|
39
|
+
return ResponseItems[DataSetId].model_validate_json(response.body)
|
|
40
|
+
|
|
41
|
+
def create(self, items: Sequence[RobotRequest]) -> list[RobotResponse]:
|
|
42
|
+
"""Create robots in CDF.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
items: List of RobotRequest objects to create.
|
|
46
|
+
Returns:
|
|
47
|
+
List of created RobotResponse objects.
|
|
48
|
+
"""
|
|
49
|
+
return self._request_item_response(items, "create")
|
|
50
|
+
|
|
51
|
+
def retrieve(self, items: Sequence[DataSetId]) -> list[RobotResponse]:
|
|
52
|
+
"""Retrieve robots from CDF.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
items: List of DataSetId objects to retrieve.
|
|
56
|
+
Returns:
|
|
57
|
+
List of retrieved RobotResponse objects.
|
|
58
|
+
"""
|
|
59
|
+
return self._request_item_response(items, method="retrieve")
|
|
60
|
+
|
|
61
|
+
def update(
|
|
62
|
+
self, items: Sequence[RobotRequest], mode: Literal["patch", "replace"] = "replace"
|
|
63
|
+
) -> list[RobotResponse]:
|
|
64
|
+
"""Update robots in CDF.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
items: List of RobotRequest objects to update.
|
|
68
|
+
mode: Update mode, either "patch" or "replace".
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
List of updated RobotResponse objects.
|
|
72
|
+
"""
|
|
73
|
+
return self._update(items, mode=mode)
|
|
74
|
+
|
|
75
|
+
def delete(self, items: Sequence[DataSetId]) -> None:
|
|
76
|
+
"""Delete robots from CDF.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
items: List of DataSetId objects to delete.
|
|
80
|
+
"""
|
|
81
|
+
self._request_no_response(items, "delete")
|
|
82
|
+
|
|
83
|
+
def paginate(
|
|
84
|
+
self,
|
|
85
|
+
limit: int = 100,
|
|
86
|
+
cursor: str | None = None,
|
|
87
|
+
) -> PagedResponse[RobotResponse]:
|
|
88
|
+
"""Paginate over robots in CDF.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
limit: Maximum number of items per page.
|
|
92
|
+
cursor: Cursor for pagination.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
PagedResponse of RobotResponse objects.
|
|
96
|
+
"""
|
|
97
|
+
return self._paginate(cursor=cursor, limit=limit)
|
|
98
|
+
|
|
99
|
+
def iterate(
|
|
100
|
+
self,
|
|
101
|
+
limit: int | None = 100,
|
|
102
|
+
) -> Iterable[list[RobotResponse]]:
|
|
103
|
+
"""Iterate over all robots in CDF.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
limit: Maximum number of items to return. None returns all.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
Iterable of lists of RobotResponse objects.
|
|
110
|
+
"""
|
|
111
|
+
return self._iterate(limit=limit)
|
|
112
|
+
|
|
113
|
+
def list(self, limit: int | None = 100) -> list[RobotResponse]:
|
|
114
|
+
"""List all robots in CDF.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
limit: Maximum number of items to return. None returns all.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
List of RobotResponse objects.
|
|
121
|
+
"""
|
|
122
|
+
return self._list(limit=limit)
|
|
@@ -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)
|