/// <summary> Get the collection of tags for a repository. </summary> /// <param name="orderBy"> Requested order of tags in the collection. </param> /// <param name="cancellationToken"> The cancellation token to use. </param> /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Container Registry service.</exception> public virtual AsyncPageable <ArtifactTagProperties> GetTagsAsync(TagOrderBy orderBy = TagOrderBy.None, CancellationToken cancellationToken = default) { async Task <Page <ArtifactTagProperties> > FirstPageFunc(int?pageSizeHint) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(RegistryArtifact)}.{nameof(GetTags)}"); scope.Start(); try { string digest = await GetDigestAsync(cancellationToken).ConfigureAwait(false); string order = orderBy == TagOrderBy.None ? null : orderBy.ToSerialString(); var response = await _restClient.GetTagsAsync(_repositoryName, last : null, n : pageSizeHint, orderby : order, digest : digest, cancellationToken : cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Tags, response.Headers.Link, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } async Task <Page <ArtifactTagProperties> > NextPageFunc(string nextLink, int?pageSizeHint) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(RegistryArtifact)}.{nameof(GetTags)}"); scope.Start(); try { string digest = await GetDigestAsync(cancellationToken).ConfigureAwait(false); string order = orderBy == TagOrderBy.None ? null : orderBy.ToSerialString(); string uriReference = ContainerRegistryClient.ParseUriReferenceFromLinkHeader(nextLink); var response = await _restClient.GetTagsNextPageAsync(uriReference, _repositoryName, last : null, n : null, orderby : order, digest : digest, cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Tags, response.Headers.Link, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc)); }
public static string ToSerialString(this TagOrderBy value) => value switch {