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 9af3c41b52e0..6911714bc858 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 @@ -261,13 +261,16 @@ internal BlobContainerInfo() { } public partial class BlobContainerItem { internal BlobContainerItem() { } + public bool? Deleted { get { throw null; } } public string Name { get { throw null; } } public Azure.Storage.Blobs.Models.BlobContainerProperties Properties { get { throw null; } } + public string Version { get { throw null; } } } public partial class BlobContainerProperties { internal BlobContainerProperties() { } public string DefaultEncryptionScope { get { throw null; } } + public System.DateTimeOffset? DeletedTime { get { throw null; } } public Azure.ETag ETag { get { throw null; } } public bool? HasImmutabilityPolicy { get { throw null; } } public bool? HasLegalHold { get { throw null; } } @@ -278,6 +281,7 @@ internal BlobContainerProperties() { } public System.Collections.Generic.IDictionary Metadata { get { throw null; } } public bool? PreventEncryptionScopeOverride { get { throw null; } } public Azure.Storage.Blobs.Models.PublicAccessType? PublicAccess { get { throw null; } } + public int? RemainingRetentionDays { get { throw null; } } } [System.FlagsAttribute] public enum BlobContainerTraits @@ -670,8 +674,12 @@ public static partial class BlobsModelFactory public static Azure.Storage.Blobs.Models.BlobBlock BlobBlock(string name, int size) { throw null; } public static Azure.Storage.Blobs.Models.BlobContainerAccessPolicy BlobContainerAccessPolicy(Azure.Storage.Blobs.Models.PublicAccessType blobPublicAccess, Azure.ETag eTag, System.DateTimeOffset lastModified, System.Collections.Generic.IEnumerable signedIdentifiers) { throw null; } public static Azure.Storage.Blobs.Models.BlobContainerInfo BlobContainerInfo(Azure.ETag eTag, System.DateTimeOffset lastModified) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Storage.Blobs.Models.BlobContainerItem BlobContainerItem(string name, Azure.Storage.Blobs.Models.BlobContainerProperties properties) { throw null; } - public static Azure.Storage.Blobs.Models.BlobContainerProperties BlobContainerProperties(System.DateTimeOffset lastModified, Azure.ETag eTag, Azure.Storage.Blobs.Models.LeaseState? leaseState = default(Azure.Storage.Blobs.Models.LeaseState?), Azure.Storage.Blobs.Models.LeaseDurationType? leaseDuration = default(Azure.Storage.Blobs.Models.LeaseDurationType?), Azure.Storage.Blobs.Models.PublicAccessType? publicAccess = default(Azure.Storage.Blobs.Models.PublicAccessType?), Azure.Storage.Blobs.Models.LeaseStatus? leaseStatus = default(Azure.Storage.Blobs.Models.LeaseStatus?), bool? hasLegalHold = default(bool?), string defaultEncryptionScope = null, bool? preventEncryptionScopeOverride = default(bool?), System.Collections.Generic.IDictionary metadata = null, bool? hasImmutabilityPolicy = default(bool?)) { throw null; } + public static Azure.Storage.Blobs.Models.BlobContainerItem BlobContainerItem(string name, Azure.Storage.Blobs.Models.BlobContainerProperties properties, bool? deleted = default(bool?), string version = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public static Azure.Storage.Blobs.Models.BlobContainerProperties BlobContainerProperties(System.DateTimeOffset lastModified, Azure.ETag eTag, Azure.Storage.Blobs.Models.LeaseState? leaseState, Azure.Storage.Blobs.Models.LeaseDurationType? leaseDuration, Azure.Storage.Blobs.Models.PublicAccessType? publicAccess, bool? hasImmutabilityPolicy, Azure.Storage.Blobs.Models.LeaseStatus? leaseStatus, string defaultEncryptionScope, bool? preventEncryptionScopeOverride, System.Collections.Generic.IDictionary metadata, bool? hasLegalHold) { throw null; } + public static Azure.Storage.Blobs.Models.BlobContainerProperties BlobContainerProperties(System.DateTimeOffset lastModified, Azure.ETag eTag, Azure.Storage.Blobs.Models.LeaseState? leaseState = default(Azure.Storage.Blobs.Models.LeaseState?), Azure.Storage.Blobs.Models.LeaseDurationType? leaseDuration = default(Azure.Storage.Blobs.Models.LeaseDurationType?), Azure.Storage.Blobs.Models.PublicAccessType? publicAccess = default(Azure.Storage.Blobs.Models.PublicAccessType?), bool? hasImmutabilityPolicy = default(bool?), Azure.Storage.Blobs.Models.LeaseStatus? leaseStatus = default(Azure.Storage.Blobs.Models.LeaseStatus?), string defaultEncryptionScope = null, bool? preventEncryptionScopeOverride = default(bool?), System.DateTimeOffset? deletedTime = default(System.DateTimeOffset?), int? remainingRetentionDays = default(int?), System.Collections.Generic.IDictionary metadata = null, bool? hasLegalHold = default(bool?)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.Storage.Blobs.Models.BlobContainerProperties BlobContainerProperties(System.DateTimeOffset lastModified, Azure.ETag eTag, Azure.Storage.Blobs.Models.LeaseStatus? leaseStatus, Azure.Storage.Blobs.Models.LeaseState? leaseState, Azure.Storage.Blobs.Models.LeaseDurationType? leaseDuration, Azure.Storage.Blobs.Models.PublicAccessType? publicAccess, bool? hasImmutabilityPolicy, bool? hasLegalHold, System.Collections.Generic.IDictionary metadata) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -704,7 +712,7 @@ public static partial class BlobsModelFactory 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.FilterBlobSegment FilterBlobSegment(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; } @@ -847,9 +855,9 @@ internal FilterBlobItem() { } public string Name { get { throw null; } } public string TagValue { get { throw null; } } } - public partial class FilterBlobResponse + public partial class FilterBlobSegment { - internal FilterBlobResponse() { } + internal FilterBlobSegment() { } public System.Collections.Generic.IEnumerable Blobs { get { throw null; } } public string NextMarker { get { throw null; } } public string ServiceEndpoint { get { throw null; } } @@ -891,6 +899,11 @@ public enum LeaseStatusType Locked = 0, Unlocked = 1, } + public enum ListContainersIncludeType + { + Metadata = 0, + Deleted = 1, + } public partial class PageBlobInfo { internal PageBlobInfo() { } diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs index 59ea8716fec1..d182b00f2429 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobServiceClient.cs @@ -525,7 +525,7 @@ internal async Task> GetBlobContainersInternal( marker: continuationToken, prefix: prefix, maxresults: pageSizeHint, - include: traits.AsIncludeType(), + include: BlobExtensions.AsIncludeItems(traits), async: async, cancellationToken: cancellationToken) .ConfigureAwait(false); diff --git a/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs b/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs index e3f6283ff1e3..33f6d537f38e 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs @@ -493,7 +493,7 @@ internal static Azure.Core.HttpMessage GetStatisticsAsync_CreateMessage( string prefix = default, string marker = default, int? maxresults = default, - Azure.Storage.Blobs.Models.ListBlobContainersIncludeType? include = default, + System.Collections.Generic.IEnumerable include = default, int? timeout = default, string requestId = default, bool async = true, @@ -563,7 +563,7 @@ internal static Azure.Core.HttpMessage ListBlobContainersSegmentAsync_CreateMess string prefix = default, string marker = default, int? maxresults = default, - Azure.Storage.Blobs.Models.ListBlobContainersIncludeType? include = default, + System.Collections.Generic.IEnumerable include = default, int? timeout = default, string requestId = default) { @@ -588,7 +588,7 @@ internal static Azure.Core.HttpMessage ListBlobContainersSegmentAsync_CreateMess if (prefix != null) { _request.Uri.AppendQuery("prefix", prefix); } if (marker != null) { _request.Uri.AppendQuery("marker", marker); } if (maxresults != null) { _request.Uri.AppendQuery("maxresults", maxresults.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); } - if (include != null) { _request.Uri.AppendQuery("include", Azure.Storage.Blobs.BlobRestClient.Serialization.ToString(include.Value)); } + if (include != null) { _request.Uri.AppendQuery("include", string.Join(",", System.Linq.Enumerable.Select(include, item => Azure.Storage.Blobs.BlobRestClient.Serialization.ToString(item)))); } if (timeout != null) { _request.Uri.AppendQuery("timeout", timeout.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); } // Add request headers @@ -1131,7 +1131,7 @@ internal static Azure.Core.HttpMessage SubmitBatchAsync_CreateMessage( /// Operation name. /// Cancellation token. /// The result of a Filter Blobs API call - public static async System.Threading.Tasks.ValueTask> FilterBlobsAsync( + public static async System.Threading.Tasks.ValueTask> FilterBlobsAsync( Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, Azure.Core.Pipeline.HttpPipeline pipeline, System.Uri resourceUri, @@ -1244,8 +1244,8 @@ internal static Azure.Core.HttpMessage FilterBlobsAsync_CreateMessage( /// /// The ClientDiagnostics instance to use. /// The raw Response. - /// The Service.FilterBlobsAsync Azure.Response{Azure.Storage.Blobs.Models.FilterBlobResponse}. - internal static Azure.Response FilterBlobsAsync_CreateResponse( + /// The Service.FilterBlobsAsync Azure.Response{Azure.Storage.Blobs.Models.FilterBlobSegment}. + internal static Azure.Response FilterBlobsAsync_CreateResponse( Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, Azure.Response response) { @@ -1256,14 +1256,14 @@ internal static Azure.Core.HttpMessage FilterBlobsAsync_CreateMessage( { // 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); + Azure.Storage.Blobs.Models.FilterBlobSegment _value = Azure.Storage.Blobs.Models.FilterBlobSegment.FromXml(_xml.Root); // Create the response return Response.FromValue(_value, response); } case 304: { - return new Azure.NoBodyResponse(response); + return new Azure.NoBodyResponse(response); } default: { @@ -2366,6 +2366,155 @@ internal static Azure.Core.HttpMessage SetAccessPolicyAsync_CreateMessage( } #endregion Container.SetAccessPolicyAsync + #region Container.RestoreAsync + /// + /// Restores a previously-deleted 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. + /// Optional. Version 2019-12-12 and laster. Specifies the name of the deleted container to restore. + /// Optional. Version 2019-12-12 and laster. Specifies the version of the deleted container to restore. + /// Whether to invoke the operation asynchronously. The default value is true. + /// Operation name. + /// Cancellation token. + /// Azure.Response + public static async System.Threading.Tasks.ValueTask RestoreAsync( + Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, + Azure.Core.Pipeline.HttpPipeline pipeline, + System.Uri resourceUri, + string version, + int? timeout = default, + string requestId = default, + string deletedContainerName = default, + string deletedContainerVersion = default, + bool async = true, + string operationName = "ContainerClient.Restore", + 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 = RestoreAsync_CreateMessage( + pipeline, + resourceUri, + version, + timeout, + requestId, + deletedContainerName, + deletedContainerVersion)) + { + 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 RestoreAsync_CreateResponse(clientDiagnostics, _response); + } + } + catch (System.Exception ex) + { + _scope.Failed(ex); + throw; + } + finally + { + _scope.Dispose(); + } + } + + /// + /// Create the Container.RestoreAsync 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. + /// Optional. Version 2019-12-12 and laster. Specifies the name of the deleted container to restore. + /// Optional. Version 2019-12-12 and laster. Specifies the version of the deleted container to restore. + /// The Container.RestoreAsync Message. + internal static Azure.Core.HttpMessage RestoreAsync_CreateMessage( + Azure.Core.Pipeline.HttpPipeline pipeline, + System.Uri resourceUri, + string version, + int? timeout = default, + string requestId = default, + string deletedContainerName = default, + string deletedContainerVersion = 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("restype", "container", escapeValue: false); + _request.Uri.AppendQuery("comp", "undelete", escapeValue: false); + if (timeout != null) { _request.Uri.AppendQuery("timeout", timeout.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); } + if (deletedContainerName != null) { _request.Headers.SetValue("x-ms-deleted-container-name", deletedContainerName); } + if (deletedContainerVersion != null) { _request.Headers.SetValue("x-ms-deleted-container-version", deletedContainerVersion); } + + return _message; + } + + /// + /// Create the Container.RestoreAsync response or throw a failure exception. + /// + /// The ClientDiagnostics instance to use. + /// The raw Response. + /// The Container.RestoreAsync Azure.Response. + internal static Azure.Response RestoreAsync_CreateResponse( + Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, + Azure.Response response) + { + // Process the response + switch (response.Status) + { + case 201: + { + 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 Container.RestoreAsync + #region Container.AcquireLeaseAsync /// /// [Update] establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite @@ -15417,6 +15566,16 @@ public partial class BlobContainerItem /// public string Name { get; internal set; } + /// + /// Deleted + /// + public bool? Deleted { get; internal set; } + + /// + /// Version + /// + public string Version { get; internal set; } + /// /// Properties of a container /// @@ -15457,6 +15616,16 @@ internal static Azure.Storage.Blobs.Models.BlobContainerItem FromXml(System.Xml. { _value.Name = _child.Value; } + _child = element.Element(System.Xml.Linq.XName.Get("Deleted", "")); + if (_child != null) + { + _value.Deleted = bool.Parse(_child.Value); + } + _child = element.Element(System.Xml.Linq.XName.Get("Version", "")); + if (_child != null) + { + _value.Version = _child.Value; + } _child = element.Element(System.Xml.Linq.XName.Get("Properties", "")); if (_child != null) { @@ -15479,12 +15648,16 @@ public static partial class BlobsModelFactory /// public static BlobContainerItem BlobContainerItem( string name, - Azure.Storage.Blobs.Models.BlobContainerProperties properties) + Azure.Storage.Blobs.Models.BlobContainerProperties properties, + bool? deleted = default, + string version = default) { return new BlobContainerItem() { Name = name, Properties = properties, + Deleted = deleted, + Version = version, }; } } @@ -15544,6 +15717,16 @@ public partial class BlobContainerProperties /// public bool? PreventEncryptionScopeOverride { get; internal set; } + /// + /// DeletedTime + /// + public System.DateTimeOffset? DeletedTime { get; internal set; } + + /// + /// RemainingRetentionDays + /// + public int? RemainingRetentionDays { get; internal set; } + /// /// ETag /// @@ -15629,6 +15812,16 @@ internal static Azure.Storage.Blobs.Models.BlobContainerProperties FromXml(Syste { _value.PreventEncryptionScopeOverride = bool.Parse(_child.Value); } + _child = element.Element(System.Xml.Linq.XName.Get("DeletedTime", "")); + if (_child != null) + { + _value.DeletedTime = System.DateTimeOffset.Parse(_child.Value, System.Globalization.CultureInfo.InvariantCulture); + } + _child = element.Element(System.Xml.Linq.XName.Get("RemainingRetentionDays", "")); + if (_child != null) + { + _value.RemainingRetentionDays = int.Parse(_child.Value, System.Globalization.CultureInfo.InvariantCulture); + } _child = element.Element(System.Xml.Linq.XName.Get("Etag", "")); if (_child != null) { @@ -15664,12 +15857,14 @@ public static BlobContainerProperties BlobContainerProperties( Azure.Storage.Blobs.Models.LeaseState? leaseState = default, Azure.Storage.Blobs.Models.LeaseDurationType? leaseDuration = default, Azure.Storage.Blobs.Models.PublicAccessType? publicAccess = default, + bool? hasImmutabilityPolicy = default, Azure.Storage.Blobs.Models.LeaseStatus? leaseStatus = default, - bool? hasLegalHold = default, string defaultEncryptionScope = default, bool? preventEncryptionScopeOverride = default, + System.DateTimeOffset? deletedTime = default, + int? remainingRetentionDays = default, System.Collections.Generic.IDictionary metadata = default, - bool? hasImmutabilityPolicy = default) + bool? hasLegalHold = default) { return new BlobContainerProperties() { @@ -15678,12 +15873,14 @@ public static BlobContainerProperties BlobContainerProperties( LeaseState = leaseState, LeaseDuration = leaseDuration, PublicAccess = publicAccess, + HasImmutabilityPolicy = hasImmutabilityPolicy, LeaseStatus = leaseStatus, - HasLegalHold = hasLegalHold, DefaultEncryptionScope = defaultEncryptionScope, PreventEncryptionScopeOverride = preventEncryptionScopeOverride, + DeletedTime = deletedTime, + RemainingRetentionDays = remainingRetentionDays, Metadata = metadata, - HasImmutabilityPolicy = hasImmutabilityPolicy, + HasLegalHold = hasLegalHold, }; } } @@ -20091,13 +20288,13 @@ public static FilterBlobItem FilterBlobItem( } #endregion class FilterBlobItem -#region class FilterBlobResponse +#region class FilterBlobSegment namespace Azure.Storage.Blobs.Models { /// /// The result of a Filter Blobs API call /// - public partial class FilterBlobResponse + public partial class FilterBlobSegment { /// /// ServiceEndpoint @@ -20120,18 +20317,18 @@ public partial class FilterBlobResponse public string NextMarker { get; internal set; } /// - /// Creates a new FilterBlobResponse instance + /// Creates a new FilterBlobSegment instance /// - internal FilterBlobResponse() + internal FilterBlobSegment() : this(false) { } /// - /// Creates a new FilterBlobResponse instance + /// Creates a new FilterBlobSegment instance /// /// Whether to skip initializing nested objects. - internal FilterBlobResponse(bool skipInitialization) + internal FilterBlobSegment(bool skipInitialization) { if (!skipInitialization) { @@ -20140,16 +20337,16 @@ internal FilterBlobResponse(bool skipInitialization) } /// - /// Deserializes XML into a new FilterBlobResponse instance. + /// Deserializes XML into a new FilterBlobSegment instance. /// /// The XML element to deserialize. - /// A deserialized FilterBlobResponse instance. - internal static Azure.Storage.Blobs.Models.FilterBlobResponse FromXml(System.Xml.Linq.XElement element) + /// A deserialized FilterBlobSegment instance. + internal static Azure.Storage.Blobs.Models.FilterBlobSegment 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); + Azure.Storage.Blobs.Models.FilterBlobSegment _value = new Azure.Storage.Blobs.Models.FilterBlobSegment(true); _attribute = element.Attribute(System.Xml.Linq.XName.Get("ServiceEndpoint", "")); if (_attribute != null) { @@ -20181,7 +20378,7 @@ internal static Azure.Storage.Blobs.Models.FilterBlobResponse FromXml(System.Xml return _value; } - static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.FilterBlobResponse value); + static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.FilterBlobSegment value); } /// @@ -20190,15 +20387,15 @@ internal static Azure.Storage.Blobs.Models.FilterBlobResponse FromXml(System.Xml public static partial class BlobsModelFactory { /// - /// Creates a new FilterBlobResponse instance for mocking. + /// Creates a new FilterBlobSegment instance for mocking. /// - public static FilterBlobResponse FilterBlobResponse( + public static FilterBlobSegment FilterBlobSegment( string serviceEndpoint, string where, System.Collections.Generic.IEnumerable blobs, string nextMarker = default) { - return new FilterBlobResponse() + return new FilterBlobSegment() { ServiceEndpoint = serviceEndpoint, Where = where, @@ -20208,7 +20405,7 @@ public static FilterBlobResponse FilterBlobResponse( } } } -#endregion class FilterBlobResponse +#endregion class FilterBlobSegment #region class FlattenedContainerItem namespace Azure.Storage.Blobs.Models @@ -20894,49 +21091,6 @@ public static Azure.Storage.Blobs.Models.LeaseStatusType ParseLeaseStatusType(st } #endregion enum LeaseStatusType -#region enum ListBlobContainersIncludeType -namespace Azure.Storage.Blobs.Models -{ - /// - /// Include this parameter to specify that the container's metadata be returned as part of the response body. - /// - internal enum ListBlobContainersIncludeType - { - /// - /// metadata - /// - Metadata - } -} - -namespace Azure.Storage.Blobs -{ - internal static partial class BlobRestClient - { - public static partial class Serialization - { - public static string ToString(Azure.Storage.Blobs.Models.ListBlobContainersIncludeType value) - { - return value switch - { - Azure.Storage.Blobs.Models.ListBlobContainersIncludeType.Metadata => "metadata", - _ => throw new System.ArgumentOutOfRangeException(nameof(value), value, "Unknown Azure.Storage.Blobs.Models.ListBlobContainersIncludeType value.") - }; - } - - public static Azure.Storage.Blobs.Models.ListBlobContainersIncludeType ParseListBlobContainersIncludeType(string value) - { - return value switch - { - "metadata" => Azure.Storage.Blobs.Models.ListBlobContainersIncludeType.Metadata, - _ => throw new System.ArgumentOutOfRangeException(nameof(value), value, "Unknown Azure.Storage.Blobs.Models.ListBlobContainersIncludeType value.") - }; - } - } - } -} -#endregion enum ListBlobContainersIncludeType - #region enum ListBlobsIncludeItem namespace Azure.Storage.Blobs.Models { @@ -21022,6 +21176,56 @@ public static Azure.Storage.Blobs.Models.ListBlobsIncludeItem ParseListBlobsIncl } #endregion enum ListBlobsIncludeItem +#region enum ListContainersIncludeType +namespace Azure.Storage.Blobs.Models +{ + /// + /// ListContainersIncludeType values + /// + public enum ListContainersIncludeType + { + /// + /// metadata + /// + Metadata, + + /// + /// deleted + /// + Deleted + } +} + +namespace Azure.Storage.Blobs +{ + internal static partial class BlobRestClient + { + public static partial class Serialization + { + public static string ToString(Azure.Storage.Blobs.Models.ListContainersIncludeType value) + { + return value switch + { + Azure.Storage.Blobs.Models.ListContainersIncludeType.Metadata => "metadata", + Azure.Storage.Blobs.Models.ListContainersIncludeType.Deleted => "deleted", + _ => throw new System.ArgumentOutOfRangeException(nameof(value), value, "Unknown Azure.Storage.Blobs.Models.ListContainersIncludeType value.") + }; + } + + public static Azure.Storage.Blobs.Models.ListContainersIncludeType ParseListContainersIncludeType(string value) + { + return value switch + { + "metadata" => Azure.Storage.Blobs.Models.ListContainersIncludeType.Metadata, + "deleted" => Azure.Storage.Blobs.Models.ListContainersIncludeType.Deleted, + _ => throw new System.ArgumentOutOfRangeException(nameof(value), value, "Unknown Azure.Storage.Blobs.Models.ListContainersIncludeType value.") + }; + } + } + } +} +#endregion enum ListContainersIncludeType + #region class PageBlobInfo namespace Azure.Storage.Blobs.Models { diff --git a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobContainerTraits.cs b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobContainerTraits.cs index 8374226647a9..5ad2efa73a7a 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobContainerTraits.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobContainerTraits.cs @@ -25,21 +25,3 @@ public enum BlobContainerTraits Metadata = 1, } } - -namespace Azure.Storage.Blobs -{ - /// - /// BlobContainerTraits enum extensions - /// - internal static partial class BlobExtensions - { - /// - /// Convert the details into a ListBlobContainersIncludeType value. - /// - /// A ListBlobContainersIncludeType value. - internal static ListBlobContainersIncludeType? AsIncludeType(this BlobContainerTraits traits) - => (traits & BlobContainerTraits.Metadata) == BlobContainerTraits.Metadata ? - ListBlobContainersIncludeType.Metadata : - (ListBlobContainersIncludeType?)null; - } -} diff --git a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs index a927757c4b76..6b41d0dc5de9 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Models/BlobsModelFactory.cs @@ -342,5 +342,51 @@ public static BlobSnapshotInfo BlobSnapshotInfo( LastModified = lastModified, IsServerEncrypted = isServerEncrypted, }; + + /// + /// Creates a new BlobContainerItem instance for mocking. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static BlobContainerItem BlobContainerItem( + string name, + BlobContainerProperties properties) + => new BlobContainerItem() + { + Name = name, + Properties = properties + }; + + /// + /// Creates a new BlobContainerProperties instance for mocking. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static BlobContainerProperties BlobContainerProperties( + DateTimeOffset lastModified, + ETag eTag, + LeaseState? leaseState, + LeaseDurationType? leaseDuration, + PublicAccessType? publicAccess, + bool? hasImmutabilityPolicy, + LeaseStatus? leaseStatus, + string defaultEncryptionScope, + bool? preventEncryptionScopeOverride, + IDictionary metadata, + bool? hasLegalHold) + { + return new BlobContainerProperties() + { + LastModified = lastModified, + ETag = eTag, + LeaseState = leaseState, + LeaseDuration = leaseDuration, + PublicAccess = publicAccess, + HasImmutabilityPolicy = hasImmutabilityPolicy, + LeaseStatus = leaseStatus, + DefaultEncryptionScope = defaultEncryptionScope, + PreventEncryptionScopeOverride = preventEncryptionScopeOverride, + Metadata = metadata, + HasLegalHold = hasLegalHold, + }; + } } } diff --git a/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobContainersAsyncCollection.cs b/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobContainersAsyncCollection.cs index fc63fa41ec6e..733d8f4a3fb6 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobContainersAsyncCollection.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Models/GetBlobContainersAsyncCollection.cs @@ -1,10 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#pragma warning disable SA1402 // File may only contain a single type + +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using Azure.Core.Pipeline; +using Azure.Storage.Blobs.Models; namespace Azure.Storage.Blobs.Models { @@ -46,3 +50,26 @@ public override async ValueTask> GetNextPageAsync( } } } +namespace Azure.Storage.Blobs +{ + /// + /// BlobContainerTraits/BlobContianerStates enum methods. + /// + internal static partial class BlobExtensions + { + /// + /// Convert the details into ListContainersIncludeType values. + /// + /// ListContainersIncludeType values + internal static IEnumerable AsIncludeItems(BlobContainerTraits traits) + { + var items = new List(); + if ((traits & BlobContainerTraits.Metadata) == BlobContainerTraits.Metadata) + { + items.Add(ListContainersIncludeType.Metadata); + } + + return items.Count > 0 ? items : null; + } + } +}