Skip to content

Commit 3b53d68

Browse files
authored
[Communication] add AzureCli to the default user-agent header (#5381)
* [Communication] fix 'chat message delete' bug * [Communication] move version out of setup file. * [Communication] add AzureCli as application id to the user agent header * [Communication] update history and version * [Communication] update test recordings
1 parent 4e17c82 commit 3b53d68

File tree

47 files changed

+1327
-1529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1327
-1529
lines changed

src/communication/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Release History
44
===============
55

6+
1.3.0
7+
++++++
8+
* Add AzureCli to the user-agent header
9+
10+
611
1.2.2
712
++++++
813
* Fix a bug in chat 'message delete command'

src/communication/azext_communication/generated/_client_factory.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212
def cf_communication_cl(cli_ctx, *_):
1313
from azure.cli.core.commands.client_factory import get_mgmt_service_client
1414
from azext_communication.vendored_sdks.communication import CommunicationServiceManagementClient
15+
from ..version import cli_application_id
16+
17+
args = {'user_agent': cli_application_id()}
18+
1519
return get_mgmt_service_client(cli_ctx,
16-
CommunicationServiceManagementClient)
20+
CommunicationServiceManagementClient,
21+
**args)
1722

1823

1924
def cf_communication_service(cli_ctx, *_):

src/communication/azext_communication/manual/_client_factory.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55

6-
76
# pylint: disable=unused-argument
87

98
from azure.cli.core.azclierror import RequiredArgumentMissingError
9+
from ..version import cli_application_id
1010

1111

1212
def cf_communication_identity(cli_ctx, kwargs):
@@ -17,7 +17,9 @@ def cf_communication_identity(cli_ctx, kwargs):
1717
error_msg = 'Please specify --connection-string, or set AZURE_COMMUNICATION_CONNECTION_STRING.'
1818
raise RequiredArgumentMissingError(error_msg)
1919

20-
client = CommunicationIdentityClient.from_connection_string(connection_string)
20+
args = {'user_agent': cli_application_id()}
21+
client = CommunicationIdentityClient.from_connection_string(connection_string, **args)
22+
2123
return client
2224

2325

@@ -29,7 +31,9 @@ def cf_communication_sms(cli_ctx, kwargs):
2931
error_msg = 'Please specify --connection-string, or set AZURE_COMMUNICATION_CONNECTION_STRING.'
3032
raise RequiredArgumentMissingError(error_msg)
3133

32-
client = SmsClient.from_connection_string(connection_string)
34+
args = {'user_agent': cli_application_id()}
35+
client = SmsClient.from_connection_string(connection_string, **args)
36+
3337
return client
3438

3539

@@ -41,7 +45,9 @@ def cf_communication_phonenumbers(cli_ctx, kwargs):
4145
error_msg = 'Please specify --connection-string, or set AZURE_COMMUNICATION_CONNECTION_STRING.'
4246
raise RequiredArgumentMissingError(error_msg)
4347

44-
client = PhoneNumbersClient.from_connection_string(connection_string)
48+
args = {'user_agent': cli_application_id()}
49+
client = PhoneNumbersClient.from_connection_string(connection_string, **args)
50+
4551
return client
4652

4753

@@ -56,5 +62,7 @@ def cf_communication_chat(cli_ctx, kwargs):
5662
if token is None:
5763
raise RequiredArgumentMissingError('Please specify --access-token or set AZURE_COMMUNICATION_ACCESS_TOKEN.')
5864

59-
client = ChatClient(endpoint, CommunicationTokenCredential(token))
65+
args = {'user_agent': cli_application_id()}
66+
client = ChatClient(endpoint, CommunicationTokenCredential(token), **args)
67+
6068
return client

src/communication/azext_communication/tests/latest/recordings/test_chat_add_participant.yaml

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,41 @@ interactions:
1313
Content-Type:
1414
- application/json
1515
User-Agent:
16-
- azsdk-python-communication-identity/1.1.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
16+
- AzureCli/1.2.2 azsdk-python-communication-identity/1.2.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
1717
x-ms-content-sha256:
1818
- kWpGozyV35fifbpKdY8mbdG64VG0Pdq5upzo7YKAFM0=
1919
x-ms-date:
20-
- Tue, 16 Aug 2022 09:50:00 GMT
20+
- Wed, 21 Sep 2022 22:41:14 GMT
2121
x-ms-return-client-request-id:
2222
- 'true'
2323
method: POST
2424
uri: https://sanitized.communication.azure.com/identities?api-version=2022-06-01
2525
response:
2626
body:
2727
string: '{"identity": {"id": "sanitized"}, "accessToken": {"token": "sanitized",
28-
"expiresOn": "2022-08-17T09:50:02.4106148+00:00"}}'
28+
"expiresOn": "2022-09-22T22:41:15.8297447+00:00"}}'
2929
headers:
3030
api-supported-versions:
3131
- 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview,
3232
2021-11-01, 2022-06-01
33-
connection:
34-
- keep-alive
3533
content-length:
3634
- '122'
3735
content-type:
3836
- application/json; charset=utf-8
3937
date:
40-
- Tue, 16 Aug 2022 09:50:02 GMT
38+
- Wed, 21 Sep 2022 22:41:15 GMT
4139
ms-cv:
42-
- LsIStMJYHEarY2XXM8Rscw.0
40+
- Uk4cxbwlTE69xVxfBQIbhA.0
4341
request-context:
4442
- appId=
4543
strict-transport-security:
4644
- max-age=2592000
4745
x-azure-ref:
48-
- 20220816T095002Z-ue5bcnvs3t2n5ee38b8kwchyq400000000dg00000000hm2r
46+
- 0C5MrYwAAAAB5NO/e2SjMQq0C5SQDzl7zWVZSMzExMDAwMTE2MDUzADlmYzdiNTE5LWE4Y2MtNGY4OS05MzVlLWM5MTQ4YWUwOWU4MQ==
4947
x-cache:
5048
- CONFIG_NOCACHE
5149
x-processing-time:
52-
- 118ms
50+
- 127ms
5351
status:
5452
code: 201
5553
message: Created
@@ -67,43 +65,41 @@ interactions:
6765
Content-Type:
6866
- application/json
6967
User-Agent:
70-
- azsdk-python-communication-identity/1.1.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
68+
- AzureCli/1.2.2 azsdk-python-communication-identity/1.2.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
7169
x-ms-content-sha256:
7270
- kWpGozyV35fifbpKdY8mbdG64VG0Pdq5upzo7YKAFM0=
7371
x-ms-date:
74-
- Tue, 16 Aug 2022 09:50:01 GMT
72+
- Wed, 21 Sep 2022 22:41:14 GMT
7573
x-ms-return-client-request-id:
7674
- 'true'
7775
method: POST
7876
uri: https://sanitized.communication.azure.com/identities?api-version=2022-06-01
7977
response:
8078
body:
8179
string: '{"identity": {"id": "sanitized"}, "accessToken": {"token": "sanitized",
82-
"expiresOn": "2022-08-17T09:50:02.9481547+00:00"}}'
80+
"expiresOn": "2022-09-22T22:41:16.5064586+00:00"}}'
8381
headers:
8482
api-supported-versions:
8583
- 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview,
8684
2021-11-01, 2022-06-01
87-
connection:
88-
- keep-alive
8985
content-length:
9086
- '122'
9187
content-type:
9288
- application/json; charset=utf-8
9389
date:
94-
- Tue, 16 Aug 2022 09:50:03 GMT
90+
- Wed, 21 Sep 2022 22:41:15 GMT
9591
ms-cv:
96-
- ZDXwchTQ0kuzz5DHfSUcvA.0
92+
- 3YY1wBloMES23Ftf/HinNw.0
9793
request-context:
9894
- appId=
9995
strict-transport-security:
10096
- max-age=2592000
10197
x-azure-ref:
102-
- 20220816T095002Z-p18hf8s3dx4xf8cgexx53pe93400000000dg000000006ehu
98+
- 0DJMrYwAAAADU0T+WXw9LT5KZzeebgMdVWVZSMzExMDAwMTE2MDQ5ADlmYzdiNTE5LWE4Y2MtNGY4OS05MzVlLWM5MTQ4YWUwOWU4MQ==
10399
x-cache:
104100
- CONFIG_NOCACHE
105101
x-processing-time:
106-
- 126ms
102+
- 122ms
107103
status:
108104
code: 201
109105
message: Created
@@ -121,43 +117,43 @@ interactions:
121117
Content-Type:
122118
- application/json
123119
User-Agent:
124-
- azsdk-python-communication-chat/1.1.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
120+
- AzureCli/1.2.2 azsdk-python-communication-chat/1.1.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
125121
repeatability-request-id:
126-
- ce6eaa92-b047-49b7-a5e9-0a708cf21f5f
122+
- 9f33df8b-7bbe-497b-910b-661dfd3de1ad
127123
method: POST
128124
uri: https://sanitized.communication.azure.com/chat/threads?api-version=2021-09-07
129125
response:
130126
body:
131127
string: '{"chatThread": {"id": "sanitized", "topic": "chat-topic", "createdOn":
132-
"2022-08-16T09:50:03Z", "createdByCommunicationIdentifier": {"rawId": "sanitized",
128+
"2022-09-21T22:41:16Z", "createdByCommunicationIdentifier": {"rawId": "sanitized",
133129
"communicationUser": {"id": "sanitized"}}}}'
134130
headers:
135131
api-supported-versions:
136132
- 2021-03-07, 2021-04-05-preview6, 2021-09-07, 2022-11-15-preview8
137133
content-type:
138134
- application/json; charset=utf-8
139135
date:
140-
- Tue, 16 Aug 2022 09:50:03 GMT
136+
- Wed, 21 Sep 2022 22:41:16 GMT
141137
location:
142-
- https://clitest000002.communication.azure.com/chat/threads/19%3Asu9i_s8IXogihisX1C3q1cvIcYcJj-4d4MLhzNbVGus1@thread.v2
138+
- https://clitest000002.communication.azure.com/chat/threads/19%3AE6Jfa050emgshaPagc283M92Dz85balT8-OlCgy0KQ81@thread.v2
143139
ms-cv:
144-
- k0FPjPB5rEqLYBZ40jT4hQ.0
140+
- yC29GuxeS0uOIKbHVVm8fw.0
145141
strict-transport-security:
146142
- max-age=2592000
147143
transfer-encoding:
148144
- chunked
149145
x-azure-ref:
150-
- 0S2j7YgAAAACOfhbXaANLToG2Dzi575PeWVZSMzExMDAwMTE1MDM3ADlmYzdiNTE5LWE4Y2MtNGY4OS05MzVlLWM5MTQ4YWUwOWU4MQ==
146+
- 0DJMrYwAAAADFr9cqWOqPSLtimBnCGDLeWVZSMzExMDAwMTE1MDI3ADlmYzdiNTE5LWE4Y2MtNGY4OS05MzVlLWM5MTQ4YWUwOWU4MQ==
151147
x-cache:
152148
- CONFIG_NOCACHE
153149
x-processing-time:
154-
- 736ms
150+
- 525ms
155151
status:
156152
code: 201
157153
message: Created
158154
- request:
159-
body: '{"participants": [{"communicationIdentifier": {"communicationUser": {"id":
160-
"8:acs:21fe0420-a046-426d-b99b-c089229ea1be_00000013-45f1-08bf-eef0-8b3a0d0003fe"}}}]}'
155+
body: '{"participants": [{"communicationIdentifier": {"rawId": "8:acs:7746014f-86bf-4850-8c90-b19f3788206d_00000014-0218-0cd5-570c-113a0d0097b9",
156+
"communicationUser": {"id": "8:acs:7746014f-86bf-4850-8c90-b19f3788206d_00000014-0218-0cd5-570c-113a0d0097b9"}}}]}'
161157
headers:
162158
Accept:
163159
- application/json
@@ -166,7 +162,7 @@ interactions:
166162
Connection:
167163
- keep-alive
168164
Content-Length:
169-
- '161'
165+
- '253'
170166
Content-Type:
171167
- application/json
172168
User-Agent:
@@ -182,19 +178,19 @@ interactions:
182178
content-type:
183179
- application/json; charset=utf-8
184180
date:
185-
- Tue, 16 Aug 2022 09:50:04 GMT
181+
- Wed, 21 Sep 2022 22:41:17 GMT
186182
ms-cv:
187-
- rJBLJ9il20+PZ/mOkRPtbg.0
183+
- SgECEBudb0exB6g4g0MEEQ.0
188184
strict-transport-security:
189185
- max-age=2592000
190186
transfer-encoding:
191187
- chunked
192188
x-azure-ref:
193-
- 0TGj7YgAAAABrI6O5f3jZSbgEDTx0OAuRWVZSMzBFREdFMDMxOQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=
189+
- 0DZMrYwAAAADQo2Gy6zZ9RoQdpPOQJM8pWVZSMzExMDAwMTE2MDA5ADlmYzdiNTE5LWE4Y2MtNGY4OS05MzVlLWM5MTQ4YWUwOWU4MQ==
194190
x-cache:
195191
- CONFIG_NOCACHE
196192
x-processing-time:
197-
- 259ms
193+
- 357ms
198194
status:
199195
code: 201
200196
message: Created

0 commit comments

Comments
 (0)