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

Update samples in ACR #20902

Merged
merged 8 commits into from
Sep 29, 2021
Merged
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
Prev Previous commit
Next Next commit
Rename sample_delete_old_tags.py to sample_delete_tags.py
YalinLi0312 committed Sep 27, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3f7b4220d3f8f0248bbae96c324e36f928f848ce
12 changes: 6 additions & 6 deletions sdk/containerregistry/azure-containerregistry/samples/README.md
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ The async versions of the samples require Python 3.6 or later.

|**File Name**|**Description**|
|-------------|---------------|
|[sample_hello_world.py][create_client] ([sample_hello_world_async.py][create_client_async]) |Instantiate a `ContainerRegistryClient` object and `ContainerRepositoryClient` object |
|[sample_delete_old_tags.py][delete_old_tags] and [sample_delete_old_tags_async.py][delete_old_tags_async] | Delete tags from a repository |
|[sample_hello_world.py][hello_world] ([sample_hello_world_async.py][hello_world_async]) |Instantiate a `ContainerRegistryClient` object and `ContainerRepositoryClient` object |
|[sample_delete_tags.py][delete_tags] and [sample_delete_tags_async.py][delete_tags_async] | Delete tags from a repository |

### Prerequisites
* Python 2.7, or 3.6 or later is required to use this package.
@@ -49,7 +49,7 @@ Check out the [API reference documentation][rest_docs] to learn more about what

[container_registry_docs]: https://docs.microsoft.com/azure/container-registry/container-registry-intro

[create_client]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/containerregistry/azure-containerregistry/samples/sample_create_client.py
[create_client_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/containerregistry/azure-containerregistry/samples/async_samples/sample_create_client_async.py
[delete_old_tags]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/containerregistry/azure-containerregistry/samples/sample_delete_old_tags.py
[delete_old_tags_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/containerregistry/azure-containerregistry/samples/async_samples/sample_delete_old_tags_async.py
[hello_world]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/containerregistry/azure-containerregistry/samples/sample_hello_world.py
[hello_world_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/containerregistry/azure-containerregistry/samples/async_samples/sample_hello_world_async.py
[delete_tags]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/containerregistry/azure-containerregistry/samples/sample_delete_tags.py
[delete_tags_async]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/containerregistry/azure-containerregistry/samples/async_samples/sample_delete_tags_async.py
Original file line number Diff line number Diff line change
@@ -7,13 +7,13 @@
# --------------------------------------------------------------------------

"""
FILE: sample_delete_old_tags_async.py
FILE: sample_delete_tags_async.py

DESCRIPTION:
These samples demonstrates deleting the three oldest tags for each repository asynchronously.
This sample demonstrates deleting all but the most recent three tags for each repository.

USAGE:
python sample_delete_old_tags_async.py
python sample_delete_tags_async.py

Set the environment variables with your own values before running the sample:
1) CONTAINERREGISTRY_ENDPOINT - The URL of you Container Registry account
@@ -23,19 +23,17 @@
from dotenv import find_dotenv, load_dotenv
import os

from azure.containerregistry import TagOrder
from azure.containerregistry.aio import ContainerRegistryClient
from azure.identity.aio import DefaultAzureCredential

class DeleteOperations(object):

class DeleteTagsAsync(object):
def __init__(self):
load_dotenv(find_dotenv())
self.account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]

async def delete_old_tags(self):
from azure.containerregistry import TagOrder
from azure.containerregistry.aio import (
ContainerRegistryClient,
)
from azure.identity.aio import DefaultAzureCredential

async def delete_tags(self):
# [START list_repository_names]
account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
credential = DefaultAzureCredential()
@@ -57,8 +55,8 @@ async def delete_old_tags(self):


async def main():
sample = DeleteOperations()
await sample.delete_old_tags()
sample = DeleteTagsAsync()
await sample.delete_tags()


if __name__ == "__main__":
Original file line number Diff line number Diff line change
@@ -7,13 +7,13 @@
# --------------------------------------------------------------------------

"""
FILE: sample_delete_old_tags.py
FILE: sample_delete_tags.py

DESCRIPTION:
These samples demonstrates deleting the three oldest tags for each repository
This sample demonstrates deleting all but the most recent three tags for each repository.

USAGE:
python sample_delete_old_tags.py
python sample_delete_tags.py

Set the environment variables with your own values before running the sample:
1) CONTAINERREGISTRY_ENDPOINT - The URL of you Container Registry account
@@ -22,16 +22,16 @@
from dotenv import find_dotenv, load_dotenv
import os

from azure.containerregistry import ContainerRegistryClient, TagOrder
from azure.identity import DefaultAzureCredential

class DeleteOperations(object):

class DeleteTags(object):
def __init__(self):
load_dotenv(find_dotenv())
self.account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]

def delete_old_tags(self):
from azure.containerregistry import ContainerRegistryClient, TagOrder
from azure.identity import DefaultAzureCredential

def delete_tags(self):
# [START list_repository_names]
account_url = os.environ["CONTAINERREGISTRY_ENDPOINT"]
credential = DefaultAzureCredential()
@@ -54,5 +54,5 @@ def delete_old_tags(self):


if __name__ == "__main__":
sample = DeleteOperations()
sample.delete_old_tags()
sample = DeleteTags()
sample.delete_tags()