From 6989ae804443b2020255c3978b73a8e5cd93613f Mon Sep 17 00:00:00 2001 From: Sean McCullough Date: Sun, 12 Apr 2020 16:50:23 -0700 Subject: [PATCH] Added Append Blob Seal swagger --- .../api/Azure.Storage.Blobs.netstandard2.0.cs | 3 +- .../src/Generated/BlobRestClient.cs | 297 ++++++++++++++++-- .../Azure.Storage.Blobs/swagger/readme.md | 10 + 3 files changed, 281 insertions(+), 29 deletions(-) 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 f3b8ba61f5af..0fbb0880d1ab 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 @@ -600,6 +600,7 @@ public BlobProperties() { } public bool AccessTierInferred { get { throw null; } } public string ArchiveStatus { get { throw null; } } public int BlobCommittedBlockCount { get { throw null; } } + public bool BlobSealed { get { throw null; } } public long BlobSequenceNumber { get { throw null; } } public Azure.Storage.Blobs.Models.BlobType BlobType { get { throw null; } } public string CacheControl { get { throw null; } } @@ -702,7 +703,7 @@ public static partial class BlobsModelFactory 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.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.BlobProperties BlobProperties(System.DateTimeOffset lastModified, long contentLength, string contentType, Azure.ETag eTag, Azure.Storage.Blobs.Models.LeaseStatus leaseStatus, string contentEncoding, string contentDisposition, string contentLanguage, string cacheControl, long blobSequenceNumber, Azure.Storage.Blobs.Models.LeaseState leaseState, string acceptRanges, Azure.Storage.Blobs.Models.LeaseDurationType leaseDuration, int blobCommittedBlockCount, string destinationSnapshot, bool isServerEncrypted, bool isIncrementalCopy, string encryptionKeySha256, Azure.Storage.Blobs.Models.CopyStatus copyStatus, string encryptionScope, System.Uri copySource, string accessTier, string copyProgress, bool accessTierInferred, string copyId, string archiveStatus, string copyStatusDescription, System.DateTimeOffset accessTierChangedOn, System.DateTimeOffset copyCompletedOn, string versionId, Azure.Storage.Blobs.Models.BlobType blobType, bool isCurrentVersion, System.Collections.Generic.IDictionary metadata, long tagCount, System.DateTimeOffset createdOn, bool blobSealed, 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; } diff --git a/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs b/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs index 33f6d537f38e..12fe2eced5d8 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/Generated/BlobRestClient.cs @@ -4107,6 +4107,10 @@ internal static Azure.Core.HttpMessage DownloadAsync_CreateMessage( { _value.TagCount = long.Parse(_header, System.Globalization.CultureInfo.InvariantCulture); } + if (response.Headers.TryGetValue("x-ms-blob-sealed", out _header)) + { + _value.BlobSealed = bool.Parse(_header); + } // Create the response return Response.FromValue(_value, response); @@ -4243,6 +4247,10 @@ internal static Azure.Core.HttpMessage DownloadAsync_CreateMessage( { _value.TagCount = long.Parse(_header, System.Globalization.CultureInfo.InvariantCulture); } + if (response.Headers.TryGetValue("x-ms-blob-sealed", out _header)) + { + _value.BlobSealed = bool.Parse(_header); + } // Create the response return Response.FromValue(_value, response); @@ -4597,6 +4605,10 @@ internal static Azure.Core.HttpMessage GetPropertiesAsync_CreateMessage( { _value.TagCount = long.Parse(_header, System.Globalization.CultureInfo.InvariantCulture); } + if (response.Headers.TryGetValue("x-ms-blob-sealed", out _header)) + { + _value.BlobSealed = bool.Parse(_header); + } // Create the response return Response.FromValue(_value, response); @@ -11976,6 +11988,191 @@ internal static Azure.Core.HttpMessage AppendBlockFromUriAsync_CreateMessage( } } #endregion AppendBlob.AppendBlockFromUriAsync + + #region AppendBlob.SealAsync + /// + /// The Seal operation seals the Append Blob to make it read-only. Seal is supported only on version 2019-12-12 version or later. + /// + /// 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. + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + /// 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. + /// Whether to invoke the operation asynchronously. The default value is true. + /// Operation name. + /// Cancellation token. + /// Azure.Response{Azure.Storage.Blobs.Models.AppendBlobSealInternal} + public static async System.Threading.Tasks.ValueTask> SealAsync( + Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, + Azure.Core.Pipeline.HttpPipeline pipeline, + System.Uri resourceUri, + string version, + int? timeout = default, + string requestId = default, + string leaseId = default, + System.DateTimeOffset? ifModifiedSince = default, + System.DateTimeOffset? ifUnmodifiedSince = default, + Azure.ETag? ifMatch = default, + Azure.ETag? ifNoneMatch = default, + bool async = true, + string operationName = "AppendBlobClient.Seal", + 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 = SealAsync_CreateMessage( + pipeline, + resourceUri, + version, + timeout, + requestId, + leaseId, + ifModifiedSince, + ifUnmodifiedSince, + ifMatch, + ifNoneMatch)) + { + 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 SealAsync_CreateResponse(clientDiagnostics, _response); + } + } + catch (System.Exception ex) + { + _scope.Failed(ex); + throw; + } + finally + { + _scope.Dispose(); + } + } + + /// + /// Create the AppendBlob.SealAsync 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. + /// If specified, the operation only succeeds if the resource's lease is active and matches this ID. + /// 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. + /// The AppendBlob.SealAsync Message. + internal static Azure.Core.HttpMessage SealAsync_CreateMessage( + Azure.Core.Pipeline.HttpPipeline pipeline, + System.Uri resourceUri, + string version, + int? timeout = default, + string requestId = default, + string leaseId = default, + System.DateTimeOffset? ifModifiedSince = default, + System.DateTimeOffset? ifUnmodifiedSince = default, + Azure.ETag? ifMatch = default, + Azure.ETag? ifNoneMatch = 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", "seal", 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 (leaseId != null) { _request.Headers.SetValue("x-ms-lease-id", leaseId); } + if (ifModifiedSince != null) { _request.Headers.SetValue("If-Modified-Since", ifModifiedSince.Value.ToString("R", System.Globalization.CultureInfo.InvariantCulture)); } + if (ifUnmodifiedSince != null) { _request.Headers.SetValue("If-Unmodified-Since", ifUnmodifiedSince.Value.ToString("R", System.Globalization.CultureInfo.InvariantCulture)); } + if (ifMatch != null) { _request.Headers.SetValue("If-Match", ifMatch.Value.ToString()); } + if (ifNoneMatch != null) { _request.Headers.SetValue("If-None-Match", ifNoneMatch.Value.ToString()); } + + return _message; + } + + /// + /// Create the AppendBlob.SealAsync response or throw a failure exception. + /// + /// The ClientDiagnostics instance to use. + /// The raw Response. + /// The AppendBlob.SealAsync Azure.Response{Azure.Storage.Blobs.Models.AppendBlobSealInternal}. + internal static Azure.Response SealAsync_CreateResponse( + Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics, + Azure.Response response) + { + // Process the response + switch (response.Status) + { + case 200: + { + // Create the result + Azure.Storage.Blobs.Models.AppendBlobSealInternal _value = new Azure.Storage.Blobs.Models.AppendBlobSealInternal(); + + // Get response headers + string _header; + if (response.Headers.TryGetValue("ETag", out _header)) + { + _value.ETag = new Azure.ETag(_header); + } + if (response.Headers.TryGetValue("Last-Modified", out _header)) + { + _value.LastModified = System.DateTimeOffset.Parse(_header, System.Globalization.CultureInfo.InvariantCulture); + } + if (response.Headers.TryGetValue("x-ms-blob-sealed", out _header)) + { + _value.BlobSealed = bool.Parse(_header); + } + + // Create the response + return Response.FromValue(_value, 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 AppendBlob.SealAsync } #endregion AppendBlob operations @@ -14647,6 +14844,38 @@ public enum AccountKind } #endregion enum AccountKind +#region class AppendBlobSealInternal +namespace Azure.Storage.Blobs.Models +{ + /// + /// AppendBlobSealInternal + /// + internal partial class AppendBlobSealInternal + { + /// + /// The ETag contains a value that you can use to perform operations conditionally. If the request version is 2011-08-18 or newer, the ETag value will be in quotes. + /// + public Azure.ETag ETag { get; internal set; } + + /// + /// Returns the date and time the container was last modified. Any operation that modifies the blob, including an update of the blob's metadata or properties, changes the last-modified time of the blob. + /// + public System.DateTimeOffset LastModified { get; internal set; } + + /// + /// If this blob has been sealed + /// + public bool BlobSealed { get; internal set; } + + /// + /// Prevent direct instantiation of AppendBlobSealInternal instances. + /// You can use BlobsModelFactory.AppendBlobSealInternal instead. + /// + internal AppendBlobSealInternal() { } + } +} +#endregion class AppendBlobSealInternal + #region enum ArchiveStatus namespace Azure.Storage.Blobs.Models { @@ -18051,6 +18280,11 @@ public partial class BlobProperties /// public long TagCount { get; internal set; } + /// + /// If this blob has been sealed + /// + public bool BlobSealed { get; internal set; } + /// /// Creates a new BlobProperties instance /// @@ -18070,79 +18304,81 @@ public static partial class BlobsModelFactory /// public static BlobProperties BlobProperties( System.DateTimeOffset lastModified, - Azure.Storage.Blobs.Models.LeaseStatus leaseStatus, long contentLength, string contentType, Azure.ETag eTag, - Azure.Storage.Blobs.Models.LeaseState leaseState, + Azure.Storage.Blobs.Models.LeaseStatus leaseStatus, string contentEncoding, string contentDisposition, string contentLanguage, string cacheControl, long blobSequenceNumber, - Azure.Storage.Blobs.Models.LeaseDurationType leaseDuration, + Azure.Storage.Blobs.Models.LeaseState leaseState, string acceptRanges, - string destinationSnapshot, + Azure.Storage.Blobs.Models.LeaseDurationType leaseDuration, int blobCommittedBlockCount, - bool isIncrementalCopy, + string destinationSnapshot, bool isServerEncrypted, - Azure.Storage.Blobs.Models.CopyStatus copyStatus, + bool isIncrementalCopy, string encryptionKeySha256, - System.Uri copySource, + Azure.Storage.Blobs.Models.CopyStatus copyStatus, string encryptionScope, - string copyProgress, + System.Uri copySource, string accessTier, - string copyId, + string copyProgress, bool accessTierInferred, - string copyStatusDescription, + string copyId, string archiveStatus, - System.DateTimeOffset copyCompletedOn, + string copyStatusDescription, System.DateTimeOffset accessTierChangedOn, - Azure.Storage.Blobs.Models.BlobType blobType, + System.DateTimeOffset copyCompletedOn, string versionId, - System.Collections.Generic.IDictionary metadata, + Azure.Storage.Blobs.Models.BlobType blobType, bool isCurrentVersion, - System.DateTimeOffset createdOn, + System.Collections.Generic.IDictionary metadata, long tagCount, + System.DateTimeOffset createdOn, + bool blobSealed, byte[] contentHash) { return new BlobProperties() { LastModified = lastModified, - LeaseStatus = leaseStatus, ContentLength = contentLength, ContentType = contentType, ETag = eTag, - LeaseState = leaseState, + LeaseStatus = leaseStatus, ContentEncoding = contentEncoding, ContentDisposition = contentDisposition, ContentLanguage = contentLanguage, CacheControl = cacheControl, BlobSequenceNumber = blobSequenceNumber, - LeaseDuration = leaseDuration, + LeaseState = leaseState, AcceptRanges = acceptRanges, - DestinationSnapshot = destinationSnapshot, + LeaseDuration = leaseDuration, BlobCommittedBlockCount = blobCommittedBlockCount, - IsIncrementalCopy = isIncrementalCopy, + DestinationSnapshot = destinationSnapshot, IsServerEncrypted = isServerEncrypted, - CopyStatus = copyStatus, + IsIncrementalCopy = isIncrementalCopy, EncryptionKeySha256 = encryptionKeySha256, - CopySource = copySource, + CopyStatus = copyStatus, EncryptionScope = encryptionScope, - CopyProgress = copyProgress, + CopySource = copySource, AccessTier = accessTier, - CopyId = copyId, + CopyProgress = copyProgress, AccessTierInferred = accessTierInferred, - CopyStatusDescription = copyStatusDescription, + CopyId = copyId, ArchiveStatus = archiveStatus, - CopyCompletedOn = copyCompletedOn, + CopyStatusDescription = copyStatusDescription, AccessTierChangedOn = accessTierChangedOn, - BlobType = blobType, + CopyCompletedOn = copyCompletedOn, VersionId = versionId, - Metadata = metadata, + BlobType = blobType, IsCurrentVersion = isCurrentVersion, - CreatedOn = createdOn, + Metadata = metadata, TagCount = tagCount, + CreatedOn = createdOn, + BlobSealed = blobSealed, ContentHash = contentHash, }; } @@ -20645,6 +20881,11 @@ internal partial class FlattenedDownloadProperties /// public long TagCount { get; internal set; } + /// + /// If this blob has been sealed + /// + public bool BlobSealed { 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. /// diff --git a/sdk/storage/Azure.Storage.Blobs/swagger/readme.md b/sdk/storage/Azure.Storage.Blobs/swagger/readme.md index d784eca3016a..3e29e2b7c87f 100644 --- a/sdk/storage/Azure.Storage.Blobs/swagger/readme.md +++ b/sdk/storage/Azure.Storage.Blobs/swagger/readme.md @@ -1418,6 +1418,16 @@ directive: $.BlobItemInternal["x-az-public"] = false; ``` +### Make AppendBlobSealResult internal +``` yaml +directive: +- from: swagger-document + where: $["x-ms-paths"]["/{containerName}/{blob}?comp=seal"] + transform: > + $.put.responses["200"]["x-az-public"] = false; + $.put.responses["200"]["x-az-response-name"] = "AppendBlobSealInternal"; +``` + ### Treat the API version as a parameter instead of a constant ``` yaml directive: