Skip to content

Commit

Permalink
Move the enum ContainerRegistryAudience to an existing file for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
YalinLi0312 committed Sep 1, 2021
1 parent 6aa1a1d commit 4a9e466
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# --------------------------------------------------------------------------

from ._container_registry_client import ContainerRegistryClient
from ._enums import ContainerRegistryAudience
from ._models import (
ArtifactArchitecture,
ArtifactOperatingSystem,
Expand All @@ -30,5 +29,4 @@
"RepositoryProperties",
"TagOrder",
"ArtifactTagProperties",
"ContainerRegistryAudience",
]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,10 @@

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

class _CaseInsensitiveEnumMeta(EnumMeta):
def __getitem__(self, name):
return super().__getitem__(name.upper())

def __getattr__(cls, name):
"""Return the enum member matching `name`
We use __getattr__ instead of descriptors or inserting into the enum
class' __dict__ in order to support `name` and `value` being both
properties for enum members (which live in the class' __dict__) and
enum members themselves.
"""
try:
return cls._member_map_[name.upper()]
except KeyError:
raise AttributeError(name)


class ArtifactArchitecture(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class ArtifactArchitecture(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):

I386 = "386"
AMD64 = "amd64"
Expand All @@ -40,7 +25,7 @@ class ArtifactArchitecture(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
S390_X = "s390x"
WASM = "wasm"

class ArtifactOperatingSystem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class ArtifactOperatingSystem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):

AIX = "aix"
ANDROID = "android"
Expand All @@ -57,7 +42,7 @@ class ArtifactOperatingSystem(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum
SOLARIS = "solaris"
WINDOWS = "windows"

class ManifestOrderBy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class ManifestOrderBy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
"""Sort options for ordering manifests in a collection.
"""

Expand All @@ -68,7 +53,7 @@ class ManifestOrderBy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
#: Order manifest by LastUpdatedOn field, from least recently updated to most recently updated.
LAST_UPDATED_ON_ASCENDING = "timeasc"

class TagOrderBy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class TagOrderBy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):

#: Do not provide an orderby value in the request.
NONE = "none"
Expand All @@ -77,9 +62,17 @@ class TagOrderBy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
#: Order tags by LastUpdatedOn field, from least recently updated to most recently updated.
LAST_UPDATED_ON_ASCENDING = "timeasc"

class TokenGrantType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)):
class TokenGrantType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
"""Grant type is expected to be refresh_token
"""

REFRESH_TOKEN = "refresh_token"
PASSWORD = "password"

class ContainerRegistryAudience(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
"""Supported container registry audience"""

ARM_CHINA = "https://management.chinacloudapi.cn"
ARM_GERMANY = "https://management.microsoftazure.de"
ARM_GOVERNMENT = "https://management.usgovcloudapi.net"
ARM_PUBLIC_CLOUD = "https://management.azure.com"
12 changes: 4 additions & 8 deletions sdk/containerregistry/azure-containerregistry/tests/testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@
import six
import time

from azure.containerregistry import ContainerRegistryAudience, ContainerRegistryClient
from azure.containerregistry import ContainerRegistryClient
from azure.containerregistry._helpers import _is_tag
from azure.containerregistry._generated.models._container_registry_enums import ContainerRegistryAudience

from azure.core.credentials import AccessToken
from azure.mgmt.containerregistry import ContainerRegistryManagementClient
from azure.mgmt.containerregistry.models import ImportImageParameters, ImportSource, ImportMode
from azure.identity import DefaultAzureCredential, AzureAuthorityHosts
from azure.identity import DefaultAzureCredential, AzureAuthorityHosts, ClientSecretCredential

from devtools_testutils import AzureTestCase, is_live
from azure_devtools.scenario_tests import (
OAuthRequestResponsesFilter,
RecordingProcessor,
)
from azure_devtools.scenario_tests import RecordingProcessor
from msrestazure.azure_cloud import AZURE_CHINA_CLOUD, AZURE_US_GOV_CLOUD, AZURE_PUBLIC_CLOUD, AZURE_GERMAN_CLOUD


REDACTED = "REDACTED"
Expand Down Expand Up @@ -252,11 +253,6 @@ def get_base_url(authority):
logger.warning("Germany scope")
return AZURE_GERMAN_CLOUD



from azure.identity import ClientSecretCredential
from msrestazure.azure_cloud import AZURE_CHINA_CLOUD, AZURE_US_GOV_CLOUD, AZURE_PUBLIC_CLOUD, AZURE_GERMAN_CLOUD

# Moving this out of testcase so the fixture and individual tests can use it
def import_image(authority, repository, tags):
logger.warning("Import image authority: {}".format(authority))
Expand Down

0 comments on commit 4a9e466

Please sign in to comment.