Skip to content

Commit 9936f6d

Browse files
committed
implemented Johan's suggestions
1 parent 8c894bc commit 9936f6d

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

sdk/core/azure-core/azure/core/credentials.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AzureKeyCredential(object):
3737
"""Credential type used for authenticating to an Azure service.
3838
It provides the ability to update the key without creating a new client.
3939
40-
:param str key: The key to your Azure account.
40+
:param str key: The key used to authenticate to an Azure service
4141
:raises: TypeError
4242
"""
4343

@@ -63,11 +63,11 @@ def update(self, key):
6363
This can be used when you've regenerated your service key and want
6464
to update long-lived clients.
6565
66-
:param str key: The key to your Azure account.
67-
:raises: TypeError
66+
:param str key: The key used to authenticate to an Azure service
67+
:raises: ValueError or TypeError
6868
"""
6969
if not key:
70-
raise TypeError("The key used for updating can not be None or empty")
70+
raise ValueError("The key used for updating can not be None or empty")
7171
if not isinstance(key, six.string_types):
7272
raise TypeError("The key used for updating must be a string.")
7373
self._key = key

sdk/core/azure-core/azure/core/pipeline/policies/_authentication.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,22 @@ def on_request(self, request):
9595

9696

9797
class AzureKeyCredentialPolicy(SansIOHTTPPolicy):
98-
"""Adds a key header for signing requests.
98+
"""Adds a key header for the provided credential.
9999
100100
:param credential: The credential used to authenticate requests.
101101
:type credential: ~azure.core.credentials.AzureKeyCredential
102-
:param str key_header: The name of the key header used for signing requests.
103-
:raises: TypeError
102+
:param str name: The name of the key header used for the credential.
103+
:raises: ValueError or TypeError
104104
"""
105-
def __init__(self, credential, key_header):
105+
def __init__(self, credential, name):
106106
# type: (AzureKeyCredential, str) -> None
107107
super(AzureKeyCredentialPolicy, self).__init__()
108108
self._credential = credential
109-
if not key_header:
110-
raise TypeError("key_header can not be None or empty")
111-
if not isinstance(key_header, six.string_types):
112-
raise TypeError("key_header must be a string.")
113-
self._key_header = key_header
109+
if not name:
110+
raise ValueError("name can not be None or empty")
111+
if not isinstance(name, six.string_types):
112+
raise TypeError("name must be a string.")
113+
self._name = name
114114

115115
def on_request(self, request):
116-
request.http_request.headers[self._key_header] = self._credential.key
116+
request.http_request.headers[self._name] = self._credential.key

0 commit comments

Comments
 (0)