internal ManifestAttributesBase(string digest, long?size, DateTimeOffset?createdOn, DateTimeOffset?lastUpdatedOn, ArtifactArchitecture?architecture, ArtifactOperatingSystem?operatingSystem, IReadOnlyList <ArtifactManifestReference> manifestReferences, IReadOnlyList <string> tags, ManifestWriteableProperties writeableProperties)
 {
     Digest              = digest;
     Size                = size;
     CreatedOn           = createdOn;
     LastUpdatedOn       = lastUpdatedOn;
     Architecture        = architecture;
     OperatingSystem     = operatingSystem;
     ManifestReferences  = manifestReferences;
     Tags                = tags;
     WriteableProperties = writeableProperties;
 }
示例#2
0
        /// <summary> Update manifest attributes. </summary>
        /// <param name="value"> Manifest properties value. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> Thrown when <paramref name="value"/> is null. </exception>
        /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Container Registry service.</exception>
        public virtual Response <ArtifactManifestProperties> SetManifestProperties(ManifestWriteableProperties value, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(value, nameof(value));

            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(RegistryArtifact)}.{nameof(SetManifestProperties)}");
            scope.Start();
            try
            {
                string digest = GetDigest(cancellationToken);
                return(_restClient.UpdateManifestProperties(_repositoryName, digest, value, cancellationToken));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#3
0
        internal static ManifestAttributesBase DeserializeManifestAttributesBase(JsonElement element)
        {
            string                              digest         = default;
            Optional <long>                     imageSize      = default;
            Optional <DateTimeOffset>           createdTime    = default;
            Optional <DateTimeOffset>           lastUpdateTime = default;
            Optional <ArtifactArchitecture?>    architecture   = default;
            Optional <ArtifactOperatingSystem?> os             = default;
            Optional <IReadOnlyList <ArtifactManifestReference> > references = default;
            Optional <IReadOnlyList <string> >     tags = default;
            Optional <ManifestWriteableProperties> changeableAttributes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("digest"))
                {
                    digest = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("imageSize"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    imageSize = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("lastUpdateTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    lastUpdateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("architecture"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        architecture = null;
                        continue;
                    }
                    architecture = new ArtifactArchitecture(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("os"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        os = null;
                        continue;
                    }
                    os = new ArtifactOperatingSystem(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("references"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ArtifactManifestReference> array = new List <ArtifactManifestReference>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ArtifactManifestReference.DeserializeArtifactManifestReference(item));
                    }
                    references = array;
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    tags = array;
                    continue;
                }
                if (property.NameEquals("changeableAttributes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    changeableAttributes = ManifestWriteableProperties.DeserializeManifestWriteableProperties(property.Value);
                    continue;
                }
            }
            return(new ManifestAttributesBase(digest, Optional.ToNullable(imageSize), Optional.ToNullable(createdTime), Optional.ToNullable(lastUpdateTime), Optional.ToNullable(architecture), Optional.ToNullable(os), Optional.ToList(references), Optional.ToList(tags), changeableAttributes.Value));
        }