Skip to content

Commit e95c68e

Browse files
committed
Adjust callautomation api based on latest swagger.
1 parent 7c00f55 commit e95c68e

File tree

16 files changed

+5344
-4308
lines changed

16 files changed

+5344
-4308
lines changed

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
from ._call_connection import CallConnection
1010
from ._callingserver_client import CallingServerClient
1111
from ._generated.models import (AddParticipantResult, CallConnectionProperties,
12-
CancelAllMediaOperationsRequest,
13-
CancelAllMediaOperationsResult,
1412
CreateCallRequest, PhoneNumberIdentifierModel,
1513
PlayAudioRequest, PlayAudioResult,
1614
MediaType, EventSubscriptionType,
@@ -32,11 +30,9 @@
3230

3331
__all__ = [
3432
'AddParticipantResult',
35-
'CancelAllMediaOperationsRequest',
3633
'CallConnectionProperties',
3734
'CallConnection',
3835
'CallingServerClient',
39-
'CancelAllMediaOperationsResult',
4036
'CommunicationIdentifier',
4137
'CommunicationUserIdentifier',
4238
'CreateCallOptions',

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_call_connection.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from ._converters import (
1111
AddParticipantRequestConverter,
1212
RemoveParticipantRequestConverter,
13-
CancelAllMediaOperationsConverter,
1413
TransferCallRequestConverter,
1514
CancelParticipantMediaOperationRequestConverter,
1615
PlayAudioRequestConverter,
@@ -19,7 +18,6 @@
1918
from ._generated.models import (
2019
AddParticipantResult,
2120
CallConnectionProperties,
22-
CancelAllMediaOperationsResult,
2321
PhoneNumberIdentifierModel,
2422
PlayAudioResult
2523
)
@@ -64,15 +62,11 @@ def hang_up(
6462
@distributed_trace()
6563
def cancel_all_media_operations(
6664
self,
67-
operation_context=None, # type: Optional[str]
6865
**kwargs # type: Any
69-
): # type: (...) -> CancelAllMediaOperationsResult
70-
71-
cancel_all_media_operations_request = CancelAllMediaOperationsConverter.convert(operation_context)
66+
): # type: (...) -> None
7267

7368
return self._call_connection_client.cancel_all_media_operations(
7469
call_connection_id=self.call_connection_id,
75-
cancel_all_media_operation_request=cancel_all_media_operations_request,
7670
**kwargs
7771
)
7872

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_converters/_converter.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
AddParticipantWithCallLocatorRequest,
1818
RemoveParticipantRequest,
1919
RemoveParticipantWithCallLocatorRequest,
20-
CancelAllMediaOperationsRequest,
21-
CancelMediaOperationRequest,
2220
CancelMediaOperationWithCallLocatorRequest,
2321
CancelParticipantMediaOperationRequest,
2422
CancelParticipantMediaOperationWithCallLocatorRequest,
@@ -215,29 +213,6 @@ def convert(
215213
remove_participant_request=RemoveParticipantRequestConverter.convert(identifier)
216214
)
217215

218-
class CancelAllMediaOperationsConverter(object):
219-
@staticmethod
220-
def convert(
221-
operation_context=None # type: str
222-
): # type: (...) -> CancelAllMediaOperationsRequest
223-
224-
return CancelAllMediaOperationsRequest(
225-
operation_context=operation_context
226-
)
227-
228-
class CancelMediaOperationRequestConverter(object):
229-
@staticmethod
230-
def convert(
231-
media_operation_id # type: str
232-
): # type: (...) -> CancelMediaOperationRequest
233-
234-
if not media_operation_id:
235-
raise ValueError("media_operation_id can not be None")
236-
237-
return CancelMediaOperationRequest(
238-
media_operation_id=media_operation_id
239-
)
240-
241216
class CancelMediaOperationWithCallLocatorRequestConverter(object):
242217
@staticmethod
243218
def convert(
@@ -252,9 +227,7 @@ def convert(
252227

253228
return CancelMediaOperationWithCallLocatorRequest(
254229
call_locator=call_locator,
255-
cancel_media_operation_request=CancelMediaOperationRequestConverter.convert(
256-
media_operation_id=media_operation_id
257-
)
230+
media_operation_id=media_operation_id
258231
)
259232

260233
class CancelParticipantMediaOperationRequestConverter(object):

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/_azure_communication_calling_server_service.py

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9+
from copy import deepcopy
910
from typing import TYPE_CHECKING
1011

1112
from azure.core import PipelineClient
1213
from msrest import Deserializer, Serializer
1314

15+
from . import models
16+
from ._configuration import AzureCommunicationCallingServerServiceConfiguration
17+
from .operations import CallConnectionsOperations, ServerCallsOperations
18+
1419
if TYPE_CHECKING:
1520
# pylint: disable=unused-import,ungrouped-imports
1621
from typing import Any
1722

18-
from azure.core.pipeline.transport import HttpRequest, HttpResponse
19-
20-
from ._configuration import AzureCommunicationCallingServerServiceConfiguration
21-
from .operations import CallConnectionsOperations
22-
from .operations import ServerCallsOperations
23-
from . import models
24-
23+
from azure.core.rest import HttpRequest, HttpResponse
2524

2625
class AzureCommunicationCallingServerService(object):
2726
"""Azure Communication Service Call Automation APIs.
2827
2928
:ivar call_connections: CallConnectionsOperations operations
30-
:vartype call_connections: azure.communication.callingserver.operations.CallConnectionsOperations
29+
:vartype call_connections:
30+
azure.communication.callingserver.operations.CallConnectionsOperations
3131
:ivar server_calls: ServerCallsOperations operations
3232
:vartype server_calls: azure.communication.callingserver.operations.ServerCallsOperations
3333
:param endpoint: The endpoint of the Azure Communication resource.
@@ -40,37 +40,48 @@ def __init__(
4040
**kwargs # type: Any
4141
):
4242
# type: (...) -> None
43-
base_url = '{endpoint}'
43+
_base_url = '{endpoint}'
4444
self._config = AzureCommunicationCallingServerServiceConfiguration(endpoint, **kwargs)
45-
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
45+
self._client = PipelineClient(base_url=_base_url, config=self._config, **kwargs)
4646

4747
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
4848
self._serialize = Serializer(client_models)
49-
self._serialize.client_side_validation = False
5049
self._deserialize = Deserializer(client_models)
50+
self._serialize.client_side_validation = False
51+
self.call_connections = CallConnectionsOperations(self._client, self._config, self._serialize, self._deserialize)
52+
self.server_calls = ServerCallsOperations(self._client, self._config, self._serialize, self._deserialize)
5153

52-
self.call_connections = CallConnectionsOperations(
53-
self._client, self._config, self._serialize, self._deserialize)
54-
self.server_calls = ServerCallsOperations(
55-
self._client, self._config, self._serialize, self._deserialize)
5654

57-
def _send_request(self, http_request, **kwargs):
58-
# type: (HttpRequest, Any) -> HttpResponse
55+
def _send_request(
56+
self,
57+
request, # type: HttpRequest
58+
**kwargs # type: Any
59+
):
60+
# type: (...) -> HttpResponse
5961
"""Runs the network request through the client's chained policies.
6062
61-
:param http_request: The network request you want to make. Required.
62-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
63-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
63+
>>> from azure.core.rest import HttpRequest
64+
>>> request = HttpRequest("GET", "https://www.example.org/")
65+
<HttpRequest [GET], url: 'https://www.example.org/'>
66+
>>> response = client._send_request(request)
67+
<HttpResponse: 200 OK>
68+
69+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
70+
71+
:param request: The network request you want to make. Required.
72+
:type request: ~azure.core.rest.HttpRequest
73+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
6474
:return: The response of your network call. Does not do error handling on your response.
65-
:rtype: ~azure.core.pipeline.transport.HttpResponse
75+
:rtype: ~azure.core.rest.HttpResponse
6676
"""
77+
78+
request_copy = deepcopy(request)
6779
path_format_arguments = {
68-
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
80+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
6981
}
70-
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
71-
stream = kwargs.pop("stream", True)
72-
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
73-
return pipeline_response.http_response
82+
83+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
84+
return self._client.send_request(request_copy, **kwargs)
7485

7586
def close(self):
7687
# type: () -> None
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# Code generated by Microsoft (R) AutoRest Code Generator.
5+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
6+
# --------------------------------------------------------------------------
7+
8+
from azure.core.pipeline.transport import HttpRequest
9+
10+
def _convert_request(request, files=None):
11+
data = request.content if not files else None
12+
request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data)
13+
if files:
14+
request.set_formdata_body(files)
15+
return request
16+
17+
def _format_url_section(template, **kwargs):
18+
components = template.split("/")
19+
while components:
20+
try:
21+
return template.format(**kwargs)
22+
except KeyError as key:
23+
formatted_components = template.split("/")
24+
components = [
25+
c for c in formatted_components if "{}".format(key.args[0]) not in c
26+
]
27+
template = "/".join(components)

sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_generated/aio/_azure_communication_calling_server_service.py

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from typing import Any
9+
from copy import deepcopy
10+
from typing import Any, Awaitable
1011

1112
from azure.core import AsyncPipelineClient
12-
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
13+
from azure.core.rest import AsyncHttpResponse, HttpRequest
1314
from msrest import Deserializer, Serializer
1415

15-
from ._configuration import AzureCommunicationCallingServerServiceConfiguration
16-
from .operations import CallConnectionsOperations
17-
from .operations import ServerCallsOperations
1816
from .. import models
17+
from ._configuration import AzureCommunicationCallingServerServiceConfiguration
18+
from .operations import CallConnectionsOperations, ServerCallsOperations
1919

20-
21-
class AzureCommunicationCallingServerService(object):
20+
class AzureCommunicationCallingServerService:
2221
"""Azure Communication Service Call Automation APIs.
2322
2423
:ivar call_connections: CallConnectionsOperations operations
25-
:vartype call_connections: azure.communication.callingserver.aio.operations.CallConnectionsOperations
24+
:vartype call_connections:
25+
azure.communication.callingserver.aio.operations.CallConnectionsOperations
2626
:ivar server_calls: ServerCallsOperations operations
2727
:vartype server_calls: azure.communication.callingserver.aio.operations.ServerCallsOperations
2828
:param endpoint: The endpoint of the Azure Communication resource.
@@ -34,36 +34,47 @@ def __init__(
3434
endpoint: str,
3535
**kwargs: Any
3636
) -> None:
37-
base_url = '{endpoint}'
37+
_base_url = '{endpoint}'
3838
self._config = AzureCommunicationCallingServerServiceConfiguration(endpoint, **kwargs)
39-
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)
39+
self._client = AsyncPipelineClient(base_url=_base_url, config=self._config, **kwargs)
4040

4141
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
4242
self._serialize = Serializer(client_models)
43-
self._serialize.client_side_validation = False
4443
self._deserialize = Deserializer(client_models)
44+
self._serialize.client_side_validation = False
45+
self.call_connections = CallConnectionsOperations(self._client, self._config, self._serialize, self._deserialize)
46+
self.server_calls = ServerCallsOperations(self._client, self._config, self._serialize, self._deserialize)
4547

46-
self.call_connections = CallConnectionsOperations(
47-
self._client, self._config, self._serialize, self._deserialize)
48-
self.server_calls = ServerCallsOperations(
49-
self._client, self._config, self._serialize, self._deserialize)
5048

51-
async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse:
49+
def _send_request(
50+
self,
51+
request: HttpRequest,
52+
**kwargs: Any
53+
) -> Awaitable[AsyncHttpResponse]:
5254
"""Runs the network request through the client's chained policies.
5355
54-
:param http_request: The network request you want to make. Required.
55-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
56-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
56+
>>> from azure.core.rest import HttpRequest
57+
>>> request = HttpRequest("GET", "https://www.example.org/")
58+
<HttpRequest [GET], url: 'https://www.example.org/'>
59+
>>> response = await client._send_request(request)
60+
<AsyncHttpResponse: 200 OK>
61+
62+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
63+
64+
:param request: The network request you want to make. Required.
65+
:type request: ~azure.core.rest.HttpRequest
66+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
5767
:return: The response of your network call. Does not do error handling on your response.
58-
:rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
68+
:rtype: ~azure.core.rest.AsyncHttpResponse
5969
"""
70+
71+
request_copy = deepcopy(request)
6072
path_format_arguments = {
61-
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
73+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
6274
}
63-
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
64-
stream = kwargs.pop("stream", True)
65-
pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs)
66-
return pipeline_response.http_response
75+
76+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
77+
return self._client.send_request(request_copy, **kwargs)
6778

6879
async def close(self) -> None:
6980
await self._client.close()

0 commit comments

Comments
 (0)