Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Communication] add AzureCli to the default user-agent header #5381

Merged
merged 6 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/communication/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

1.3.0
++++++
* Add AzureCli to the user-agent header


1.2.2
++++++
* Fix a bug in chat 'message delete command'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
def cf_communication_cl(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azext_communication.vendored_sdks.communication import CommunicationServiceManagementClient
from ..version import cli_application_id

args = {'user_agent': cli_application_id()}

return get_mgmt_service_client(cli_ctx,
CommunicationServiceManagementClient)
CommunicationServiceManagementClient,
**args)


def cf_communication_service(cli_ctx, *_):
Expand Down
18 changes: 13 additions & 5 deletions src/communication/azext_communication/manual/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


# pylint: disable=unused-argument

from azure.cli.core.azclierror import RequiredArgumentMissingError
from ..version import cli_application_id


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

client = CommunicationIdentityClient.from_connection_string(connection_string)
args = {'user_agent': cli_application_id()}
client = CommunicationIdentityClient.from_connection_string(connection_string, **args)

return client


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

client = SmsClient.from_connection_string(connection_string)
args = {'user_agent': cli_application_id()}
client = SmsClient.from_connection_string(connection_string, **args)

return client


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

client = PhoneNumbersClient.from_connection_string(connection_string)
args = {'user_agent': cli_application_id()}
client = PhoneNumbersClient.from_connection_string(connection_string, **args)

return client


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

client = ChatClient(endpoint, CommunicationTokenCredential(token))
args = {'user_agent': cli_application_id()}
client = ChatClient(endpoint, CommunicationTokenCredential(token), **args)

return client
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,41 @@ interactions:
Content-Type:
- application/json
User-Agent:
- azsdk-python-communication-identity/1.1.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
- AzureCli/1.2.2 azsdk-python-communication-identity/1.2.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
x-ms-content-sha256:
- kWpGozyV35fifbpKdY8mbdG64VG0Pdq5upzo7YKAFM0=
x-ms-date:
- Tue, 16 Aug 2022 09:50:00 GMT
- Wed, 21 Sep 2022 22:41:14 GMT
x-ms-return-client-request-id:
- 'true'
method: POST
uri: https://sanitized.communication.azure.com/identities?api-version=2022-06-01
response:
body:
string: '{"identity": {"id": "sanitized"}, "accessToken": {"token": "sanitized",
"expiresOn": "2022-08-17T09:50:02.4106148+00:00"}}'
"expiresOn": "2022-09-22T22:41:15.8297447+00:00"}}'
headers:
api-supported-versions:
- 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview,
2021-11-01, 2022-06-01
connection:
- keep-alive
content-length:
- '122'
content-type:
- application/json; charset=utf-8
date:
- Tue, 16 Aug 2022 09:50:02 GMT
- Wed, 21 Sep 2022 22:41:15 GMT
ms-cv:
- LsIStMJYHEarY2XXM8Rscw.0
- Uk4cxbwlTE69xVxfBQIbhA.0
request-context:
- appId=
strict-transport-security:
- max-age=2592000
x-azure-ref:
- 20220816T095002Z-ue5bcnvs3t2n5ee38b8kwchyq400000000dg00000000hm2r
- 0C5MrYwAAAAB5NO/e2SjMQq0C5SQDzl7zWVZSMzExMDAwMTE2MDUzADlmYzdiNTE5LWE4Y2MtNGY4OS05MzVlLWM5MTQ4YWUwOWU4MQ==
x-cache:
- CONFIG_NOCACHE
x-processing-time:
- 118ms
- 127ms
status:
code: 201
message: Created
Expand All @@ -67,43 +65,41 @@ interactions:
Content-Type:
- application/json
User-Agent:
- azsdk-python-communication-identity/1.1.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
- AzureCli/1.2.2 azsdk-python-communication-identity/1.2.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
x-ms-content-sha256:
- kWpGozyV35fifbpKdY8mbdG64VG0Pdq5upzo7YKAFM0=
x-ms-date:
- Tue, 16 Aug 2022 09:50:01 GMT
- Wed, 21 Sep 2022 22:41:14 GMT
x-ms-return-client-request-id:
- 'true'
method: POST
uri: https://sanitized.communication.azure.com/identities?api-version=2022-06-01
response:
body:
string: '{"identity": {"id": "sanitized"}, "accessToken": {"token": "sanitized",
"expiresOn": "2022-08-17T09:50:02.9481547+00:00"}}'
"expiresOn": "2022-09-22T22:41:16.5064586+00:00"}}'
headers:
api-supported-versions:
- 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-10-31-preview,
2021-11-01, 2022-06-01
connection:
- keep-alive
content-length:
- '122'
content-type:
- application/json; charset=utf-8
date:
- Tue, 16 Aug 2022 09:50:03 GMT
- Wed, 21 Sep 2022 22:41:15 GMT
ms-cv:
- ZDXwchTQ0kuzz5DHfSUcvA.0
- 3YY1wBloMES23Ftf/HinNw.0
request-context:
- appId=
strict-transport-security:
- max-age=2592000
x-azure-ref:
- 20220816T095002Z-p18hf8s3dx4xf8cgexx53pe93400000000dg000000006ehu
- 0DJMrYwAAAADU0T+WXw9LT5KZzeebgMdVWVZSMzExMDAwMTE2MDQ5ADlmYzdiNTE5LWE4Y2MtNGY4OS05MzVlLWM5MTQ4YWUwOWU4MQ==
x-cache:
- CONFIG_NOCACHE
x-processing-time:
- 126ms
- 122ms
status:
code: 201
message: Created
Expand All @@ -121,43 +117,43 @@ interactions:
Content-Type:
- application/json
User-Agent:
- azsdk-python-communication-chat/1.1.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
- AzureCli/1.2.2 azsdk-python-communication-chat/1.1.0 Python/3.8.10 (Windows-10-10.0.19044-SP0)
repeatability-request-id:
- ce6eaa92-b047-49b7-a5e9-0a708cf21f5f
- 9f33df8b-7bbe-497b-910b-661dfd3de1ad
method: POST
uri: https://sanitized.communication.azure.com/chat/threads?api-version=2021-09-07
response:
body:
string: '{"chatThread": {"id": "sanitized", "topic": "chat-topic", "createdOn":
"2022-08-16T09:50:03Z", "createdByCommunicationIdentifier": {"rawId": "sanitized",
"2022-09-21T22:41:16Z", "createdByCommunicationIdentifier": {"rawId": "sanitized",
"communicationUser": {"id": "sanitized"}}}}'
headers:
api-supported-versions:
- 2021-03-07, 2021-04-05-preview6, 2021-09-07, 2022-11-15-preview8
content-type:
- application/json; charset=utf-8
date:
- Tue, 16 Aug 2022 09:50:03 GMT
- Wed, 21 Sep 2022 22:41:16 GMT
location:
- https://clitest000002.communication.azure.com/chat/threads/19%3Asu9i_s8IXogihisX1C3q1cvIcYcJj-4d4MLhzNbVGus1@thread.v2
- https://clitest000002.communication.azure.com/chat/threads/19%3AE6Jfa050emgshaPagc283M92Dz85balT8-OlCgy0KQ81@thread.v2
ms-cv:
- k0FPjPB5rEqLYBZ40jT4hQ.0
- yC29GuxeS0uOIKbHVVm8fw.0
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
x-azure-ref:
- 0S2j7YgAAAACOfhbXaANLToG2Dzi575PeWVZSMzExMDAwMTE1MDM3ADlmYzdiNTE5LWE4Y2MtNGY4OS05MzVlLWM5MTQ4YWUwOWU4MQ==
- 0DJMrYwAAAADFr9cqWOqPSLtimBnCGDLeWVZSMzExMDAwMTE1MDI3ADlmYzdiNTE5LWE4Y2MtNGY4OS05MzVlLWM5MTQ4YWUwOWU4MQ==
x-cache:
- CONFIG_NOCACHE
x-processing-time:
- 736ms
- 525ms
status:
code: 201
message: Created
- request:
body: '{"participants": [{"communicationIdentifier": {"communicationUser": {"id":
"8:acs:21fe0420-a046-426d-b99b-c089229ea1be_00000013-45f1-08bf-eef0-8b3a0d0003fe"}}}]}'
body: '{"participants": [{"communicationIdentifier": {"rawId": "8:acs:7746014f-86bf-4850-8c90-b19f3788206d_00000014-0218-0cd5-570c-113a0d0097b9",
"communicationUser": {"id": "8:acs:7746014f-86bf-4850-8c90-b19f3788206d_00000014-0218-0cd5-570c-113a0d0097b9"}}}]}'
headers:
Accept:
- application/json
Expand All @@ -166,7 +162,7 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '161'
- '253'
Content-Type:
- application/json
User-Agent:
Expand All @@ -182,19 +178,19 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Tue, 16 Aug 2022 09:50:04 GMT
- Wed, 21 Sep 2022 22:41:17 GMT
ms-cv:
- rJBLJ9il20+PZ/mOkRPtbg.0
- SgECEBudb0exB6g4g0MEEQ.0
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
x-azure-ref:
- 0TGj7YgAAAABrI6O5f3jZSbgEDTx0OAuRWVZSMzBFREdFMDMxOQA5ZmM3YjUxOS1hOGNjLTRmODktOTM1ZS1jOTE0OGFlMDllODE=
- 0DZMrYwAAAADQo2Gy6zZ9RoQdpPOQJM8pWVZSMzExMDAwMTE2MDA5ADlmYzdiNTE5LWE4Y2MtNGY4OS05MzVlLWM5MTQ4YWUwOWU4MQ==
x-cache:
- CONFIG_NOCACHE
x-processing-time:
- 259ms
- 357ms
status:
code: 201
message: Created
Expand Down
Loading