7
7
# --------------------------------------------------------------------------
8
8
9
9
from copy import deepcopy
10
- from typing import Any , TYPE_CHECKING
10
+ from typing import Any , Optional , TYPE_CHECKING , cast
11
+ from typing_extensions import Self
11
12
13
+ from azure .core .pipeline import policies
12
14
from azure .core .rest import HttpRequest , HttpResponse
15
+ from azure .core .settings import settings
13
16
from azure .mgmt .core import ARMPipelineClient
17
+ from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18
+ from azure .mgmt .core .tools import get_arm_endpoints
14
19
15
20
from . import models as _models
16
21
from ._configuration import AzureBotServiceConfiguration
17
- from ._serialization import Deserializer , Serializer
22
+ from ._utils . serialization import Deserializer , Serializer
18
23
from .operations import (
19
24
BotConnectionOperations ,
20
25
BotsOperations ,
21
26
ChannelsOperations ,
22
27
DirectLineOperations ,
23
28
EmailOperations ,
24
29
HostSettingsOperations ,
30
+ NetworkSecurityPerimeterConfigurationsOperations ,
25
31
OperationResultsOperations ,
26
32
Operations ,
27
33
PrivateEndpointConnectionsOperations ,
30
36
)
31
37
32
38
if TYPE_CHECKING :
33
- # pylint: disable=unused-import,ungrouped-imports
34
39
from azure .core .credentials import TokenCredential
35
40
36
41
37
- class AzureBotService : # pylint: disable=client-accepts-api-version-keyword, too-many-instance-attributes
42
+ class AzureBotService : # pylint: disable=too-many-instance-attributes
38
43
"""Azure Bot Service is a platform for creating smart conversational agents.
39
44
40
45
:ivar bots: BotsOperations operations
41
46
:vartype bots: azure.mgmt.botservice.operations.BotsOperations
42
- :ivar channels: ChannelsOperations operations
43
- :vartype channels: azure.mgmt.botservice.operations.ChannelsOperations
44
- :ivar direct_line: DirectLineOperations operations
45
- :vartype direct_line: azure.mgmt.botservice.operations.DirectLineOperations
46
- :ivar email: EmailOperations operations
47
- :vartype email: azure.mgmt.botservice.operations.EmailOperations
48
47
:ivar operations: Operations operations
49
48
:vartype operations: azure.mgmt.botservice.operations.Operations
49
+ :ivar host_settings: HostSettingsOperations operations
50
+ :vartype host_settings: azure.mgmt.botservice.operations.HostSettingsOperations
50
51
:ivar bot_connection: BotConnectionOperations operations
51
52
:vartype bot_connection: azure.mgmt.botservice.operations.BotConnectionOperations
52
53
:ivar qn_amaker_endpoint_keys: QnAMakerEndpointKeysOperations operations
53
54
:vartype qn_amaker_endpoint_keys:
54
55
azure.mgmt.botservice.operations.QnAMakerEndpointKeysOperations
55
- :ivar host_settings: HostSettingsOperations operations
56
- :vartype host_settings: azure.mgmt.botservice.operations.HostSettingsOperations
57
56
:ivar operation_results: OperationResultsOperations operations
58
57
:vartype operation_results: azure.mgmt.botservice.operations.OperationResultsOperations
58
+ :ivar channels: ChannelsOperations operations
59
+ :vartype channels: azure.mgmt.botservice.operations.ChannelsOperations
60
+ :ivar direct_line: DirectLineOperations operations
61
+ :vartype direct_line: azure.mgmt.botservice.operations.DirectLineOperations
62
+ :ivar email: EmailOperations operations
63
+ :vartype email: azure.mgmt.botservice.operations.EmailOperations
64
+ :ivar network_security_perimeter_configurations:
65
+ NetworkSecurityPerimeterConfigurationsOperations operations
66
+ :vartype network_security_perimeter_configurations:
67
+ azure.mgmt.botservice.operations.NetworkSecurityPerimeterConfigurationsOperations
59
68
:ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations
60
69
:vartype private_endpoint_connections:
61
70
azure.mgmt.botservice.operations.PrivateEndpointConnectionsOperations
@@ -64,52 +73,77 @@ class AzureBotService: # pylint: disable=client-accepts-api-version-keyword,too
64
73
azure.mgmt.botservice.operations.PrivateLinkResourcesOperations
65
74
:param credential: Credential needed for the client to connect to Azure. Required.
66
75
:type credential: ~azure.core.credentials.TokenCredential
67
- :param subscription_id: Azure Subscription ID . Required.
76
+ :param subscription_id: The ID of the target subscription . Required.
68
77
:type subscription_id: str
69
- :param base_url: Service URL. Default value is "https://management.azure.com" .
78
+ :param base_url: Service URL. Default value is None .
70
79
:type base_url: str
71
- :keyword api_version: Api Version. Default value is "2022 -09-15". Note that overriding this
72
- default value may result in unsupported behavior.
80
+ :keyword api_version: Api Version. Default value is "2023 -09-15-preview ". Note that overriding
81
+ this default value may result in unsupported behavior.
73
82
:paramtype api_version: str
74
83
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
75
84
Retry-After header is present.
76
85
"""
77
86
78
87
def __init__ (
79
- self ,
80
- credential : "TokenCredential" ,
81
- subscription_id : str ,
82
- base_url : str = "https://management.azure.com" ,
83
- ** kwargs : Any
88
+ self , credential : "TokenCredential" , subscription_id : str , base_url : Optional [str ] = None , ** kwargs : Any
84
89
) -> None :
85
- self ._config = AzureBotServiceConfiguration (credential = credential , subscription_id = subscription_id , ** kwargs )
86
- self ._client = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
90
+ _cloud = kwargs .pop ("cloud_setting" , None ) or settings .current .azure_cloud # type: ignore
91
+ _endpoints = get_arm_endpoints (_cloud )
92
+ if not base_url :
93
+ base_url = _endpoints ["resource_manager" ]
94
+ credential_scopes = kwargs .pop ("credential_scopes" , _endpoints ["credential_scopes" ])
95
+ self ._config = AzureBotServiceConfiguration (
96
+ credential = credential , subscription_id = subscription_id , credential_scopes = credential_scopes , ** kwargs
97
+ )
98
+
99
+ _policies = kwargs .pop ("policies" , None )
100
+ if _policies is None :
101
+ _policies = [
102
+ policies .RequestIdPolicy (** kwargs ),
103
+ self ._config .headers_policy ,
104
+ self ._config .user_agent_policy ,
105
+ self ._config .proxy_policy ,
106
+ policies .ContentDecodePolicy (** kwargs ),
107
+ ARMAutoResourceProviderRegistrationPolicy (),
108
+ self ._config .redirect_policy ,
109
+ self ._config .retry_policy ,
110
+ self ._config .authentication_policy ,
111
+ self ._config .custom_hook_policy ,
112
+ self ._config .logging_policy ,
113
+ policies .DistributedTracingPolicy (** kwargs ),
114
+ policies .SensitiveHeaderCleanupPolicy (** kwargs ) if self ._config .redirect_policy else None ,
115
+ self ._config .http_logging_policy ,
116
+ ]
117
+ self ._client : ARMPipelineClient = ARMPipelineClient (base_url = cast (str , base_url ), policies = _policies , ** kwargs )
87
118
88
119
client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
89
120
self ._serialize = Serializer (client_models )
90
121
self ._deserialize = Deserializer (client_models )
91
122
self ._serialize .client_side_validation = False
92
123
self .bots = BotsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
93
- self .channels = ChannelsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
94
- self .direct_line = DirectLineOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
95
- self .email = EmailOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
96
124
self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
125
+ self .host_settings = HostSettingsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
97
126
self .bot_connection = BotConnectionOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
98
127
self .qn_amaker_endpoint_keys = QnAMakerEndpointKeysOperations (
99
128
self ._client , self ._config , self ._serialize , self ._deserialize
100
129
)
101
- self .host_settings = HostSettingsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
102
130
self .operation_results = OperationResultsOperations (
103
131
self ._client , self ._config , self ._serialize , self ._deserialize
104
132
)
133
+ self .channels = ChannelsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
134
+ self .direct_line = DirectLineOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
135
+ self .email = EmailOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
136
+ self .network_security_perimeter_configurations = NetworkSecurityPerimeterConfigurationsOperations (
137
+ self ._client , self ._config , self ._serialize , self ._deserialize
138
+ )
105
139
self .private_endpoint_connections = PrivateEndpointConnectionsOperations (
106
140
self ._client , self ._config , self ._serialize , self ._deserialize
107
141
)
108
142
self .private_link_resources = PrivateLinkResourcesOperations (
109
143
self ._client , self ._config , self ._serialize , self ._deserialize
110
144
)
111
145
112
- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
146
+ def _send_request (self , request : HttpRequest , * , stream : bool = False , * *kwargs : Any ) -> HttpResponse :
113
147
"""Runs the network request through the client's chained policies.
114
148
115
149
>>> from azure.core.rest import HttpRequest
@@ -129,14 +163,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
129
163
130
164
request_copy = deepcopy (request )
131
165
request_copy .url = self ._client .format_url (request_copy .url )
132
- return self ._client .send_request (request_copy , ** kwargs )
166
+ return self ._client .send_request (request_copy , stream = stream , ** kwargs ) # type: ignore
133
167
134
168
def close (self ) -> None :
135
169
self ._client .close ()
136
170
137
- def __enter__ (self ) -> "AzureBotService" :
171
+ def __enter__ (self ) -> Self :
138
172
self ._client .__enter__ ()
139
173
return self
140
174
141
- def __exit__ (self , * exc_details ) -> None :
175
+ def __exit__ (self , * exc_details : Any ) -> None :
142
176
self ._client .__exit__ (* exc_details )
0 commit comments