-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Container Registry] Improved samples #18263
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
Changes from all commits
2cd779a
89ff226
8ff2256
592f0c2
2902a53
16f264c
a3b9ba8
4bc1f2c
c9e4dcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,15 @@ def __init__(self, endpoint, repository, credential, **kwargs): | |
| :type credential: :class:`~azure.core.credentials.TokenCredential` | ||
| :returns: None | ||
| :raises: None | ||
|
|
||
| .. admonition:: Example: | ||
|
|
||
| .. literalinclude:: ../samples/sample_create_client.py | ||
| :start-after: [START create_repository_client] | ||
| :end-before: [END create_repository_client] | ||
| :language: python | ||
| :dedent: 8 | ||
| :caption: Instantiate an instance of `ContainerRepositoryClient` | ||
| """ | ||
| if not endpoint.startswith("https://") and not endpoint.startswith("http://"): | ||
| endpoint = "https://" + endpoint | ||
|
|
@@ -63,6 +72,17 @@ def delete(self, **kwargs): | |
| :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() | ||
| """ | ||
| return DeleteRepositoryResult._from_generated( # pylint: disable=protected-access | ||
| self._client.container_registry.delete_repository(self.repository, **kwargs) | ||
|
|
@@ -77,6 +97,18 @@ def delete_registry_artifact(self, digest, **kwargs): | |
| :type digest: str | ||
| :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_registry_artifacts(): | ||
| client.delete_registry_artifact(artifact.digest) | ||
| """ | ||
| self._client.container_registry.delete_manifest(self.repository, digest, **kwargs) | ||
|
|
||
|
|
@@ -88,6 +120,18 @@ def delete_tag(self, tag, **kwargs): | |
| :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(): | ||
| client.delete_tag(tag.name) | ||
| """ | ||
| self._client.container_registry.delete_tag(self.repository, tag, **kwargs) | ||
|
|
||
|
|
@@ -98,6 +142,24 @@ def get_properties(self, **kwargs): | |
|
|
||
| :returns: :class:`~azure.containerregistry.RepositoryProperties` | ||
| :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()) | ||
| repository_properties = client.get_properties() | ||
| print(repository_properties.name) | ||
| print(repository_properties.content_permissions) | ||
| print(repository_properties.created_on) | ||
| print(repository_properties.last_updated_on) | ||
| print(repository_properties.manifest_count) | ||
| print(repository_properties.registry) | ||
| print(repository_properties.tag_count) | ||
| """ | ||
| return RepositoryProperties._from_generated( # pylint: disable=protected-access | ||
| self._client.container_registry.get_properties(self.repository, **kwargs) | ||
|
|
@@ -112,6 +174,18 @@ def get_registry_artifact_properties(self, tag_or_digest, **kwargs): | |
| :type tag_or_digest: str | ||
| :returns: :class:`~azure.containerregistry.RegistryArtifactProperties` | ||
| :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_registry_artifacts(): | ||
| properties = client.get_registry_artifact_properties(artifact.digest) | ||
| """ | ||
| if _is_tag(tag_or_digest): | ||
| tag_or_digest = self._get_digest_from_tag(tag_or_digest) | ||
|
|
@@ -129,6 +203,18 @@ def get_tag_properties(self, tag, **kwargs): | |
| :type tag: str | ||
| :returns: :class:`~azure.containerregistry.ArtifactTagProperties` | ||
| :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 tag in client.list_tags(): | ||
| tag_properties = client.get_tag_properties(tag.name) | ||
| """ | ||
| return ArtifactTagProperties._from_generated( # pylint: disable=protected-access | ||
| self._client.container_registry.get_tag_properties(self.repository, tag, **kwargs), | ||
|
|
@@ -150,6 +236,18 @@ def list_registry_artifacts(self, **kwargs): | |
| :return: ItemPaged[:class:`RegistryArtifactProperties`] | ||
| :rtype: :class:`~azure.core.paging.ItemPaged` | ||
| :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_registry_artifacts(): | ||
| print(artifact.digest) | ||
| """ | ||
| name = self.repository | ||
| last = kwargs.pop("last", None) | ||
|
|
@@ -268,6 +366,18 @@ def list_tags(self, **kwargs): | |
| :return: ItemPaged[:class:`~azure.containerregistry.ArtifactTagProperties`] | ||
| :rtype: :class:`~azure.core.paging.ItemPaged` | ||
| :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 tag in client.list_tags(): | ||
| tag_properties = client.get_tag_properties(tag.name) | ||
| """ | ||
| name = self.repository | ||
| last = kwargs.pop("last", None) | ||
|
|
@@ -386,6 +496,26 @@ def set_manifest_properties(self, digest, permissions, **kwargs): | |
| :type permissions: ContentProperties | ||
| :returns: :class:`~azure.containerregistry.RegistryArtifactProperties` | ||
| :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_registry_artifacts(): | ||
| received_permissions = client.set_manifest_properties( | ||
| artifact.digest, | ||
| ContentPermissions( | ||
| can_delete=False, | ||
| can_list=False, | ||
| can_read=False, | ||
| can_write=False, | ||
| ), | ||
| ) | ||
| """ | ||
| return RegistryArtifactProperties._from_generated( # pylint: disable=protected-access | ||
| self._client.container_registry.update_manifest_properties( | ||
|
|
@@ -404,6 +534,26 @@ def set_tag_properties(self, tag, permissions, **kwargs): | |
| :type permissions: ContentProperties | ||
| :returns: :class:`~azure.containerregistry.ArtifactTagProperties` | ||
| :raises: :class:`~azure.core.exceptions.ResourceNotFoundError` | ||
|
|
||
| Example | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there some sort of guideline on which samples should be inserted here vs. pointing to the samples folder? Was this just decided on due to length of sample?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have a great understanding of how customers are going to use the library, which means we have limited samples but I wanted to include how each client method would be used so this was my compromise.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense. Thinking from a user perspective, having samples in a But since you said you'll test things out in the UX studies, I'm good with this :) |
||
|
|
||
| .. 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( | ||
| can_delete=False, | ||
| can_list=False, | ||
| can_read=False, | ||
| can_write=False, | ||
| ), | ||
| ) | ||
| """ | ||
| return ArtifactTagProperties._from_generated( # pylint: disable=protected-access | ||
| self._client.container_registry.update_tag_attributes( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.