Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import pickle
from typing import TYPE_CHECKING

from six import raise_from
from six.moves.urllib_parse import urlparse
from urllib.parse import urlparse

from ._models import KeyVaultBackupResult
from ._internal import KeyVaultClientBase, parse_folder_url
Expand Down Expand Up @@ -73,13 +72,10 @@ def begin_backup(self, blob_storage_url, sas_token, **kwargs):
try:
job_id = _parse_status_url(status_url)
except Exception as ex: # pylint: disable=broad-except
raise_from(
ValueError(
"The provided continuation_token is malformed. A valid token can be obtained from the "
+ "operation poller's continuation_token() method"
),
ex,
)
raise ValueError(
"The provided continuation_token is malformed. A valid token can be obtained from the "
+ "operation poller's continuation_token() method"
) from ex

pipeline_response = self._client.full_backup_status(
vault_base_url=self._vault_url, job_id=job_id, cls=lambda pipeline_response, _, __: pipeline_response
Expand Down Expand Up @@ -138,13 +134,10 @@ def begin_restore(self, folder_url, sas_token, **kwargs):
try:
job_id = _parse_status_url(status_url)
except Exception as ex: # pylint: disable=broad-except
raise_from(
ValueError(
"The provided continuation_token is malformed. A valid token can be obtained from the "
+ "operation poller's continuation_token() method"
),
ex,
)
raise ValueError(
"The provided continuation_token is malformed. A valid token can be obtained from the "
+ "operation poller's continuation_token() method"
) from ex

pipeline_response = self._client.restore_status(
vault_base_url=self._vault_url, job_id=job_id, cls=lambda pipeline_response, _, __: pipeline_response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
# Licensed under the MIT License.
# ------------------------------------
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta

# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)


class KeyVaultRoleScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyVaultRoleScope(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Collection of well known role scopes. This list is not exhaustive."""

GLOBAL = "/" #: use this if you want role assignments to apply to everything on the resource
KEYS = "/keys" #: use this if you want role assignments to apply to all keys


class KeyVaultDataAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyVaultDataAction(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported permissions for data actions."""

#: Read HSM key metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ------------------------------------
from collections import namedtuple

from six.moves.urllib_parse import urlparse
from urllib.parse import urlparse

from .challenge_auth_policy import ChallengeAuthPolicy
from .client_base import KeyVaultClientBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)

from typing import TYPE_CHECKING
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline.policies import HttpLoggingPolicy
Expand All @@ -20,7 +19,7 @@
from azure.core.credentials import TokenCredential


class ApiVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Key Vault API versions supported by this package"""

#: this is the default version
Expand Down
1 change: 0 additions & 1 deletion sdk/keyvault/azure-keyvault-administration/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"azure-common~=1.1",
"azure-core<2.0.0,>=1.24.0",
"isodate>=0.6.1",
"six>=1.11.0",
"typing-extensions>=4.0.1",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License.
# ------------------------------------
import json
import six
from urllib import parse

try:
from unittest import mock
Expand Down Expand Up @@ -47,7 +47,7 @@ def add_discrepancy(name, expected, actual):
if self.url_substring and self.url_substring not in request.url:
add_discrepancy("url substring", self.url_substring, request.url)

parsed = six.moves.urllib_parse.urlparse(request.url)
parsed = parse.urlparse(request.url)
if self.authority and parsed.netloc != self.authority:
add_discrepancy("authority", self.authority, parsed.netloc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
# ------------------------------------
import json

import six

_has_json_body = lambda req: req.body and "json" in req.headers.get("Content-Type", "")


def json_attribute_matcher(r1, r2):
"""Tests whether two vcr.py requests have JSON content with identical attributes (ignoring values)."""

if _has_json_body(r1) and _has_json_body(r2):
c1 = json.loads(six.ensure_str(r1.body))
c2 = json.loads(six.ensure_str(r2.body))
c1 = json.loads(str(r1.body))
c2 = json.loads(str(r2.body))
assert sorted(c1.keys()) == sorted(c2.keys())
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)

# pylint: disable=enum-must-be-uppercase

from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta


class CertificatePolicyAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class CertificatePolicyAction(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The supported action types for the lifetime of a certificate"""

email_contacts = "EmailContacts"
auto_renew = "AutoRenew"


class CertificateContentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class CertificateContentType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Content type of the secrets as specified in Certificate Policy"""

pkcs12 = "application/x-pkcs12"
pem = "application/x-pem-file"


class KeyUsageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyUsageType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The supported types of key usages"""

digital_signature = "digitalSignature"
Expand All @@ -37,7 +38,7 @@ class KeyUsageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
decipher_only = "decipherOnly"


class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported key types"""

ec = "EC" #: Elliptic Curve
Expand All @@ -55,7 +56,7 @@ def _missing_(cls, value):
raise ValueError(f"{value} is not a valid KeyType")


class KeyCurveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyCurveName(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported elliptic curves"""

p_256 = "P-256" #: The NIST P-256 elliptic curve, AKA SECG curve SECP256R1.
Expand All @@ -64,7 +65,7 @@ class KeyCurveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
p_256_k = "P-256K" #: The SECG SECP256K1 elliptic curve.


class WellKnownIssuerNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class WellKnownIssuerNames(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Collection of well-known issuer names"""

self = "Self" #: Use this issuer for a self-signed certificate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)
from typing import TYPE_CHECKING
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline.policies import HttpLoggingPolicy
Expand All @@ -20,7 +18,7 @@
from azure.core.credentials import TokenCredential


class ApiVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Key Vault API versions supported by this package"""

#: this is the default version
Expand Down
1 change: 0 additions & 1 deletion sdk/keyvault/azure-keyvault-certificates/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"azure-common~=1.1",
"azure-core<2.0.0,>=1.24.0",
"isodate>=0.6.1",
"six>=1.11.0",
"typing-extensions>=4.0.1",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License.
# ------------------------------------
import json
import six
from urllib import parse

try:
from unittest import mock
Expand Down Expand Up @@ -47,7 +47,7 @@ def add_discrepancy(name, expected, actual):
if self.url_substring and self.url_substring not in request.url:
add_discrepancy("url substring", self.url_substring, request.url)

parsed = six.moves.urllib_parse.urlparse(request.url)
parsed = parse.urlparse(request.url)
if self.authority and parsed.netloc != self.authority:
add_discrepancy("authority", self.authority, parsed.netloc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
# ------------------------------------
import json

import six

_has_json_body = lambda req: req.body and "json" in req.headers.get("Content-Type", "")


def json_attribute_matcher(r1, r2):
"""Tests whether two vcr.py requests have JSON content with identical attributes (ignoring values)."""

if _has_json_body(r1) and _has_json_body(r2):
c1 = json.loads(six.ensure_str(r1.body))
c2 = json.loads(six.ensure_str(r2.body))
c1 = json.loads(str(r1.body))
c2 = json.loads(str(r2.body))
assert sorted(c1.keys()) == sorted(c2.keys())
15 changes: 8 additions & 7 deletions sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)

# pylint: disable=enum-must-be-uppercase

from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta


class KeyCurveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyCurveName(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported elliptic curves"""

p_256 = "P-256" #: The NIST P-256 elliptic curve, AKA SECG curve SECP256R1.
Expand All @@ -18,15 +19,15 @@ class KeyCurveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
p_256_k = "P-256K" #: The SECG SECP256K1 elliptic curve.


class KeyExportEncryptionAlgorithm(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyExportEncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported algorithms for protecting exported key material"""

ckm_rsa_aes_key_wrap = "CKM_RSA_AES_KEY_WRAP"
rsa_aes_key_wrap_256 = "RSA_AES_KEY_WRAP_256"
rsa_aes_key_wrap_384 = "RSA_AES_KEY_WRAP_384"


class KeyOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported key operations"""

encrypt = "encrypt"
Expand All @@ -39,14 +40,14 @@ class KeyOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
export = "export"


class KeyRotationPolicyAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyRotationPolicyAction(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The action that will be executed in a key rotation policy"""

rotate = "Rotate" #: Rotate the key based on the key policy.
notify = "Notify" #: Trigger Event Grid events.


class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Supported key types"""

ec = "EC" #: Elliptic Curve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)
from typing import TYPE_CHECKING
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta
from azure.core.pipeline.policies import HttpLoggingPolicy
Expand All @@ -20,7 +18,7 @@
from azure.core.credentials import TokenCredential


class ApiVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Key Vault API versions supported by this package"""

#: this is the default version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import logging
from typing import TYPE_CHECKING, cast

import six
from azure.core.exceptions import HttpResponseError
from azure.core.tracing.decorator import distributed_trace

Expand Down Expand Up @@ -119,7 +118,7 @@ def __init__(self, key, credential, **kwargs):
if key.properties._attributes: # pylint:disable=protected-access
self._not_before = key.properties.not_before
self._expires_on = key.properties.expires_on
elif isinstance(key, six.string_types):
elif isinstance(key, str):
self._key = None
self._key_id = parse_key_vault_id(key)
if self._key_id.version is None:
Expand All @@ -135,7 +134,7 @@ def __init__(self, key, credential, **kwargs):
self._local_provider = get_local_cryptography_provider(cast(JsonWebKey, self._key))
self._initialized = True
except Exception as ex: # pylint:disable=broad-except
six.raise_from(ValueError("The provided jwk is not valid for local cryptography"), ex)
raise ValueError("The provided jwk is not valid for local cryptography") from ex
else:
self._local_provider = NoLocalCryptography()
self._initialized = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# ------------------------------------

from abc import ABCMeta, abstractmethod
from six import with_metaclass
from .algorithm import Algorithm

try:
Expand All @@ -16,7 +15,7 @@
# pylint:disable=unused-import
from typing import Any, FrozenSet

class Key(with_metaclass(ABCMeta, object)):
class Key(object, metaclass=ABCMeta):
_supported_encryption_algorithms = frozenset([]) # type: FrozenSet[Any]
_supported_key_wrap_algorithms = frozenset([]) # type: FrozenSet[Any]
_supported_signature_algorithms = frozenset([]) # type: FrozenSet[Any]
Expand Down
Loading