public static string ToSerialString(this ArtifactManifestOrderBy value) => value switch
 {
Exemple #2
0
        /// <summary> List the manifests associated with this repository and the properties of each.
        /// This is useful for determining the collection of artifacts associated with this repository, as each artifact is uniquely identified by its manifest. </summary>
        /// <param name="orderBy"> Requested order of manifests 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 <ArtifactManifestProperties> GetManifestPropertiesCollection(ArtifactManifestOrderBy orderBy = ArtifactManifestOrderBy.None, CancellationToken cancellationToken = default)
        {
            Page <ArtifactManifestProperties> FirstPageFunc(int?pageSizeHint)
            {
                using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ContainerRepository)}.{nameof(GetManifestPropertiesCollection)}");
                scope.Start();
                try
                {
                    string order    = orderBy == ArtifactManifestOrderBy.None ? null : orderBy.ToSerialString();
                    var    response = _restClient.GetManifests(Name, last: null, n: pageSizeHint, orderby: order, cancellationToken: cancellationToken);
                    return(Page.FromValues(response.Value.RegistryArtifacts, response.Headers.Link, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            Page <ArtifactManifestProperties> NextPageFunc(string nextLink, int?pageSizeHint)
            {
                using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ContainerRepository)}.{nameof(GetManifestPropertiesCollection)}");
                scope.Start();
                try
                {
                    string order        = orderBy == ArtifactManifestOrderBy.None ? null : orderBy.ToSerialString();
                    string uriReference = ContainerRegistryClient.ParseUriReferenceFromLinkHeader(nextLink);
                    var    response     = _restClient.GetManifestsNextPage(uriReference, Name, last: null, n: null, orderby: order, cancellationToken);
                    return(Page.FromValues(response.Value.RegistryArtifacts, response.Headers.Link, response.GetRawResponse()));
                }
                catch (Exception e)
                {
                    scope.Failed(e);
                    throw;
                }
            }

            return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc));
        }