From c1eb76a2d8e6f26a2d7af244834c137093830a4e Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Sat, 4 Apr 2020 15:12:29 -0700 Subject: [PATCH] Updated for Blob Tags swagger --- .../api/Azure.Storage.Blobs.netstandard2.0.cs | 23 +- .../src/BlobContainerClient.cs | 2 +- .../Azure.Storage.Blobs/src/BlobExtensions.cs | 65 + .../src/Generated/BlobRestClient.cs | 1510 ++++++++++++++--- .../src/Models/BlobItem.cs | 57 + .../src/Models/BlobsModelFactory.cs | 26 + .../src/Models/GetBlobsAsyncCollection.cs | 2 +- .../GetBlobsByHierarchyAsyncCollection.cs | 2 +- .../Azure.Storage.Blobs/swagger/readme.md | 22 +- 9 files changed, 1429 insertions(+), 280 deletions(-) create mode 100644 sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs create mode 100644 sdk/storage/Azure.Storage.Blobs/src/Models/BlobItem.cs diff --git a/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs b/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs index 04b2e703fb66..9af3c41b52e0 100644 --- a/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs +++ b/sdk/storage/Azure.Storage.Blobs/api/Azure.Storage.Blobs.netstandard2.0.cs @@ -532,6 +532,7 @@ internal BlobItem() { } public string Name { get { throw null; } } public Azure.Storage.Blobs.Models.BlobItemProperties Properties { get { throw null; } } public string Snapshot { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } public string VersionId { get { throw null; } } } public partial class BlobItemProperties @@ -623,6 +624,7 @@ public BlobProperties() { } public Azure.Storage.Blobs.Models.LeaseState LeaseState { get { throw null; } } public Azure.Storage.Blobs.Models.LeaseStatus LeaseStatus { get { throw null; } } public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public long TagCount { get { throw null; } } public string VersionId { get { throw null; } } } public partial class BlobRequestConditions : Azure.RequestConditions @@ -685,14 +687,14 @@ public static partial class BlobsModelFactory public static Azure.Storage.Blobs.Models.BlobInfo BlobInfo(Azure.ETag eTag, System.DateTimeOffset lastModified) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Storage.Blobs.Models.BlobItem BlobItem(string name, bool deleted, Azure.Storage.Blobs.Models.BlobItemProperties properties, string snapshot = null, System.Collections.Generic.IDictionary metadata = null) { throw null; } - public static Azure.Storage.Blobs.Models.BlobItem BlobItem(string name, bool deleted, Azure.Storage.Blobs.Models.BlobItemProperties properties, string snapshot = null, string versionId = null, bool? isCurrentVersion = default(bool?), System.Collections.Generic.IDictionary metadata = null) { throw null; } + public static Azure.Storage.Blobs.Models.BlobItem BlobItem(string name, bool deleted, Azure.Storage.Blobs.Models.BlobItemProperties properties, string snapshot = null, string versionId = null, bool? isCurrentVersion = default(bool?), System.Collections.Generic.IDictionary metadata = null, System.Collections.Generic.IDictionary tags = null) { throw null; } public static Azure.Storage.Blobs.Models.BlobItemProperties BlobItemProperties(bool accessTierInferred, string copyProgress = null, string contentType = null, string contentEncoding = null, string contentLanguage = null, byte[] contentHash = null, string contentDisposition = null, string cacheControl = null, long? blobSequenceNumber = default(long?), Azure.Storage.Blobs.Models.BlobType? blobType = default(Azure.Storage.Blobs.Models.BlobType?), Azure.Storage.Blobs.Models.LeaseStatus? leaseStatus = default(Azure.Storage.Blobs.Models.LeaseStatus?), Azure.Storage.Blobs.Models.LeaseState? leaseState = default(Azure.Storage.Blobs.Models.LeaseState?), Azure.Storage.Blobs.Models.LeaseDurationType? leaseDuration = default(Azure.Storage.Blobs.Models.LeaseDurationType?), string copyId = null, Azure.Storage.Blobs.Models.CopyStatus? copyStatus = default(Azure.Storage.Blobs.Models.CopyStatus?), System.Uri copySource = null, long? contentLength = default(long?), string copyStatusDescription = null, bool? serverEncrypted = default(bool?), bool? incrementalCopy = default(bool?), string destinationSnapshot = null, int? remainingRetentionDays = default(int?), Azure.Storage.Blobs.Models.AccessTier? accessTier = default(Azure.Storage.Blobs.Models.AccessTier?), System.DateTimeOffset? lastModified = default(System.DateTimeOffset?), Azure.Storage.Blobs.Models.ArchiveStatus? archiveStatus = default(Azure.Storage.Blobs.Models.ArchiveStatus?), string customerProvidedKeySha256 = null, string encryptionScope = null, Azure.ETag? eTag = default(Azure.ETag?), System.DateTimeOffset? createdOn = default(System.DateTimeOffset?), System.DateTimeOffset? copyCompletedOn = default(System.DateTimeOffset?), System.DateTimeOffset? deletedOn = default(System.DateTimeOffset?), System.DateTimeOffset? accessTierChangedOn = default(System.DateTimeOffset?)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Storage.Blobs.Models.BlobItemProperties BlobItemProperties(bool accessTierInferred, System.Uri copySource, string contentType, string contentEncoding, string contentLanguage, byte[] contentHash, string contentDisposition, string cacheControl, long? blobSequenceNumber, Azure.Storage.Blobs.Models.BlobType? blobType, Azure.Storage.Blobs.Models.LeaseStatus? leaseStatus, Azure.Storage.Blobs.Models.LeaseState? leaseState, Azure.Storage.Blobs.Models.LeaseDurationType? leaseDuration, string copyId, Azure.Storage.Blobs.Models.CopyStatus? copyStatus, long? contentLength, string copyProgress, string copyStatusDescription, bool? serverEncrypted, bool? incrementalCopy, string destinationSnapshot, int? remainingRetentionDays, Azure.Storage.Blobs.Models.AccessTier? accessTier, System.DateTimeOffset? lastModified, Azure.Storage.Blobs.Models.ArchiveStatus? archiveStatus, string customerProvidedKeySha256, Azure.ETag? eTag, System.DateTimeOffset? createdOn, System.DateTimeOffset? copyCompletedOn, System.DateTimeOffset? deletedOn, System.DateTimeOffset? accessTierChangedOn) { throw null; } public static Azure.Storage.Blobs.Models.BlobLease BlobLease(Azure.ETag eTag, System.DateTimeOffset lastModified, string leaseId) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Storage.Blobs.Models.BlobProperties BlobProperties(System.DateTimeOffset lastModified, Azure.Storage.Blobs.Models.LeaseDurationType leaseDuration, Azure.Storage.Blobs.Models.LeaseState leaseState, Azure.Storage.Blobs.Models.LeaseStatus leaseStatus, long contentLength, string destinationSnapshot, Azure.ETag eTag, byte[] contentHash, string contentEncoding, string contentDisposition, string contentLanguage, bool isIncrementalCopy, string cacheControl, Azure.Storage.Blobs.Models.CopyStatus copyStatus, long blobSequenceNumber, System.Uri copySource, string acceptRanges, string copyProgress, int blobCommittedBlockCount, string copyId, bool isServerEncrypted, string copyStatusDescription, string encryptionKeySha256, System.DateTimeOffset copyCompletedOn, string accessTier, Azure.Storage.Blobs.Models.BlobType blobType, bool accessTierInferred, System.Collections.Generic.IDictionary metadata, string archiveStatus, System.DateTimeOffset createdOn, System.DateTimeOffset accessTierChangedOn, string contentType) { throw null; } - public static Azure.Storage.Blobs.Models.BlobProperties BlobProperties(System.DateTimeOffset lastModified, Azure.Storage.Blobs.Models.LeaseStatus leaseStatus, long contentLength, string contentType, Azure.Storage.Blobs.Models.LeaseState leaseState, byte[] contentHash, string contentEncoding, string contentDisposition, string contentLanguage, string cacheControl, Azure.Storage.Blobs.Models.LeaseDurationType leaseDuration, long blobSequenceNumber, string destinationSnapshot, string acceptRanges, bool isIncrementalCopy, int blobCommittedBlockCount, Azure.Storage.Blobs.Models.CopyStatus copyStatus, bool isServerEncrypted, System.Uri copySource, string encryptionKeySha256, string copyProgress, string encryptionScope, string copyId, string accessTier, string copyStatusDescription, bool accessTierInferred, System.DateTimeOffset copyCompletedOn, string archiveStatus, Azure.Storage.Blobs.Models.BlobType blobType, System.DateTimeOffset accessTierChangedOn, System.Collections.Generic.IDictionary metadata, string versionId, System.DateTimeOffset createdOn, bool isCurrentVersion, Azure.ETag eTag) { throw null; } + public static Azure.Storage.Blobs.Models.BlobProperties BlobProperties(System.DateTimeOffset lastModified, Azure.Storage.Blobs.Models.LeaseStatus leaseStatus, long contentLength, string contentType, Azure.ETag eTag, Azure.Storage.Blobs.Models.LeaseState leaseState, string contentEncoding, string contentDisposition, string contentLanguage, string cacheControl, long blobSequenceNumber, Azure.Storage.Blobs.Models.LeaseDurationType leaseDuration, string acceptRanges, string destinationSnapshot, int blobCommittedBlockCount, bool isIncrementalCopy, bool isServerEncrypted, Azure.Storage.Blobs.Models.CopyStatus copyStatus, string encryptionKeySha256, System.Uri copySource, string encryptionScope, string copyProgress, string accessTier, string copyId, bool accessTierInferred, string copyStatusDescription, string archiveStatus, System.DateTimeOffset copyCompletedOn, System.DateTimeOffset accessTierChangedOn, Azure.Storage.Blobs.Models.BlobType blobType, string versionId, System.Collections.Generic.IDictionary metadata, bool isCurrentVersion, System.DateTimeOffset createdOn, long tagCount, byte[] contentHash) { throw null; } public static Azure.Storage.Blobs.Models.BlobServiceStatistics BlobServiceStatistics(Azure.Storage.Blobs.Models.BlobGeoReplication geoReplication = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Storage.Blobs.Models.BlobSnapshotInfo BlobSnapshotInfo(string snapshot, Azure.ETag eTag, System.DateTimeOffset lastModified, bool isServerEncrypted) { throw null; } @@ -701,6 +703,8 @@ public static partial class BlobsModelFactory public static Azure.Storage.Blobs.Models.BlockInfo BlockInfo(byte[] contentHash, byte[] contentCrc64, string encryptionKeySha256) { throw null; } public static Azure.Storage.Blobs.Models.BlockInfo BlockInfo(byte[] contentHash, byte[] contentCrc64, string encryptionKeySha256, string encryptionScope) { throw null; } public static Azure.Storage.Blobs.Models.BlockList BlockList(System.Collections.Generic.IEnumerable committedBlocks = null, System.Collections.Generic.IEnumerable uncommittedBlocks = null) { throw null; } + public static Azure.Storage.Blobs.Models.FilterBlobItem FilterBlobItem(string name, string containerName, string tagValue) { throw null; } + public static Azure.Storage.Blobs.Models.FilterBlobResponse FilterBlobResponse(string serviceEndpoint, string where, System.Collections.Generic.IEnumerable blobs, string nextMarker = null) { throw null; } public static Azure.Storage.Blobs.Models.PageBlobInfo PageBlobInfo(Azure.ETag eTag, System.DateTimeOffset lastModified, long blobSequenceNumber) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Storage.Blobs.Models.PageInfo PageInfo(Azure.ETag eTag, System.DateTimeOffset lastModified, byte[] contentHash, byte[] contentCrc64, long blobSequenceNumber, string encryptionKeySha256) { throw null; } @@ -836,6 +840,21 @@ public enum EncryptionAlgorithmType { Aes256 = 0, } + public partial class FilterBlobItem + { + internal FilterBlobItem() { } + public string ContainerName { get { throw null; } } + public string Name { get { throw null; } } + public string TagValue { get { throw null; } } + } + public partial class FilterBlobResponse + { + internal FilterBlobResponse() { } + public System.Collections.Generic.IEnumerable Blobs { get { throw null; } } + public string NextMarker { get { throw null; } } + public string ServiceEndpoint { get { throw null; } } + public string Where { get { throw null; } } + } public partial class JsonTextConfiguration { public JsonTextConfiguration() { } diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs index 7e69be74db24..4a7b7d0443f8 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobContainerClient.cs @@ -2128,7 +2128,7 @@ internal async Task> GetBlobsInternal( .ConfigureAwait(false); if ((traits & BlobTraits.Metadata) != BlobTraits.Metadata) { - IEnumerable blobItems = response.Value.BlobItems; + IEnumerable blobItems = response.Value.BlobItems.ToBlobItems(); foreach (BlobItem blobItem in blobItems) { blobItem.Metadata = null; diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs new file mode 100644 index 000000000000..7e683d37026b --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Azure.Storage.Blobs.Models; + +namespace Azure.Storage.Blobs +{ + internal static partial class BlobExtensions + { + internal static IDictionary ToTags(this BlobTags blobTags) + { + if (blobTags?.BlobTagSet == null) + { + return null; + } + Dictionary tags = new Dictionary(); + foreach (BlobTag blobTag in blobTags.BlobTagSet.BlobTagList) + { + tags[blobTag.Key] = blobTag.Value; + } + + return tags; + } + + internal static BlobItem ToBlobItem(this BlobItemInternal blobItemInternal) + { + if (blobItemInternal == null) + { + return null; + } + + return new BlobItem + { + Name = blobItemInternal.Name, + Deleted = blobItemInternal.Deleted, + Snapshot = blobItemInternal.Snapshot, + Properties = blobItemInternal.Properties, + VersionId = blobItemInternal.VersionId, + IsCurrentVersion = blobItemInternal.IsCurrentVersion, + Metadata = blobItemInternal.Metadata?.Count > 0 + ? blobItemInternal.Metadata + : null, + Tags = blobItemInternal.BlobTags.ToTags() + }; + } + + internal static IEnumerable ToBlobItems(this IEnumerable blobItemInternals) + { + if (blobItemInternals == null) + { + return null; + } + + List blobItems = new List(); + foreach (BlobItemInternal blobItemInternal in blobItemInternals) + { + blobItems.Add(blobItemInternal.ToBlobItem()); + } + return blobItems; + } + } +} diff --git a/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs b/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs index 0098de33e969..e3f6283ff1e3 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs @@ -1113,6 +1113,169 @@ internal static Azure.Core.HttpMessage SubmitBatchAsync_CreateMessage( } } #endregion Service.SubmitBatchAsync + + #region Service.FilterBlobsAsync + /// + /// The Filter Blobs operation enables callers to list blobs across all containers whose tags match a given search expression. Filter blobs searches across all containers within a storage account but can be scoped within the expression to a single container. + /// + /// The ClientDiagnostics instance used for operation reporting. + /// The pipeline used for sending requests. + /// The URL of the service account, container, or blob that is the targe of the desired operation. + /// Specifies the version of the operation to use for this request. + /// The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Blob Service Operations. + /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Filters the results to return only to return only blobs whose tags match the specified expression. + /// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The operation returns the NextMarker value within the response body if the listing operation did not return all containers remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the next page of list items. The marker value is opaque to the client. + /// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the listing operation crosses a partition boundary, then the service will return a continuation token for retrieving the remainder of the results. For this reason, it is possible that the service will return fewer results than specified by maxresults, or than the default of 5000. + /// Whether to invoke the operation asynchronously. The default value is true. + /// Operation name. + /// Cancellation token. + /// The result of a Filter Blobs API call + public static async System.Threading.Tasks.ValueTask> FilterBlobsAsync( + Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, + Azure.Core.Pipeline.HttpPipeline pipeline, + System.Uri resourceUri, + string version, + int? timeout = default, + string requestId = default, + string where = default, + string marker = default, + int? maxresults = default, + bool async = true, + string operationName = "ServiceClient.FilterBlobs", + System.Threading.CancellationToken cancellationToken = default) + { + Azure.Core.Pipeline.DiagnosticScope _scope = clientDiagnostics.CreateScope(operationName); + try + { + _scope.AddAttribute("url", resourceUri); + _scope.Start(); + using (Azure.Core.HttpMessage _message = FilterBlobsAsync_CreateMessage( + pipeline, + resourceUri, + version, + timeout, + requestId, + where, + marker, + maxresults)) + { + if (async) + { + // Send the request asynchronously if we're being called via an async path + await pipeline.SendAsync(_message, cancellationToken).ConfigureAwait(false); + } + else + { + // Send the request synchronously through the API that blocks if we're being called via a sync path + // (this is safe because the Task will complete before the user can call Wait) + pipeline.Send(_message, cancellationToken); + } + Azure.Response _response = _message.Response; + cancellationToken.ThrowIfCancellationRequested(); + return FilterBlobsAsync_CreateResponse(clientDiagnostics, _response); + } + } + catch (System.Exception ex) + { + _scope.Failed(ex); + throw; + } + finally + { + _scope.Dispose(); + } + } + + /// + /// Create the Service.FilterBlobsAsync request. + /// + /// The pipeline used for sending requests. + /// The URL of the service account, container, or blob that is the targe of the desired operation. + /// Specifies the version of the operation to use for this request. + /// The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Blob Service Operations. + /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Filters the results to return only to return only blobs whose tags match the specified expression. + /// A string value that identifies the portion of the list of containers to be returned with the next listing operation. The operation returns the NextMarker value within the response body if the listing operation did not return all containers remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in a subsequent call to request the next page of list items. The marker value is opaque to the client. + /// Specifies the maximum number of containers to return. If the request does not specify maxresults, or specifies a value greater than 5000, the server will return up to 5000 items. Note that if the listing operation crosses a partition boundary, then the service will return a continuation token for retrieving the remainder of the results. For this reason, it is possible that the service will return fewer results than specified by maxresults, or than the default of 5000. + /// The Service.FilterBlobsAsync Message. + internal static Azure.Core.HttpMessage FilterBlobsAsync_CreateMessage( + Azure.Core.Pipeline.HttpPipeline pipeline, + System.Uri resourceUri, + string version, + int? timeout = default, + string requestId = default, + string where = default, + string marker = default, + int? maxresults = default) + { + // Validation + if (resourceUri == null) + { + throw new System.ArgumentNullException(nameof(resourceUri)); + } + if (version == null) + { + throw new System.ArgumentNullException(nameof(version)); + } + + // Create the request + Azure.Core.HttpMessage _message = pipeline.CreateMessage(); + Azure.Core.Request _request = _message.Request; + + // Set the endpoint + _request.Method = Azure.Core.RequestMethod.Get; + _request.Uri.Reset(resourceUri); + _request.Uri.AppendQuery("comp", "blobs", escapeValue: false); + if (timeout != null) { _request.Uri.AppendQuery("timeout", timeout.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); } + if (where != null) { _request.Uri.AppendQuery("where", where); } + if (marker != null) { _request.Uri.AppendQuery("marker", marker); } + if (maxresults != null) { _request.Uri.AppendQuery("maxresults", maxresults.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); } + + // Add request headers + _request.Headers.SetValue("x-ms-version", version); + if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); } + + return _message; + } + + /// + /// Create the Service.FilterBlobsAsync response or throw a failure exception. + /// + /// The ClientDiagnostics instance to use. + /// The raw Response. + /// The Service.FilterBlobsAsync Azure.Response{Azure.Storage.Blobs.Models.FilterBlobResponse}. + internal static Azure.Response FilterBlobsAsync_CreateResponse( + Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, + Azure.Response response) + { + // Process the response + switch (response.Status) + { + case 200: + { + // Create the result + System.Xml.Linq.XDocument _xml = System.Xml.Linq.XDocument.Load(response.ContentStream, System.Xml.Linq.LoadOptions.PreserveWhitespace); + Azure.Storage.Blobs.Models.FilterBlobResponse _value = Azure.Storage.Blobs.Models.FilterBlobResponse.FromXml(_xml.Root); + + // Create the response + return Response.FromValue(_value, response); + } + case 304: + { + return new Azure.NoBodyResponse(response); + } + default: + { + // Create the result + System.Xml.Linq.XDocument _xml = System.Xml.Linq.XDocument.Load(response.ContentStream, System.Xml.Linq.LoadOptions.PreserveWhitespace); + Azure.Storage.Blobs.Models.StorageError _value = Azure.Storage.Blobs.Models.StorageError.FromXml(_xml.Root); + + throw _value.CreateException(clientDiagnostics, response); + } + } + } + #endregion Service.FilterBlobsAsync } #endregion Service operations @@ -3791,6 +3954,10 @@ internal static Azure.Core.HttpMessage DownloadAsync_CreateMessage( { _value.BlobContentHash = System.Convert.FromBase64String(_header); } + if (response.Headers.TryGetValue("x-ms-tag-count", out _header)) + { + _value.TagCount = long.Parse(_header, System.Globalization.CultureInfo.InvariantCulture); + } // Create the response return Response.FromValue(_value, response); @@ -3923,6 +4090,10 @@ internal static Azure.Core.HttpMessage DownloadAsync_CreateMessage( { _value.BlobContentHash = System.Convert.FromBase64String(_header); } + if (response.Headers.TryGetValue("x-ms-tag-count", out _header)) + { + _value.TagCount = long.Parse(_header, System.Globalization.CultureInfo.InvariantCulture); + } // Create the response return Response.FromValue(_value, response); @@ -4273,6 +4444,10 @@ internal static Azure.Core.HttpMessage GetPropertiesAsync_CreateMessage( { _value.IsCurrentVersion = bool.Parse(_header); } + if (response.Headers.TryGetValue("x-ms-tag-count", out _header)) + { + _value.TagCount = long.Parse(_header, System.Globalization.CultureInfo.InvariantCulture); + } // Create the response return Response.FromValue(_value, response); @@ -6970,6 +7145,7 @@ internal static Azure.Core.HttpMessage CreateSnapshotAsync_CreateMessage( /// Specify an ETag value to operate only on blobs without a matching value. /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. /// Whether to invoke the operation asynchronously. The default value is true. /// Operation name. /// Cancellation token. @@ -6994,6 +7170,7 @@ internal static Azure.Core.HttpMessage CreateSnapshotAsync_CreateMessage( Azure.ETag? ifNoneMatch = default, string leaseId = default, string requestId = default, + string blobTagsString = default, bool async = true, string operationName = "BlobClient.StartCopyFromUri", System.Threading.CancellationToken cancellationToken = default) @@ -7021,7 +7198,8 @@ internal static Azure.Core.HttpMessage CreateSnapshotAsync_CreateMessage( ifMatch, ifNoneMatch, leaseId, - requestId)) + requestId, + blobTagsString)) { if (async) { @@ -7071,6 +7249,7 @@ internal static Azure.Core.HttpMessage CreateSnapshotAsync_CreateMessage( /// Specify an ETag value to operate only on blobs without a matching value. /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. /// The Blob.StartCopyFromUriAsync Message. internal static Azure.Core.HttpMessage StartCopyFromUriAsync_CreateMessage( Azure.Core.Pipeline.HttpPipeline pipeline, @@ -7090,7 +7269,8 @@ internal static Azure.Core.HttpMessage StartCopyFromUriAsync_CreateMessage( Azure.ETag? ifMatch = default, Azure.ETag? ifNoneMatch = default, string leaseId = default, - string requestId = default) + string requestId = default, + string blobTagsString = default) { // Validation if (resourceUri == null) @@ -7136,6 +7316,7 @@ internal static Azure.Core.HttpMessage StartCopyFromUriAsync_CreateMessage( if (ifNoneMatch != null) { _request.Headers.SetValue("If-None-Match", ifNoneMatch.Value.ToString()); } if (leaseId != null) { _request.Headers.SetValue("x-ms-lease-id", leaseId); } if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); } + if (blobTagsString != null) { _request.Headers.SetValue("x-ms-tags", blobTagsString); } return _message; } @@ -7219,6 +7400,7 @@ internal static Azure.Core.HttpMessage StartCopyFromUriAsync_CreateMessage( /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. /// Specify the md5 calculated for the range of bytes that must be read from the copy source. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. /// Whether to invoke the operation asynchronously. The default value is true. /// Operation name. /// Cancellation token. @@ -7243,6 +7425,7 @@ internal static Azure.Core.HttpMessage StartCopyFromUriAsync_CreateMessage( string leaseId = default, string requestId = default, byte[] sourceContentHash = default, + string blobTagsString = default, bool async = true, string operationName = "BlobClient.CopyFromUri", System.Threading.CancellationToken cancellationToken = default) @@ -7270,7 +7453,8 @@ internal static Azure.Core.HttpMessage StartCopyFromUriAsync_CreateMessage( ifNoneMatch, leaseId, requestId, - sourceContentHash)) + sourceContentHash, + blobTagsString)) { if (async) { @@ -7320,6 +7504,7 @@ internal static Azure.Core.HttpMessage StartCopyFromUriAsync_CreateMessage( /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. /// Specify the md5 calculated for the range of bytes that must be read from the copy source. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. /// The Blob.CopyFromUriAsync Message. internal static Azure.Core.HttpMessage CopyFromUriAsync_CreateMessage( Azure.Core.Pipeline.HttpPipeline pipeline, @@ -7339,7 +7524,8 @@ internal static Azure.Core.HttpMessage CopyFromUriAsync_CreateMessage( Azure.ETag? ifNoneMatch = default, string leaseId = default, string requestId = default, - byte[] sourceContentHash = default) + byte[] sourceContentHash = default, + string blobTagsString = default) { // Validation if (resourceUri == null) @@ -7386,6 +7572,7 @@ internal static Azure.Core.HttpMessage CopyFromUriAsync_CreateMessage( if (leaseId != null) { _request.Headers.SetValue("x-ms-lease-id", leaseId); } if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); } if (sourceContentHash != null) { _request.Headers.SetValue("x-ms-source-content-md5", System.Convert.ToBase64String(sourceContentHash)); } + if (blobTagsString != null) { _request.Headers.SetValue("x-ms-tags", blobTagsString); } return _message; } @@ -8217,78 +8404,34 @@ internal static Azure.Core.HttpMessage QuickQueryAsync_CreateMessage( } } #endregion Blob.QuickQueryAsync - } - #endregion Blob operations - #region PageBlob operations - /// - /// PageBlob operations for Azure Blob Storage - /// - public static partial class PageBlob - { - #region PageBlob.CreateAsync + #region Blob.GetTagsAsync /// - /// The Create operation creates a new page blob. + /// The Get Tags operation enables users to get the tags associated with a blob. /// /// The ClientDiagnostics instance used for operation reporting. /// The pipeline used for sending requests. /// The URL of the service account, container, or blob that is the targe of the desired operation. - /// The length of the request. - /// This header specifies the maximum size for the page blob, up to 1 TB. The page blob size must be aligned to a 512-byte boundary. /// Specifies the version of the operation to use for this request. /// The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Blob Service Operations. - /// Optional. Indicates the tier to be set on the page blob. - /// Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. - /// Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read request. - /// Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read request. - /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks were validated when each was uploaded. - /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read request. - /// Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata for more information. - /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. - /// Optional. Sets the blob's Content-Disposition header. - /// Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. - /// The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. - /// The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. - /// Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. - /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. - /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. - /// Specify an ETag value to operate only on blobs with a matching value. - /// Specify an ETag value to operate only on blobs without a matching value. - /// Set for page blobs only. The sequence number is a user-controlled value that you can use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see Creating a Snapshot of a Blob. + /// The version id parameter is an opaque DateTime value that, when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and newer. /// Whether to invoke the operation asynchronously. The default value is true. /// Operation name. /// Cancellation token. - /// Azure.Response{Azure.Storage.Blobs.Models.BlobContentInfo} - public static async System.Threading.Tasks.ValueTask> CreateAsync( + /// Blob tags + public static async System.Threading.Tasks.ValueTask> GetTagsAsync( Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, Azure.Core.Pipeline.HttpPipeline pipeline, System.Uri resourceUri, - long contentLength, - long blobContentLength, string version, int? timeout = default, - Azure.Storage.Blobs.Models.AccessTier? tier = default, - string blobContentType = default, - string blobContentEncoding = default, - string blobContentLanguage = default, - byte[] blobContentHash = default, - string blobCacheControl = default, - System.Collections.Generic.IDictionary metadata = default, - string leaseId = default, - string blobContentDisposition = default, - string encryptionKey = default, - string encryptionKeySha256 = default, - Azure.Storage.Blobs.Models.EncryptionAlgorithmType? encryptionAlgorithm = default, - string encryptionScope = default, - System.DateTimeOffset? ifModifiedSince = default, - System.DateTimeOffset? ifUnmodifiedSince = default, - Azure.ETag? ifMatch = default, - Azure.ETag? ifNoneMatch = default, - long? blobSequenceNumber = default, string requestId = default, + string snapshot = default, + string versionId = default, bool async = true, - string operationName = "PageBlobClient.Create", + string operationName = "BlobClient.GetTags", System.Threading.CancellationToken cancellationToken = default) { Azure.Core.Pipeline.DiagnosticScope _scope = clientDiagnostics.CreateScope(operationName); @@ -8296,32 +8439,14 @@ public static partial class PageBlob { _scope.AddAttribute("url", resourceUri); _scope.Start(); - using (Azure.Core.HttpMessage _message = CreateAsync_CreateMessage( + using (Azure.Core.HttpMessage _message = GetTagsAsync_CreateMessage( pipeline, resourceUri, - contentLength, - blobContentLength, version, timeout, - tier, - blobContentType, - blobContentEncoding, - blobContentLanguage, - blobContentHash, - blobCacheControl, - metadata, - leaseId, - blobContentDisposition, - encryptionKey, - encryptionKeySha256, - encryptionAlgorithm, - encryptionScope, - ifModifiedSince, - ifUnmodifiedSince, - ifMatch, - ifNoneMatch, - blobSequenceNumber, - requestId)) + requestId, + snapshot, + versionId)) { if (async) { @@ -8336,7 +8461,7 @@ public static partial class PageBlob } Azure.Response _response = _message.Response; cancellationToken.ThrowIfCancellationRequested(); - return CreateAsync_CreateResponse(clientDiagnostics, _response); + return GetTagsAsync_CreateResponse(clientDiagnostics, _response); } } catch (System.Exception ex) @@ -8351,36 +8476,319 @@ public static partial class PageBlob } /// - /// Create the PageBlob.CreateAsync request. + /// Create the Blob.GetTagsAsync request. /// /// The pipeline used for sending requests. /// The URL of the service account, container, or blob that is the targe of the desired operation. - /// The length of the request. - /// This header specifies the maximum size for the page blob, up to 1 TB. The page blob size must be aligned to a 512-byte boundary. /// Specifies the version of the operation to use for this request. /// The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Blob Service Operations. - /// Optional. Indicates the tier to be set on the page blob. - /// Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. - /// Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read request. - /// Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read request. - /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks were validated when each was uploaded. - /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read request. - /// Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata for more information. - /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. - /// Optional. Sets the blob's Content-Disposition header. - /// Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. - /// The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. - /// The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. - /// Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. - /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. - /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. - /// Specify an ETag value to operate only on blobs with a matching value. - /// Specify an ETag value to operate only on blobs without a matching value. - /// Set for page blobs only. The sequence number is a user-controlled value that you can use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. - /// The PageBlob.CreateAsync Message. - internal static Azure.Core.HttpMessage CreateAsync_CreateMessage( - Azure.Core.Pipeline.HttpPipeline pipeline, + /// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see Creating a Snapshot of a Blob. + /// The version id parameter is an opaque DateTime value that, when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and newer. + /// The Blob.GetTagsAsync Message. + internal static Azure.Core.HttpMessage GetTagsAsync_CreateMessage( + Azure.Core.Pipeline.HttpPipeline pipeline, + System.Uri resourceUri, + string version, + int? timeout = default, + string requestId = default, + string snapshot = default, + string versionId = default) + { + // Validation + if (resourceUri == null) + { + throw new System.ArgumentNullException(nameof(resourceUri)); + } + if (version == null) + { + throw new System.ArgumentNullException(nameof(version)); + } + + // Create the request + Azure.Core.HttpMessage _message = pipeline.CreateMessage(); + Azure.Core.Request _request = _message.Request; + + // Set the endpoint + _request.Method = Azure.Core.RequestMethod.Get; + _request.Uri.Reset(resourceUri); + _request.Uri.AppendQuery("comp", "tags", escapeValue: false); + if (timeout != null) { _request.Uri.AppendQuery("timeout", timeout.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); } + if (snapshot != null) { _request.Uri.AppendQuery("snapshot", snapshot); } + if (versionId != null) { _request.Uri.AppendQuery("versionid", versionId); } + + // Add request headers + _request.Headers.SetValue("x-ms-version", version); + if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); } + + return _message; + } + + /// + /// Create the Blob.GetTagsAsync response or throw a failure exception. + /// + /// The ClientDiagnostics instance to use. + /// The raw Response. + /// The Blob.GetTagsAsync Azure.Response{Azure.Storage.Blobs.Models.BlobTags}. + internal static Azure.Response GetTagsAsync_CreateResponse( + Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, + Azure.Response response) + { + // Process the response + switch (response.Status) + { + case 200: + { + // Create the result + System.Xml.Linq.XDocument _xml = System.Xml.Linq.XDocument.Load(response.ContentStream, System.Xml.Linq.LoadOptions.PreserveWhitespace); + Azure.Storage.Blobs.Models.BlobTags _value = Azure.Storage.Blobs.Models.BlobTags.FromXml(_xml.Root); + + // Create the response + return Response.FromValue(_value, response); + } + case 304: + { + return new Azure.NoBodyResponse(response); + } + default: + { + // Create the result + System.Xml.Linq.XDocument _xml = System.Xml.Linq.XDocument.Load(response.ContentStream, System.Xml.Linq.LoadOptions.PreserveWhitespace); + Azure.Storage.Blobs.Models.StorageError _value = Azure.Storage.Blobs.Models.StorageError.FromXml(_xml.Root); + + throw _value.CreateException(clientDiagnostics, response); + } + } + } + #endregion Blob.GetTagsAsync + + #region Blob.SetTagsAsync + /// + /// The Set Tags operation enables users to set tags on a blob. + /// + /// The ClientDiagnostics instance used for operation reporting. + /// The pipeline used for sending requests. + /// The URL of the service account, container, or blob that is the targe of the desired operation. + /// Specifies the version of the operation to use for this request. + /// The length of the request. + /// The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Blob Service Operations. + /// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see Creating a Snapshot of a Blob. + /// The version id parameter is an opaque DateTime value that, when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and newer. + /// Specify the transactional md5 for the body, to be validated by the service. + /// Specify the transactional crc64 for the body, to be validated by the service. + /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Blob tags + /// Whether to invoke the operation asynchronously. The default value is true. + /// Operation name. + /// Cancellation token. + /// Azure.Response + public static async System.Threading.Tasks.ValueTask SetTagsAsync( + Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, + Azure.Core.Pipeline.HttpPipeline pipeline, + System.Uri resourceUri, + string version, + long contentLength, + int? timeout = default, + string snapshot = default, + string versionId = default, + byte[] transactionalContentHash = default, + byte[] transactionalContentCrc64 = default, + string requestId = default, + Azure.Storage.Blobs.Models.BlobTags tags = default, + bool async = true, + string operationName = "BlobClient.SetTags", + System.Threading.CancellationToken cancellationToken = default) + { + Azure.Core.Pipeline.DiagnosticScope _scope = clientDiagnostics.CreateScope(operationName); + try + { + _scope.AddAttribute("url", resourceUri); + _scope.Start(); + using (Azure.Core.HttpMessage _message = SetTagsAsync_CreateMessage( + pipeline, + resourceUri, + version, + contentLength, + timeout, + snapshot, + versionId, + transactionalContentHash, + transactionalContentCrc64, + requestId, + tags)) + { + if (async) + { + // Send the request asynchronously if we're being called via an async path + await pipeline.SendAsync(_message, cancellationToken).ConfigureAwait(false); + } + else + { + // Send the request synchronously through the API that blocks if we're being called via a sync path + // (this is safe because the Task will complete before the user can call Wait) + pipeline.Send(_message, cancellationToken); + } + Azure.Response _response = _message.Response; + cancellationToken.ThrowIfCancellationRequested(); + return SetTagsAsync_CreateResponse(clientDiagnostics, _response); + } + } + catch (System.Exception ex) + { + _scope.Failed(ex); + throw; + } + finally + { + _scope.Dispose(); + } + } + + /// + /// Create the Blob.SetTagsAsync request. + /// + /// The pipeline used for sending requests. + /// The URL of the service account, container, or blob that is the targe of the desired operation. + /// Specifies the version of the operation to use for this request. + /// The length of the request. + /// The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Blob Service Operations. + /// The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve. For more information on working with blob snapshots, see Creating a Snapshot of a Blob. + /// The version id parameter is an opaque DateTime value that, when present, specifies the version of the blob to operate on. It's for service version 2019-10-10 and newer. + /// Specify the transactional md5 for the body, to be validated by the service. + /// Specify the transactional crc64 for the body, to be validated by the service. + /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Blob tags + /// The Blob.SetTagsAsync Message. + internal static Azure.Core.HttpMessage SetTagsAsync_CreateMessage( + Azure.Core.Pipeline.HttpPipeline pipeline, + System.Uri resourceUri, + string version, + long contentLength, + int? timeout = default, + string snapshot = default, + string versionId = default, + byte[] transactionalContentHash = default, + byte[] transactionalContentCrc64 = default, + string requestId = default, + Azure.Storage.Blobs.Models.BlobTags tags = default) + { + // Validation + if (resourceUri == null) + { + throw new System.ArgumentNullException(nameof(resourceUri)); + } + if (version == null) + { + throw new System.ArgumentNullException(nameof(version)); + } + + // Create the request + Azure.Core.HttpMessage _message = pipeline.CreateMessage(); + Azure.Core.Request _request = _message.Request; + + // Set the endpoint + _request.Method = Azure.Core.RequestMethod.Put; + _request.Uri.Reset(resourceUri); + _request.Uri.AppendQuery("comp", "tags", escapeValue: false); + if (timeout != null) { _request.Uri.AppendQuery("timeout", timeout.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); } + if (snapshot != null) { _request.Uri.AppendQuery("snapshot", snapshot); } + if (versionId != null) { _request.Uri.AppendQuery("versionid", versionId); } + + // Add request headers + _request.Headers.SetValue("x-ms-version", version); + _request.Headers.SetValue("Content-Length", contentLength.ToString(System.Globalization.CultureInfo.InvariantCulture)); + if (transactionalContentHash != null) { _request.Headers.SetValue("Content-MD5", System.Convert.ToBase64String(transactionalContentHash)); } + if (transactionalContentCrc64 != null) { _request.Headers.SetValue("x-ms-content-crc64", System.Convert.ToBase64String(transactionalContentCrc64)); } + if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); } + + // Create the body + if (tags != null) + { + System.Xml.Linq.XElement _body = Azure.Storage.Blobs.Models.BlobTags.ToXml(tags, "Tags", ""); + string _text = _body.ToString(System.Xml.Linq.SaveOptions.DisableFormatting); + _request.Headers.SetValue("Content-Type", "application/xml"); + _request.Headers.SetValue("Content-Length", _text.Length.ToString(System.Globalization.CultureInfo.InvariantCulture)); + _request.Content = Azure.Core.RequestContent.Create(System.Text.Encoding.UTF8.GetBytes(_text)); + } + + return _message; + } + + /// + /// Create the Blob.SetTagsAsync response or throw a failure exception. + /// + /// The ClientDiagnostics instance to use. + /// The raw Response. + /// The Blob.SetTagsAsync Azure.Response. + internal static Azure.Response SetTagsAsync_CreateResponse( + Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, + Azure.Response response) + { + // Process the response + switch (response.Status) + { + case 204: + { + return response; + } + default: + { + // Create the result + System.Xml.Linq.XDocument _xml = System.Xml.Linq.XDocument.Load(response.ContentStream, System.Xml.Linq.LoadOptions.PreserveWhitespace); + Azure.Storage.Blobs.Models.StorageError _value = Azure.Storage.Blobs.Models.StorageError.FromXml(_xml.Root); + + throw _value.CreateException(clientDiagnostics, response); + } + } + } + #endregion Blob.SetTagsAsync + } + #endregion Blob operations + + #region PageBlob operations + /// + /// PageBlob operations for Azure Blob Storage + /// + public static partial class PageBlob + { + #region PageBlob.CreateAsync + /// + /// The Create operation creates a new page blob. + /// + /// The ClientDiagnostics instance used for operation reporting. + /// The pipeline used for sending requests. + /// The URL of the service account, container, or blob that is the targe of the desired operation. + /// The length of the request. + /// This header specifies the maximum size for the page blob, up to 1 TB. The page blob size must be aligned to a 512-byte boundary. + /// Specifies the version of the operation to use for this request. + /// The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Blob Service Operations. + /// Optional. Indicates the tier to be set on the page blob. + /// Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. + /// Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read request. + /// Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read request. + /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks were validated when each was uploaded. + /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read request. + /// Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata for more information. + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + /// Optional. Sets the blob's Content-Disposition header. + /// Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. + /// The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. + /// The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. + /// Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. + /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. + /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. + /// Specify an ETag value to operate only on blobs with a matching value. + /// Specify an ETag value to operate only on blobs without a matching value. + /// Set for page blobs only. The sequence number is a user-controlled value that you can use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. + /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. + /// Whether to invoke the operation asynchronously. The default value is true. + /// Operation name. + /// Cancellation token. + /// Azure.Response{Azure.Storage.Blobs.Models.BlobContentInfo} + public static async System.Threading.Tasks.ValueTask> CreateAsync( + Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, + Azure.Core.Pipeline.HttpPipeline pipeline, System.Uri resourceUri, long contentLength, long blobContentLength, @@ -8404,7 +8812,129 @@ internal static Azure.Core.HttpMessage CreateAsync_CreateMessage( Azure.ETag? ifMatch = default, Azure.ETag? ifNoneMatch = default, long? blobSequenceNumber = default, - string requestId = default) + string requestId = default, + string blobTagsString = default, + bool async = true, + string operationName = "PageBlobClient.Create", + System.Threading.CancellationToken cancellationToken = default) + { + Azure.Core.Pipeline.DiagnosticScope _scope = clientDiagnostics.CreateScope(operationName); + try + { + _scope.AddAttribute("url", resourceUri); + _scope.Start(); + using (Azure.Core.HttpMessage _message = CreateAsync_CreateMessage( + pipeline, + resourceUri, + contentLength, + blobContentLength, + version, + timeout, + tier, + blobContentType, + blobContentEncoding, + blobContentLanguage, + blobContentHash, + blobCacheControl, + metadata, + leaseId, + blobContentDisposition, + encryptionKey, + encryptionKeySha256, + encryptionAlgorithm, + encryptionScope, + ifModifiedSince, + ifUnmodifiedSince, + ifMatch, + ifNoneMatch, + blobSequenceNumber, + requestId, + blobTagsString)) + { + if (async) + { + // Send the request asynchronously if we're being called via an async path + await pipeline.SendAsync(_message, cancellationToken).ConfigureAwait(false); + } + else + { + // Send the request synchronously through the API that blocks if we're being called via a sync path + // (this is safe because the Task will complete before the user can call Wait) + pipeline.Send(_message, cancellationToken); + } + Azure.Response _response = _message.Response; + cancellationToken.ThrowIfCancellationRequested(); + return CreateAsync_CreateResponse(clientDiagnostics, _response); + } + } + catch (System.Exception ex) + { + _scope.Failed(ex); + throw; + } + finally + { + _scope.Dispose(); + } + } + + /// + /// Create the PageBlob.CreateAsync request. + /// + /// The pipeline used for sending requests. + /// The URL of the service account, container, or blob that is the targe of the desired operation. + /// The length of the request. + /// This header specifies the maximum size for the page blob, up to 1 TB. The page blob size must be aligned to a 512-byte boundary. + /// Specifies the version of the operation to use for this request. + /// The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Blob Service Operations. + /// Optional. Indicates the tier to be set on the page blob. + /// Optional. Sets the blob's content type. If specified, this property is stored with the blob and returned with a read request. + /// Optional. Sets the blob's content encoding. If specified, this property is stored with the blob and returned with a read request. + /// Optional. Set the blob's content language. If specified, this property is stored with the blob and returned with a read request. + /// Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks were validated when each was uploaded. + /// Optional. Sets the blob's cache control. If specified, this property is stored with the blob and returned with a read request. + /// Optional. Specifies a user-defined name-value pair associated with the blob. If no name-value pairs are specified, the operation will copy the metadata from the source blob or file to the destination blob. If one or more name-value pairs are specified, the destination blob is created with the specified metadata, and metadata is not copied from the source blob or file. Note that beginning with version 2009-09-19, metadata names must adhere to the naming rules for C# identifiers. See Naming and Referencing Containers, Blobs, and Metadata for more information. + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + /// Optional. Sets the blob's Content-Disposition header. + /// Optional. Specifies the encryption key to use to encrypt the data provided in the request. If not specified, encryption is performed with the root account encryption key. For more information, see Encryption at Rest for Azure Storage Services. + /// The SHA-256 hash of the provided encryption key. Must be provided if the x-ms-encryption-key header is provided. + /// The algorithm used to produce the encryption key hash. Currently, the only accepted value is "AES256". Must be provided if the x-ms-encryption-key header is provided. + /// Optional. Version 2019-07-07 and later. Specifies the name of the encryption scope to use to encrypt the data provided in the request. If not specified, encryption is performed with the default account encryption scope. For more information, see Encryption at Rest for Azure Storage Services. + /// Specify this header value to operate only on a blob if it has been modified since the specified date/time. + /// Specify this header value to operate only on a blob if it has not been modified since the specified date/time. + /// Specify an ETag value to operate only on blobs with a matching value. + /// Specify an ETag value to operate only on blobs without a matching value. + /// Set for page blobs only. The sequence number is a user-controlled value that you can use to track requests. The value of the sequence number must be between 0 and 2^63 - 1. + /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. + /// The PageBlob.CreateAsync Message. + internal static Azure.Core.HttpMessage CreateAsync_CreateMessage( + Azure.Core.Pipeline.HttpPipeline pipeline, + System.Uri resourceUri, + long contentLength, + long blobContentLength, + string version, + int? timeout = default, + Azure.Storage.Blobs.Models.AccessTier? tier = default, + string blobContentType = default, + string blobContentEncoding = default, + string blobContentLanguage = default, + byte[] blobContentHash = default, + string blobCacheControl = default, + System.Collections.Generic.IDictionary metadata = default, + string leaseId = default, + string blobContentDisposition = default, + string encryptionKey = default, + string encryptionKeySha256 = default, + Azure.Storage.Blobs.Models.EncryptionAlgorithmType? encryptionAlgorithm = default, + string encryptionScope = default, + System.DateTimeOffset? ifModifiedSince = default, + System.DateTimeOffset? ifUnmodifiedSince = default, + Azure.ETag? ifMatch = default, + Azure.ETag? ifNoneMatch = default, + long? blobSequenceNumber = default, + string requestId = default, + string blobTagsString = default) { // Validation if (resourceUri == null) @@ -8454,6 +8984,7 @@ internal static Azure.Core.HttpMessage CreateAsync_CreateMessage( if (ifNoneMatch != null) { _request.Headers.SetValue("If-None-Match", ifNoneMatch.Value.ToString()); } if (blobSequenceNumber != null) { _request.Headers.SetValue("x-ms-blob-sequence-number", blobSequenceNumber.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); } if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); } + if (blobTagsString != null) { _request.Headers.SetValue("x-ms-tags", blobTagsString); } return _message; } @@ -10442,6 +10973,7 @@ public static partial class AppendBlob /// Specify an ETag value to operate only on blobs with a matching value. /// Specify an ETag value to operate only on blobs without a matching value. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. /// Whether to invoke the operation asynchronously. The default value is true. /// Operation name. /// Cancellation token. @@ -10470,6 +11002,7 @@ public static partial class AppendBlob Azure.ETag? ifMatch = default, Azure.ETag? ifNoneMatch = default, string requestId = default, + string blobTagsString = default, bool async = true, string operationName = "AppendBlobClient.Create", System.Threading.CancellationToken cancellationToken = default) @@ -10501,7 +11034,8 @@ public static partial class AppendBlob ifUnmodifiedSince, ifMatch, ifNoneMatch, - requestId)) + requestId, + blobTagsString)) { if (async) { @@ -10555,6 +11089,7 @@ public static partial class AppendBlob /// Specify an ETag value to operate only on blobs with a matching value. /// Specify an ETag value to operate only on blobs without a matching value. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. /// The AppendBlob.CreateAsync Message. internal static Azure.Core.HttpMessage CreateAsync_CreateMessage( Azure.Core.Pipeline.HttpPipeline pipeline, @@ -10578,7 +11113,8 @@ internal static Azure.Core.HttpMessage CreateAsync_CreateMessage( System.DateTimeOffset? ifUnmodifiedSince = default, Azure.ETag? ifMatch = default, Azure.ETag? ifNoneMatch = default, - string requestId = default) + string requestId = default, + string blobTagsString = default) { // Validation if (resourceUri == null) @@ -10625,6 +11161,7 @@ internal static Azure.Core.HttpMessage CreateAsync_CreateMessage( if (ifMatch != null) { _request.Headers.SetValue("If-Match", ifMatch.Value.ToString()); } if (ifNoneMatch != null) { _request.Headers.SetValue("If-None-Match", ifNoneMatch.Value.ToString()); } if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); } + if (blobTagsString != null) { _request.Headers.SetValue("x-ms-tags", blobTagsString); } return _message; } @@ -11329,6 +11866,7 @@ public static partial class BlockBlob /// Specify an ETag value to operate only on blobs with a matching value. /// Specify an ETag value to operate only on blobs without a matching value. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. /// Whether to invoke the operation asynchronously. The default value is true. /// Operation name. /// Cancellation token. @@ -11360,6 +11898,7 @@ public static partial class BlockBlob Azure.ETag? ifMatch = default, Azure.ETag? ifNoneMatch = default, string requestId = default, + string blobTagsString = default, bool async = true, string operationName = "BlockBlobClient.Upload", System.Threading.CancellationToken cancellationToken = default) @@ -11394,7 +11933,8 @@ public static partial class BlockBlob ifUnmodifiedSince, ifMatch, ifNoneMatch, - requestId)) + requestId, + blobTagsString)) { if (async) { @@ -11451,6 +11991,7 @@ public static partial class BlockBlob /// Specify an ETag value to operate only on blobs with a matching value. /// Specify an ETag value to operate only on blobs without a matching value. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. /// The BlockBlob.UploadAsync Message. internal static Azure.Core.HttpMessage UploadAsync_CreateMessage( Azure.Core.Pipeline.HttpPipeline pipeline, @@ -11477,7 +12018,8 @@ internal static Azure.Core.HttpMessage UploadAsync_CreateMessage( System.DateTimeOffset? ifUnmodifiedSince = default, Azure.ETag? ifMatch = default, Azure.ETag? ifNoneMatch = default, - string requestId = default) + string requestId = default, + string blobTagsString = default) { // Validation if (resourceUri == null) @@ -11530,6 +12072,7 @@ internal static Azure.Core.HttpMessage UploadAsync_CreateMessage( if (ifMatch != null) { _request.Headers.SetValue("If-Match", ifMatch.Value.ToString()); } if (ifNoneMatch != null) { _request.Headers.SetValue("If-None-Match", ifNoneMatch.Value.ToString()); } if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); } + if (blobTagsString != null) { _request.Headers.SetValue("x-ms-tags", blobTagsString); } // Create the body _request.Content = Azure.Core.RequestContent.Create(body); @@ -12131,6 +12674,7 @@ internal static Azure.Core.HttpMessage StageBlockFromUriAsync_CreateMessage( /// Specify an ETag value to operate only on blobs with a matching value. /// Specify an ETag value to operate only on blobs without a matching value. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. /// Whether to invoke the operation asynchronously. The default value is true. /// Operation name. /// Cancellation token. @@ -12162,6 +12706,7 @@ internal static Azure.Core.HttpMessage StageBlockFromUriAsync_CreateMessage( Azure.ETag? ifMatch = default, Azure.ETag? ifNoneMatch = default, string requestId = default, + string blobTagsString = default, bool async = true, string operationName = "BlockBlobClient.CommitBlockList", System.Threading.CancellationToken cancellationToken = default) @@ -12196,7 +12741,8 @@ internal static Azure.Core.HttpMessage StageBlockFromUriAsync_CreateMessage( ifUnmodifiedSince, ifMatch, ifNoneMatch, - requestId)) + requestId, + blobTagsString)) { if (async) { @@ -12253,6 +12799,7 @@ internal static Azure.Core.HttpMessage StageBlockFromUriAsync_CreateMessage( /// Specify an ETag value to operate only on blobs with a matching value. /// Specify an ETag value to operate only on blobs without a matching value. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. + /// Optional. A URL encoded query param string which specifies the tags to be created with the Blob object. e.g. TagName1=TagValue1&TagName2=TagValue2. The x-ms-tags header may contain up to 2kb of tags. /// The BlockBlob.CommitBlockListAsync Message. internal static Azure.Core.HttpMessage CommitBlockListAsync_CreateMessage( Azure.Core.Pipeline.HttpPipeline pipeline, @@ -12279,7 +12826,8 @@ internal static Azure.Core.HttpMessage CommitBlockListAsync_CreateMessage( System.DateTimeOffset? ifUnmodifiedSince = default, Azure.ETag? ifMatch = default, Azure.ETag? ifNoneMatch = default, - string requestId = default) + string requestId = default, + string blobTagsString = default) { // Validation if (resourceUri == null) @@ -12332,6 +12880,7 @@ internal static Azure.Core.HttpMessage CommitBlockListAsync_CreateMessage( if (ifMatch != null) { _request.Headers.SetValue("If-Match", ifMatch.Value.ToString()); } if (ifNoneMatch != null) { _request.Headers.SetValue("If-None-Match", ifNoneMatch.Value.ToString()); } if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); } + if (blobTagsString != null) { _request.Headers.SetValue("x-ms-tags", blobTagsString); } // Create the body System.Xml.Linq.XElement _body = Azure.Storage.Blobs.Models.BlockLookupList.ToXml(blocks, "BlockList", ""); @@ -16326,13 +16875,13 @@ public static BlobInfo BlobInfo( } #endregion class BlobInfo -#region class BlobItem +#region class BlobItemInternal namespace Azure.Storage.Blobs.Models { /// /// An Azure Storage blob /// - public partial class BlobItem + internal partial class BlobItemInternal { /// /// Name @@ -16370,36 +16919,42 @@ public partial class BlobItem public System.Collections.Generic.IDictionary Metadata { get; internal set; } /// - /// Creates a new BlobItem instance + /// Blob tags + /// + public Azure.Storage.Blobs.Models.BlobTags BlobTags { get; internal set; } + + /// + /// Creates a new BlobItemInternal instance /// - internal BlobItem() + public BlobItemInternal() : this(false) { } /// - /// Creates a new BlobItem instance + /// Creates a new BlobItemInternal instance /// /// Whether to skip initializing nested objects. - internal BlobItem(bool skipInitialization) + internal BlobItemInternal(bool skipInitialization) { if (!skipInitialization) { Properties = new Azure.Storage.Blobs.Models.BlobItemProperties(); Metadata = new System.Collections.Generic.Dictionary(System.StringComparer.OrdinalIgnoreCase); + BlobTags = new Azure.Storage.Blobs.Models.BlobTags(); } } /// - /// Deserializes XML into a new BlobItem instance. + /// Deserializes XML into a new BlobItemInternal instance. /// /// The XML element to deserialize. - /// A deserialized BlobItem instance. - internal static Azure.Storage.Blobs.Models.BlobItem FromXml(System.Xml.Linq.XElement element) + /// A deserialized BlobItemInternal instance. + internal static Azure.Storage.Blobs.Models.BlobItemInternal FromXml(System.Xml.Linq.XElement element) { System.Diagnostics.Debug.Assert(element != null); System.Xml.Linq.XElement _child; - Azure.Storage.Blobs.Models.BlobItem _value = new Azure.Storage.Blobs.Models.BlobItem(true); + Azure.Storage.Blobs.Models.BlobItemInternal _value = new Azure.Storage.Blobs.Models.BlobItemInternal(true); _child = element.Element(System.Xml.Linq.XName.Get("Name", "")); if (_child != null) { @@ -16439,44 +16994,19 @@ internal static Azure.Storage.Blobs.Models.BlobItem FromXml(System.Xml.Linq.XEle _value.Metadata[_pair.Name.LocalName] = _pair.Value; } } - CustomizeFromXml(element, _value); - return _value; - } - - static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.BlobItem value); - } - - /// - /// BlobsModelFactory provides utilities for mocking. - /// - public static partial class BlobsModelFactory - { - /// - /// Creates a new BlobItem instance for mocking. - /// - public static BlobItem BlobItem( - string name, - bool deleted, - Azure.Storage.Blobs.Models.BlobItemProperties properties, - string snapshot = default, - string versionId = default, - bool? isCurrentVersion = default, - System.Collections.Generic.IDictionary metadata = default) - { - return new BlobItem() + _child = element.Element(System.Xml.Linq.XName.Get("Tags", "")); + if (_child != null) { - Name = name, - Deleted = deleted, - Properties = properties, - Snapshot = snapshot, - VersionId = versionId, - IsCurrentVersion = isCurrentVersion, - Metadata = metadata, - }; + _value.BlobTags = Azure.Storage.Blobs.Models.BlobTags.FromXml(_child); + } + CustomizeFromXml(element, _value); + return _value; } + + static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.BlobItemInternal value); } } -#endregion class BlobItem +#endregion class BlobItemInternal #region class BlobItemProperties namespace Azure.Storage.Blobs.Models @@ -17319,6 +17849,11 @@ public partial class BlobProperties /// public bool IsCurrentVersion { get; internal set; } + /// + /// The number of tags associated with the blob + /// + public long TagCount { get; internal set; } + /// /// Creates a new BlobProperties instance /// @@ -17341,37 +17876,38 @@ public static BlobProperties BlobProperties( Azure.Storage.Blobs.Models.LeaseStatus leaseStatus, long contentLength, string contentType, + Azure.ETag eTag, Azure.Storage.Blobs.Models.LeaseState leaseState, - byte[] contentHash, string contentEncoding, string contentDisposition, string contentLanguage, string cacheControl, - Azure.Storage.Blobs.Models.LeaseDurationType leaseDuration, long blobSequenceNumber, - string destinationSnapshot, + Azure.Storage.Blobs.Models.LeaseDurationType leaseDuration, string acceptRanges, - bool isIncrementalCopy, + string destinationSnapshot, int blobCommittedBlockCount, - Azure.Storage.Blobs.Models.CopyStatus copyStatus, + bool isIncrementalCopy, bool isServerEncrypted, - System.Uri copySource, + Azure.Storage.Blobs.Models.CopyStatus copyStatus, string encryptionKeySha256, - string copyProgress, + System.Uri copySource, string encryptionScope, - string copyId, + string copyProgress, string accessTier, - string copyStatusDescription, + string copyId, bool accessTierInferred, - System.DateTimeOffset copyCompletedOn, + string copyStatusDescription, string archiveStatus, - Azure.Storage.Blobs.Models.BlobType blobType, + System.DateTimeOffset copyCompletedOn, System.DateTimeOffset accessTierChangedOn, - System.Collections.Generic.IDictionary metadata, + Azure.Storage.Blobs.Models.BlobType blobType, string versionId, - System.DateTimeOffset createdOn, + System.Collections.Generic.IDictionary metadata, bool isCurrentVersion, - Azure.ETag eTag) + System.DateTimeOffset createdOn, + long tagCount, + byte[] contentHash) { return new BlobProperties() { @@ -17379,37 +17915,38 @@ public static BlobProperties BlobProperties( LeaseStatus = leaseStatus, ContentLength = contentLength, ContentType = contentType, + ETag = eTag, LeaseState = leaseState, - ContentHash = contentHash, ContentEncoding = contentEncoding, ContentDisposition = contentDisposition, ContentLanguage = contentLanguage, CacheControl = cacheControl, - LeaseDuration = leaseDuration, BlobSequenceNumber = blobSequenceNumber, - DestinationSnapshot = destinationSnapshot, + LeaseDuration = leaseDuration, AcceptRanges = acceptRanges, - IsIncrementalCopy = isIncrementalCopy, + DestinationSnapshot = destinationSnapshot, BlobCommittedBlockCount = blobCommittedBlockCount, - CopyStatus = copyStatus, + IsIncrementalCopy = isIncrementalCopy, IsServerEncrypted = isServerEncrypted, - CopySource = copySource, + CopyStatus = copyStatus, EncryptionKeySha256 = encryptionKeySha256, - CopyProgress = copyProgress, + CopySource = copySource, EncryptionScope = encryptionScope, - CopyId = copyId, + CopyProgress = copyProgress, AccessTier = accessTier, - CopyStatusDescription = copyStatusDescription, + CopyId = copyId, AccessTierInferred = accessTierInferred, - CopyCompletedOn = copyCompletedOn, + CopyStatusDescription = copyStatusDescription, ArchiveStatus = archiveStatus, - BlobType = blobType, + CopyCompletedOn = copyCompletedOn, AccessTierChangedOn = accessTierChangedOn, - Metadata = metadata, + BlobType = blobType, VersionId = versionId, - CreatedOn = createdOn, + Metadata = metadata, IsCurrentVersion = isCurrentVersion, - ETag = eTag, + CreatedOn = createdOn, + TagCount = tagCount, + ContentHash = contentHash, }; } } @@ -17864,132 +18401,349 @@ public partial class BlobSnapshotInfo public bool IsServerEncrypted { get; internal set; } /// - /// Prevent direct instantiation of BlobSnapshotInfo instances. - /// You can use BlobsModelFactory.BlobSnapshotInfo instead. + /// Prevent direct instantiation of BlobSnapshotInfo instances. + /// You can use BlobsModelFactory.BlobSnapshotInfo instead. + /// + internal BlobSnapshotInfo() { } + } + + /// + /// BlobsModelFactory provides utilities for mocking. + /// + public static partial class BlobsModelFactory + { + /// + /// Creates a new BlobSnapshotInfo instance for mocking. + /// + public static BlobSnapshotInfo BlobSnapshotInfo( + string snapshot, + Azure.ETag eTag, + System.DateTimeOffset lastModified, + string versionId, + bool isServerEncrypted) + { + return new BlobSnapshotInfo() + { + Snapshot = snapshot, + ETag = eTag, + LastModified = lastModified, + VersionId = versionId, + IsServerEncrypted = isServerEncrypted, + }; + } + } +} +#endregion class BlobSnapshotInfo + +#region class BlobStaticWebsite +namespace Azure.Storage.Blobs.Models +{ + /// + /// The properties that enable an account to host a static website + /// + public partial class BlobStaticWebsite + { + /// + /// Indicates whether this account is hosting a static website + /// + public bool Enabled { get; set; } + + /// + /// The default name of the index page under each directory + /// + public string IndexDocument { get; set; } + + /// + /// The absolute path of the custom 404 page + /// + public string ErrorDocument404Path { get; set; } + + /// + /// Creates a new BlobStaticWebsite instance + /// + public BlobStaticWebsite() { } + + /// + /// Serialize a BlobStaticWebsite instance as XML. + /// + /// The BlobStaticWebsite instance to serialize. + /// An optional name to use for the root element instead of "StaticWebsite". + /// An optional namespace to use for the root element instead of "". + /// The serialized XML element. + internal static System.Xml.Linq.XElement ToXml(Azure.Storage.Blobs.Models.BlobStaticWebsite value, string name = "StaticWebsite", string ns = "") + { + System.Diagnostics.Debug.Assert(value != null); + System.Xml.Linq.XElement _element = new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get(name, ns)); + _element.Add(new System.Xml.Linq.XElement( + System.Xml.Linq.XName.Get("Enabled", ""), + #pragma warning disable CA1308 // Normalize strings to uppercase + value.Enabled.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLowerInvariant())); + #pragma warning restore CA1308 // Normalize strings to uppercase + if (value.IndexDocument != null) + { + _element.Add(new System.Xml.Linq.XElement( + System.Xml.Linq.XName.Get("IndexDocument", ""), + value.IndexDocument)); + } + if (value.ErrorDocument404Path != null) + { + _element.Add(new System.Xml.Linq.XElement( + System.Xml.Linq.XName.Get("ErrorDocument404Path", ""), + value.ErrorDocument404Path)); + } + return _element; + } + + /// + /// Deserializes XML into a new BlobStaticWebsite instance. + /// + /// The XML element to deserialize. + /// A deserialized BlobStaticWebsite instance. + internal static Azure.Storage.Blobs.Models.BlobStaticWebsite FromXml(System.Xml.Linq.XElement element) + { + System.Diagnostics.Debug.Assert(element != null); + System.Xml.Linq.XElement _child; + Azure.Storage.Blobs.Models.BlobStaticWebsite _value = new Azure.Storage.Blobs.Models.BlobStaticWebsite(); + _child = element.Element(System.Xml.Linq.XName.Get("Enabled", "")); + if (_child != null) + { + _value.Enabled = bool.Parse(_child.Value); + } + _child = element.Element(System.Xml.Linq.XName.Get("IndexDocument", "")); + if (_child != null) + { + _value.IndexDocument = _child.Value; + } + _child = element.Element(System.Xml.Linq.XName.Get("ErrorDocument404Path", "")); + if (_child != null) + { + _value.ErrorDocument404Path = _child.Value; + } + CustomizeFromXml(element, _value); + return _value; + } + + static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.BlobStaticWebsite value); + } +} +#endregion class BlobStaticWebsite + +#region class BlobTag +namespace Azure.Storage.Blobs.Models +{ + /// + /// BlobTag + /// + internal partial class BlobTag + { + /// + /// Key + /// + public string Key { get; set; } + + /// + /// Value + /// + public string Value { get; set; } + + /// + /// Creates a new BlobTag instance + /// + public BlobTag() { } + + /// + /// Serialize a BlobTag instance as XML. + /// + /// The BlobTag instance to serialize. + /// An optional name to use for the root element instead of "Tag". + /// An optional namespace to use for the root element instead of "". + /// The serialized XML element. + internal static System.Xml.Linq.XElement ToXml(Azure.Storage.Blobs.Models.BlobTag value, string name = "Tag", string ns = "") + { + System.Diagnostics.Debug.Assert(value != null); + System.Xml.Linq.XElement _element = new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get(name, ns)); + _element.Add(new System.Xml.Linq.XElement( + System.Xml.Linq.XName.Get("Key", ""), + value.Key)); + _element.Add(new System.Xml.Linq.XElement( + System.Xml.Linq.XName.Get("Value", ""), + value.Value)); + return _element; + } + + /// + /// Deserializes XML into a new BlobTag instance. + /// + /// The XML element to deserialize. + /// A deserialized BlobTag instance. + internal static Azure.Storage.Blobs.Models.BlobTag FromXml(System.Xml.Linq.XElement element) + { + System.Diagnostics.Debug.Assert(element != null); + System.Xml.Linq.XElement _child; + Azure.Storage.Blobs.Models.BlobTag _value = new Azure.Storage.Blobs.Models.BlobTag(); + _child = element.Element(System.Xml.Linq.XName.Get("Key", "")); + if (_child != null) + { + _value.Key = _child.Value; + } + _child = element.Element(System.Xml.Linq.XName.Get("Value", "")); + if (_child != null) + { + _value.Value = _child.Value; + } + CustomizeFromXml(element, _value); + return _value; + } + + static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.BlobTag value); + } +} +#endregion class BlobTag + +#region class BlobTagSet +namespace Azure.Storage.Blobs.Models +{ + /// + /// a collection of blob tags + /// + internal partial class BlobTagSet + { + /// + /// a collection of blob tags + /// + public System.Collections.Generic.IList BlobTagList { get; internal set; } + + /// + /// Creates a new BlobTagSet instance + /// + public BlobTagSet() + : this(false) + { + } + + /// + /// Creates a new BlobTagSet instance + /// + /// Whether to skip initializing nested objects. + internal BlobTagSet(bool skipInitialization) + { + if (!skipInitialization) + { + BlobTagList = new System.Collections.Generic.List(); + } + } + + /// + /// Serialize a BlobTagSet instance as XML. /// - internal BlobSnapshotInfo() { } - } + /// The BlobTagSet instance to serialize. + /// An optional name to use for the root element instead of "TagSet". + /// An optional namespace to use for the root element instead of "". + /// The serialized XML element. + internal static System.Xml.Linq.XElement ToXml(Azure.Storage.Blobs.Models.BlobTagSet value, string name = "TagSet", string ns = "") + { + System.Diagnostics.Debug.Assert(value != null); + System.Xml.Linq.XElement _element = new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get(name, ns)); + foreach (Azure.Storage.Blobs.Models.BlobTag _child in value.BlobTagList) + { + _element.Add(Azure.Storage.Blobs.Models.BlobTag.ToXml(_child)); + } + return _element; + } - /// - /// BlobsModelFactory provides utilities for mocking. - /// - public static partial class BlobsModelFactory - { /// - /// Creates a new BlobSnapshotInfo instance for mocking. + /// Deserializes XML into a new BlobTagSet instance. /// - public static BlobSnapshotInfo BlobSnapshotInfo( - string snapshot, - Azure.ETag eTag, - System.DateTimeOffset lastModified, - string versionId, - bool isServerEncrypted) + /// The XML element to deserialize. + /// A deserialized BlobTagSet instance. + internal static Azure.Storage.Blobs.Models.BlobTagSet FromXml(System.Xml.Linq.XElement element) { - return new BlobSnapshotInfo() - { - Snapshot = snapshot, - ETag = eTag, - LastModified = lastModified, - VersionId = versionId, - IsServerEncrypted = isServerEncrypted, - }; + System.Diagnostics.Debug.Assert(element != null); + Azure.Storage.Blobs.Models.BlobTagSet _value = new Azure.Storage.Blobs.Models.BlobTagSet(true); + _value.BlobTagList = System.Linq.Enumerable.ToList( + System.Linq.Enumerable.Select( + element.Elements(System.Xml.Linq.XName.Get("Tag", "")), + e => Azure.Storage.Blobs.Models.BlobTag.FromXml(e))); + CustomizeFromXml(element, _value); + return _value; } + + static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.BlobTagSet value); } } -#endregion class BlobSnapshotInfo +#endregion class BlobTagSet -#region class BlobStaticWebsite +#region class BlobTags namespace Azure.Storage.Blobs.Models { /// - /// The properties that enable an account to host a static website + /// Blob tags /// - public partial class BlobStaticWebsite + internal partial class BlobTags { /// - /// Indicates whether this account is hosting a static website - /// - public bool Enabled { get; set; } - - /// - /// The default name of the index page under each directory + /// a collection of blob tags /// - public string IndexDocument { get; set; } + public Azure.Storage.Blobs.Models.BlobTagSet BlobTagSet { get; set; } /// - /// The absolute path of the custom 404 page + /// Creates a new BlobTags instance /// - public string ErrorDocument404Path { get; set; } + public BlobTags() + : this(false) + { + } /// - /// Creates a new BlobStaticWebsite instance + /// Creates a new BlobTags instance /// - public BlobStaticWebsite() { } + /// Whether to skip initializing nested objects. + internal BlobTags(bool skipInitialization) + { + if (!skipInitialization) + { + BlobTagSet = new Azure.Storage.Blobs.Models.BlobTagSet(); + } + } /// - /// Serialize a BlobStaticWebsite instance as XML. + /// Serialize a BlobTags instance as XML. /// - /// The BlobStaticWebsite instance to serialize. - /// An optional name to use for the root element instead of "StaticWebsite". + /// The BlobTags instance to serialize. + /// An optional name to use for the root element instead of "Tags". /// An optional namespace to use for the root element instead of "". /// The serialized XML element. - internal static System.Xml.Linq.XElement ToXml(Azure.Storage.Blobs.Models.BlobStaticWebsite value, string name = "StaticWebsite", string ns = "") + internal static System.Xml.Linq.XElement ToXml(Azure.Storage.Blobs.Models.BlobTags value, string name = "Tags", string ns = "") { System.Diagnostics.Debug.Assert(value != null); System.Xml.Linq.XElement _element = new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get(name, ns)); - _element.Add(new System.Xml.Linq.XElement( - System.Xml.Linq.XName.Get("Enabled", ""), - #pragma warning disable CA1308 // Normalize strings to uppercase - value.Enabled.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLowerInvariant())); - #pragma warning restore CA1308 // Normalize strings to uppercase - if (value.IndexDocument != null) - { - _element.Add(new System.Xml.Linq.XElement( - System.Xml.Linq.XName.Get("IndexDocument", ""), - value.IndexDocument)); - } - if (value.ErrorDocument404Path != null) - { - _element.Add(new System.Xml.Linq.XElement( - System.Xml.Linq.XName.Get("ErrorDocument404Path", ""), - value.ErrorDocument404Path)); - } + _element.Add(Azure.Storage.Blobs.Models.BlobTagSet.ToXml(value.BlobTagSet, "TagSet", "")); return _element; } /// - /// Deserializes XML into a new BlobStaticWebsite instance. + /// Deserializes XML into a new BlobTags instance. /// /// The XML element to deserialize. - /// A deserialized BlobStaticWebsite instance. - internal static Azure.Storage.Blobs.Models.BlobStaticWebsite FromXml(System.Xml.Linq.XElement element) + /// A deserialized BlobTags instance. + internal static Azure.Storage.Blobs.Models.BlobTags FromXml(System.Xml.Linq.XElement element) { System.Diagnostics.Debug.Assert(element != null); System.Xml.Linq.XElement _child; - Azure.Storage.Blobs.Models.BlobStaticWebsite _value = new Azure.Storage.Blobs.Models.BlobStaticWebsite(); - _child = element.Element(System.Xml.Linq.XName.Get("Enabled", "")); - if (_child != null) - { - _value.Enabled = bool.Parse(_child.Value); - } - _child = element.Element(System.Xml.Linq.XName.Get("IndexDocument", "")); - if (_child != null) - { - _value.IndexDocument = _child.Value; - } - _child = element.Element(System.Xml.Linq.XName.Get("ErrorDocument404Path", "")); + Azure.Storage.Blobs.Models.BlobTags _value = new Azure.Storage.Blobs.Models.BlobTags(true); + _child = element.Element(System.Xml.Linq.XName.Get("TagSet", "")); if (_child != null) { - _value.ErrorDocument404Path = _child.Value; + _value.BlobTagSet = Azure.Storage.Blobs.Models.BlobTagSet.FromXml(_child); } CustomizeFromXml(element, _value); return _value; } - static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.BlobStaticWebsite value); + static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.BlobTags value); } } -#endregion class BlobStaticWebsite +#endregion class BlobTags #region enum BlobType namespace Azure.Storage.Blobs.Models @@ -18089,7 +18843,7 @@ internal partial class BlobsFlatSegment /// /// BlobItems /// - public System.Collections.Generic.IEnumerable BlobItems { get; internal set; } + public System.Collections.Generic.IEnumerable BlobItems { get; internal set; } /// /// Creates a new BlobsFlatSegment instance @@ -18107,7 +18861,7 @@ internal BlobsFlatSegment(bool skipInitialization) { if (!skipInitialization) { - BlobItems = new System.Collections.Generic.List(); + BlobItems = new System.Collections.Generic.List(); } } @@ -18158,11 +18912,11 @@ internal static Azure.Storage.Blobs.Models.BlobsFlatSegment FromXml(System.Xml.L _value.BlobItems = System.Linq.Enumerable.ToList( System.Linq.Enumerable.Select( _child.Elements(System.Xml.Linq.XName.Get("Blob", "")), - e => Azure.Storage.Blobs.Models.BlobItem.FromXml(e))); + e => Azure.Storage.Blobs.Models.BlobItemInternal.FromXml(e))); } else { - _value.BlobItems = new System.Collections.Generic.List(); + _value.BlobItems = new System.Collections.Generic.List(); } CustomizeFromXml(element, _value); return _value; @@ -18219,7 +18973,7 @@ internal partial class BlobsHierarchySegment /// /// BlobItems /// - public System.Collections.Generic.IEnumerable BlobItems { get; internal set; } + public System.Collections.Generic.IEnumerable BlobItems { get; internal set; } /// /// BlobPrefixes @@ -18242,7 +18996,7 @@ internal BlobsHierarchySegment(bool skipInitialization) { if (!skipInitialization) { - BlobItems = new System.Collections.Generic.List(); + BlobItems = new System.Collections.Generic.List(); BlobPrefixes = new System.Collections.Generic.List(); } } @@ -18299,11 +19053,11 @@ internal static Azure.Storage.Blobs.Models.BlobsHierarchySegment FromXml(System. _value.BlobItems = System.Linq.Enumerable.ToList( System.Linq.Enumerable.Select( _child.Elements(System.Xml.Linq.XName.Get("Blob", "")), - e => Azure.Storage.Blobs.Models.BlobItem.FromXml(e))); + e => Azure.Storage.Blobs.Models.BlobItemInternal.FromXml(e))); } else { - _value.BlobItems = new System.Collections.Generic.List(); + _value.BlobItems = new System.Collections.Generic.List(); } _child = element.Element(System.Xml.Linq.XName.Get("Blobs", "")); if (_child != null) @@ -19252,6 +20006,210 @@ public static Azure.Storage.Blobs.Models.EncryptionAlgorithmType ParseEncryption } #endregion enum EncryptionAlgorithmType +#region class FilterBlobItem +namespace Azure.Storage.Blobs.Models +{ + /// + /// Blob info from a Filter Blobs API call + /// + public partial class FilterBlobItem + { + /// + /// Name + /// + public string Name { get; internal set; } + + /// + /// ContainerName + /// + public string ContainerName { get; internal set; } + + /// + /// TagValue + /// + public string TagValue { get; internal set; } + + /// + /// Prevent direct instantiation of FilterBlobItem instances. + /// You can use BlobsModelFactory.FilterBlobItem instead. + /// + internal FilterBlobItem() { } + + /// + /// Deserializes XML into a new FilterBlobItem instance. + /// + /// The XML element to deserialize. + /// A deserialized FilterBlobItem instance. + internal static Azure.Storage.Blobs.Models.FilterBlobItem FromXml(System.Xml.Linq.XElement element) + { + System.Diagnostics.Debug.Assert(element != null); + System.Xml.Linq.XElement _child; + Azure.Storage.Blobs.Models.FilterBlobItem _value = new Azure.Storage.Blobs.Models.FilterBlobItem(); + _child = element.Element(System.Xml.Linq.XName.Get("Name", "")); + if (_child != null) + { + _value.Name = _child.Value; + } + _child = element.Element(System.Xml.Linq.XName.Get("ContainerName", "")); + if (_child != null) + { + _value.ContainerName = _child.Value; + } + _child = element.Element(System.Xml.Linq.XName.Get("TagValue", "")); + if (_child != null) + { + _value.TagValue = _child.Value; + } + CustomizeFromXml(element, _value); + return _value; + } + + static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.FilterBlobItem value); + } + + /// + /// BlobsModelFactory provides utilities for mocking. + /// + public static partial class BlobsModelFactory + { + /// + /// Creates a new FilterBlobItem instance for mocking. + /// + public static FilterBlobItem FilterBlobItem( + string name, + string containerName, + string tagValue) + { + return new FilterBlobItem() + { + Name = name, + ContainerName = containerName, + TagValue = tagValue, + }; + } + } +} +#endregion class FilterBlobItem + +#region class FilterBlobResponse +namespace Azure.Storage.Blobs.Models +{ + /// + /// The result of a Filter Blobs API call + /// + public partial class FilterBlobResponse + { + /// + /// ServiceEndpoint + /// + public string ServiceEndpoint { get; internal set; } + + /// + /// Where + /// + public string Where { get; internal set; } + + /// + /// Blobs + /// + public System.Collections.Generic.IEnumerable Blobs { get; internal set; } + + /// + /// NextMarker + /// + public string NextMarker { get; internal set; } + + /// + /// Creates a new FilterBlobResponse instance + /// + internal FilterBlobResponse() + : this(false) + { + } + + /// + /// Creates a new FilterBlobResponse instance + /// + /// Whether to skip initializing nested objects. + internal FilterBlobResponse(bool skipInitialization) + { + if (!skipInitialization) + { + Blobs = new System.Collections.Generic.List(); + } + } + + /// + /// Deserializes XML into a new FilterBlobResponse instance. + /// + /// The XML element to deserialize. + /// A deserialized FilterBlobResponse instance. + internal static Azure.Storage.Blobs.Models.FilterBlobResponse FromXml(System.Xml.Linq.XElement element) + { + System.Diagnostics.Debug.Assert(element != null); + System.Xml.Linq.XElement _child; + System.Xml.Linq.XAttribute _attribute; + Azure.Storage.Blobs.Models.FilterBlobResponse _value = new Azure.Storage.Blobs.Models.FilterBlobResponse(true); + _attribute = element.Attribute(System.Xml.Linq.XName.Get("ServiceEndpoint", "")); + if (_attribute != null) + { + _value.ServiceEndpoint = _attribute.Value; + } + _child = element.Element(System.Xml.Linq.XName.Get("Where", "")); + if (_child != null) + { + _value.Where = _child.Value; + } + _child = element.Element(System.Xml.Linq.XName.Get("Blobs", "")); + if (_child != null) + { + _value.Blobs = System.Linq.Enumerable.ToList( + System.Linq.Enumerable.Select( + _child.Elements(System.Xml.Linq.XName.Get("Blob", "")), + e => Azure.Storage.Blobs.Models.FilterBlobItem.FromXml(e))); + } + else + { + _value.Blobs = new System.Collections.Generic.List(); + } + _child = element.Element(System.Xml.Linq.XName.Get("NextMarker", "")); + if (_child != null) + { + _value.NextMarker = _child.Value; + } + CustomizeFromXml(element, _value); + return _value; + } + + static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.FilterBlobResponse value); + } + + /// + /// BlobsModelFactory provides utilities for mocking. + /// + public static partial class BlobsModelFactory + { + /// + /// Creates a new FilterBlobResponse instance for mocking. + /// + public static FilterBlobResponse FilterBlobResponse( + string serviceEndpoint, + string where, + System.Collections.Generic.IEnumerable blobs, + string nextMarker = default) + { + return new FilterBlobResponse() + { + ServiceEndpoint = serviceEndpoint, + Where = where, + Blobs = blobs, + NextMarker = nextMarker, + }; + } + } +} +#endregion class FilterBlobResponse + #region class FlattenedContainerItem namespace Azure.Storage.Blobs.Models { @@ -19485,6 +20443,11 @@ internal partial class FlattenedDownloadProperties public byte[] BlobContentHash { get; internal set; } #pragma warning restore CA1819 // Properties should not return arrays + /// + /// The number of tags associated with the blob + /// + public long TagCount { get; internal set; } + /// /// A DateTime value returned by the service that uniquely identifies the blob. The value of this header indicates the blob version, and may be used in subsequent requests to access this version of the blob. /// @@ -20010,7 +20973,12 @@ internal enum ListBlobsIncludeItem /// /// versions /// - Versions + Versions, + + /// + /// tags + /// + Tags } } @@ -20030,6 +20998,7 @@ public static string ToString(Azure.Storage.Blobs.Models.ListBlobsIncludeItem va Azure.Storage.Blobs.Models.ListBlobsIncludeItem.Snapshots => "snapshots", Azure.Storage.Blobs.Models.ListBlobsIncludeItem.Uncommittedblobs => "uncommittedblobs", Azure.Storage.Blobs.Models.ListBlobsIncludeItem.Versions => "versions", + Azure.Storage.Blobs.Models.ListBlobsIncludeItem.Tags => "tags", _ => throw new System.ArgumentOutOfRangeException(nameof(value), value, "Unknown Azure.Storage.Blobs.Models.ListBlobsIncludeItem value.") }; } @@ -20044,6 +21013,7 @@ public static Azure.Storage.Blobs.Models.ListBlobsIncludeItem ParseListBlobsIncl "snapshots" => Azure.Storage.Blobs.Models.ListBlobsIncludeItem.Snapshots, "uncommittedblobs" => Azure.Storage.Blobs.Models.ListBlobsIncludeItem.Uncommittedblobs, "versions" => Azure.Storage.Blobs.Models.ListBlobsIncludeItem.Versions, + "tags" => Azure.Storage.Blobs.Models.ListBlobsIncludeItem.Tags, _ => throw new System.ArgumentOutOfRangeException(nameof(value), value, "Unknown Azure.Storage.Blobs.Models.ListBlobsIncludeItem value.") }; } diff --git a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobItem.cs b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobItem.cs new file mode 100644 index 000000000000..31dbacae02ae --- /dev/null +++ b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobItem.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Azure.Storage.Blobs.Models +{ + /// + /// An Azure Storage blob. + /// + public class BlobItem + { + internal BlobItem() { } + + /// + /// Name. + /// + public string Name { get; internal set; } + + /// + /// Deleted. + /// + public bool Deleted { get; internal set; } + + /// + /// Snapshot. + /// + public string Snapshot { get; internal set; } + + /// + /// VersionId. + /// + public string VersionId { get; internal set; } + + /// + /// IsCurrentVersion. + /// + public bool? IsCurrentVersion { get; internal set; } + + /// + /// Properties of a blob. + /// + public BlobItemProperties Properties { get; internal set; } + + /// + /// Metadata. + /// + public IDictionary Metadata { get; internal set; } + + /// + /// Tags. + /// + public IDictionary Tags { get; internal set; } + } +} diff --git a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs index 4320344063e1..a927757c4b76 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs @@ -281,6 +281,32 @@ public static BlobCopyInfo BlobCopyInfo( CopyStatus = copyStatus, }; + /// + /// Creates a new BlobItem instance for mocking. + /// + public static BlobItem BlobItem( + string name, + bool deleted, + BlobItemProperties properties, + string snapshot = default, + string versionId = default, + bool? isCurrentVersion = default, + IDictionary metadata = default, + IDictionary tags = default) + { + return new BlobItem() + { + Name = name, + Deleted = deleted, + Properties = properties, + Snapshot = snapshot, + VersionId = versionId, + IsCurrentVersion = isCurrentVersion, + Metadata = metadata, + Tags = tags + }; + } + /// /// Creates a new BlobItem instance for mocking. /// diff --git a/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobsAsyncCollection.cs b/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobsAsyncCollection.cs index 2c704ed6d11b..e887986f4d0b 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobsAsyncCollection.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobsAsyncCollection.cs @@ -47,7 +47,7 @@ public override async ValueTask> GetNextPageAsync( cancellationToken).ConfigureAwait(false); return Page.FromValues( - response.Value.BlobItems.ToArray(), + response.Value.BlobItems.ToBlobItems().ToArray(), response.Value.NextMarker, response.GetRawResponse()); } diff --git a/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobsByHierarchyAsyncCollection.cs b/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobsByHierarchyAsyncCollection.cs index 6e2d6f198763..a6e924a00cce 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobsByHierarchyAsyncCollection.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobsByHierarchyAsyncCollection.cs @@ -49,7 +49,7 @@ public override async ValueTask> GetNextPageAsync( var items = new List(); items.AddRange(response.Value.BlobPrefixes.Select(p => new BlobHierarchyItem(p.Name, null))); - items.AddRange(response.Value.BlobItems.Select(b => new BlobHierarchyItem(null, b))); + items.AddRange(response.Value.BlobItems.Select(b => new BlobHierarchyItem(null, b.ToBlobItem()))); return Page.FromValues( items.ToArray(), response.Value.NextMarker, diff --git a/sdk/storage/Azure.Storage.Blobs/swagger/readme.md b/sdk/storage/Azure.Storage.Blobs/swagger/readme.md index a13c08a454b1..d784eca3016a 100644 --- a/sdk/storage/Azure.Storage.Blobs/swagger/readme.md +++ b/sdk/storage/Azure.Storage.Blobs/swagger/readme.md @@ -359,12 +359,12 @@ directive: $.BlobsFlatSegment.properties.BlobItems = { "type": "array", "xml": { "name": "Blobs", "wrapped": true }, - "items": { "$ref": path + "BlobItem" } + "items": { "$ref": path + "BlobItemInternal" } }; delete $.BlobsFlatSegment.properties.Segment; delete $.BlobFlatListSegment; } - $.BlobItem.required = [ "Name", "Properties", "Deleted" ]; + $.BlobItemInternal.required = [ "Name", "Properties", "Deleted" ]; - from: swagger-document where: $["x-ms-paths"]["/{containerName}?restype=container&comp=list&flat"] transform: > @@ -393,7 +393,7 @@ directive: $.BlobsHierarchySegment.properties.BlobItems = { "type": "array", "xml": { "name": "Blobs", "wrapped": true }, - "items": { "$ref": path + "BlobItem" } + "items": { "$ref": path + "BlobItemInternal" } }; $.BlobsHierarchySegment.properties.BlobPrefixes = { "type": "array", @@ -461,8 +461,8 @@ directive: $.BlobItemProperties.properties["Content-MD5"]["x-ms-client-name"] = "ContentHash"; $.BlobItemProperties.properties.CopySource.format = "url"; $.BlobItemProperties.required = ["AccessTierInferred"]; - const path = $.BlobItem.properties.Properties.$ref.replace(/[#].*$/, "#/definitions/BlobItemProperties"); - $.BlobItem.properties.Properties = { "$ref": path }; + const path = $.BlobItemInternal.properties.Properties.$ref.replace(/[#].*$/, "#/definitions/BlobItemProperties"); + $.BlobItemInternal.properties.Properties = { "$ref": path }; $.BlobItemProperties.properties.CreatedOn = $.BlobItemProperties.properties["Creation-Time"]; $.BlobItemProperties.properties.CreatedOn.xml = {"name": "Creation-Time"}; @@ -1406,6 +1406,18 @@ directive: $.post.responses["206"]["x-az-public"] = false; ``` +### Hide BlobTags/BlobTagSet/BlobTag/BlobItemInternal +``` yaml +directive: +- from: swagger-document + where: $.definitions + transform: > + $.BlobTag["x-az-public"] = false; + $.BlobTagSet["x-az-public"] = false; + $.BlobTags["x-az-public"] = false; + $.BlobItemInternal["x-az-public"] = false; +``` + ### Treat the API version as a parameter instead of a constant ``` yaml directive: