Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
66359b8
document async transport requirement (#6541)
chlowell Jul 30, 2019
379c1a1
[AutoPR] alertsmanagement/resource-manager (#5697)
AutorestCI Jul 30, 2019
7a0f5d3
Synchronous username/password auth (#6416)
chlowell Jul 30, 2019
f9f2db1
Synchronous interactive browser authentication (#6466)
chlowell Jul 30, 2019
f583901
we dont need thread locks (#6551)
SuyogSoti Jul 30, 2019
e833df0
KV aiohttp by default (#6563)
lmazuel Jul 31, 2019
95220b7
[AutoPR hanaonazure/resource-manager] Removing monitoring hana instan…
AutorestCI Jul 31, 2019
02e17b7
KV moved paging return type to ItemPaged (#6558)
lmazuel Jul 31, 2019
37c46c6
azure-core history 1.0.0b2 (#6562)
lmazuel Jul 31, 2019
c6ebc93
Make private Cosmos modules private [WIP] (#6329)
bryevdv Jul 31, 2019
d3d96df
Accept extension of JSON content-type (#6583)
lmazuel Jul 31, 2019
d2ed7d8
Remove docdb mgmt package from master (#6585)
lmazuel Jul 31, 2019
92583cf
Revert "Remove docdb mgmt package from master (#6585)" (#6593)
lmazuel Jul 31, 2019
1d86ae8
azure-core black/pylint/mypy (#6581)
lmazuel Aug 1, 2019
a08c25a
adjusting to allow default omission of packages for CI. (#6595)
scbedd Aug 1, 2019
b0bd437
Synchronous device code credential (#6464)
chlowell Aug 1, 2019
f700299
[AutoPR alertsmanagement/resource-manager] fixing subscription id iss…
AutorestCI Aug 1, 2019
64b121c
Remove Configuration from public API (#6603)
chlowell Aug 1, 2019
ccd73c1
[AutoPR] security/resource-manager (#5709)
AutorestCI Aug 1, 2019
33d6e4a
Minimal change to disable code coverage publishing for PRs. (#6614)
mitchdenny Aug 1, 2019
0249a7c
Readme doc update for azure-core (#6611)
lmazuel Aug 1, 2019
e12b658
Mypy fixes for azure.core.tracing (#6590)
SuyogSoti Aug 2, 2019
abc3f20
MyPy azure-core (#6619)
lmazuel Aug 2, 2019
8eb5e9b
Update Key Vault docstrings (#6632)
chlowell Aug 2, 2019
2a7a965
Update Key Vault user agent (#6640)
chlowell Aug 2, 2019
b647582
Update README.md (#6635)
lmazuel Aug 2, 2019
f9ab732
mypy fixes (#6641)
SuyogSoti Aug 2, 2019
46c7ad6
Policies as kwargs for KeyVault (#6616)
lmazuel Aug 3, 2019
5b5ed26
Mypy fixes (#6646)
xiangyan99 Aug 3, 2019
8d17ca3
[AutoPR healthcareapis/resource-manager] Fixed healthcareapi readme.m…
AutorestCI Aug 5, 2019
c257006
fixed bug in maxItemCount propagation for Order by queries (#6608)
Aug 5, 2019
4470f79
Final azure-identity preview 2 changes (#6664)
chlowell Aug 5, 2019
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
Prev Previous commit
Next Next commit
Update Key Vault user agent (#6640)
  • Loading branch information
chlowell authored Aug 2, 2019
commit 2a7a965083108f1813f5d3b705d8e3ec7627772c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
# Licensed under the MIT License.
# ------------------------------------
from collections import namedtuple
import platform
from .._version import VERSION

try:
import urllib.parse as parse
except ImportError:
# pylint:disable=import-error
import urlparse as parse # type: ignore

USER_AGENT = "azsdk-python-keyvault-keys/{} Python/{} ({})".format(
VERSION, platform.python_version(), platform.platform()
)

from .challenge_auth_policy import ChallengeAuthPolicy, ChallengeAuthPolicyBase
from .client_base import KeyVaultClientBase
from .http_challenge import HttpChallenge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
# Licensed under the MIT License.
# ------------------------------------
from typing import Any, Callable, Mapping, AsyncIterator, TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import AsyncPipeline
from azure.core.pipeline.policies import UserAgentPolicy
from azure.core.pipeline.policies.distributed_tracing import DistributedTracingPolicy
from azure.core.pipeline.transport import AsyncHttpTransport
from msrest.serialization import Model

from ._generated import KeyVaultClient
from . import AsyncChallengeAuthPolicy
from . import AsyncChallengeAuthPolicy, USER_AGENT


if TYPE_CHECKING:
Expand All @@ -22,14 +24,7 @@


class AsyncKeyVaultClientBase:
"""
:param credential: A credential or credential provider which can be used to authenticate to the vault,
a ValueError will be raised if the entity is not provided
:type credential: azure.authentication.Credential or azure.authentication.CredentialProvider
:param str vault_url: The url of the vault to which the client will connect,
a ValueError will be raised if the entity is not provided
:param ~azure.core.configuration.Configuration config: The configuration for the SecretClient
"""
"""Base class for async Key Vault clients"""

@staticmethod
def _create_config(
Expand All @@ -39,6 +34,11 @@ def _create_config(
api_version = KeyVaultClient.DEFAULT_API_VERSION
config = KeyVaultClient.get_configuration_class(api_version, aio=True)(credential, **kwargs)
config.authentication_policy = AsyncChallengeAuthPolicy(credential)

# replace the autorest-generated UserAgentPolicy and its hard-coded user agent
# https://github.com/Azure/azure-sdk-for-python/issues/6637
config.user_agent_policy = UserAgentPolicy(base_user_agent=USER_AGENT, **kwargs)

return config

def __init__(
Expand Down Expand Up @@ -86,6 +86,7 @@ def _build_pipeline(config: Configuration, transport: AsyncHttpTransport, **kwar

if transport is None:
from azure.core.pipeline.transport import AioHttpTransport

transport = AioHttpTransport(**kwargs)

return AsyncPipeline(transport, policies=policies)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# Licensed under the MIT License.
# ------------------------------------
from typing import TYPE_CHECKING

from azure.core import Configuration
from azure.core.pipeline import Pipeline
from azure.core.pipeline.policies import UserAgentPolicy
from azure.core.pipeline.transport import RequestsTransport
from azure.core.pipeline.policies.distributed_tracing import DistributedTracingPolicy
from ._generated import KeyVaultClient
Expand All @@ -16,20 +18,14 @@
from azure.core.pipeline.transport import HttpTransport

from .challenge_auth_policy import ChallengeAuthPolicy
from . import USER_AGENT


KEY_VAULT_SCOPE = "https://vault.azure.net/.default"


class KeyVaultClientBase(object):
"""
:param credential: A credential or credential provider which can be used to authenticate to the vault,
a ValueError will be raised if the entity is not provided
:type credential: azure.core.credentials.TokenCredential
:param str vault_url: The url of the vault to which the client will connect,
a ValueError will be raised if the entity is not provided
:param ~azure.core.configuration.Configuration config: The configuration for the KeyClient
"""
"""Base class for Key Vault clients"""

@staticmethod
def _create_config(credential, api_version=None, **kwargs):
Expand All @@ -38,6 +34,11 @@ def _create_config(credential, api_version=None, **kwargs):
api_version = KeyVaultClient.DEFAULT_API_VERSION
config = KeyVaultClient.get_configuration_class(api_version, aio=False)(credential, **kwargs)
config.authentication_policy = ChallengeAuthPolicy(credential)

# replace the autorest-generated UserAgentPolicy and its hard-coded user agent
# https://github.com/Azure/azure-sdk-for-python/issues/6637
config.user_agent_policy = UserAgentPolicy(base_user_agent=USER_AGENT, **kwargs)

return config

def __init__(self, vault_url, credential, transport=None, api_version=None, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@


class KeyClient(AsyncKeyVaultClientBase):
"""A high-level interface for managing a vault's keys.
"""A high-level asynchronous interface for managing a vault's keys.

:param credential: An object which can provide an access token for the vault, such as a credential from
:mod:`azure.identity.aio`
:param str vault_url: URL of the vault the client will access

Example:
.. literalinclude:: ../tests/test_samples_keys_async.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
class KeyClient(KeyVaultClientBase):
"""A high-level interface for managing a vault's keys.

:param credential: An object which can provide an access token for the vault, such as a credential from
:mod:`azure.identity`
:param str vault_url: URL of the vault the client will access

Example:
.. literalinclude:: ../tests/test_samples_keys.py
:start-after: [START create_key_client]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@


class SecretClient(AsyncKeyVaultClientBase):
"""A high-level interface for managing a vault's secrets.
"""A high-level asynchronous interface for managing a vault's secrets.

:param credential: An object which can provide an access token for the vault, such as a credential from
:mod:`azure.identity.aio`
:param str vault_url: URL of the vault the client will access

Example:
.. literalinclude:: ../tests/test_samples_secrets_async.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
class SecretClient(KeyVaultClientBase):
"""A high-level interface for managing a vault's secrets.

:param credential: An object which can provide an access token for the vault, such as a credential from
:mod:`azure.identity`
:param str vault_url: URL of the vault the client will access

Example:
.. literalinclude:: ../tests/test_samples_secrets.py
:start-after: [START create_secret_client]
Expand Down