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

[KeyVault] Remove references to six package #25902

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -65,13 +64,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 @@ -130,13 +126,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,20 @@
# 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)
ponopono0322 marked this conversation as resolved.
Show resolved Hide resolved


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 @@ -7,11 +7,10 @@
# --------------------------------------------------------------------------

from enum import Enum
from six import with_metaclass
from azure.core import CaseInsensitiveEnumMeta


class DataAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class DataAction(str, Enum, metaclass=CaseInsensitiveEnumMeta):
ponopono0322 marked this conversation as resolved.
Show resolved Hide resolved
"""Supported permissions for data actions.
"""

Expand Down Expand Up @@ -78,13 +77,13 @@ class DataAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
#: Read an HSM restore status.
READ_HSM_RESTORE_STATUS = "Microsoft.KeyVault/managedHsm/restore/status/action"

class RoleDefinitionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class RoleDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The role definition type.
"""

MICROSOFT_AUTHORIZATION_ROLE_DEFINITIONS = "Microsoft.Authorization/roleDefinitions"

class RoleScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class RoleScope(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The role scope.
"""

Expand All @@ -93,7 +92,7 @@ class RoleScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
#: Keys scope.
KEYS = "/keys"

class RoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class RoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The role type.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
# --------------------------------------------------------------------------

from enum import Enum
from six import with_metaclass
from azure.core import CaseInsensitiveEnumMeta


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

Expand Down Expand Up @@ -84,13 +83,13 @@ class DataAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
#: Generate random numbers.
RANDOM_NUMBERS_GENERATE = "Microsoft.KeyVault/managedHsm/rng/action"

class RoleDefinitionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class RoleDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The role definition type.
"""

MICROSOFT_AUTHORIZATION_ROLE_DEFINITIONS = "Microsoft.Authorization/roleDefinitions"

class RoleScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class RoleScope(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The role scope.
"""

Expand All @@ -99,7 +98,7 @@ class RoleScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
#: Keys scope.
KEYS = "/keys"

class RoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class RoleType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The role type.
"""

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 @@ -5,7 +5,6 @@
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)
ponopono0322 marked this conversation as resolved.
Show resolved Hide resolved
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
2 changes: 1 addition & 1 deletion sdk/keyvault/azure-keyvault-administration/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@
]
),
python_requires=">=3.6",
install_requires=["azure-common~=1.1", "azure-core<2.0.0,>=1.24.0", "msrest>=0.6.21", "six>=1.11.0"],
install_requires=["azure-common~=1.1", "azure-core<2.0.0,>=1.24.0", "msrest>=0.6.21"],
)
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,7 +4,6 @@
# ------------------------------------
import json

import six

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

Expand All @@ -13,6 +12,6 @@ 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 @@ -4,26 +4,25 @@
# ------------------------------------
# pylint:skip-file (avoids crash due to six.with_metaclass https://github.com/PyCQA/astroid/issues/713)
ponopono0322 marked this conversation as resolved.
Show resolved Hide resolved
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 +36,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 +54,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 +63,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 @@ -7,18 +7,17 @@
# --------------------------------------------------------------------------

from enum import Enum
from six import with_metaclass
from azure.core import CaseInsensitiveEnumMeta


class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The type of the action.
"""

EMAIL_CONTACTS = "EmailContacts"
AUTO_RENEW = "AutoRenew"

class DeletionRecoveryLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class DeletionRecoveryLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Reflects the deletion recovery level currently in effect for keys in the current vault. If it
contains 'Purgeable' the key can be permanently deleted by a privileged user; otherwise, only
the system can purge the key, at the end of the retention interval.
Expand All @@ -37,7 +36,7 @@ class DeletionRecoveryLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
#: deletion.
RECOVERABLE_PROTECTED_SUBSCRIPTION = "Recoverable+ProtectedSubscription"

class JsonWebKeyCurveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class JsonWebKeyCurveName(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Elliptic curve name. For valid values, see JsonWebKeyCurveName.
"""

Expand All @@ -50,15 +49,15 @@ class JsonWebKeyCurveName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
#: The SECG SECP256K1 elliptic curve.
SECP256_K1 = "SECP256K1"

class JsonWebKeyEncryptionAlgorithm(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class JsonWebKeyEncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""algorithm identifier
"""

RSA_OAEP = "RSA-OAEP"
RSA_OAEP256 = "RSA-OAEP-256"
RSA1_5 = "RSA1_5"

class JsonWebKeyOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class JsonWebKeyOperation(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""JSON web key operations. For more information, see JsonWebKeyOperation.
"""

Expand All @@ -69,7 +68,7 @@ class JsonWebKeyOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
WRAP_KEY = "wrapKey"
UNWRAP_KEY = "unwrapKey"

class JsonWebKeySignatureAlgorithm(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class JsonWebKeySignatureAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The signing/verification algorithm identifier. For more information on possible algorithm
types, see JsonWebKeySignatureAlgorithm.
"""
Expand All @@ -86,7 +85,7 @@ class JsonWebKeySignatureAlgorithm(with_metaclass(CaseInsensitiveEnumMeta, str,
ES512 = "ES512"
ECDSA256 = "ECDSA256"

class JsonWebKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class JsonWebKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""JsonWebKey key type (kty).
"""

Expand All @@ -96,7 +95,7 @@ class JsonWebKeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
RSA_HSM = "RSA-HSM"
OCT = "oct"

class KeyUsageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
class KeyUsageType(str, Enum, metaclass=CaseInsensitiveEnumMeta):

DIGITAL_SIGNATURE = "digitalSignature"
NON_REPUDIATION = "nonRepudiation"
Expand Down
Loading