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 list_repositories pageable #17714

Merged
merged 103 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 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
94c3488
fixing up scrubber
seankane-msft Mar 30, 2021
822d407
addressing charles comments on auth and exchange clients
seankane-msft Mar 30, 2021
db97e0f
fixed up list_repositories method
seankane-msft Mar 31, 2021
52a746f
merge conflicts
seankane-msft Apr 1, 2021
89ab5d0
page_size -> results_per_page
seankane-msft Apr 1, 2021
a728852
list tags not ready for results_per_page
seankane-msft Apr 1, 2021
f2a5da9
fixing up sync pageables
seankane-msft Apr 2, 2021
31fc9ff
running black
seankane-msft Apr 2, 2021
db4040f
async list manifests operations
seankane-msft Apr 2, 2021
0be38fe
async list tags methods complete
seankane-msft Apr 2, 2021
3e6b8c2
linting
seankane-msft Apr 2, 2021
4b11a77
linting fixes
seankane-msft Apr 2, 2021
47e395b
merge conflicts
seankane-msft Apr 2, 2021
0cabe74
conflicts
seankane-msft Apr 2, 2021
c2eaab3
fix to scrubber
seankane-msft Apr 2, 2021
de15691
merge conflicts
seankane-msft Apr 5, 2021
a30712d
black and lint fixes
seankane-msft Apr 5, 2021
af91b4a
merge conflicts
seankane-msft Apr 5, 2021
c36ed08
merge conflicts
seankane-msft Apr 5, 2021
9dda7f8
new recordings
seankane-msft Apr 5, 2021
a8adc8b
fixing setup to make verify readmes happy
seankane-msft Apr 5, 2021
0fcb0b8
greater than -> greater than or equal
seankane-msft Apr 5, 2021
64c8fc0
(hopefully) final changes
seankane-msft Apr 5, 2021
23f55d6
lint fixes
seankane-msft Apr 6, 2021
0a2c1eb
krista, mccoy, and swathis comments, thank you all
seankane-msft Apr 6, 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 @@ -29,6 +29,7 @@ class ContainerRegistryBaseClient(object):
:param credential: AAD Token for authenticating requests with Azure
:type credential: :class:`azure.identity.DefaultTokenCredential`
"""

def __init__(self, endpoint, credential, **kwargs):
# type: (str, TokenCredential, Dict[str, Any]) -> None
auth_policy = ContainerRegistryChallengePolicy(credential, endpoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
# Licensed under the MIT License.
# ------------------------------------
from typing import TYPE_CHECKING

from azure.core.exceptions import (
ClientAuthenticationError,
ResourceNotFoundError,
ResourceExistsError,
HttpResponseError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import Pipeline
from azure.core.tracing.decorator import distributed_trace

from ._base_client import ContainerRegistryBaseClient, TransportWrapper
from ._container_repository_client import ContainerRepositoryClient
from ._generated.models import AcrErrors
from ._helpers import _parse_next_link
from ._models import DeletedRepositoryResult

if TYPE_CHECKING:
Expand All @@ -24,7 +32,8 @@ def __init__(self, endpoint, credential, **kwargs):
"""Create a ContainerRegistryClient from an ACR endpoint and a credential

:param str endpoint: An ACR endpoint
:param TokenCredential credential: The credential with which to authenticate
:param credential: The credential with which to authenticate
:type credential: :class:`~azure.core.credentials.TokenCredential`
:returns: None
:raises: None
"""
Expand Down Expand Up @@ -54,19 +63,106 @@ def list_repositories(self, **kwargs):
"""List all repositories

:keyword max: Maximum number of repositories to return
:type max: int
:paramtype max: int
:keyword last: Query parameter for the last item in the previous call. Ensuing
call will return values after last lexically
:type last: str
:keyword results_per_page: Numer of repositories to return in a single page
:type results_per_page: int
:paramtype last: str
:keyword results_per_page: Number of repositories to return per page
:paramtype results_per_page: int
:return: ItemPaged[str]
:rtype: :class:`~azure.core.paging.ItemPaged`
:raises: :class:`~azure.core.exceptions.ResourceNotFoundError`
"""
return self._client.container_registry.get_repositories(
last=kwargs.pop("last", None), n=kwargs.pop("max", None), **kwargs
)
n = kwargs.pop("results_per_page", None)
last = kwargs.pop("last", None)

cls = kwargs.pop("cls", None) # type: ClsType["_models.Repositories"]
error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop("error_map", {}))
accept = "application/json"

def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters["Accept"] = self._client._serialize.header( # pylint: disable=protected-access
"accept", accept, "str"
)

if not next_link:
# Construct URL
url = "/acr/v1/_catalog"
path_format_arguments = {
"url": self._client._serialize.url( # pylint: disable=protected-access
"self._config.url",
self._client._config.url, # pylint: disable=protected-access
"str",
skip_quote=True,
),
}
url = self._client._client.format_url(url, **path_format_arguments) # pylint: disable=protected-access
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
if last is not None:
query_parameters["last"] = self._client._serialize.query( # pylint: disable=protected-access
"last", last, "str"
)
if n is not None:
query_parameters["n"] = self._client._serialize.query( # pylint: disable=protected-access
"n", n, "int"
)

request = self._client._client.get( # pylint: disable=protected-access
url, query_parameters, header_parameters
)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
path_format_arguments = {
"url": self._client._serialize.url( # pylint: disable=protected-access
"self._config.url",
self._client._config.url, # pylint: disable=protected-access
"str",
skip_quote=True,
),
}
url = self._client._client.format_url(url, **path_format_arguments) # pylint: disable=protected-access
request = self._client._client.get( # pylint: disable=protected-access
url, query_parameters, header_parameters
)
return request

def extract_data(pipeline_response):
deserialized = self._client._deserialize( # pylint: disable=protected-access
"Repositories", pipeline_response
)
list_of_elem = deserialized.repositories
if cls:
list_of_elem = cls(list_of_elem)
link = None
if "Link" in pipeline_response.http_response.headers.keys():
link = _parse_next_link(pipeline_response.http_response.headers["Link"])
elif "link" in pipeline_response.http_response.headers.keys(): # python 2.7 turns this into lowercase
link = _parse_next_link(pipeline_response.http_response.headers["link"])
return link, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)

pipeline_response = self._client._client._pipeline.run( # pylint: disable=protected-access
request, stream=False, **kwargs
)
response = pipeline_response.http_response

if response.status_code not in [200]:
error = self._client._deserialize.failsafe_deserialize( # pylint: disable=protected-access
AcrErrors, response
)
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, model=error)

return pipeline_response

return ItemPaged(get_next, extract_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

oof, lot of code, sorry you had to copy that. I think the code looks reasonable, my only question is if you want to move this code to the helper section. Not a big deal, just think keeping the main container registry client page as bare as possible is neater

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about that, but then I need to pass in the client too and this was a bit simpler.


@distributed_trace
def get_repository_client(self, repository, **kwargs):
Expand Down
Loading