示例#1
0
        /// <summary> List the tags that uniquely identify this artifact and the properties of each. </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 Pageable <ArtifactTagProperties> GetTagPropertiesCollection(ArtifactTagOrderBy orderBy = ArtifactTagOrderBy.None, CancellationToken cancellationToken = default)
        {
            Page <ArtifactTagProperties> FirstPageFunc(int?pageSizeHint)
            {
                using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(RegistryArtifact)}.{nameof(GetTagPropertiesCollection)}");
                scope.Start();
                try
                {
                    string digest   = GetDigest(cancellationToken);
                    string order    = orderBy == ArtifactTagOrderBy.None ? null : orderBy.ToSerialString();
                    var    response = _restClient.GetTags(_repositoryName, last: null, n: pageSizeHint, orderby: order, digest: digest, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.Tags, response.Headers.Link, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <ArtifactTagProperties> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(RegistryArtifact)}.{nameof(GetTagPropertiesCollection)}");
                scope.Start();
                try
                {
                    string digest       = GetDigest(cancellationToken);
                    string order        = orderBy == ArtifactTagOrderBy.None ? null : orderBy.ToSerialString();
                    string uriReference = ContainerRegistryClient.ParseUriReferenceFromLinkHeader(nextLink);
                    var    response     = _restClient.GetTagsNextPage(uriReference, _repositoryName, last: null, n: null, orderby: order, digest: digest, cancellationToken);
                    return(Page.FromValues(response.Value.Tags, response.Headers.Link, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc));
        }
示例#2
0
 public static string ToSerialString(this ArtifactTagOrderBy value) => value switch
 {