77# --------------------------------------------------------------------------
88
99from copy import deepcopy
10- from typing import TYPE_CHECKING
11-
12- from msrest import Deserializer , Serializer
10+ from typing import Any , Optional , TYPE_CHECKING
11+ from typing_extensions import Self
1312
1413from azure .core import PipelineClient
14+ from azure .core .pipeline import policies
15+ from azure .core .rest import HttpRequest , HttpResponse
1516
16- from . import models
17+ from . import models as _models
1718from ._configuration import AzureDigitalTwinsAPIConfiguration
18- from .operations import DigitalTwinModelsOperations , DigitalTwinsOperations , EventRoutesOperations , QueryOperations
19+ from ._utils .serialization import Deserializer , Serializer
20+ from .operations import (
21+ DeleteJobsOperations ,
22+ DigitalTwinModelsOperations ,
23+ DigitalTwinsOperations ,
24+ EventRoutesOperations ,
25+ ImportJobsOperations ,
26+ QueryOperations ,
27+ )
1928
2029if TYPE_CHECKING :
21- # pylint: disable=unused-import,ungrouped-imports
22- from typing import Any
23-
2430 from azure .core .credentials import TokenCredential
25- from azure .core .rest import HttpRequest , HttpResponse
2631
27- class AzureDigitalTwinsAPI (object ):
32+
33+ class AzureDigitalTwinsAPI :
2834 """A service for managing and querying digital twins and digital twin models.
2935
3036 :ivar digital_twin_models: DigitalTwinModelsOperations operations
@@ -35,41 +41,74 @@ class AzureDigitalTwinsAPI(object):
3541 :vartype digital_twins: azure.digitaltwins.core.operations.DigitalTwinsOperations
3642 :ivar event_routes: EventRoutesOperations operations
3743 :vartype event_routes: azure.digitaltwins.core.operations.EventRoutesOperations
38- :param credential: Credential needed for the client to connect to Azure.
44+ :ivar import_jobs: ImportJobsOperations operations
45+ :vartype import_jobs: azure.digitaltwins.core.operations.ImportJobsOperations
46+ :ivar delete_jobs: DeleteJobsOperations operations
47+ :vartype delete_jobs: azure.digitaltwins.core.operations.DeleteJobsOperations
48+ :param credential: Credential needed for the client to connect to Azure. Required.
3949 :type credential: ~azure.core.credentials.TokenCredential
50+ :param operation_id: ID for the operation's status monitor. The ID is generated if header was
51+ not passed by the client. Default value is None.
52+ :type operation_id: str
53+ :param timeout_in_minutes: Desired timeout for the delete job. Once the specified timeout is
54+ reached, service will stop any delete operations triggered by the current delete job that are
55+ in progress, and go to a failed state. Please note that this will leave your instance in an
56+ unknown state as there won't be any rollback operation. Default value is None.
57+ :type timeout_in_minutes: int
4058 :param base_url: Service URL. Default value is "https://digitaltwins-hostname".
4159 :type base_url: str
42- :keyword api_version: Api Version. Default value is "2022-05 -31". Note that overriding
43- this default value may result in unsupported behavior.
60+ :keyword api_version: Api Version. Default value is "2023-10 -31". Note that overriding this
61+ default value may result in unsupported behavior.
4462 :paramtype api_version: str
63+ :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
64+ Retry-After header is present.
4565 """
4666
4767 def __init__ (
4868 self ,
49- credential , # type: "TokenCredential"
50- base_url = "https://digitaltwins-hostname" , # type: str
51- ** kwargs # type: Any
52- ):
53- # type: (...) -> None
54- self ._config = AzureDigitalTwinsAPIConfiguration (credential = credential , ** kwargs )
55- self ._client = PipelineClient (base_url = base_url , config = self ._config , ** kwargs )
56-
57- client_models = {k : v for k , v in models .__dict__ .items () if isinstance (v , type )}
69+ credential : "TokenCredential" ,
70+ operation_id : Optional [str ] = None ,
71+ timeout_in_minutes : Optional [int ] = None ,
72+ base_url : str = "https://digitaltwins-hostname" ,
73+ ** kwargs : Any
74+ ) -> None :
75+ self ._config = AzureDigitalTwinsAPIConfiguration (
76+ credential = credential , operation_id = operation_id , timeout_in_minutes = timeout_in_minutes , ** kwargs
77+ )
78+
79+ _policies = kwargs .pop ("policies" , None )
80+ if _policies is None :
81+ _policies = [
82+ policies .RequestIdPolicy (** kwargs ),
83+ self ._config .headers_policy ,
84+ self ._config .user_agent_policy ,
85+ self ._config .proxy_policy ,
86+ policies .ContentDecodePolicy (** kwargs ),
87+ self ._config .redirect_policy ,
88+ self ._config .retry_policy ,
89+ self ._config .authentication_policy ,
90+ self ._config .custom_hook_policy ,
91+ self ._config .logging_policy ,
92+ policies .DistributedTracingPolicy (** kwargs ),
93+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
94+ self ._config .http_logging_policy ,
95+ ]
96+ self ._client : PipelineClient = PipelineClient (base_url = base_url , policies = _policies , ** kwargs )
97+
98+ client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
5899 self ._serialize = Serializer (client_models )
59100 self ._deserialize = Deserializer (client_models )
60101 self ._serialize .client_side_validation = False
61- self .digital_twin_models = DigitalTwinModelsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
102+ self .digital_twin_models = DigitalTwinModelsOperations (
103+ self ._client , self ._config , self ._serialize , self ._deserialize
104+ )
62105 self .query = QueryOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
63106 self .digital_twins = DigitalTwinsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
64107 self .event_routes = EventRoutesOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
108+ self .import_jobs = ImportJobsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
109+ self .delete_jobs = DeleteJobsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
65110
66-
67- def _send_request (
68- self ,
69- request , # type: HttpRequest
70- ** kwargs # type: Any
71- ):
72- # type: (...) -> HttpResponse
111+ def _send_request (self , request : HttpRequest , * , stream : bool = False , ** kwargs : Any ) -> HttpResponse :
73112 """Runs the network request through the client's chained policies.
74113
75114 >>> from azure.core.rest import HttpRequest
@@ -78,7 +117,7 @@ def _send_request(
78117 >>> response = client._send_request(request)
79118 <HttpResponse: 200 OK>
80119
81- For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
120+ For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/ python/send_request
82121
83122 :param request: The network request you want to make. Required.
84123 :type request: ~azure.core.rest.HttpRequest
@@ -89,17 +128,14 @@ def _send_request(
89128
90129 request_copy = deepcopy (request )
91130 request_copy .url = self ._client .format_url (request_copy .url )
92- return self ._client .send_request (request_copy , ** kwargs )
131+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
93132
94- def close (self ):
95- # type: () -> None
133+ def close (self ) -> None :
96134 self ._client .close ()
97135
98- def __enter__ (self ):
99- # type: () -> AzureDigitalTwinsAPI
136+ def __enter__ (self ) -> Self :
100137 self ._client .__enter__ ()
101138 return self
102139
103- def __exit__ (self , * exc_details ):
104- # type: (Any) -> None
140+ def __exit__ (self , * exc_details : Any ) -> None :
105141 self ._client .__exit__ (* exc_details )
0 commit comments