AAS HTTP Client Documentation
Loading...
Searching...
No Matches
sm_implementation.py
Go to the documentation of this file.
1"""Implementation of Submodel related API calls."""
2
3import json
4import logging
5from typing import TYPE_CHECKING
6
7import requests
8from pydantic import BaseModel
9
10if TYPE_CHECKING:
11 from aas_http_client.classes.client.aas_client import AasHttpClient
12
13from aas_http_client.utilities.encoder import encode_base_64
15 STATUS_CODE_200,
16 STATUS_CODE_201,
17 STATUS_CODE_204,
18 STATUS_CODE_404,
19 log_response,
20)
21
22_logger = logging.getLogger(__name__)
23
24
26 """Implementation of Submodel related API calls."""
27
28 def __init__(self, client: "AasHttpClient"):
29 """Initializes the SmImplementation with the given parameters."""
30 self._client = client
31
32 session = client.get_session()
33 if session is None:
34 raise ValueError(
35 "HTTP session is not initialized in the client. Call 'initialize()' method of the client before creating SubmodelRegistryImplementation instance."
36 )
37
38 self._session: requests.Session = session
39
40 # GET /submodels/{submodelIdentifier}
41 def get_submodel_by_id(self, submodel_identifier: str, level: str = "", extent: str = "") -> dict | None:
42 """Returns a specific Submodel.
43
44 :param submodel_identifier: The Submodels unique id
45 :param level: Determines the structural depth of the respective resource content. Available values : deep, core
46 :param extent: Determines to which extent the resource is being serialized. Available values : withBlobValue, withoutBlobValue
47 :return: Submodel data or None if an error occurred
48 """
49 if not self._client.encoded_ids:
50 submodel_identifier = encode_base_64(submodel_identifier)
52 url = f"{self._client.base_url}/submodels/{submodel_identifier}"
53
54 params: dict[str, str] = {}
55 if level:
56 params["level"] = level
57 if extent:
58 params["extent"] = extent
59
60 self._client.set_token()
61
62 try:
63 response = self._session.get(url, params=params, timeout=self._client.time_out)
64 _logger.debug(f"Call REST API url '{response.url}'")
65
66 if response.status_code == STATUS_CODE_404:
67 _logger.warning(f"Submodel with id '{submodel_identifier}' not found.")
68 _logger.debug(response.text)
69 return None
70
71 if response.status_code != STATUS_CODE_200:
72 log_response(response)
73 return None
74
75 except requests.exceptions.RequestException as e:
76 _logger.error(f"Error call REST API: {e}")
77 return None
78
79 content = response.content.decode("utf-8")
80 return json.loads(content)
81
82 # PUT /submodels/{submodelIdentifier}
83 def put_submodels_by_id(self, submodel_identifier: str, request_body: dict) -> bool:
84 """Updates a existing Submodel.
85
86 :param submodel_identifier: The Submodels unique id
87 :param request_body: Json data of the Submodel to update
88 :return: True if the update was successful, False otherwise
89 """
90 if not self._client.encoded_ids:
91 submodel_identifier = encode_base_64(submodel_identifier)
93 url = f"{self._client.base_url}/submodels/{submodel_identifier}"
94
95 self._client.set_token()
96
97 try:
98 response = self._session.put(url, json=request_body, timeout=self._client.time_out)
99 _logger.debug(f"Call REST API url '{response.url}'")
100
101 if response.status_code == STATUS_CODE_404:
102 _logger.warning(f"Submodel with id '{submodel_identifier}' not found.")
103 _logger.debug(response.text)
104 return False
105
106 if response.status_code != STATUS_CODE_204:
107 log_response(response)
108 return False
109
110 except requests.exceptions.RequestException as e:
111 _logger.error(f"Error call REST API: {e}")
112 return False
113
114 return True
115
116 # DELETE /submodels/{submodelIdentifier}
117 def delete_submodel_by_id(self, submodel_identifier: str) -> bool:
118 """Deletes a Submodel.
119
120 :param submodel_identifier: The Submodels unique id
121 :return: True if the deletion was successful, False otherwise
122 """
123 if not self._client.encoded_ids:
124 submodel_identifier = encode_base_64(submodel_identifier)
126 url = f"{self._client.base_url}/submodels/{submodel_identifier}"
127
128 self._client.set_token()
129
130 try:
131 response = self._session.delete(url, timeout=self._client.time_out)
132 _logger.debug(f"Call REST API url '{response.url}'")
133
134 if response.status_code == STATUS_CODE_404:
135 _logger.warning(f"Submodel with id '{submodel_identifier}' not found.")
136 _logger.debug(response.text)
137 return False
138
139 if response.status_code != STATUS_CODE_204:
140 log_response(response)
141 return False
142
143 except requests.exceptions.RequestException as e:
144 _logger.error(f"Error call REST API: {e}")
145 return False
146
147 return True
148
149 # GET /submodels/{submodelIdentifier}/submodel-elements/{idShortPath}
151 self, submodel_identifier: str, id_short_path: str, level: str = "", extent: str = ""
152 ) -> dict | None:
153 """Returns a specific submodel element from the Submodel at a specified path.
154
155 :param submodel_identifier: The Submodels unique id
156 :param id_short_path: IdShort path to the submodel element (dot-separated)
157 :param level: Determines the structural depth of the respective resource content. Available values : deep, core
158 :param extent: Determines to which extent the resource is being serialized. Available values : withBlobValue, withoutBlobValue
159 :return: Submodel element data or None if an error occurred
160 """
161 if not self._client.encoded_ids:
162 submodel_identifier = encode_base_64(submodel_identifier)
163
164 url = f"{self._client.base_url}/submodels/{submodel_identifier}/submodel-elements/{id_short_path}"
165
166 params: dict[str, str] = {}
167 if level:
168 params["level"] = level
169 if extent:
170 params["extent"] = extent
171
172 self._client.set_token()
173
174 try:
175 response = self._session.get(url, params=params, timeout=self._client.time_out)
176 _logger.debug(f"Call REST API url '{response.url}'")
177
178 if response.status_code == STATUS_CODE_404:
179 _logger.warning(f"Submodel with id '{submodel_identifier}' or Submodel element with IDShort path '{id_short_path}' not found.")
180 _logger.debug(response.text)
181 return None
182
183 if response.status_code != STATUS_CODE_200:
184 log_response(response)
185 return None
186
187 except requests.exceptions.RequestException as e:
188 _logger.error(f"Error call REST API: {e}")
189 return None
190
191 content = response.content.decode("utf-8")
192 return json.loads(content)
193
194 # PUT /submodels/{submodelIdentifier}/submodel-elements/{idShortPath}
195 def put_submodel_element_by_path_submodel_repo(self, submodel_identifier: str, id_short_path: str, request_body: dict, level: str = "") -> bool:
196 """Creates or updates an existing submodel element at a specified path within submodel elements hierarchy.
197
198 :param submodel_identifier: The Submodels unique id
199 :param id_short_path: IdShort path to the submodel element (dot-separated)
200 :param request_body: Data for the submodel element
201 :param level: Determines the structural depth of the respective resource content. Available values : deep, core
202 :return: True if the operation was successful, False otherwise
203 """
204 if not self._client.encoded_ids:
205 submodel_identifier = encode_base_64(submodel_identifier)
207 url = f"{self._client.base_url}/submodels/{submodel_identifier}/submodel-elements/{id_short_path}"
208
209 params: dict[str, str] = {}
210 if level:
211 params["level"] = level
212
213 self._client.set_token()
214
215 try:
216 response = self._session.put(url, json=request_body, params=params, timeout=self._client.time_out)
217 _logger.debug(f"Call REST API url '{response.url}'")
218
219 if response.status_code == STATUS_CODE_404:
220 _logger.warning(f"Submodel with id '{submodel_identifier}' or Submodel element with IDShort path '{id_short_path}' not found.")
221 _logger.debug(response.text)
222 return False
223
224 if response.status_code != STATUS_CODE_204:
225 log_response(response)
226 return False
227
228 except requests.exceptions.RequestException as e:
229 _logger.error(f"Error call REST API: {e}")
230 return False
231
232 return True
233
234 # POST /submodels/{submodelIdentifier}/submodel-elements/{idShortPath}
236 self, submodel_identifier: str, id_short_path: str, request_body: dict, level: str = "", extent: str = ""
237 ) -> dict | None:
238 """Creates a new submodel element at a specified path within submodel elements hierarchy.
239
240 :param submodel_identifier: The Submodels unique id
241 :param id_short_path: IdShort path to the submodel element (dot-separated)
242 :param request_body: Data for the new Submodel element
243 :param level: Determines the structural depth of the respective resource content. Available values : deep, core
244 :param extent: Determines to which extent the resource is being serialized. Available values : withBlobValue, withoutBlobValue
245 :return: Submodel element data or None if an error occurred
246 """
247 if not self._client.encoded_ids:
248 submodel_identifier = encode_base_64(submodel_identifier)
249
250 url = f"{self._client.base_url}/submodels/{submodel_identifier}/submodel-elements/{id_short_path}"
251
252 params: dict[str, str] = {}
253 if level:
254 params["level"] = level
255 if extent:
256 params["extent"] = extent
257
258 self._client.set_token()
259
260 try:
261 response = self._session.post(url, json=request_body, params=params, timeout=self._client.time_out)
262 _logger.debug(f"Call REST API url '{response.url}'")
263
264 if response.status_code == STATUS_CODE_404:
265 _logger.warning(f"Submodel with id '{submodel_identifier}' or Submodel element with IDShort path '{id_short_path}' not found.")
266 _logger.debug(response.text)
267 return None
268
269 if response.status_code != STATUS_CODE_201:
270 log_response(response)
271 return None
272
273 except requests.exceptions.RequestException as e:
274 _logger.error(f"Error call REST API: {e}")
275 return None
276
277 content = response.content.decode("utf-8")
278 return json.loads(content)
279
280 # DELETE /submodels/{submodelIdentifier}/submodel-elements/{idShortPath}
281 def delete_submodel_element_by_path_submodel_repo(self, submodel_identifier: str, id_short_path: str) -> bool:
282 """Deletes a submodel element at a specified path within the submodel elements hierarchy.
283
284 :param submodel_identifier: The Submodels unique id
285 :param id_short_path: IdShort path to the submodel element (dot-separated)
286 :return: True if the deletion was successful, False otherwise
287 """
288 if not self._client.encoded_ids:
289 submodel_identifier = encode_base_64(submodel_identifier)
291 url = f"{self._client.base_url}/submodels/{submodel_identifier}/submodel-elements/{id_short_path}"
292
293 self._client.set_token()
294 try:
295 response = self._session.delete(url, timeout=self._client.time_out)
296 _logger.debug(f"Call REST API url '{response.url}'")
297
298 if response.status_code == STATUS_CODE_404:
299 _logger.warning(f"Submodel with id '{submodel_identifier}' or Submodel element with IDShort path '{id_short_path}' not found.")
300 _logger.debug(response.text)
301 return False
302
303 if response.status_code != STATUS_CODE_204:
304 log_response(response)
305 return False
306
307 except requests.exceptions.RequestException as e:
308 _logger.error(f"Error call REST API: {e}")
309 return False
310
311 return True
312
313 # GET /submodels
315 self, semantic_id: str = "", id_short: str = "", limit: int = 0, cursor: str = "", level: str = "", extent: str = ""
316 ) -> dict | None:
317 """Returns all Submodels.
318
319 :param semantic_id: The value of the semantic id reference (UTF8-BASE64-URL-encoded)
320 :param id_short: The Submodels IdShort
321 :param limit: The maximum number of elements in the response array
322 :param cursor: A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
323 :param level: Determines the structural depth of the respective resource content. Available values : deep, core
324 :param extent: Determines to which extent the resource is being serialized. Available values : withBlobValue, withoutBlobValue
325 :return: List of Submodel data or None if an error occurred
326 """
327 url = f"{self._client.base_url}/submodels"
328
329 params: dict[str, str] = {}
330 if semantic_id:
331 params["semanticId"] = semantic_id
332 if id_short:
333 params["idShort"] = id_short
334 if limit:
335 params["limit"] = str(limit)
336 if cursor:
337 params["cursor"] = cursor
338 if level:
339 params["level"] = level
340 if extent:
341 params["extent"] = extent
342
343 self._client.set_token()
344
345 try:
346 response = self._session.get(url, params=params, timeout=self._client.time_out)
347 _logger.debug(f"Call REST API url '{response.url}'")
348
349 if response.status_code != STATUS_CODE_200:
350 log_response(response)
351 return None
352
353 except requests.exceptions.RequestException as e:
354 _logger.error(f"Error call REST API: {e}")
355 return None
356
357 content = response.content.decode("utf-8")
358 return json.loads(content)
359
360 # POST /submodels
361 def post_submodel(self, request_body: dict) -> dict | None:
362 """Creates a new Submodel.
363
364 :param request_body: Json data of the Submodel to post
365 :return: Submodel data or None if an error occurred
366 """
367 url = f"{self._client.base_url}/submodels"
368
369 self._client.set_token()
370
371 try:
372 response = self._session.post(url, json=request_body, timeout=self._client.time_out)
373 _logger.debug(f"Call REST API url '{response.url}'")
374
375 if response.status_code != STATUS_CODE_201:
376 log_response(response)
377 return None
378
379 except requests.exceptions.RequestException as e:
380 _logger.error(f"Error call REST API: {e}")
381 return None
382
383 content = response.content.decode("utf-8")
384 return json.loads(content)
385
386 # GET /submodels/{submodelIdentifier}/submodel-elements
388 self, submodel_identifier: str, limit: int = 100, cursor: str = "", level: str = "", extent: str = ""
389 ) -> dict | None:
390 """Returns all submodel elements including their hierarchy.
391
392 :param submodel_identifier: The Submodels unique id
393 :param limit: The maximum number of elements in the response array
394 :param cursor: A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue
395 :param level: Determines the structural depth of the respective resource content. Available values : deep, core
396 :param extent: Determines to which extent the resource is being serialized. Available values : withBlobValue, withoutBlobValue
397 :return: List of Submodel element data or None if an error occurred
398 """
399 if not self._client.encoded_ids:
400 submodel_identifier = encode_base_64(submodel_identifier)
401
402 url = f"{self._client.base_url}/submodels/{submodel_identifier}/submodel-elements"
403
404 params: dict[str, str] = {}
405 if limit:
406 params["limit"] = str(limit)
407 if cursor:
408 params["cursor"] = cursor
409 if level:
410 params["level"] = level
411 if extent:
412 params["extent"] = extent
413
414 self._client.set_token()
415
416 try:
417 response = self._session.get(url, params=params, timeout=self._client.time_out)
418 _logger.debug(f"Call REST API url '{response.url}'")
419
420 if response.status_code != STATUS_CODE_200:
421 log_response(response)
422 return None
423
424 except requests.exceptions.RequestException as e:
425 _logger.error(f"Error call REST API: {e}")
426 return None
427
428 content = response.content.decode("utf-8")
429 return json.loads(content)
430
431 # POST /submodels/{submodelIdentifier}/submodel-elements
432 def post_submodel_element_submodel_repo(self, submodel_identifier: str, request_body: dict) -> dict | None:
433 """Creates a new submodel element.
434
435 :param submodel_identifier: The Submodels unique id
436 :param request_body: Data for the new Submodel element
437 :return: Submodel element data or None if an error occurred
438 """
439 if not self._client.encoded_ids:
440 submodel_identifier = encode_base_64(submodel_identifier)
442 url = f"{self._client.base_url}/submodels/{submodel_identifier}/submodel-elements"
443
444 self._client.set_token()
445
446 try:
447 response = self._session.post(url, json=request_body, timeout=self._client.time_out)
448 _logger.debug(f"Call REST API url '{response.url}'")
449
450 if response.status_code != STATUS_CODE_201:
451 log_response(response)
452 return None
453
454 except requests.exceptions.RequestException as e:
455 _logger.error(f"Error call REST API: {e}")
456 return None
457
458 content = response.content.decode("utf-8")
459 return json.loads(content)
460
461 # POST /submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke
462 def invoke_operation_submodel_repo(self, submodel_identifier: str, id_short_path: str, request_body: dict, async_: str = "async") -> dict | None:
463 """Synchronously invokes an Operation at a specified path.
464
465 :param submodel_identifier: The Submodels unique id
466 :param id_short_path: IdShort path to the operation element (dot-separated)
467 :param request_body: Input parameters for the operation
468 :param async_: Determines whether an operation invocation is performed asynchronously or synchronously
469 :return: Operation result or None if an error occurred
470 """
471 if not self._client.encoded_ids:
472 submodel_identifier = encode_base_64(submodel_identifier)
474 url = f"{self._client.base_url}/submodels/{submodel_identifier}/submodel-elements/{id_short_path}/invoke"
475
476 self._client.set_token()
477
478 try:
479 response = self._session.post(url, json=request_body, timeout=self._client.time_out)
480 _logger.debug(f"Call REST API url '{response.url}'")
481
482 if response.status_code != STATUS_CODE_200:
483 log_response(response)
484 return None
485
486 except requests.exceptions.RequestException as e:
487 _logger.error(f"Error call REST API: {e}")
488 return None
489
490 content = response.content.decode("utf-8")
491 return json.loads(content)
492
493 # GET /submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value
494 def get_submodel_element_by_path_value_only_submodel_repo(self, submodel_identifier: str, id_short_path: str) -> str | None:
495 """Retrieves the value of a specific SubmodelElement.
496
497 :param submodel_identifier: The Submodels unique id
498 :param id_short_path: IdShort path to the submodel element (dot-separated)
499 :return: Submodel element value or None if an error occurred
500 """
501 if not self._client.encoded_ids:
502 submodel_identifier = encode_base_64(submodel_identifier)
504 url = f"{self._client.base_url}/submodels/{submodel_identifier}/submodel-elements/{id_short_path}/$value"
505
506 self._client.set_token()
507
508 try:
509 response = self._session.get(url, timeout=self._client.time_out)
510 _logger.debug(f"Call REST API url '{response.url}'")
511
512 if response.status_code != STATUS_CODE_200:
513 log_response(response)
514 return None
515
516 except requests.exceptions.RequestException as e:
517 _logger.error(f"Error call REST API: {e}")
518 return None
519
520 content = response.content.decode("utf-8")
521 return json.loads(content)
522
523 # PATCH /submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value
525 self, submodel_identifier: str, id_short_path: str, value: str, level: str = ""
526 ) -> bool:
527 """Updates the value of an existing SubmodelElement.
528
529 :param submodel_identifier: The Submodels unique id
530 :param id_short_path: IdShort path to the submodel element (dot-separated)
531 :param value: Submodel element value to update as string
532 :param level: Determines the structural depth of the respective resource content. Available values : deep, core
533 :return: True if the patch was successful, False otherwise
534 """
535 if not self._client.encoded_ids:
536 submodel_identifier = encode_base_64(submodel_identifier)
537
538 url = f"{self._client.base_url}/submodels/{submodel_identifier}/submodel-elements/{id_short_path}/$value"
539
540 params: dict[str, str] = {}
541 if level:
542 params["level"] = level
543
544 self._client.set_token()
545
546 try:
547 response = self._session.patch(url, json=value, params=params, timeout=self._client.time_out)
548 _logger.debug(f"Call REST API url '{response.url}'")
549
550 if response.status_code == STATUS_CODE_404:
551 _logger.warning(f"Submodel with id '{submodel_identifier}' or Submodel element with IDShort path '{id_short_path}' not found.")
552 _logger.debug(response.text)
553 return False
554
555 if response.status_code != STATUS_CODE_204:
556 log_response(response)
557 return False
558
559 except requests.exceptions.RequestException as e:
560 _logger.error(f"Error call REST API: {e}")
561 return False
562
563 return True
564
565 # GET /submodels/{submodelIdentifier}/$value
566 def get_submodel_by_id_value_only(self, submodel_identifier: str, level: str = "", extent: str = "") -> dict | None:
567 """Returns a specific Submodel in the ValueOnly representation.
568
569 :param submodel_identifier: The Submodels unique id
570 :param level: Determines the structural depth of the respective resource content. Available values : deep, core
571 :param extent: Determines to which extent the resource is being serialized. Available values : withBlobValue, withoutBlobValue
572 :return: Submodel value as dict or None if an error occurred
573 """
574 params: dict[str, str] = {}
575 if level:
576 params["level"] = level
577 if extent:
578 params["extent"] = extent
579
580 if not self._client.encoded_ids:
581 submodel_identifier = encode_base_64(submodel_identifier)
582
583 url = f"{self._client.base_url}/submodels/{submodel_identifier}/$value"
584
585 self._client.set_token()
586
587 try:
588 response = self._session.get(url, params=params, timeout=self._client.time_out)
589 _logger.debug(f"Call REST API url '{response.url}'")
590
591 if response.status_code == STATUS_CODE_404:
592 _logger.warning(f"Submodel with id '{submodel_identifier}' not found.")
593 _logger.debug(response.text)
594 return None
595
596 if response.status_code != STATUS_CODE_200:
597 log_response(response)
598 return None
599
600 except requests.exceptions.RequestException as e:
601 _logger.error(f"Error call REST API: {e}")
602 return None
603
604 content = response.content.decode("utf-8")
605 return json.loads(content)
606
607 # PATCH /submodels/{submodelIdentifier}/$value
608 def patch_submodel_by_id_value_only(self, submodel_identifier: str, request_body: dict, level: str = "") -> bool:
609 """Updates the values of an existing Submodel.
610
611 :param submodel_identifier: The Submodels unique id
612 :param request_body: Submodel values to update as dict
613 :param level: Determines the structural depth of the respective resource content. Available values : deep, core
614 :return: True if the patch was successful, False otherwise
615 """
616 params: dict[str, str] = {}
617 if level:
618 params["level"] = level
619
620 if not self._client.encoded_ids:
621 submodel_identifier = encode_base_64(submodel_identifier)
622
623 url = f"{self._client.base_url}/submodels/{submodel_identifier}/$value"
624
625 self._client.set_token()
626
627 try:
628 response = self._session.patch(url, json=request_body, params=params, timeout=self._client.time_out)
629 _logger.debug(f"Call REST API url '{response.url}'")
630
631 if response.status_code == STATUS_CODE_404:
632 _logger.warning(f"Submodel with id '{submodel_identifier}' not found.")
633 _logger.debug(response.text)
634 return False
635
636 if response.status_code != STATUS_CODE_204:
637 log_response(response)
638 return False
639
640 except requests.exceptions.RequestException as e:
641 _logger.error(f"Error call REST API: {e}")
642 return False
643
644 return True
645
646 # GET /submodels/{submodelIdentifier}/$metadata
647 def get_submodel_by_id_metadata(self, submodel_identifier: str, level: str = "") -> dict | None:
648 """Returns the metadata attributes of a specific Submodel.
649
650 :param submodel_identifier: The Submodels unique id
651 :param level: Determines the structural depth of the respective resource content. Available values : deep, core
652 :return: Metadata attributes of the Submodel as dict or None if an error occurred
653 """
654 params: dict[str, str] = {}
655 if level:
656 params["level"] = level
657
658 if not self._client.encoded_ids:
659 submodel_identifier = encode_base_64(submodel_identifier)
660
661 url = f"{self._client.base_url}/submodels/{submodel_identifier}/$metadata"
662
663 self._client.set_token()
664
665 try:
666 response = self._session.get(url, params=params, timeout=self._client.time_out)
667 _logger.debug(f"Call REST API url '{response.url}'")
668
669 if response.status_code == STATUS_CODE_404:
670 _logger.warning(f"Submodel with id '{submodel_identifier}' not found.")
671 _logger.debug(response.text)
672 return None
673
674 if response.status_code != STATUS_CODE_200:
675 log_response(response)
676 return None
677
678 except requests.exceptions.RequestException as e:
679 _logger.error(f"Error call REST API: {e}")
680 return None
681
682 content = response.content.decode("utf-8")
683 return json.loads(content)
684
685 # not supported by Java Server
686
687 # PATCH /submodels/{submodelIdentifier}
688 def patch_submodel_by_id(self, submodel_identifier: str, submodel_data: dict) -> bool:
689 """Updates an existing Submodel.
690
691 :param submodel_identifier: The Submodels unique id
692 :return: True if the patch was successful, False otherwise
693 """
694 if not self._client.encoded_ids:
695 submodel_identifier = encode_base_64(submodel_identifier)
697 url = f"{self._client.base_url}/submodels/{submodel_identifier}"
698
699 self._client.set_token()
700
701 try:
702 response = self._session.patch(url, json=submodel_data, timeout=self._client.time_out)
703 _logger.debug(f"Call REST API url '{response.url}'")
704
705 if response.status_code == STATUS_CODE_404:
706 _logger.warning(f"Submodel with id '{submodel_identifier}' not found.")
707 _logger.debug(response.text)
708 return False
709
710 if response.status_code != STATUS_CODE_204:
711 log_response(response)
712 return False
713
714 except requests.exceptions.RequestException as e:
715 _logger.error(f"Error call REST API: {e}")
716 return False
717
718 return True
Implementation of Submodel related API calls.
dict|None get_submodel_by_id(self, str submodel_identifier, str level="", str extent="")
Returns a specific Submodel.
dict|None get_submodel_element_by_path_submodel_repo(self, str submodel_identifier, str id_short_path, str level="", str extent="")
Returns a specific submodel element from the Submodel at a specified path.
__init__(self, "AasHttpClient" client)
Initializes the SmImplementation with the given parameters.
str|None get_submodel_element_by_path_value_only_submodel_repo(self, str submodel_identifier, str id_short_path)
Retrieves the value of a specific SubmodelElement.
dict|None get_all_submodels(self, str semantic_id="", str id_short="", int limit=0, str cursor="", str level="", str extent="")
Returns all Submodels.
dict|None get_submodel_by_id_metadata(self, str submodel_identifier, str level="")
Returns the metadata attributes of a specific Submodel.
dict|None post_submodel(self, dict request_body)
Creates a new Submodel.
dict|None post_submodel_element_by_path_submodel_repo(self, str submodel_identifier, str id_short_path, dict request_body, str level="", str extent="")
Creates a new submodel element at a specified path within submodel elements hierarchy.
bool patch_submodel_element_by_path_value_only_submodel_repo(self, str submodel_identifier, str id_short_path, str value, str level="")
Updates the value of an existing SubmodelElement.
dict|None post_submodel_element_submodel_repo(self, str submodel_identifier, dict request_body)
Creates a new submodel element.
dict|None get_submodel_by_id_value_only(self, str submodel_identifier, str level="", str extent="")
Returns a specific Submodel in the ValueOnly representation.
bool put_submodel_element_by_path_submodel_repo(self, str submodel_identifier, str id_short_path, dict request_body, str level="")
Creates or updates an existing submodel element at a specified path within submodel elements hierarch...
bool patch_submodel_by_id(self, str submodel_identifier, dict submodel_data)
Updates an existing Submodel.
bool delete_submodel_by_id(self, str submodel_identifier)
Deletes a Submodel.
dict|None invoke_operation_submodel_repo(self, str submodel_identifier, str id_short_path, dict request_body, str async_="async")
Synchronously invokes an Operation at a specified path.
bool delete_submodel_element_by_path_submodel_repo(self, str submodel_identifier, str id_short_path)
Deletes a submodel element at a specified path within the submodel elements hierarchy.
bool put_submodels_by_id(self, str submodel_identifier, dict request_body)
Updates a existing Submodel.
bool patch_submodel_by_id_value_only(self, str submodel_identifier, dict request_body, str level="")
Updates the values of an existing Submodel.
dict|None get_all_submodel_elements_submodel_repository(self, str submodel_identifier, int limit=100, str cursor="", str level="", str extent="")
Returns all submodel elements including their hierarchy.