77# --------------------------------------------------------------------------
88
99from 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
1112
13+ from azure .core .pipeline import policies
1214from azure .core .rest import HttpRequest , HttpResponse
15+ from azure .core .settings import settings
1316from azure .mgmt .core import ARMPipelineClient
17+ from azure .mgmt .core .policies import ARMAutoResourceProviderRegistrationPolicy
18+ from azure .mgmt .core .tools import get_arm_endpoints
1419
1520from . import models as _models
1621from ._configuration import AzureBotServiceConfiguration
17- from ._serialization import Deserializer , Serializer
22+ from ._utils . serialization import Deserializer , Serializer
1823from .operations import (
1924 BotConnectionOperations ,
2025 BotsOperations ,
2126 ChannelsOperations ,
2227 DirectLineOperations ,
2328 EmailOperations ,
2429 HostSettingsOperations ,
30+ NetworkSecurityPerimeterConfigurationsOperations ,
2531 OperationResultsOperations ,
2632 Operations ,
2733 PrivateEndpointConnectionsOperations ,
3036)
3137
3238if TYPE_CHECKING :
33- # pylint: disable=unused-import,ungrouped-imports
3439 from azure .core .credentials import TokenCredential
3540
3641
37- class AzureBotService : # pylint: disable=client-accepts-api-version-keyword, too-many-instance-attributes
42+ class AzureBotService : # pylint: disable=too-many-instance-attributes
3843 """Azure Bot Service is a platform for creating smart conversational agents.
3944
4045 :ivar bots: BotsOperations operations
4146 :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
4847 :ivar operations: Operations operations
4948 :vartype operations: azure.mgmt.botservice.operations.Operations
49+ :ivar host_settings: HostSettingsOperations operations
50+ :vartype host_settings: azure.mgmt.botservice.operations.HostSettingsOperations
5051 :ivar bot_connection: BotConnectionOperations operations
5152 :vartype bot_connection: azure.mgmt.botservice.operations.BotConnectionOperations
5253 :ivar qn_amaker_endpoint_keys: QnAMakerEndpointKeysOperations operations
5354 :vartype qn_amaker_endpoint_keys:
5455 azure.mgmt.botservice.operations.QnAMakerEndpointKeysOperations
55- :ivar host_settings: HostSettingsOperations operations
56- :vartype host_settings: azure.mgmt.botservice.operations.HostSettingsOperations
5756 :ivar operation_results: OperationResultsOperations operations
5857 :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
5968 :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations
6069 :vartype private_endpoint_connections:
6170 azure.mgmt.botservice.operations.PrivateEndpointConnectionsOperations
@@ -64,52 +73,77 @@ class AzureBotService: # pylint: disable=client-accepts-api-version-keyword,too
6473 azure.mgmt.botservice.operations.PrivateLinkResourcesOperations
6574 :param credential: Credential needed for the client to connect to Azure. Required.
6675 :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.
6877 :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 .
7079 :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.
7382 :paramtype api_version: str
7483 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no
7584 Retry-After header is present.
7685 """
7786
7887 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
8489 ) -> 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 )
87118
88119 client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
89120 self ._serialize = Serializer (client_models )
90121 self ._deserialize = Deserializer (client_models )
91122 self ._serialize .client_side_validation = False
92123 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 )
96124 self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
125+ self .host_settings = HostSettingsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
97126 self .bot_connection = BotConnectionOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
98127 self .qn_amaker_endpoint_keys = QnAMakerEndpointKeysOperations (
99128 self ._client , self ._config , self ._serialize , self ._deserialize
100129 )
101- self .host_settings = HostSettingsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
102130 self .operation_results = OperationResultsOperations (
103131 self ._client , self ._config , self ._serialize , self ._deserialize
104132 )
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+ )
105139 self .private_endpoint_connections = PrivateEndpointConnectionsOperations (
106140 self ._client , self ._config , self ._serialize , self ._deserialize
107141 )
108142 self .private_link_resources = PrivateLinkResourcesOperations (
109143 self ._client , self ._config , self ._serialize , self ._deserialize
110144 )
111145
112- def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
146+ def _send_request (self , request : HttpRequest , * , stream : bool = False , * *kwargs : Any ) -> HttpResponse :
113147 """Runs the network request through the client's chained policies.
114148
115149 >>> from azure.core.rest import HttpRequest
@@ -129,14 +163,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
129163
130164 request_copy = deepcopy (request )
131165 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
133167
134168 def close (self ) -> None :
135169 self ._client .close ()
136170
137- def __enter__ (self ) -> "AzureBotService" :
171+ def __enter__ (self ) -> Self :
138172 self ._client .__enter__ ()
139173 return self
140174
141- def __exit__ (self , * exc_details ) -> None :
175+ def __exit__ (self , * exc_details : Any ) -> None :
142176 self ._client .__exit__ (* exc_details )
0 commit comments