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

[Container Registry] Acr delete artifact #17645

Merged
merged 91 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
5e854e6
generated code from swagger
seankane-msft Feb 22, 2021
eb5eb54
adding files from template
seankane-msft Feb 22, 2021
785564d
adding a tests.yml file
seankane-msft Feb 22, 2021
561128f
outlining base structures
seankane-msft Feb 23, 2021
beba7fc
adding more skeleton code
seankane-msft Feb 24, 2021
9c7acd5
formatting code
seankane-msft Feb 25, 2021
8c03d93
adding some async files
seankane-msft Feb 25, 2021
5a16d1c
fixes for apiview
seankane-msft Feb 26, 2021
b628b6f
added models and clients based on feedback from arch board
seankane-msft Mar 8, 2021
b70ce96
running black to keep code clean
seankane-msft Mar 8, 2021
2bedabe
more changes to auth
seankane-msft Mar 9, 2021
fa6f78e
have a basic pipeline
seankane-msft Mar 9, 2021
514d03b
added an auth policy for username & password
seankane-msft Mar 10, 2021
4063d4d
have a working auth policy
seankane-msft Mar 10, 2021
c280520
need to add a page iterator class for returned repositories
seankane-msft Mar 10, 2021
4a9cc33
working list tags and list repositories methods
seankane-msft Mar 10, 2021
5e2270c
adding a change to the tests.yml file to run in live mode once I get …
seankane-msft Mar 10, 2021
b2ba50f
added more methods
seankane-msft Mar 16, 2021
fb4189f
adding test infra
seankane-msft Mar 16, 2021
7108594
adding swagger file
seankane-msft Mar 16, 2021
4dd3c8c
regen with Jeremys swagger, fixing up implementations
seankane-msft Mar 16, 2021
4533cce
added delete method, more models are filled out
seankane-msft Mar 16, 2021
2b3bb91
code formatting and adding helper method to repository client
seankane-msft Mar 16, 2021
34b094e
adding changes from newest swagger
seankane-msft Mar 17, 2021
a4d0258
updated generated code
seankane-msft Mar 17, 2021
2058b4a
adding tests for list and delete not exists, small changes to tests.yml
seankane-msft Mar 18, 2021
70d8524
adding more list tests
seankane-msft Mar 18, 2021
9da7eee
updating readme and setup
seankane-msft Mar 18, 2021
eea6749
adding more things the pipelines need
seankane-msft Mar 18, 2021
875b422
fixing pylint issues to get pipeline green
seankane-msft Mar 18, 2021
648102b
making all tests live tests
seankane-msft Mar 18, 2021
7a6bd87
updating ci and readme with tables copies
seankane-msft Mar 18, 2021
f82ed35
updates to readme
seankane-msft Mar 18, 2021
6ba90be
adding more changes
seankane-msft Mar 19, 2021
b0922ba
draft based on pallavis code
seankane-msft Mar 19, 2021
82c5d3c
updating readme
seankane-msft Mar 19, 2021
103db71
removing old sections from readme
seankane-msft Mar 19, 2021
9a26fcf
more readme deletions
seankane-msft Mar 19, 2021
8ec00fd
adding auth policy back in
seankane-msft Mar 19, 2021
7e4333e
ignore swagger readme
seankane-msft Mar 19, 2021
5d12869
adding devtoolsback
seankane-msft Mar 19, 2021
5bd806b
readme fix, linting fix
seankane-msft Mar 19, 2021
b56c29e
updating shared reqs
seankane-msft Mar 19, 2021
5151b8d
regenerated code, fixed changelog, modified test structure
seankane-msft Mar 22, 2021
cb9611b
formatting
seankane-msft Mar 22, 2021
cf02b85
fixed up all lint and mypy issues
seankane-msft Mar 22, 2021
544c9b7
formatting
seankane-msft Mar 22, 2021
1f1eb4c
adding devtools to dev_reqs
seankane-msft Mar 22, 2021
643e937
including samples and license in manifest, thank you scbedd
seankane-msft Mar 22, 2021
dfdbe82
updating swagger
seankane-msft Mar 22, 2021
d68285b
Merge branch 'acr' of https://github.com/seankane-msft/azure-sdk-for-…
seankane-msft Mar 22, 2021
93ad7c4
adding skeleton for auth flow
seankane-msft Mar 22, 2021
c1f5198
more auth files
seankane-msft Mar 23, 2021
166661e
committing for izy to take a look
seankane-msft Mar 23, 2021
b14a81b
forgot new files
seankane-msft Mar 23, 2021
06fb6a5
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-pytho…
seankane-msft Mar 24, 2021
fc88483
working auth policy using challenge
seankane-msft Mar 24, 2021
da18b29
working tests
seankane-msft Mar 24, 2021
f3dc746
deleting recordings
seankane-msft Mar 24, 2021
aef65bd
authentication flow test
seankane-msft Mar 24, 2021
6304e37
regenerated
seankane-msft Mar 24, 2021
17a1a07
fixing up test
seankane-msft Mar 24, 2021
7465c81
new generated code, fixed user agent, passing tests
seankane-msft Mar 24, 2021
7ed5107
adding generated and merge conflict repairs
seankane-msft Mar 24, 2021
340d128
fixing up a few tests
seankane-msft Mar 24, 2021
76b8ca0
changing a test slightly
seankane-msft Mar 24, 2021
ac6352b
async policy almost working, problem with the same url encoding
seankane-msft Mar 24, 2021
ce532bc
more test fixes
seankane-msft Mar 25, 2021
6be366a
working live and playback
seankane-msft Mar 25, 2021
d8e3a4d
linting fixes, had to remove mypy because of issues in generated
seankane-msft Mar 25, 2021
5d97e0b
adding conftest, fixing up async issue
seankane-msft Mar 26, 2021
451a186
renaming the async test file
seankane-msft Mar 26, 2021
23caed4
fixing async tests
seankane-msft Mar 26, 2021
f4799e5
more fixes
seankane-msft Mar 26, 2021
35df077
removing async tests folder
seankane-msft Mar 26, 2021
f95947d
addressing charles and anna's comments, thank you both
seankane-msft Mar 26, 2021
0941cec
removing more from authpolicy
seankane-msft Mar 26, 2021
4714e61
removing exchange client
seankane-msft Mar 26, 2021
209ecaa
tests for delete tag
seankane-msft Mar 26, 2021
9c62e8c
importing tags for delete operations
seankane-msft Mar 26, 2021
c26d422
cleanup
seankane-msft Mar 29, 2021
96d9095
forgot to include a recording
seankane-msft Mar 29, 2021
a2a9967
add delete repo tests:
seankane-msft Mar 29, 2021
510a046
regenerated from autorest, added delete artifact method to sync and a…
seankane-msft Mar 29, 2021
7ed4a02
fixing up recording files
seankane-msft Mar 30, 2021
850d699
linting issue
seankane-msft Mar 30, 2021
86c0b5b
merge conflicts
seankane-msft Apr 1, 2021
8ad7702
run black
seankane-msft Apr 1, 2021
e228e3b
undoing all changes to generated code
seankane-msft Apr 1, 2021
5cb3d0f
merge conflicts
seankane-msft Apr 2, 2021
738eb9e
adding distributed trace decorators
seankane-msft Apr 2, 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 @@ -4,7 +4,9 @@
# Licensed under the MIT License.
# ------------------------------------
from typing import TYPE_CHECKING

from azure.core.paging import ItemPaged
from azure.core.tracing.decorator import distributed_trace

from ._base_client import ContainerRegistryBaseClient
from ._container_repository_client import ContainerRepositoryClient
Expand Down Expand Up @@ -33,6 +35,7 @@ def __init__(self, endpoint, credential, **kwargs):
self._credential = credential
super(ContainerRegistryClient, self).__init__(endpoint=endpoint, credential=credential, **kwargs)

@distributed_trace
def delete_repository(self, repository, **kwargs):
# type: (str, Dict[str, Any]) -> DeletedRepositoryResult
"""Delete a repository
Expand All @@ -42,11 +45,11 @@ def delete_repository(self, repository, **kwargs):
:returns: None
:raises: :class:~azure.core.exceptions.ResourceNotFoundError
"""
# NOTE: DELETE `/acr/v1/{name}`
return DeletedRepositoryResult._from_generated( # pylint: disable=protected-access
self._client.container_registry.delete_repository(repository, **kwargs)
)

@distributed_trace
def list_repositories(self, **kwargs):
# type: (Dict[str, Any]) -> ItemPaged[str]
"""List all repositories
Expand All @@ -62,12 +65,14 @@ def list_repositories(self, **kwargs):
last=kwargs.pop("last", None), n=kwargs.pop("max", None), **kwargs
)

@distributed_trace
def get_repository_client(self, repository, **kwargs):
# type: (str, Dict[str, Any]) -> ContainerRepositoryClient
"""Get a repository client

:param repository: The repository to create a client for
:type repository: str
:returns: :class:~azure.containerregistry.ContainerRepositoryClient
:raises: None
"""
return ContainerRepositoryClient(self._endpoint, repository, credential=self._credential, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# ------------------------------------
from typing import TYPE_CHECKING

from azure.core.tracing.decorator import distributed_trace

from ._base_client import ContainerRegistryBaseClient
from ._helpers import _is_tag
from ._models import RepositoryProperties, TagProperties, RegistryArtifactProperties
Expand Down Expand Up @@ -41,6 +43,7 @@ def _get_digest_from_tag(self, tag):
tag_props = self.get_tag_properties(tag)
return tag_props.digest

@distributed_trace
def delete(self, **kwargs):
# type: (...) -> None
"""Delete a repository
Expand All @@ -50,17 +53,19 @@ def delete(self, **kwargs):
"""
self._client.container_registry.delete_repository(self.repository, **kwargs)

@distributed_trace
def delete_registry_artifact(self, digest, **kwargs):
# type: (str) -> None
"""Delete a registry artifact
"""Delete a registry artifact. A registry artifact can only be deleted from the digest

:param digest: The digest of the artifact to be deleted
:type digest: str
:returns: None
swathipil marked this conversation as resolved.
Show resolved Hide resolved
:raises: :class:~azure.core.exceptions.ResourceNotFoundError
"""
raise NotImplementedError("Has not been implemented")
self._client.container_registry_repository.delete_manifest(self.repository, digest, **kwargs)

@distributed_trace
def delete_tag(self, tag, **kwargs):
# type: (str) -> None
"""Delete a tag from a repository
Expand All @@ -72,6 +77,7 @@ def delete_tag(self, tag, **kwargs):
"""
self._client.container_registry_repository.delete_tag(self.repository, tag, **kwargs)

@distributed_trace
def get_properties(self, **kwargs):
# type: (...) -> RepositoryProperties
"""Get the properties of a repository
Expand All @@ -84,6 +90,7 @@ def get_properties(self, **kwargs):
self._client.container_registry_repository.get_properties(self.repository, **kwargs)
)

@distributed_trace
def get_registry_artifact_properties(self, tag_or_digest, **kwargs):
# type: (str, Dict[str, Any]) -> RegistryArtifactProperties
"""Get the properties of a registry artifact
Expand All @@ -102,6 +109,7 @@ def get_registry_artifact_properties(self, tag_or_digest, **kwargs):
)
)

@distributed_trace
def get_tag_properties(self, tag, **kwargs):
# type: (str, Dict[str, Any]) -> TagProperties
"""Get the properties for a tag
Expand All @@ -115,6 +123,7 @@ def get_tag_properties(self, tag, **kwargs):
self._client.container_registry_repository.get_tag_properties(self.repository, tag, **kwargs)
)

@distributed_trace
def list_registry_artifacts(self, **kwargs):
# type: (...) -> ItemPaged[RegistryArtifactProperties]
"""List the artifacts for a repository
Expand Down Expand Up @@ -142,6 +151,7 @@ def list_registry_artifacts(self, **kwargs):
],
)

@distributed_trace
def list_tags(self, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params are specified in the docstring, but it looks like they should be keyword?

# type: (...) -> ItemPaged[TagProperties]
"""List the tags for a repository
Expand All @@ -163,6 +173,7 @@ def list_tags(self, **kwargs):
**kwargs
)

@distributed_trace
def set_manifest_properties(self, digest, permissions, **kwargs):
# type: (str, ContentPermissions) -> None
"""Set the properties for a manifest
Expand All @@ -179,6 +190,7 @@ def set_manifest_properties(self, digest, permissions, **kwargs):
self.repository, digest, value=permissions._to_generated(), **kwargs # pylint: disable=protected-access
)

@distributed_trace
def set_tag_properties(self, tag_or_digest, permissions, **kwargs):
# type: (str, ContentPermissions) -> None
"""Set the properties for a tag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ def __init__(self, **kwargs):
self.digest = kwargs.get("digest", None)
self.last_updated_on = kwargs.get("last_updated_on", None)
self.operating_system = kwargs.get("operating_system", None)
self.registry_artifacts = kwargs.get("registry_artifacts", None)
self.references = kwargs.get("references", None)
self.size = kwargs.get("size", None)
self.tags = kwargs.get("tags", None)
self.content_permissions = kwargs.get("manifest_properties", None)
self.content_permissions = kwargs.get("content_permissions", None)
if self.content_permissions:
self.content_permissions = ContentPermissions._from_generated(self.content_permissions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from typing import Any, Dict, TYPE_CHECKING

from azure.core.async_paging import AsyncItemPaged
from azure.core.tracing.decorator import distributed_trace
from azure.core.tracing.decorator_async import distributed_trace_async

from ._async_base_client import ContainerRegistryBaseClient
from ._async_container_repository_client import ContainerRepositoryClient
Expand All @@ -32,6 +34,7 @@ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs:
self._credential = credential
super(ContainerRegistryClient, self).__init__(endpoint=endpoint, credential=credential, **kwargs)

@distributed_trace_async
async def delete_repository(self, repository: str, **kwargs: Dict[str, Any]) -> DeletedRepositoryResult:
"""Delete a repository

Expand All @@ -43,12 +46,14 @@ async def delete_repository(self, repository: str, **kwargs: Dict[str, Any]) ->
result = await self._client.container_registry.delete_repository(repository, **kwargs)
return DeletedRepositoryResult._from_generated(result) # pylint: disable=protected-access

@distributed_trace
def list_repositories(self, **kwargs) -> AsyncItemPaged[str]:

return self._client.container_registry.get_repositories(
last=kwargs.pop("last", None), n=kwargs.pop("page_size", None), **kwargs
)

@distributed_trace_async
def get_repository_client(self, name: str, **kwargs) -> ContainerRepositoryClient:

return ContainerRepositoryClient(self._endpoint, name, self._credential, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from typing import TYPE_CHECKING, Dict, Any

from azure.core.async_paging import AsyncItemPaged
from azure.core.tracing.decorator import distributed_trace
from azure.core.tracing.decorator_async import distributed_trace_async

from ._async_base_client import ContainerRegistryBaseClient
from .._helpers import _is_tag
Expand Down Expand Up @@ -44,6 +46,7 @@ async def _get_digest_from_tag(self, tag: str) -> None:
tag_props = await self.get_tag_properties(tag)
return tag_props.digest

@distributed_trace_async
async def delete(self, **kwargs: Dict[str, Any]) -> None:
"""Delete a repository

Expand All @@ -52,6 +55,7 @@ async def delete(self, **kwargs: Dict[str, Any]) -> None:
"""
await self._client.container_registry.delete_repository(self.repository, **kwargs)

@distributed_trace_async
async def delete_registry_artifact(self, digest: str, **kwargs) -> None:
"""Delete a registry artifact

Expand All @@ -60,8 +64,9 @@ async def delete_registry_artifact(self, digest: str, **kwargs) -> None:
:returns: None
:raises: :class:~azure.core.exceptions.ResourceNotFoundError
"""
raise NotImplementedError("Has not been implemented")
await self._client.container_registry_repository.delete_manifest(self.repository, digest, **kwargs)

@distributed_trace_async
async def delete_tag(self, tag: str, **kwargs) -> None:
seankane-msft marked this conversation as resolved.
Show resolved Hide resolved
"""Delete a tag from a repository

Expand All @@ -72,6 +77,7 @@ async def delete_tag(self, tag: str, **kwargs) -> None:
"""
await self._client.container_registry_repository.delete_tag(self.repository, tag, **kwargs)

@distributed_trace_async
async def get_properties(self, **kwargs) -> RepositoryProperties:
"""Get the properties of a repository

Expand All @@ -82,6 +88,7 @@ async def get_properties(self, **kwargs) -> RepositoryProperties:
await self._client.container_registry_repository.get_properties(self.repository, **kwargs)
)

@distributed_trace_async
async def get_registry_artifact_properties(self, tag_or_digest: str, **kwargs) -> RegistryArtifactProperties:
"""Get the properties of a registry artifact

Expand All @@ -99,6 +106,7 @@ async def get_registry_artifact_properties(self, tag_or_digest: str, **kwargs) -
)
)

@distributed_trace_async
async def get_tag_properties(self, tag: str, **kwargs) -> TagProperties:
"""Get the properties for a tag

Expand All @@ -111,7 +119,8 @@ async def get_tag_properties(self, tag: str, **kwargs) -> TagProperties:
await self._client.container_registry_repository.get_tag_properties(self.repository, tag, **kwargs)
)

async def list_registry_artifacts(self, **kwargs) -> AsyncItemPaged[RegistryArtifactProperties]:
@distributed_trace
def list_registry_artifacts(self, **kwargs) -> AsyncItemPaged[RegistryArtifactProperties]:
"""List the artifacts for a repository

:keyword last: Query parameter for the last item in the previous query
Expand All @@ -126,7 +135,7 @@ async def list_registry_artifacts(self, **kwargs) -> AsyncItemPaged[RegistryArti
last = kwargs.pop("last", None)
n = kwargs.pop("page_size", None)
orderby = kwargs.pop("order_by", None)
return await self._client.container_registry_repository.get_manifests(
return self._client.container_registry_repository.get_manifests(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the await gone

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list methods don't return a coroutine, they return an AsyncItemPaged

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah lmao, ignore me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the "async" before the def list_registry_artifacts too

self.repository,
last=last,
n=n,
Expand All @@ -137,7 +146,8 @@ async def list_registry_artifacts(self, **kwargs) -> AsyncItemPaged[RegistryArti
**kwargs
)

async def list_tags(self, **kwargs) -> AsyncItemPaged[TagProperties]:
@distributed_trace
def list_tags(self, **kwargs) -> AsyncItemPaged[TagProperties]:
"""List the tags for a repository

:param last: Query parameter for the last item in the previous call. Ensuing
Expand All @@ -147,7 +157,7 @@ async def list_tags(self, **kwargs) -> AsyncItemPaged[TagProperties]:
:returns: ~azure.core.paging.AsyncItemPaged[TagProperties]
:raises: None
"""
return await self._client.container_registry_repository.get_tags(
return self._client.container_registry_repository.get_tags(
self.repository,
last=kwargs.pop("last", None),
n=kwargs.pop("top", None),
Expand All @@ -157,6 +167,7 @@ async def list_tags(self, **kwargs) -> AsyncItemPaged[TagProperties]:
**kwargs
)

@distributed_trace_async
async def set_manifest_properties(self, digest: str, permissions: ContentPermissions, **kwargs) -> None:
"""Set the properties for a manifest

Expand All @@ -172,6 +183,7 @@ async def set_manifest_properties(self, digest: str, permissions: ContentPermiss
self.repository, digest, value=permissions._to_generated(), **kwargs # pylint: disable=protected-access
)

@distributed_trace_async
async def set_tag_properties(self, tag_or_digest: str, permissions: ContentPermissions, **kwargs) -> None:
"""Set the properties for a tag

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# coding=utf-8
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------

TO_BE_DELETED = "to_be_deleted"
DOES_NOT_EXIST = "does_not_exist"
Loading