Skip to content

Commit 37f3075

Browse files
[ACS][CallAutomation] Python feedback updates (Azure#30091)
* Initial feedback commit * Fixing tests and swagger * added unit test cases * Adding aio and fixing lint * updated unit test * Further updates to accomodate the feedbacks and detailed summaries * Fix pylint and spelling * Fix pipeline ci pass * indent fix * fixing double tabs * Python github review feedback updates * readme updates * testing fix * Adding necessary models and removing unnecessary ones * Adding one last missing enum, final touch of updated models and its docstring * Removed client validation * remove client validation, added await for redirect (missing before), operation context for play * Missing comma * removing not needed item * Changes on both client & aio, and removed unnessary import --------- Co-authored-by: Min Woo Lee 🧊 <77083090+minwoolee-ms@users.noreply.github.com> Co-authored-by: juntuchen <juntuchen@microsoft.com>
1 parent d2a457d commit 37f3075

27 files changed

+3000
-2458
lines changed

sdk/communication/azure-communication-callautomation/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ pip install azure-communication-callautomation
2424
## Key concepts
2525
| Name | Description |
2626
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
27-
| CallAutomationClient | `CallAutomationClient` is the primary interface for developers using this client library. It can be used to initiate calls by `createCall` or `answerCall`. |
28-
| CallConnectionClient | `CallConnectionClient` represents a ongoing call. Once the call is established with `createCall` or `answerCall`, further actions can be performed for the call, such as `transfer` or `addParticipant`. |
29-
| CallMediaClient | `CallMediaClient` can be used to do media related actions, such as `play`, to play media file. This can be retrieved from established `CallConnectionClient`. |
30-
| CallRecordingClient | `CallRecordingClient` can be used to do recording related actions, such as `startRecording`. This can be retrieved from `CallAutomationClient`. |
31-
| Callback Events | Callback events are events sent back during duration of the call. It gives information and state of the call, such as `CallConnected`. `CallbackUrl` must be provided during `createCall` and `answerCall`, and callback events will be sent to this url. You can use `callAutomationEventParser` to parse these events when it arrives. |
27+
| CallAutomationClient | `CallAutomationClient` is the primary interface for developers using this client library. It can be used to initiate calls by `createCall` or `answerCall`. It can also be used to do recording actions such as `startRecording` | |
28+
| CallConnectionClient | `CallConnectionClient` represents a ongoing call. Once the call is established with `createCall` or `answerCall`, further actions can be performed for the call, such as `transfer` or `play_media`. | |
29+
| Callback Events | Callback events are events sent back during duration of the call. It gives information and state of the call, such as `CallConnected`. `CallbackUrl` must be provided during `createCall` and `answerCall`, and callback events will be sent to this url. |
3230
| Incoming Call Event | When incoming call happens (that can be answered with `answerCall`), incoming call eventgrid event will be sent. This is different from Callback events above, and should be setup on Azure portal. See [Incoming Call][incomingcall] for detail. |
3331

3432
## Examples
@@ -59,14 +57,20 @@ call_invite = CallInvite(target=user)
5957
callback_url = "https://<MY-EVENT-HANDLER-URL>/events"
6058

6159
# send out the invitation, creating call
62-
response = client.create_call(call_invite, callback_url)
60+
result = client.create_call(call_invite, callback_url)
61+
62+
# this id can be used to do further actions in the call
63+
call_connection_id = result.call_connection_id
6364
```
6465

6566
### Play Media
6667
```Python
67-
# from callconnection of response above, play media of media file
68-
my_file = FileSource(uri="https://<FILE-SOURCE>/<SOME-FILE>.wav")
69-
const response = call_connection.get_call_media().play_to_all(my_file)
68+
# using call connection id, get call connection
69+
call_connection = client.get_call_connection(call_connection_id)
70+
71+
# from callconnection of result above, play media to all participants
72+
my_file = FileSource(url="https://<FILE-SOURCE>/<SOME-FILE>.wav")
73+
call_connection.play_to_all(my_file)
7074
```
7175

7276
## Troubleshooting
Lines changed: 67 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,90 @@
1+
# -------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
# --------------------------------------------------------------------------
16
from ._version import VERSION
7+
from ._call_automation_client import CallAutomationClient
28
from ._call_connection_client import CallConnectionClient
3-
from ._call_media_client import CallMediaClient
4-
from ._call_recording_client import CallRecordingClient
5-
from ._call_automation_client import (
6-
CallAutomationClient,
7-
AnswerCallResult,
8-
CreateCallResult
9-
)
10-
from ._call_automation_event_parser import CallAutomationEventParser
119
from ._models import (
12-
RecordingStateResponse,
13-
StartRecordingOptions,
10+
CallConnectionProperties,
11+
CallInvite,
1412
ServerCallLocator,
1513
GroupCallLocator,
16-
CallInvite,
17-
RecordingFormat,
18-
RecordingContent,
19-
RecordingStorage,
20-
RecordingChannel,
21-
PlaySource,
2214
FileSource,
23-
CallMediaRecognizeOptions,
24-
CallConnectionProperties,
2515
CallParticipant,
26-
CallMediaRecognizeDtmfOptions,
27-
Gender,
28-
DtmfTone,
29-
CallRejectReason
16+
RecordingProperties,
17+
AddParticipantResult,
18+
RemoveParticipantResult,
19+
TransferCallResult,
20+
MediaStreamingConfiguration
3021
)
3122
from ._shared.models import (
3223
CommunicationIdentifier,
3324
PhoneNumberIdentifier,
3425
MicrosoftTeamsUserIdentifier,
35-
CommunicationUserIdentifier
36-
)
37-
from ._events import (
38-
AddParticipantSucceeded,
39-
AddParticipantFailed,
40-
CallConnected,
41-
CallDisconnected,
42-
CallTransferAccepted,
43-
CallTransferFailed,
44-
ParticipantsUpdated,
45-
RecordingStateChanged,
46-
PlayCompleted,
47-
PlayFailed,
48-
PlayCanceled,
49-
RecognizeCompleted,
50-
RecognizeCanceled,
51-
RecognizeFailed,
52-
RemoveParticipantSucceeded,
53-
RemoveParticipantFailed,
54-
ContinuousDtmfRecognitionToneReceived,
55-
ContinuousDtmfRecognitionToneFailed,
56-
ContinuousDtmfRecognitionStopped,
57-
SendDtmfCompleted,
58-
SendDtmfFailed,
26+
CommunicationUserIdentifier,
27+
CommunicationIdentifierKind,
28+
CommunicationCloudEnvironment,
29+
MicrosoftBotIdentifier,
30+
UnknownIdentifier,
5931
)
60-
from ._generated.models import (
61-
GetParticipantsResponse,
62-
TransferCallResponse,
63-
AddParticipantResponse,
64-
CustomContext,
65-
RemoveParticipantResponse
32+
from ._generated.models._enums import (
33+
CallRejectReason,
34+
RecordingContent,
35+
RecordingChannel,
36+
RecordingFormat,
37+
RecordingStorage,
38+
RecognizeInputType,
39+
MediaStreamingAudioChannelType,
40+
MediaStreamingContentType,
41+
MediaStreamingTransportType,
42+
DtmfTone,
43+
CallConnectionState,
44+
RecordingState
6645
)
67-
6846
__all__ = [
69-
'CallAutomationClient',
70-
'RecordingFormat',
71-
'RecordingContent',
72-
'RecordingStorage',
73-
'RecordingChannel',
74-
'CallConnectionClient',
75-
'CallMediaClient',
76-
'CallRecordingClient',
77-
"StartRecordingOptions",
78-
"RecordingStateResponse",
47+
# clients and parser
48+
"CallAutomationClient",
49+
"CallConnectionClient",
50+
51+
# models for input
52+
"CallInvite",
7953
"ServerCallLocator",
8054
"GroupCallLocator",
81-
"CallAutomationEventParser",
82-
"AddParticipantSucceeded",
83-
"AddParticipantFailed",
84-
"CallConnected",
85-
"CallDisconnected",
86-
"CallTransferAccepted",
87-
"CallTransferFailed",
88-
"ParticipantsUpdated",
89-
"RecordingStateChanged",
90-
"PlayCompleted",
91-
"PlayFailed",
92-
"PlayCanceled",
93-
"RecognizeCompleted",
94-
"RecognizeCanceled",
95-
"RecognizeFailed",
96-
"CallInvite",
97-
"CommunicationIdentifier",
98-
"CommunicationUserIdentifier",
99-
"PhoneNumberIdentifier",
100-
"MicrosoftTeamsUserIdentifier",
101-
"PlaySource",
10255
"FileSource",
103-
"CallMediaRecognizeOptions",
104-
"CallMediaRecognizeDtmfOptions",
105-
"AnswerCallResult",
106-
"CreateCallResult",
56+
57+
# models for output
10758
"CallConnectionProperties",
10859
"CallParticipant",
109-
"GetParticipantsResponse",
110-
"TransferCallResponse",
111-
"AddParticipantResponse",
112-
"CustomContext",
113-
"RemoveParticipantResponse",
114-
"Gender",
115-
"DtmfTone",
60+
"RecordingProperties",
61+
"AddParticipantResult",
62+
"RemoveParticipantResult",
63+
"TransferCallResult",
64+
"MediaStreamingConfiguration",
65+
66+
# common ACS communication identifier
67+
"CommunicationIdentifier",
68+
"PhoneNumberIdentifier",
69+
"MicrosoftTeamsUserIdentifier",
70+
"CommunicationUserIdentifier",
71+
"CommunicationIdentifierKind",
72+
"CommunicationCloudEnvironment",
73+
"MicrosoftBotIdentifier",
74+
"UnknownIdentifier",
75+
76+
# enums
11677
"CallRejectReason",
117-
"RemoveParticipantSucceeded",
118-
"RemoveParticipantFailed",
119-
"ContinuousDtmfRecognitionToneReceived",
120-
"ContinuousDtmfRecognitionToneFailed",
121-
"ContinuousDtmfRecognitionStopped",
122-
"SendDtmfCompleted",
123-
"SendDtmfFailed"
78+
"RecordingContent",
79+
"RecordingChannel",
80+
"RecordingFormat",
81+
"RecordingStorage",
82+
"RecognizeInputType",
83+
"MediaStreamingAudioChannelType",
84+
"MediaStreamingContentType",
85+
"MediaStreamingTransportType",
86+
"DtmfTone",
87+
"CallConnectionState",
88+
"RecordingState"
12489
]
12590
__version__ = VERSION
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# ------------------------------------
2-
# Copyright (c) Microsoft Corporation.
3-
# Licensed under the MIT License.
4-
# ------------------------------------
5-
1+
# -------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
# --------------------------------------------------------------------------
66
from enum import Enum
77
from azure.core import CaseInsensitiveEnumMeta
88

99
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
1010
V2023_01_15_PREVIEW = "2023-01-15-preview"
1111

12-
DEFAULT_VERSION = ApiVersion.V2023_01_15_PREVIEW
12+
DEFAULT_VERSION = ApiVersion.V2023_01_15_PREVIEW.value

0 commit comments

Comments
 (0)