Skip to content

Commit 82283d9

Browse files
authored
Applying new swagger changes to recording (#21179)
* Fixing missing validators module while installing wheel * Reenabling download in parallel test * Added overrides for CallingServer * Fixing wrong called overrides * Fixing validators version to match frozen * Fixing pylint issue * Fixing validators version to 0.10.4 * New Swagger autorest changes * Fixing start recording
1 parent 95cd52c commit 82283d9

18 files changed

+4942
-2951
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
StartCallRecordingResult,
2323
CallRecordingProperties,
2424
StartCallRecordingRequest,
25-
StartCallRecordingWithCallLocatorRequest
25+
StartCallRecordingWithCallLocatorRequest,
26+
RecordingContentType,
27+
RecordingChannelType,
28+
RecordingFormatType
2629
)
2730
from ._shared.models import CommunicationIdentifier
2831
from ._call_connection import CallConnection
@@ -391,11 +394,15 @@ def cancel_participant_media_operation(
391394
**kwargs
392395
)
393396

397+
#pylint:disable=too-many-arguments
394398
@distributed_trace()
395399
def start_recording(
396400
self,
397401
call_locator, # type: CallLocator
398402
recording_state_callback_uri, # type: str
403+
recording_content_type = None, # type: Optional[RecordingContentType]
404+
recording_channel_type = None, # type: Optional[RecordingChannelType]
405+
recording_format_type = None, # type: Optional[RecordingFormatType]
399406
**kwargs # type: Any
400407
): # type: (...) -> StartCallRecordingResult
401408

@@ -406,6 +413,9 @@ def start_recording(
406413

407414
start_call_recording_request = StartCallRecordingRequest(
408415
recording_state_callback_uri=recording_state_callback_uri,
416+
recording_content_type=recording_content_type,
417+
recording_channel_type=recording_channel_type,
418+
recording_format_type=recording_format_type,
409419
**kwargs
410420
)
411421

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)