cognite-toolkit 0.7.70__py3-none-any.whl → 0.7.72__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/client/_resource_base.py +0 -22
- cognite_toolkit/_cdf_tk/client/_toolkit_client.py +0 -2
- cognite_toolkit/_cdf_tk/client/api/infield.py +56 -204
- cognite_toolkit/_cdf_tk/client/api/instances.py +239 -16
- cognite_toolkit/_cdf_tk/client/api/robotics_capabilities.py +9 -3
- cognite_toolkit/_cdf_tk/client/api/robotics_data_postprocessing.py +12 -3
- cognite_toolkit/_cdf_tk/client/api/robotics_frames.py +10 -3
- cognite_toolkit/_cdf_tk/client/api/robotics_locations.py +10 -3
- cognite_toolkit/_cdf_tk/client/api/robotics_maps.py +10 -3
- cognite_toolkit/_cdf_tk/client/api/robotics_robots.py +10 -3
- cognite_toolkit/_cdf_tk/client/cdf_client/responses.py +3 -3
- cognite_toolkit/_cdf_tk/client/http_client/_client.py +1 -1
- cognite_toolkit/_cdf_tk/client/resource_classes/infield.py +133 -72
- cognite_toolkit/_cdf_tk/client/resource_classes/instance_api.py +119 -79
- cognite_toolkit/_cdf_tk/client/testing.py +14 -16
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/fieldops.py +45 -46
- cognite_toolkit/_cdf_tk/cruds/_resource_cruds/robotics.py +154 -160
- 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.70.dist-info → cognite_toolkit-0.7.72.dist-info}/METADATA +1 -1
- {cognite_toolkit-0.7.70.dist-info → cognite_toolkit-0.7.72.dist-info}/RECORD +25 -35
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/__init__.py +0 -8
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/api.py +0 -20
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/capabilities.py +0 -142
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/data_postprocessing.py +0 -144
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/frames.py +0 -136
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/locations.py +0 -136
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/maps.py +0 -136
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/robots.py +0 -132
- cognite_toolkit/_cdf_tk/client/api/legacy/robotics/utlis.py +0 -13
- cognite_toolkit/_cdf_tk/client/resource_classes/legacy/robotics.py +0 -970
- {cognite_toolkit-0.7.70.dist-info → cognite_toolkit-0.7.72.dist-info}/WHEEL +0 -0
- {cognite_toolkit-0.7.70.dist-info → cognite_toolkit-0.7.72.dist-info}/entry_points.txt +0 -0
|
@@ -53,7 +53,7 @@ class CapabilitiesAPI(CDFResourceAPI[ExternalId, RobotCapabilityRequest, RobotCa
|
|
|
53
53
|
"""
|
|
54
54
|
return self._request_item_response(items, "create")
|
|
55
55
|
|
|
56
|
-
def retrieve(self, items: Sequence[ExternalId]) -> list[RobotCapabilityResponse]:
|
|
56
|
+
def retrieve(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> list[RobotCapabilityResponse]:
|
|
57
57
|
"""Retrieve capabilities from CDF.
|
|
58
58
|
|
|
59
59
|
Args:
|
|
@@ -61,6 +61,8 @@ class CapabilitiesAPI(CDFResourceAPI[ExternalId, RobotCapabilityRequest, RobotCa
|
|
|
61
61
|
Returns:
|
|
62
62
|
List of retrieved RobotCapabilityResponse objects.
|
|
63
63
|
"""
|
|
64
|
+
if ignore_unknown_ids:
|
|
65
|
+
return self._request_item_split_retries(items, method="retrieve")
|
|
64
66
|
return self._request_item_response(items, method="retrieve")
|
|
65
67
|
|
|
66
68
|
def update(
|
|
@@ -77,13 +79,17 @@ class CapabilitiesAPI(CDFResourceAPI[ExternalId, RobotCapabilityRequest, RobotCa
|
|
|
77
79
|
"""
|
|
78
80
|
return self._update(items, mode=mode)
|
|
79
81
|
|
|
80
|
-
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
82
|
+
def delete(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
81
83
|
"""Delete capabilities from CDF.
|
|
82
84
|
|
|
83
85
|
Args:
|
|
84
86
|
items: List of ExternalId objects to delete.
|
|
87
|
+
ignore_unknown_ids: If True, ignores unknown IDs during deletion.
|
|
85
88
|
"""
|
|
86
|
-
|
|
89
|
+
if ignore_unknown_ids:
|
|
90
|
+
self._request_item_split_retries_no_response(items, "delete")
|
|
91
|
+
else:
|
|
92
|
+
self._request_no_response(items, "delete")
|
|
87
93
|
|
|
88
94
|
def paginate(
|
|
89
95
|
self,
|
|
@@ -64,14 +64,19 @@ class DataPostProcessingAPI(
|
|
|
64
64
|
"""
|
|
65
65
|
return self._request_item_response(items, "create")
|
|
66
66
|
|
|
67
|
-
def retrieve(
|
|
67
|
+
def retrieve(
|
|
68
|
+
self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False
|
|
69
|
+
) -> list[RobotDataPostProcessingResponse]:
|
|
68
70
|
"""Retrieve data post-processing configurations from CDF.
|
|
69
71
|
|
|
70
72
|
Args:
|
|
71
73
|
items: List of ExternalId objects to retrieve.
|
|
74
|
+
ignore_unknown_ids: If True, ignores unknown IDs during retrieval.
|
|
72
75
|
Returns:
|
|
73
76
|
List of retrieved RobotDataPostProcessingResponse objects.
|
|
74
77
|
"""
|
|
78
|
+
if ignore_unknown_ids:
|
|
79
|
+
return self._request_item_split_retries(items, method="retrieve")
|
|
75
80
|
return self._request_item_response(items, method="retrieve")
|
|
76
81
|
|
|
77
82
|
def update(
|
|
@@ -88,13 +93,17 @@ class DataPostProcessingAPI(
|
|
|
88
93
|
"""
|
|
89
94
|
return self._update(items, mode=mode)
|
|
90
95
|
|
|
91
|
-
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
96
|
+
def delete(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
92
97
|
"""Delete data post-processing configurations from CDF.
|
|
93
98
|
|
|
94
99
|
Args:
|
|
95
100
|
items: List of ExternalId objects to delete.
|
|
101
|
+
ignore_unknown_ids: If True, ignores unknown IDs during deletion.
|
|
96
102
|
"""
|
|
97
|
-
|
|
103
|
+
if ignore_unknown_ids:
|
|
104
|
+
self._request_item_split_retries_no_response(items, "delete")
|
|
105
|
+
else:
|
|
106
|
+
self._request_no_response(items, "delete")
|
|
98
107
|
|
|
99
108
|
def paginate(
|
|
100
109
|
self,
|
|
@@ -48,14 +48,17 @@ class FramesAPI(CDFResourceAPI[ExternalId, RobotFrameRequest, RobotFrameResponse
|
|
|
48
48
|
"""
|
|
49
49
|
return self._request_item_response(items, "create")
|
|
50
50
|
|
|
51
|
-
def retrieve(self, items: Sequence[ExternalId]) -> list[RobotFrameResponse]:
|
|
51
|
+
def retrieve(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> list[RobotFrameResponse]:
|
|
52
52
|
"""Retrieve frames from CDF.
|
|
53
53
|
|
|
54
54
|
Args:
|
|
55
55
|
items: List of ExternalId objects to retrieve.
|
|
56
|
+
ignore_unknown_ids: If True, ignores unknown IDs during retrieval.
|
|
56
57
|
Returns:
|
|
57
58
|
List of retrieved RobotFrameResponse objects.
|
|
58
59
|
"""
|
|
60
|
+
if ignore_unknown_ids:
|
|
61
|
+
return self._request_item_split_retries(items, method="retrieve")
|
|
59
62
|
return self._request_item_response(items, method="retrieve")
|
|
60
63
|
|
|
61
64
|
def update(
|
|
@@ -72,13 +75,17 @@ class FramesAPI(CDFResourceAPI[ExternalId, RobotFrameRequest, RobotFrameResponse
|
|
|
72
75
|
"""
|
|
73
76
|
return self._update(items, mode=mode)
|
|
74
77
|
|
|
75
|
-
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
78
|
+
def delete(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
76
79
|
"""Delete frames from CDF.
|
|
77
80
|
|
|
78
81
|
Args:
|
|
79
82
|
items: List of ExternalId objects to delete.
|
|
83
|
+
ignore_unknown_ids: If True, ignores unknown IDs during deletion.
|
|
80
84
|
"""
|
|
81
|
-
|
|
85
|
+
if ignore_unknown_ids:
|
|
86
|
+
self._request_item_split_retries_no_response(items, "delete")
|
|
87
|
+
else:
|
|
88
|
+
self._request_no_response(items, "delete")
|
|
82
89
|
|
|
83
90
|
def paginate(
|
|
84
91
|
self,
|
|
@@ -53,14 +53,17 @@ class LocationsAPI(CDFResourceAPI[ExternalId, RobotLocationRequest, RobotLocatio
|
|
|
53
53
|
"""
|
|
54
54
|
return self._request_item_response(items, "create")
|
|
55
55
|
|
|
56
|
-
def retrieve(self, items: Sequence[ExternalId]) -> list[RobotLocationResponse]:
|
|
56
|
+
def retrieve(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> list[RobotLocationResponse]:
|
|
57
57
|
"""Retrieve locations from CDF.
|
|
58
58
|
|
|
59
59
|
Args:
|
|
60
60
|
items: List of ExternalId objects to retrieve.
|
|
61
|
+
ignore_unknown_ids: If True, ignores unknown IDs during retrieval.
|
|
61
62
|
Returns:
|
|
62
63
|
List of retrieved RobotLocationResponse objects.
|
|
63
64
|
"""
|
|
65
|
+
if ignore_unknown_ids:
|
|
66
|
+
return self._request_item_split_retries(items, method="retrieve")
|
|
64
67
|
return self._request_item_response(items, method="retrieve")
|
|
65
68
|
|
|
66
69
|
def update(
|
|
@@ -77,13 +80,17 @@ class LocationsAPI(CDFResourceAPI[ExternalId, RobotLocationRequest, RobotLocatio
|
|
|
77
80
|
"""
|
|
78
81
|
return self._update(items, mode=mode)
|
|
79
82
|
|
|
80
|
-
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
83
|
+
def delete(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
81
84
|
"""Delete locations from CDF.
|
|
82
85
|
|
|
83
86
|
Args:
|
|
84
87
|
items: List of ExternalId objects to delete.
|
|
88
|
+
ignore_unknown_ids: If True, ignores unknown IDs during deletion.
|
|
85
89
|
"""
|
|
86
|
-
|
|
90
|
+
if ignore_unknown_ids:
|
|
91
|
+
self._request_item_split_retries_no_response(items, "delete")
|
|
92
|
+
else:
|
|
93
|
+
self._request_no_response(items, "delete")
|
|
87
94
|
|
|
88
95
|
def paginate(
|
|
89
96
|
self,
|
|
@@ -48,14 +48,17 @@ class MapsAPI(CDFResourceAPI[ExternalId, RobotMapRequest, RobotMapResponse]):
|
|
|
48
48
|
"""
|
|
49
49
|
return self._request_item_response(items, "create")
|
|
50
50
|
|
|
51
|
-
def retrieve(self, items: Sequence[ExternalId]) -> list[RobotMapResponse]:
|
|
51
|
+
def retrieve(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> list[RobotMapResponse]:
|
|
52
52
|
"""Retrieve maps from CDF.
|
|
53
53
|
|
|
54
54
|
Args:
|
|
55
55
|
items: List of ExternalId objects to retrieve.
|
|
56
|
+
ignore_unknown_ids: If True, ignores unknown IDs during retrieval.
|
|
56
57
|
Returns:
|
|
57
58
|
List of retrieved RobotMapResponse objects.
|
|
58
59
|
"""
|
|
60
|
+
if ignore_unknown_ids:
|
|
61
|
+
return self._request_item_split_retries(items, method="retrieve")
|
|
59
62
|
return self._request_item_response(items, method="retrieve")
|
|
60
63
|
|
|
61
64
|
def update(
|
|
@@ -72,13 +75,17 @@ class MapsAPI(CDFResourceAPI[ExternalId, RobotMapRequest, RobotMapResponse]):
|
|
|
72
75
|
"""
|
|
73
76
|
return self._update(items, mode=mode)
|
|
74
77
|
|
|
75
|
-
def delete(self, items: Sequence[ExternalId]) -> None:
|
|
78
|
+
def delete(self, items: Sequence[ExternalId], ignore_unknown_ids: bool = False) -> None:
|
|
76
79
|
"""Delete maps from CDF.
|
|
77
80
|
|
|
78
81
|
Args:
|
|
79
82
|
items: List of ExternalId objects to delete.
|
|
83
|
+
ignore_unknown_ids: If True, ignores unknown IDs during deletion.
|
|
80
84
|
"""
|
|
81
|
-
|
|
85
|
+
if ignore_unknown_ids:
|
|
86
|
+
self._request_item_split_retries_no_response(items, "delete")
|
|
87
|
+
else:
|
|
88
|
+
self._request_no_response(items, "delete")
|
|
82
89
|
|
|
83
90
|
def paginate(
|
|
84
91
|
self,
|
|
@@ -46,14 +46,17 @@ class RobotsAPI(CDFResourceAPI[DataSetId, RobotRequest, RobotResponse]):
|
|
|
46
46
|
"""
|
|
47
47
|
return self._request_item_response(items, "create")
|
|
48
48
|
|
|
49
|
-
def retrieve(self, items: Sequence[DataSetId]) -> list[RobotResponse]:
|
|
49
|
+
def retrieve(self, items: Sequence[DataSetId], ignore_unknown_ids: bool = False) -> list[RobotResponse]:
|
|
50
50
|
"""Retrieve robots from CDF.
|
|
51
51
|
|
|
52
52
|
Args:
|
|
53
53
|
items: List of DataSetId objects to retrieve.
|
|
54
|
+
ignore_unknown_ids: If True, ignores unknown IDs during retrieval.
|
|
54
55
|
Returns:
|
|
55
56
|
List of retrieved RobotResponse objects.
|
|
56
57
|
"""
|
|
58
|
+
if ignore_unknown_ids:
|
|
59
|
+
return self._request_item_split_retries(items, method="retrieve")
|
|
57
60
|
return self._request_item_response(items, method="retrieve")
|
|
58
61
|
|
|
59
62
|
def update(
|
|
@@ -70,13 +73,17 @@ class RobotsAPI(CDFResourceAPI[DataSetId, RobotRequest, RobotResponse]):
|
|
|
70
73
|
"""
|
|
71
74
|
return self._update(items, mode=mode)
|
|
72
75
|
|
|
73
|
-
def delete(self, items: Sequence[DataSetId]) -> None:
|
|
76
|
+
def delete(self, items: Sequence[DataSetId], ignore_unknown_ids: bool = False) -> None:
|
|
74
77
|
"""Delete robots from CDF.
|
|
75
78
|
|
|
76
79
|
Args:
|
|
77
80
|
items: List of DataSetId objects to delete.
|
|
81
|
+
ignore_unknown_ids: If True, ignores unknown IDs during deletion.
|
|
78
82
|
"""
|
|
79
|
-
|
|
83
|
+
if ignore_unknown_ids:
|
|
84
|
+
self._request_item_split_retries_no_response(items, "delete")
|
|
85
|
+
else:
|
|
86
|
+
self._request_no_response(items, "delete")
|
|
80
87
|
|
|
81
88
|
def paginate(
|
|
82
89
|
self,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Generic, TypeVar
|
|
1
|
+
from typing import Any, Generic, TypeVar
|
|
2
2
|
|
|
3
3
|
from pydantic import BaseModel, Field, JsonValue
|
|
4
4
|
|
|
@@ -22,8 +22,8 @@ class PagedResponse(BaseModel, Generic[T]):
|
|
|
22
22
|
next_cursor: str | None = Field(None, alias="nextCursor")
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
class QueryResponse(BaseModel
|
|
26
|
-
items: dict[str, list[
|
|
25
|
+
class QueryResponse(BaseModel):
|
|
26
|
+
items: dict[str, list[dict[str, Any]]]
|
|
27
27
|
typing: dict[str, JsonValue] | None = None
|
|
28
28
|
next_cursor: dict[str, str] = Field(alias="nextCursor")
|
|
29
29
|
debug: dict[str, JsonValue] | None = None
|
|
@@ -65,7 +65,7 @@ class HTTPClient:
|
|
|
65
65
|
pool_connections: int = 10,
|
|
66
66
|
pool_maxsize: int = 20,
|
|
67
67
|
retry_status_codes: Set[int] = frozenset({408, 429, 502, 503, 504}),
|
|
68
|
-
split_items_status_codes: Set[int] = frozenset({400, 408, 409, 422, 502, 503, 504}),
|
|
68
|
+
split_items_status_codes: Set[int] = frozenset({400, 404, 408, 409, 422, 502, 503, 504}),
|
|
69
69
|
console: Console | None = None,
|
|
70
70
|
):
|
|
71
71
|
self.config = config
|
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
import sys
|
|
2
1
|
from typing import Any, ClassVar, Literal
|
|
3
2
|
|
|
4
|
-
from pydantic import JsonValue,
|
|
5
|
-
from pydantic_core.core_schema import ValidationInfo
|
|
3
|
+
from pydantic import JsonValue, model_validator
|
|
6
4
|
|
|
7
|
-
from cognite_toolkit._cdf_tk.client._resource_base import
|
|
8
|
-
from cognite_toolkit._cdf_tk.protocols import (
|
|
9
|
-
ResourceRequestListProtocol,
|
|
10
|
-
ResourceResponseListProtocol,
|
|
11
|
-
)
|
|
5
|
+
from cognite_toolkit._cdf_tk.client._resource_base import BaseModelObject
|
|
12
6
|
from cognite_toolkit._cdf_tk.utils.text import sanitize_instance_external_id
|
|
13
7
|
|
|
14
|
-
from .instance_api import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
from .instance_api import (
|
|
9
|
+
TypedInstanceIdentifier,
|
|
10
|
+
TypedNodeIdentifier,
|
|
11
|
+
TypedViewReference,
|
|
12
|
+
WrappedInstanceListRequest,
|
|
13
|
+
WrappedInstanceListResponse,
|
|
14
|
+
WrappedInstanceRequest,
|
|
15
|
+
WrappedInstanceResponse,
|
|
16
|
+
move_properties,
|
|
17
|
+
)
|
|
20
18
|
|
|
21
|
-
INFIELD_LOCATION_CONFIG_VIEW_ID =
|
|
22
|
-
|
|
19
|
+
INFIELD_LOCATION_CONFIG_VIEW_ID = TypedViewReference(
|
|
20
|
+
space="cdf_infield", external_id="InFieldLocationConfig", version="v1"
|
|
21
|
+
)
|
|
22
|
+
INFIELD_CDM_LOCATION_CONFIG_VIEW_ID = TypedViewReference(
|
|
23
23
|
space="infield_cdm_source_desc_sche_asset_file_ts", external_id="InFieldCDMLocationConfig", version="v1"
|
|
24
24
|
)
|
|
25
|
-
DATA_EXPLORATION_CONFIG_VIEW_ID =
|
|
25
|
+
DATA_EXPLORATION_CONFIG_VIEW_ID = TypedViewReference(
|
|
26
|
+
space="cdf_infield", external_id="DataExplorationConfig", version="v1"
|
|
27
|
+
)
|
|
26
28
|
|
|
27
29
|
|
|
28
|
-
class DataExplorationConfig(
|
|
30
|
+
class DataExplorationConfig(BaseModelObject):
|
|
29
31
|
"""Data Exploration Configuration resource class."""
|
|
30
32
|
|
|
31
|
-
VIEW_ID: ClassVar[
|
|
32
|
-
|
|
33
|
+
VIEW_ID: ClassVar[TypedViewReference] = DATA_EXPLORATION_CONFIG_VIEW_ID
|
|
34
|
+
space: str | None = None
|
|
35
|
+
external_id: str | None = None
|
|
33
36
|
|
|
34
37
|
observations: dict[str, JsonValue] | None = None
|
|
35
38
|
activities: dict[str, JsonValue] | None = None
|
|
@@ -37,19 +40,19 @@ class DataExplorationConfig(InstanceRequestResource):
|
|
|
37
40
|
notifications: dict[str, JsonValue] | None = None
|
|
38
41
|
assets: dict[str, JsonValue] | None = None
|
|
39
42
|
|
|
43
|
+
@model_validator(mode="before")
|
|
44
|
+
@classmethod
|
|
45
|
+
def move_properties(cls, data: dict[str, Any]) -> dict[str, Any]:
|
|
46
|
+
return move_properties(data, cls.VIEW_ID)
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
InstanceRequestResource,
|
|
44
|
-
):
|
|
48
|
+
|
|
49
|
+
class InFieldLocationConfig(BaseModelObject):
|
|
45
50
|
"""Infield Location Configuration resource class.
|
|
46
51
|
|
|
47
52
|
This class is used for both the response and request resource for Infield Location Configuration nodes.
|
|
48
53
|
"""
|
|
49
54
|
|
|
50
|
-
VIEW_ID: ClassVar[
|
|
51
|
-
instance_type: Literal["node"] = "node"
|
|
52
|
-
|
|
55
|
+
VIEW_ID: ClassVar[TypedViewReference] = INFIELD_LOCATION_CONFIG_VIEW_ID
|
|
53
56
|
root_location_external_id: str | None = None
|
|
54
57
|
feature_toggles: dict[str, JsonValue] | None = None
|
|
55
58
|
app_instance_space: str | None = None
|
|
@@ -57,48 +60,94 @@ class InfieldLocationConfig(
|
|
|
57
60
|
data_filters: dict[str, JsonValue] | None = None
|
|
58
61
|
data_exploration_config: DataExplorationConfig | None = None
|
|
59
62
|
|
|
60
|
-
def as_request_resource(self) -> "InfieldLocationConfig":
|
|
61
|
-
return self
|
|
62
|
-
|
|
63
|
-
def as_write(self) -> Self:
|
|
64
|
-
return self
|
|
65
|
-
|
|
66
|
-
@field_validator("data_exploration_config", mode="before")
|
|
67
|
-
@classmethod
|
|
68
|
-
def generate_identifier_if_missing(cls, value: Any, info: ValidationInfo) -> Any:
|
|
69
|
-
"""We do not require the user to specify the space and externalId for the data exploration config."""
|
|
70
|
-
if isinstance(value, dict):
|
|
71
|
-
if value.get("space") is None:
|
|
72
|
-
value["space"] = info.data["space"]
|
|
73
|
-
if value.get("externalId") is None:
|
|
74
|
-
external_id = info.data["external_id"]
|
|
75
|
-
candidate = f"{external_id}_data_exploration_config"
|
|
76
|
-
value["externalId"] = sanitize_instance_external_id(candidate)
|
|
77
|
-
return value
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class InfieldLocationConfigList(
|
|
81
|
-
BaseResourceList[InfieldLocationConfig],
|
|
82
|
-
ResourceResponseListProtocol,
|
|
83
|
-
ResourceRequestListProtocol,
|
|
84
|
-
):
|
|
85
|
-
"""A list of InfieldLocationConfig objects."""
|
|
86
|
-
|
|
87
|
-
_RESOURCE = InfieldLocationConfig
|
|
88
|
-
|
|
89
|
-
def as_write(self) -> Self:
|
|
90
|
-
return self
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
class InFieldCDMLocationConfig(ResponseResource["InFieldCDMLocationConfig"], InstanceRequestResource):
|
|
94
|
-
"""InField CDM Location Configuration resource class.
|
|
95
|
-
|
|
96
|
-
This class is used for both the response and request resource for InField CDM Location Configuration nodes.
|
|
97
|
-
"""
|
|
98
|
-
|
|
99
|
-
VIEW_ID: ClassVar[ViewReference] = INFIELD_CDM_LOCATION_CONFIG_VIEW_ID
|
|
100
|
-
instance_type: Literal["node"] = "node"
|
|
101
63
|
|
|
64
|
+
class InFieldLocationConfigRequest(WrappedInstanceListRequest, InFieldLocationConfig):
|
|
65
|
+
def dump_instances(self) -> list[dict[str, Any]]:
|
|
66
|
+
space: str | None = None
|
|
67
|
+
external_id: str | None = None
|
|
68
|
+
if self.data_exploration_config:
|
|
69
|
+
space = self.data_exploration_config.space or self.space
|
|
70
|
+
if self.data_exploration_config.external_id:
|
|
71
|
+
external_id = self.data_exploration_config.external_id
|
|
72
|
+
else:
|
|
73
|
+
candidate = f"{self.external_id}_data_exploration_config"
|
|
74
|
+
external_id = sanitize_instance_external_id(candidate)
|
|
75
|
+
|
|
76
|
+
properties = self.model_dump(
|
|
77
|
+
by_alias=True,
|
|
78
|
+
exclude_unset=True,
|
|
79
|
+
exclude={"data_exploration_config", "instance_type", "space", "external_id"},
|
|
80
|
+
)
|
|
81
|
+
if space and external_id:
|
|
82
|
+
properties["dataExplorationConfig"] = {"space": space, "externalId": external_id}
|
|
83
|
+
output: list[dict[str, Any]] = [
|
|
84
|
+
{
|
|
85
|
+
"instanceType": self.instance_type,
|
|
86
|
+
"space": self.space,
|
|
87
|
+
"externalId": self.external_id,
|
|
88
|
+
"sources": [
|
|
89
|
+
{
|
|
90
|
+
"source": self.VIEW_ID.dump(),
|
|
91
|
+
"properties": properties,
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
if space and external_id and self.data_exploration_config:
|
|
97
|
+
output.append(
|
|
98
|
+
{
|
|
99
|
+
"instanceType": "node",
|
|
100
|
+
"space": space,
|
|
101
|
+
"externalId": external_id,
|
|
102
|
+
"sources": [
|
|
103
|
+
{
|
|
104
|
+
"source": DataExplorationConfig.VIEW_ID.dump(),
|
|
105
|
+
"properties": self.data_exploration_config.model_dump(
|
|
106
|
+
by_alias=True, exclude_unset=True, exclude={"space", "external_id"}
|
|
107
|
+
),
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
return output
|
|
113
|
+
|
|
114
|
+
def as_ids(self) -> list[TypedInstanceIdentifier]:
|
|
115
|
+
output: list[TypedInstanceIdentifier] = [self.as_id()]
|
|
116
|
+
if (
|
|
117
|
+
self.data_exploration_config
|
|
118
|
+
and self.data_exploration_config.space
|
|
119
|
+
and self.data_exploration_config.external_id
|
|
120
|
+
):
|
|
121
|
+
output.append(
|
|
122
|
+
TypedNodeIdentifier(
|
|
123
|
+
space=self.data_exploration_config.space,
|
|
124
|
+
external_id=self.data_exploration_config.external_id,
|
|
125
|
+
)
|
|
126
|
+
)
|
|
127
|
+
return output
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class InFieldLocationConfigResponse(WrappedInstanceListResponse, InFieldLocationConfig):
|
|
131
|
+
def as_request_resource(self) -> InFieldLocationConfigRequest:
|
|
132
|
+
return InFieldLocationConfigRequest.model_validate(self.dump(), extra="ignore")
|
|
133
|
+
|
|
134
|
+
def as_ids(self) -> list[TypedInstanceIdentifier]:
|
|
135
|
+
output: list[TypedInstanceIdentifier] = [TypedNodeIdentifier(space=self.space, external_id=self.external_id)]
|
|
136
|
+
if (
|
|
137
|
+
self.data_exploration_config
|
|
138
|
+
and self.data_exploration_config.space
|
|
139
|
+
and self.data_exploration_config.external_id
|
|
140
|
+
):
|
|
141
|
+
output.append(
|
|
142
|
+
TypedNodeIdentifier(
|
|
143
|
+
space=self.data_exploration_config.space,
|
|
144
|
+
external_id=self.data_exploration_config.external_id,
|
|
145
|
+
)
|
|
146
|
+
)
|
|
147
|
+
return output
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class InFieldCDMLocationConfig(BaseModelObject):
|
|
102
151
|
name: str | None = None
|
|
103
152
|
description: str | None = None
|
|
104
153
|
feature_toggles: dict[str, JsonValue] | None = None
|
|
@@ -109,8 +158,20 @@ class InFieldCDMLocationConfig(ResponseResource["InFieldCDMLocationConfig"], Ins
|
|
|
109
158
|
disciplines: list[dict[str, JsonValue]] | None = None
|
|
110
159
|
data_exploration_config: dict[str, JsonValue] | None = None
|
|
111
160
|
|
|
112
|
-
def as_request_resource(self) -> "InFieldCDMLocationConfig":
|
|
113
|
-
return self
|
|
114
161
|
|
|
115
|
-
|
|
116
|
-
|
|
162
|
+
class InFieldCDMLocationConfigRequest(WrappedInstanceRequest, InFieldCDMLocationConfig):
|
|
163
|
+
VIEW_ID: ClassVar[TypedViewReference] = INFIELD_CDM_LOCATION_CONFIG_VIEW_ID
|
|
164
|
+
instance_type: Literal["node"] = "node"
|
|
165
|
+
|
|
166
|
+
def as_id(self) -> TypedNodeIdentifier:
|
|
167
|
+
return TypedNodeIdentifier(space=self.space, external_id=self.external_id)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class InFieldCDMLocationConfigResponse(
|
|
171
|
+
WrappedInstanceResponse[InFieldCDMLocationConfigRequest], InFieldCDMLocationConfig
|
|
172
|
+
):
|
|
173
|
+
VIEW_ID: ClassVar[TypedViewReference] = INFIELD_CDM_LOCATION_CONFIG_VIEW_ID
|
|
174
|
+
instance_type: Literal["node"] = "node"
|
|
175
|
+
|
|
176
|
+
def as_request_resource(self) -> InFieldCDMLocationConfigRequest:
|
|
177
|
+
return InFieldCDMLocationConfigRequest.model_validate(self.dump(), extra="ignore")
|