Skip to content

Commit 1f16747

Browse files
sofiar-msftCopilot
andauthored
Remove str from credentials (#42310)
* Remove `mypy=false` and `type_check_samples=false` * Enhance PhoneNumbersClient with type casting and improve error handling * Enhance SipRoutingClient with additional type annotations and improve error handling for trunk retrieval * Refactor environment variable access to use os.environ for consistency across samples * Fix pylint errors * Update sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample_async.py Remove redundant initialization Co-authored-by: Copilot <[email protected]> * Update sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_phone_numbers_sample.py Co-authored-by: Copilot <[email protected]> * Update sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample_async.py Co-authored-by: Copilot <[email protected]> * Update sdk/communication/azure-communication-phonenumbers/samples/browse_and_reserve_numbers_bulk_sample.py Co-authored-by: Copilot <[email protected]> * Update config trunks error message * Remove string from the credential type * Fix pylint extra whitespace --------- Co-authored-by: Copilot <[email protected]>
1 parent b001b0a commit 1f16747

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_sip_routing_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ class SipRoutingClient(object):
2929
:param endpoint: The endpoint url for Azure Communication Service resource.
3030
:type endpoint: str
3131
:param credential: The credentials with which to authenticate.
32-
:type credential: Union[TokenCredential, AzureKeyCredential, str]
32+
:type credential: Union[TokenCredential, AzureKeyCredential]
3333
:keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding
3434
this default value may result in unsupported behavior.
3535
:paramtype api_version: str
3636
"""
3737
def __init__(
3838
self,
3939
endpoint: str,
40-
credential: Union["TokenCredential", AzureKeyCredential, str],
40+
credential: Union["TokenCredential", AzureKeyCredential],
4141
**kwargs: Any
4242
) -> None:
4343

@@ -72,8 +72,8 @@ def from_connection_string(
7272
:returns: The newly created client.
7373
:rtype: ~azure.communication.siprouting.SipRoutingClient
7474
"""
75-
endpoint, credential = parse_connection_str(conn_str)
76-
return cls(endpoint, credential, **kwargs)
75+
endpoint, access_key = parse_connection_str(conn_str)
76+
return cls(endpoint, AzureKeyCredential(access_key), **kwargs)
7777

7878
@distributed_trace
7979
def get_trunk(

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/aio/_sip_routing_client_async.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SipRoutingClient(object):
3131
:param endpoint: The endpoint url for Azure Communication Service resource.
3232
:type endpoint: str
3333
:param credential: The credentials with which to authenticate.
34-
:type credential: Union[AsyncTokenCredential, AzureKeyCredential, str]
34+
:type credential: Union[AsyncTokenCredential, AzureKeyCredential]
3535
:keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding
3636
this default value may result in unsupported behavior.
3737
:paramtype api_version: str
@@ -40,7 +40,7 @@ class SipRoutingClient(object):
4040
def __init__(
4141
self,
4242
endpoint: str,
43-
credential: Union["AsyncTokenCredential", AzureKeyCredential, str],
43+
credential: Union["AsyncTokenCredential", AzureKeyCredential],
4444
**kwargs: Any
4545
) -> None:
4646

@@ -77,8 +77,8 @@ def from_connection_string(
7777
:rtype: ~azure.communication.siprouting.models.SipRoutingClient
7878
"""
7979

80-
endpoint, credential = parse_connection_str(conn_str)
81-
return cls(endpoint, credential, **kwargs)
80+
endpoint, access_key = parse_connection_str(conn_str)
81+
return cls(endpoint, AzureKeyCredential(access_key), **kwargs)
8282

8383
@distributed_trace_async
8484
async def get_trunk(

0 commit comments

Comments
 (0)