1313from azure .core import MatchConditions
1414
1515from ._utils import (
16- prep_if_match
16+ prep_if_match ,
17+ prep_if_none_match
1718)
1819
1920from ._generated import models
@@ -65,6 +66,9 @@ def upsert_digital_twin(self, digital_twin_id, digital_twin, **kwargs):
6566 :param str digital_twin_id: The Id of the digital twin.
6667 :param Dict[str, object] digital_twin:
6768 Dictionary containing the twin to create or update.
69+ :keyword str etag: Only perform the operation if the entity does not already exist.
70+ :keyword ~azure.core.MatchConditions match_condition:
71+ The match condition to use upon the etag
6872 :return: Dictionary containing the created or updated twin.
6973 :rtype: Dict[str, object]
7074 :raises :class: `~azure.core.exceptions.HttpResponseError`
@@ -73,9 +77,13 @@ def upsert_digital_twin(self, digital_twin_id, digital_twin, **kwargs):
7377 :raises :class: `~azure.core.exceptions.ResourceExistsError`:
7478 If the digital twin is already exist.
7579 """
80+ etag = kwargs .get ("etag" , None )
81+ match_condition = kwargs .get ("match_condition" , MatchConditions .Unconditionally )
82+
7683 return self ._client .digital_twins .add (
7784 digital_twin_id ,
7885 digital_twin ,
86+ if_none_match = prep_if_none_match (etag , match_condition ),
7987 ** kwargs
8088 )
8189
@@ -146,12 +154,12 @@ def delete_digital_twin(
146154 )
147155
148156 @distributed_trace
149- def get_component (self , digital_twin_id , component_path , ** kwargs ):
157+ def get_component (self , digital_twin_id , component_name , ** kwargs ):
150158 # type: (str, str, **Any) -> Dict[str, object]
151159 """Get a component on a digital twin.
152160
153161 :param str digital_twin_id: The Id of the digital twin.
154- :param str component_path : The component being retrieved.
162+ :param str component_name : The component being retrieved.
155163 :return: Dictionary containing the component.
156164 :rtype: Dict[str, object]
157165 :raises :class: `~azure.core.exceptions.HttpResponseError`
@@ -160,23 +168,23 @@ def get_component(self, digital_twin_id, component_path, **kwargs):
160168 """
161169 return self ._client .digital_twins .get_component (
162170 digital_twin_id ,
163- component_path ,
171+ component_name ,
164172 ** kwargs
165173 )
166174
167175 @distributed_trace
168176 def update_component (
169177 self ,
170178 digital_twin_id ,
171- component_path ,
179+ component_name ,
172180 json_patch ,
173181 ** kwargs
174182 ):
175183 # type: (str, str, Dict[str, object], **Any) -> None
176184 """Update properties of a component on a digital twin using a JSON patch.
177185
178186 :param str digital_twin_id: The Id of the digital twin.
179- :param str component_path : The component being updated.
187+ :param str component_name : The component being updated.
180188 :param Dict[str, object] json_patch: An update specification described by JSON Patch.
181189 :keyword str etag: Only perform the operation if the entity's etag matches one of
182190 the etags provided or * is provided.
@@ -193,7 +201,7 @@ def update_component(
193201
194202 return self ._client .digital_twins .update_component (
195203 digital_twin_id ,
196- component_path ,
204+ component_name ,
197205 patch_document = json_patch ,
198206 if_match = prep_if_match (etag , match_condition ),
199207 ** kwargs
@@ -226,17 +234,24 @@ def upsert_relationship(self, digital_twin_id, relationship_id, relationship=Non
226234 :param str digital_twin_id: The Id of the digital twin.
227235 :param str relationship_id: The Id of the relationship to retrieve.
228236 :param Dict[str, object] relationship: Dictionary containing the relationship.
237+ :keyword str etag: Only perform the operation if the entity does not already exist.
238+ :keyword ~azure.core.MatchConditions match_condition:
239+ The match condition to use upon the etag
229240 :return: The created or updated relationship.
230241 :rtype: Dict[str, object]
231242 :raises :class: `~azure.core.exceptions.HttpResponseError`
232243 :raises :class: `~azure.core.exceptions.ServiceRequestError`: If the request is invalid.
233244 :raises :class: `~azure.core.exceptions.ResourceNotFoundError`: If there is either no
234245 digital twin, target digital twin or relationship with the provided id.
235246 """
247+ etag = kwargs .get ("etag" , None )
248+ match_condition = kwargs .get ("match_condition" , MatchConditions .Unconditionally )
249+
236250 return self ._client .digital_twins .add_relationship (
237251 id = digital_twin_id ,
238252 relationship_id = relationship_id ,
239253 relationship = relationship ,
254+ if_none_match = prep_if_none_match (etag , match_condition ),
240255 ** kwargs
241256 )
242257
@@ -378,7 +393,7 @@ def publish_telemetry(self, digital_twin_id, payload, message_id=None, **kwargs)
378393 def publish_component_telemetry (
379394 self ,
380395 digital_twin_id ,
381- component_path ,
396+ component_name ,
382397 payload ,
383398 message_id = None ,
384399 ** kwargs
@@ -388,7 +403,7 @@ def publish_component_telemetry(
388403 one or many destination endpoints (subscribers) defined under.
389404
390405 :param str digital_twin_id: The Id of the digital twin.
391- :param str component_path : The name of the DTDL component.
406+ :param str component_name : The name of the DTDL component.
392407 :param object payload: The telemetry payload to be sent.
393408 :param str message_id: The message Id.
394409 :return: None
@@ -404,7 +419,7 @@ def publish_component_telemetry(
404419
405420 return self ._client .digital_twins .send_component_telemetry (
406421 digital_twin_id ,
407- component_path ,
422+ component_name ,
408423 dt_id = message_id ,
409424 telemetry = payload ,
410425 dt_timestamp = timestamp ,
@@ -464,7 +479,7 @@ def list_models(self, dependencies_for, **kwargs):
464479 )
465480
466481 @distributed_trace
467- def create_models (self , model_list = None , ** kwargs ):
482+ def create_models (self , dtdl_models = None , ** kwargs ):
468483 # type: (Optional[List[object]], **Any) -> List[~azure.digitaltwins.models.ModelData]
469484 """Create one or more models. When any error occurs, no models are uploaded.
470485
@@ -477,7 +492,7 @@ def create_models(self, model_list=None, **kwargs):
477492 the provided models already exist.
478493 """
479494 return self ._client .digital_twin_models .add (
480- model_list ,
495+ dtdl_models ,
481496 ** kwargs
482497 )
483498
@@ -524,12 +539,12 @@ def delete_model(self, model_id, **kwargs):
524539
525540 @distributed_trace
526541 def get_event_route (self , event_route_id , ** kwargs ):
527- # type: (str, **Any) -> ~azure.digitaltwins.models.EventRoute
542+ # type: (str, **Any) -> DigitalTwinsEventRoute
528543 """Get an event route.
529544
530545 :param str event_route_id: The Id of the event route.
531- :return: The EventRoute object.
532- :rtype: ~azure.digitaltwins.models.EventRoute
546+ :return: The DigitalTwinsEventRoute object.
547+ :rtype: DigitalTwinsEventRoute
533548 :raises :class: `~azure.core.exceptions.HttpResponseError`
534549 :raises :class: `~azure.core.exceptions.ResourceNotFoundError`: There is no
535550 event route with the provided id.
@@ -541,13 +556,13 @@ def get_event_route(self, event_route_id, **kwargs):
541556
542557 @distributed_trace
543558 def list_event_routes (self , ** kwargs ):
544- # type: (**Any) -> ~azure.core.paging.ItemPaged[~azure.digitaltwins.models.EventRoute ]
559+ # type: (**Any) -> ~azure.core.paging.ItemPaged[DigitalTwinsEventRoute ]
545560 """Retrieves all event routes.
546561
547562 :keyword int results_per_page: The maximum number of items to retrieve per request.
548563 The server may choose to return less than the requested max.
549- :return: An iterator instance of list of EventRoute .
550- :rtype: ~azure.core.paging.ItemPaged[~azure.digitaltwins.models.EventRoute ]
564+ :return: An iterator instance of list of DigitalTwinsEventRoute .
565+ :rtype: ~azure.core.paging.ItemPaged[DigitalTwinsEventRoute ]
551566 :raises :class: `~azure.core.exceptions.HttpResponseError`
552567 :raises :class: `~azure.core.exceptions.ServiceRequestError`: The request is invalid.
553568 """
@@ -563,11 +578,11 @@ def list_event_routes(self, **kwargs):
563578
564579 @distributed_trace
565580 def upsert_event_route (self , event_route_id , event_route , ** kwargs ):
566- # type: (str, "models.EventRoute ", **Any) -> None
581+ # type: (str, "DigitalTwinsEventRoute ", **Any) -> None
567582 """Create or update an event route.
568583
569584 :param str event_route_id: The Id of the event route to create or update.
570- :param ~azure.digitaltwins.models.EventRoute event_route: The event route data.
585+ :param DigitalTwinsEventRoute event_route: The event route data.
571586 :return: None
572587 :rtype: None
573588 :raises :class: `~azure.core.exceptions.HttpResponseError`
@@ -599,6 +614,9 @@ def delete_event_route(self, event_route_id, **kwargs):
599614 def query_twins (self , query_expression , ** kwargs ):
600615 # type: (str, **Any) -> ~azure.core.async_paging.ItemPaged[Dict[str, object]]
601616 """Query for digital twins.
617+ Note: that there may be a delay between before changes in your instance are reflected in queries.
618+ For more details on query limitations, see
619+ https://docs.microsoft.com/en-us/azure/digital-twins/how-to-query-graph#query-limitations
602620
603621 :param str query_expression: The query expression to execute.
604622 :return: The QueryResult object.
0 commit comments