Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d7bcfe6
changing ContainerRepositoryClient to ContainerRepository
seankane-msft Apr 27, 2021
7a0b598
renaming files
seankane-msft Apr 27, 2021
15bbaaf
re-recording, commenting out tests that are not necessary
seankane-msft Apr 27, 2021
b91302c
working sync registry artifact class
seankane-msft Apr 28, 2021
6f7c55c
async registry artifact
seankane-msft Apr 28, 2021
22ecb18
issue with recording infra that is removing an acr specific oauth path
seankane-msft Apr 28, 2021
d5986dd
pylint issues
seankane-msft Apr 28, 2021
1287136
recording and processors
seankane-msft Apr 28, 2021
145949b
removing commented out code
seankane-msft Apr 28, 2021
09f3636
undoing changes to cache
seankane-msft Apr 28, 2021
6e38bf1
more lint fixes
seankane-msft Apr 28, 2021
d9659c0
help with logging output
seankane-msft Apr 28, 2021
af8959d
adding enums
seankane-msft Apr 28, 2021
c355fdd
updating enums
seankane-msft Apr 28, 2021
506c1ef
merge conflicts
seankane-msft May 6, 2021
2ec30e1
merge conflicts
seankane-msft May 6, 2021
09a7d4e
added spacing between inline examples
seankane-msft May 6, 2021
74151e7
merge conflicts
seankane-msft May 7, 2021
7d93184
pylint fixes
seankane-msft May 9, 2021
c32799b
undoing changes to recording files
seankane-msft May 9, 2021
ff9fa17
undoing changes to two generated files
seankane-msft May 9, 2021
cc2396f
removing early return
seankane-msft May 9, 2021
cf8d784
fixing based on laurents feedback
seankane-msft May 10, 2021
ec45042
fixing vartype docs
seankane-msft May 10, 2021
5899334
Update sdk/containerregistry/azure-containerregistry/azure/containerr…
seankane-msft May 11, 2021
2788897
Update sdk/containerregistry/azure-containerregistry/azure/containerr…
seankane-msft May 11, 2021
a186814
kristas comments
seankane-msft May 11, 2021
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 @@ -9,8 +9,10 @@
from ._container_registry_client import ContainerRegistryClient
from ._container_repository import ContainerRepository
from ._models import (
DeleteRepositoryResult,
ArtifactArchitecture,
ArtifactOperatingSystem,
ContentProperties,
DeleteRepositoryResult,
ManifestOrder,
ArtifactManifestProperties,
RepositoryProperties,
Expand All @@ -23,6 +25,8 @@
__version__ = VERSION

__all__ = [
"ArtifactArchitecture",
"ArtifactOperatingSystem",
"ContainerRegistryClient",
"ContainerRepository",
"ContentProperties",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class ContainerRegistryClient(ContainerRegistryBaseClient):
def __init__(self, endpoint, credential, **kwargs):
# type: (str, TokenCredential, Dict[str, Any]) -> None
"""Create a ContainerRegistryClient from an ACR endpoint and a credential

:param str endpoint: An ACR endpoint
:param credential: The credential with which to authenticate
:type credential: :class:`~azure.core.credentials.TokenCredential`
Expand Down Expand Up @@ -80,7 +79,6 @@ def delete_repository(self, repository_name, **kwargs):
def list_repository_names(self, **kwargs):
# type: (Dict[str, Any]) -> ItemPaged[str]
"""List all repositories

:keyword max: Maximum number of repositories to return
:paramtype max: int
:keyword last: Query parameter for the last item in the previous call. Ensuing
Expand All @@ -95,8 +93,8 @@ def list_repository_names(self, **kwargs):
.. admonition:: Example:

.. literalinclude:: ../samples/sample_delete_old_tags.py
:start-after: [START list_repositories]
:end-before: [END list_repositories]
:start-after: [START list_repository_names]
:end-before: [END list_repository_names]
:language: python
:dedent: 8
:caption: List repositories in a container registry account
Expand Down Expand Up @@ -204,13 +202,11 @@ def get_repository(self, repository_name, **kwargs):
Example

.. code-block:: python

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential

account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRegistryClient(account_url, DefaultAzureCredential())
repository_client = client.get_repository_client("my_repository")
repository_client = client.get_repository("my_repository")
"""
_pipeline = Pipeline(
transport=TransportWrapper(self._client._client._pipeline._transport), # pylint: disable=protected-access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def list_manifests(self, **kwargs):
call will return values after last lexically
:paramtype last: str
:keyword order_by: Query parameter for ordering by time ascending or descending
:paramtype order_by: :class:`~azure.containerregistry.ManifestOrder`
:paramtype order_by: :class:`~azure.containerregistry.ManifestOrder` or str
:keyword results_per_page: Number of repositories to return per page
:paramtype results_per_page: int
:return: ItemPaged[:class:`ArtifactManifestProperties`]
Expand Down Expand Up @@ -206,7 +206,9 @@ def set_properties(self, properties, **kwargs):
"""
return RepositoryProperties._from_generated( # pylint: disable=protected-access
self._client.container_registry.set_properties(
self.name, properties._to_generated(), **kwargs # pylint: disable=protected-access
self.name,
properties._to_generated(), # pylint: disable=protected-access
**kwargs
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

from enum import Enum
from typing import TYPE_CHECKING, Dict, Any
from ._generated.models import ContentProperties as GeneratedContentProperties

from ._generated.models import RepositoryProperties as GeneratedRepositoryProperties
from ._generated.models import ContentProperties as GeneratedContentProperties

if TYPE_CHECKING:
from ._generated.models import ManifestAttributesBase
Expand All @@ -24,7 +25,7 @@ class ContentProperties(object):
"""

def __init__(self, **kwargs):
"""Create ContentPermissions for an artifact, tag, or manifest
"""Create ContentProperties for an artifact, tag, or manifest

:keyword bool can_delete: Delete operation status for the object
:keyword bool can_list: List operation status for the object
Expand Down Expand Up @@ -78,26 +79,32 @@ def _from_generated(cls, gen):
class ArtifactManifestProperties(object):
"""Represents properties of a registry artifact

:ivar str cpu_architecture: CPU Architecture of an artifact
:ivar architecture: CPU Architecture of an artifact
:vartype architecture: ~azure.containerregistry.ArtifactArchitecture
:ivar created_on: Time and date an artifact was created
:vartype created_on: :class:`~datetime.datetime`
:vartype created_on: ~datetime.datetime
:ivar str digest: Digest for the artifact
:ivar last_updated_on: Time and date an artifact was last updated
:vartype last_updated_on: :class:`~datetime.datetime`
:ivar str operating_system: Operating system for the artifact
:vartype last_updated_on: datetime.datetime
:ivar operating_system: Operating system for the artifact
:vartype operating_system: ~azure.containerregistry.ArtifactOperatingSystem
:ivar str repository_name: Repository name the artifact belongs to
:ivar str size: Size of the artifact
:ivar List[str] tags: Tags associated with a registry artifact
:ivar writeable_properties: Permissions for an artifact
:vartype writeable_properties: :class:`~azure.containerregistry.ContentProperties`
:vartype writeable_properties: ~azure.containerregistry.ContentProperties
"""

def __init__(self, **kwargs):
self.cpu_architecture = kwargs.get("cpu_architecture", None)
self.architecture = kwargs.get("cpu_architecture", None)
if self.architecture is not None:
self.architecture = ArtifactArchitecture(self.architecture)
self.created_on = kwargs.get("created_on", None)
self.digest = kwargs.get("digest", None)
self.last_updated_on = kwargs.get("last_updated_on", None)
self.operating_system = kwargs.get("operating_system", None)
if self.operating_system is not None:
self.operating_system = ArtifactOperatingSystem(self.operating_system)
self.repository_name = kwargs.get("repository_name", None)
self.size = kwargs.get("size", None)
self.tags = kwargs.get("tags", None)
Expand Down Expand Up @@ -125,11 +132,11 @@ class RepositoryProperties(object):
"""Model for storing properties of a single repository

:ivar writeable_properties: Read/Write/List/Delete permissions for the repository
:vartype writeable_properties: :class:`~azure.containerregistry.ContentProperties`
:vartype writeable_properties: ~azure.containerregistry.ContentProperties
:ivar created_on: Time the repository was created
:vartype created_on: :class:`datetime.datetime`
:vartype created_on: datetime.datetime
:ivar last_updated_on: Time the repository was last updated
:vartype last_updated_on: :class:`datetime.datetime`
:vartype last_updated_on: datetime.datetime
:ivar int manifest_count: Number of manifest in the repository
:ivar str name: Name of the repository
:ivar int tag_count: Number of tags associated with the repository
Expand Down Expand Up @@ -168,6 +175,17 @@ def _to_generated(self):
writeable_properties=self.writeable_properties._to_generated(), # pylint: disable=protected-access
)

def _to_generated(self):
# type: () -> GeneratedRepositoryProperties
return GeneratedRepositoryProperties(
name=self.name,
created_on=self.created_on,
last_updated_on=self.last_updated_on,
manifest_count=self.manifest_count,
tag_count=self.tag_count,
writeable_properties=self.writeable_properties._to_generated(), # pylint: disable=protected-access
)


class ManifestOrder(str, Enum):
"""Enum for ordering registry artifacts"""
Expand All @@ -187,12 +205,12 @@ class ArtifactTagProperties(object):
"""Model for storing properties of a single tag

:ivar writeable_properties: Read/Write/List/Delete permissions for the tag
:vartype writeable_properties: :class:`~azure.containerregistry.ContentProperties`
:vartype writeable_properties: ~azure.containerregistry.ContentProperties
:ivar created_on: Time the tag was created
:vartype created_on: :class:`datetime.datetime`
:vartype created_on: datetime.datetime
:ivar str digest: Digest for the tag
:ivar last_updated_on: Time the tag was last updated
:vartype last_updated_on: :class:`datetime.datetime`
:vartype last_updated_on: datetime.datetime
:ivar str name: Name of the image the tag corresponds to
:ivar str repository: Repository the tag belongs to
"""
Expand All @@ -218,3 +236,38 @@ def _from_generated(cls, generated, **kwargs):
writeable_properties=generated.writeable_properties,
repository=kwargs.get("repository", None),
)


class ArtifactArchitecture(str, Enum):

AMD64 = "amd64"
ARM = "arm"
ARM64 = "arm64"
I386 = "386"
MIPS = "mips"
MIPS64 = "mips64"
MIPS64LE = "mips64le"
MIPSLE = "mipsle"
PPC64 = "ppc64"
PPC64LE = "ppc64le"
RISCV64 = "riscv64"
S390X = "s390x"
WASM = "wasm"


class ArtifactOperatingSystem(str, Enum):

AIX = "aix"
ANDROID = "android"
DARWIN = "darwin"
DRAGONFLY = "dragonfly"
FREEBSD = "freebsd"
ILLUMOS = "illumos"
IOS = "ios"
JS = "js"
LINUX = "linux"
NETBSD = "netbsd"
OPENBSD = "openbsd"
PLAN9 = "plan9"
SOLARIS = "solaris"
WINDOWS = "windows"
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,15 @@ def _get_digest_from_tag(self):
def delete(self, **kwargs):
# type: (Dict[str, Any]) -> None
"""Delete a repository

:returns: Object containing information about the deleted repository
:rtype: :class:`~azure.containerregistry.DeleteRepositoryResult`
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError`

Example

.. code-block:: python

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential

account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
client.delete()
Expand All @@ -98,18 +95,15 @@ def delete(self, **kwargs):
def delete_tag(self, tag, **kwargs):
# type: (str, Dict[str, Any]) -> None
"""Delete a tag from a repository

:param str tag: The tag to be deleted
:returns: None
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError`

Example

.. code-block:: python

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential

account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
for artifact in client.list_tags():
Expand All @@ -128,13 +122,11 @@ def get_manifest_properties(self, **kwargs):
Example

.. code-block:: python

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential

account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
for artifact in client.list_registry_artifacts():
for artifact in client.list_manifests():
properties = client.get_registry_artifact_properties(artifact.digest)
"""
if not self._digest:
Expand All @@ -149,7 +141,6 @@ def get_manifest_properties(self, **kwargs):
def get_tag_properties(self, tag, **kwargs):
# type: (str, Dict[str, Any]) -> ArtifactTagProperties
"""Get the properties for a tag

:param tag: The tag to get properties for
:type tag: str
:returns: :class:`~azure.containerregistry.ArtifactTagProperties`
Expand All @@ -158,10 +149,8 @@ def get_tag_properties(self, tag, **kwargs):
Example

.. code-block:: python

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential

account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
for tag in client.list_tags():
Expand All @@ -176,7 +165,6 @@ def get_tag_properties(self, tag, **kwargs):
def list_tags(self, **kwargs):
# type: (Dict[str, Any]) -> ItemPaged[ArtifactTagProperties]
"""List the tags for a repository

:keyword last: Query parameter for the last item in the previous call. Ensuing
call will return values after last lexically
:paramtype last: str
Expand All @@ -191,10 +179,8 @@ def list_tags(self, **kwargs):
Example

.. code-block:: python

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential

account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
for tag in client.list_tags():
Expand Down Expand Up @@ -319,16 +305,14 @@ def set_manifest_properties(self, permissions, **kwargs):
Example

.. code-block:: python

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential

account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
for artifact in client.list_registry_artifacts():
for artifact in client.list_manifests():
received_permissions = client.set_manifest_properties(
artifact.digest,
ContentPermissions(
ContentProperties(
can_delete=False,
can_list=False,
can_read=False,
Expand All @@ -353,7 +337,6 @@ def set_manifest_properties(self, permissions, **kwargs):
def set_tag_properties(self, tag, permissions, **kwargs):
# type: (str, ContentProperties, Dict[str, Any]) -> ArtifactTagProperties
"""Set the properties for a tag

:param tag: Tag to set properties for
:type tag: str
:param permissions: The property's values to be set
Expand All @@ -364,16 +347,14 @@ def set_tag_properties(self, tag, permissions, **kwargs):
Example

.. code-block:: python

from azure.containerregistry import ContainerRepositoryClient
from azure.identity import DefaultAzureCredential

account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
client = ContainerRepositoryClient(account_url, "my_repository", DefaultAzureCredential())
tag_identifier = "latest"
received = client.set_tag_properties(
tag_identifier,
ContentPermissions(
ContentProperties(
can_delete=False,
can_list=False,
can_read=False,
Expand Down
Loading