< Summary

Class:Azure.Storage.Blobs.Models.StorageError
Assembly:Azure.Storage.Blobs.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.Batch\src\Generated\BatchRestClient.cs
C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.Batch\src\Models\StorageError.cs
Covered lines:18
Uncovered lines:0
Coverable lines:18
Total lines:719
Line coverage:100% (18 of 18)
Covered branches:10
Total branches:10
Branch coverage:100% (10 of 10)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_Message()-100%100%
get_Code()-100%100%
.ctor()-100%100%
FromXml(...)-100%100%
get_AdditionalInformation()-100%100%
CustomizeFromXml(...)-100%100%
CreateException(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.Batch\src\Generated\BatchRestClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// This file was automatically generated.  Do not edit.
 5
 6#pragma warning disable IDE0016 // Null check can be simplified
 7#pragma warning disable IDE0017 // Variable declaration can be inlined
 8#pragma warning disable IDE0018 // Object initialization can be simplified
 9#pragma warning disable SA1402  // File may only contain a single type
 10
 11#region Service
 12namespace Azure.Storage.Blobs
 13{
 14    /// <summary>
 15    /// Azure Blob Storage
 16    /// </summary>
 17    internal static partial class BatchRestClient
 18    {
 19        #region Service operations
 20        /// <summary>
 21        /// Service operations for Azure Blob Storage
 22        /// </summary>
 23        public static partial class Service
 24        {
 25            #region Service.SubmitBatchAsync
 26            /// <summary>
 27            /// The Batch operation allows multiple API calls to be embedded into a single HTTP request.
 28            /// </summary>
 29            /// <param name="clientDiagnostics">The ClientDiagnostics instance used for operation reporting.</param>
 30            /// <param name="pipeline">The pipeline used for sending requests.</param>
 31            /// <param name="resourceUri">The URL of the service account, container, or blob that is the targe of the de
 32            /// <param name="body">Initial data</param>
 33            /// <param name="contentLength">The length of the request.</param>
 34            /// <param name="multipartContentType">Required. The value of this header must be multipart/mixed with a bat
 35            /// <param name="version">Specifies the version of the operation to use for this request.</param>
 36            /// <param name="timeout">The timeout parameter is expressed in seconds. For more information, see <a href="
 37            /// <param name="requestId">Provides a client-generated, opaque value with a 1 KB character limit that is re
 38            /// <param name="async">Whether to invoke the operation asynchronously.  The default value is true.</param>
 39            /// <param name="operationName">Operation name.</param>
 40            /// <param name="cancellationToken">Cancellation token.</param>
 41            /// <returns>Azure.Response{Azure.Storage.Blobs.Models.BlobBatchResult}</returns>
 42            public static async System.Threading.Tasks.ValueTask<Azure.Response<Azure.Storage.Blobs.Models.BlobBatchResu
 43                Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics,
 44                Azure.Core.Pipeline.HttpPipeline pipeline,
 45                System.Uri resourceUri,
 46                System.IO.Stream body,
 47                long contentLength,
 48                string multipartContentType,
 49                string version,
 50                int? timeout = default,
 51                string requestId = default,
 52                bool async = true,
 53                string operationName = "ServiceClient.SubmitBatch",
 54                System.Threading.CancellationToken cancellationToken = default)
 55            {
 56                Azure.Core.Pipeline.DiagnosticScope _scope = clientDiagnostics.CreateScope(operationName);
 57                try
 58                {
 59                    _scope.AddAttribute("url", resourceUri);
 60                    _scope.Start();
 61                    using (Azure.Core.HttpMessage _message = SubmitBatchAsync_CreateMessage(
 62                        pipeline,
 63                        resourceUri,
 64                        body,
 65                        contentLength,
 66                        multipartContentType,
 67                        version,
 68                        timeout,
 69                        requestId))
 70                    {
 71                        if (async)
 72                        {
 73                            // Send the request asynchronously if we're being called via an async path
 74                            await pipeline.SendAsync(_message, cancellationToken).ConfigureAwait(false);
 75                        }
 76                        else
 77                        {
 78                            // Send the request synchronously through the API that blocks if we're being called via a sy
 79                            // (this is safe because the Task will complete before the user can call Wait)
 80                            pipeline.Send(_message, cancellationToken);
 81                        }
 82                        Azure.Response _response = _message.Response;
 83                        cancellationToken.ThrowIfCancellationRequested();
 84                        return SubmitBatchAsync_CreateResponse(clientDiagnostics, _response);
 85                    }
 86                }
 87                catch (System.Exception ex)
 88                {
 89                    _scope.Failed(ex);
 90                    throw;
 91                }
 92                finally
 93                {
 94                    _scope.Dispose();
 95                }
 96            }
 97
 98            /// <summary>
 99            /// Create the Service.SubmitBatchAsync request.
 100            /// </summary>
 101            /// <param name="pipeline">The pipeline used for sending requests.</param>
 102            /// <param name="resourceUri">The URL of the service account, container, or blob that is the targe of the de
 103            /// <param name="body">Initial data</param>
 104            /// <param name="contentLength">The length of the request.</param>
 105            /// <param name="multipartContentType">Required. The value of this header must be multipart/mixed with a bat
 106            /// <param name="version">Specifies the version of the operation to use for this request.</param>
 107            /// <param name="timeout">The timeout parameter is expressed in seconds. For more information, see <a href="
 108            /// <param name="requestId">Provides a client-generated, opaque value with a 1 KB character limit that is re
 109            /// <returns>The Service.SubmitBatchAsync Message.</returns>
 110            internal static Azure.Core.HttpMessage SubmitBatchAsync_CreateMessage(
 111                Azure.Core.Pipeline.HttpPipeline pipeline,
 112                System.Uri resourceUri,
 113                System.IO.Stream body,
 114                long contentLength,
 115                string multipartContentType,
 116                string version,
 117                int? timeout = default,
 118                string requestId = default)
 119            {
 120                // Validation
 121                if (resourceUri == null)
 122                {
 123                    throw new System.ArgumentNullException(nameof(resourceUri));
 124                }
 125                if (body == null)
 126                {
 127                    throw new System.ArgumentNullException(nameof(body));
 128                }
 129                if (multipartContentType == null)
 130                {
 131                    throw new System.ArgumentNullException(nameof(multipartContentType));
 132                }
 133                if (version == null)
 134                {
 135                    throw new System.ArgumentNullException(nameof(version));
 136                }
 137
 138                // Create the request
 139                Azure.Core.HttpMessage _message = pipeline.CreateMessage();
 140                Azure.Core.Request _request = _message.Request;
 141
 142                // Set the endpoint
 143                _request.Method = Azure.Core.RequestMethod.Post;
 144                _request.Uri.Reset(resourceUri);
 145                _request.Uri.AppendQuery("comp", "batch", escapeValue: false);
 146                if (timeout != null) { _request.Uri.AppendQuery("timeout", timeout.Value.ToString(System.Globalization.C
 147
 148                // Add request headers
 149                _request.Headers.SetValue("Content-Length", contentLength.ToString(System.Globalization.CultureInfo.Inva
 150                _request.Headers.SetValue("Content-Type", multipartContentType);
 151                _request.Headers.SetValue("x-ms-version", version);
 152                if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); }
 153
 154                // Create the body
 155                _request.Content = Azure.Core.RequestContent.Create(body);
 156
 157                return _message;
 158            }
 159
 160            /// <summary>
 161            /// Create the Service.SubmitBatchAsync response or throw a failure exception.
 162            /// </summary>
 163            /// <param name="clientDiagnostics">The ClientDiagnostics instance to use.</param>
 164            /// <param name="response">The raw Response.</param>
 165            /// <returns>The Service.SubmitBatchAsync Azure.Response{Azure.Storage.Blobs.Models.BlobBatchResult}.</retur
 166            internal static Azure.Response<Azure.Storage.Blobs.Models.BlobBatchResult> SubmitBatchAsync_CreateResponse(
 167                Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics,
 168                Azure.Response response)
 169            {
 170                // Process the response
 171                switch (response.Status)
 172                {
 173                    case 202:
 174                    {
 175                        // Create the result
 176                        Azure.Storage.Blobs.Models.BlobBatchResult _value = new Azure.Storage.Blobs.Models.BlobBatchResu
 177                        _value.Content = response.ContentStream; // You should manually wrap with RetriableStream!
 178
 179                        // Get response headers
 180                        string _header;
 181                        if (response.Headers.TryGetValue("Content-Type", out _header))
 182                        {
 183                            _value.ContentType = _header;
 184                        }
 185
 186                        // Create the response
 187                        return Response.FromValue(_value, response);
 188                    }
 189                    default:
 190                    {
 191                        // Create the result
 192                        System.Xml.Linq.XDocument _xml = System.Xml.Linq.XDocument.Load(response.ContentStream, System.X
 193                        Azure.Storage.Blobs.Models.StorageError _value = Azure.Storage.Blobs.Models.StorageError.FromXml
 194
 195                        throw _value.CreateException(clientDiagnostics, response);
 196                    }
 197                }
 198            }
 199            #endregion Service.SubmitBatchAsync
 200        }
 201        #endregion Service operations
 202
 203        #region Blob operations
 204        /// <summary>
 205        /// Blob operations for Azure Blob Storage
 206        /// </summary>
 207        public static partial class Blob
 208        {
 209            #region Blob.SetAccessTierAsync
 210            /// <summary>
 211            /// The Set Tier operation sets the tier on a blob. The operation is allowed on a page blob in a premium sto
 212            /// </summary>
 213            /// <param name="clientDiagnostics">The ClientDiagnostics instance used for operation reporting.</param>
 214            /// <param name="pipeline">The pipeline used for sending requests.</param>
 215            /// <param name="resourceUri">The URL of the service account, container, or blob that is the targe of the de
 216            /// <param name="tier">Indicates the tier to be set on the blob.</param>
 217            /// <param name="version">Specifies the version of the operation to use for this request.</param>
 218            /// <param name="timeout">The timeout parameter is expressed in seconds. For more information, see <a href="
 219            /// <param name="rehydratePriority">Optional: Indicates the priority with which to rehydrate an archived blo
 220            /// <param name="requestId">Provides a client-generated, opaque value with a 1 KB character limit that is re
 221            /// <param name="leaseId">If specified, the operation only succeeds if the resource's lease is active and ma
 222            /// <param name="async">Whether to invoke the operation asynchronously.  The default value is true.</param>
 223            /// <param name="operationName">Operation name.</param>
 224            /// <param name="cancellationToken">Cancellation token.</param>
 225            /// <returns>Azure.Response</returns>
 226            public static async System.Threading.Tasks.ValueTask<Azure.Response> SetAccessTierAsync(
 227                Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics,
 228                Azure.Core.Pipeline.HttpPipeline pipeline,
 229                System.Uri resourceUri,
 230                Azure.Storage.Blobs.Models.AccessTier tier,
 231                string version,
 232                int? timeout = default,
 233                Azure.Storage.Blobs.Models.RehydratePriority? rehydratePriority = default,
 234                string requestId = default,
 235                string leaseId = default,
 236                bool async = true,
 237                string operationName = "BlobClient.SetAccessTier",
 238                System.Threading.CancellationToken cancellationToken = default)
 239            {
 240                Azure.Core.Pipeline.DiagnosticScope _scope = clientDiagnostics.CreateScope(operationName);
 241                try
 242                {
 243                    _scope.AddAttribute("url", resourceUri);
 244                    _scope.Start();
 245                    using (Azure.Core.HttpMessage _message = SetAccessTierAsync_CreateMessage(
 246                        pipeline,
 247                        resourceUri,
 248                        tier,
 249                        version,
 250                        timeout,
 251                        rehydratePriority,
 252                        requestId,
 253                        leaseId))
 254                    {
 255                        if (async)
 256                        {
 257                            // Send the request asynchronously if we're being called via an async path
 258                            await pipeline.SendAsync(_message, cancellationToken).ConfigureAwait(false);
 259                        }
 260                        else
 261                        {
 262                            // Send the request synchronously through the API that blocks if we're being called via a sy
 263                            // (this is safe because the Task will complete before the user can call Wait)
 264                            pipeline.Send(_message, cancellationToken);
 265                        }
 266                        Azure.Response _response = _message.Response;
 267                        cancellationToken.ThrowIfCancellationRequested();
 268                        return SetAccessTierAsync_CreateResponse(clientDiagnostics, _response);
 269                    }
 270                }
 271                catch (System.Exception ex)
 272                {
 273                    _scope.Failed(ex);
 274                    throw;
 275                }
 276                finally
 277                {
 278                    _scope.Dispose();
 279                }
 280            }
 281
 282            /// <summary>
 283            /// Create the Blob.SetAccessTierAsync request.
 284            /// </summary>
 285            /// <param name="pipeline">The pipeline used for sending requests.</param>
 286            /// <param name="resourceUri">The URL of the service account, container, or blob that is the targe of the de
 287            /// <param name="tier">Indicates the tier to be set on the blob.</param>
 288            /// <param name="version">Specifies the version of the operation to use for this request.</param>
 289            /// <param name="timeout">The timeout parameter is expressed in seconds. For more information, see <a href="
 290            /// <param name="rehydratePriority">Optional: Indicates the priority with which to rehydrate an archived blo
 291            /// <param name="requestId">Provides a client-generated, opaque value with a 1 KB character limit that is re
 292            /// <param name="leaseId">If specified, the operation only succeeds if the resource's lease is active and ma
 293            /// <returns>The Blob.SetAccessTierAsync Message.</returns>
 294            internal static Azure.Core.HttpMessage SetAccessTierAsync_CreateMessage(
 295                Azure.Core.Pipeline.HttpPipeline pipeline,
 296                System.Uri resourceUri,
 297                Azure.Storage.Blobs.Models.AccessTier tier,
 298                string version,
 299                int? timeout = default,
 300                Azure.Storage.Blobs.Models.RehydratePriority? rehydratePriority = default,
 301                string requestId = default,
 302                string leaseId = default)
 303            {
 304                // Validation
 305                if (resourceUri == null)
 306                {
 307                    throw new System.ArgumentNullException(nameof(resourceUri));
 308                }
 309                if (version == null)
 310                {
 311                    throw new System.ArgumentNullException(nameof(version));
 312                }
 313
 314                // Create the request
 315                Azure.Core.HttpMessage _message = pipeline.CreateMessage();
 316                Azure.Core.Request _request = _message.Request;
 317
 318                // Set the endpoint
 319                _request.Method = Azure.Core.RequestMethod.Put;
 320                _request.Uri.Reset(resourceUri);
 321                _request.Uri.AppendQuery("comp", "tier", escapeValue: false);
 322                if (timeout != null) { _request.Uri.AppendQuery("timeout", timeout.Value.ToString(System.Globalization.C
 323
 324                // Add request headers
 325                _request.Headers.SetValue("x-ms-access-tier", tier.ToString());
 326                _request.Headers.SetValue("x-ms-version", version);
 327                if (rehydratePriority != null) { _request.Headers.SetValue("x-ms-rehydrate-priority", rehydratePriority.
 328                if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); }
 329                if (leaseId != null) { _request.Headers.SetValue("x-ms-lease-id", leaseId); }
 330
 331                return _message;
 332            }
 333
 334            /// <summary>
 335            /// Create the Blob.SetAccessTierAsync response or throw a failure exception.
 336            /// </summary>
 337            /// <param name="clientDiagnostics">The ClientDiagnostics instance to use.</param>
 338            /// <param name="response">The raw Response.</param>
 339            /// <returns>The Blob.SetAccessTierAsync Azure.Response.</returns>
 340            internal static Azure.Response SetAccessTierAsync_CreateResponse(
 341                Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics,
 342                Azure.Response response)
 343            {
 344                // Process the response
 345                switch (response.Status)
 346                {
 347                    case 200:
 348                    {
 349                        return response;
 350                    }
 351                    case 202:
 352                    {
 353                        return response;
 354                    }
 355                    default:
 356                    {
 357                        // Create the result
 358                        System.Xml.Linq.XDocument _xml = System.Xml.Linq.XDocument.Load(response.ContentStream, System.X
 359                        Azure.Storage.Blobs.Models.StorageError _value = Azure.Storage.Blobs.Models.StorageError.FromXml
 360
 361                        throw _value.CreateException(clientDiagnostics, response);
 362                    }
 363                }
 364            }
 365            #endregion Blob.SetAccessTierAsync
 366
 367            #region Blob.DeleteAsync
 368            /// <summary>
 369            /// If the storage account's soft delete feature is disabled then, when a blob is deleted, it is permanently
 370            /// </summary>
 371            /// <param name="clientDiagnostics">The ClientDiagnostics instance used for operation reporting.</param>
 372            /// <param name="pipeline">The pipeline used for sending requests.</param>
 373            /// <param name="resourceUri">The URL of the service account, container, or blob that is the targe of the de
 374            /// <param name="version">Specifies the version of the operation to use for this request.</param>
 375            /// <param name="snapshot">The snapshot parameter is an opaque DateTime value that, when present, specifies 
 376            /// <param name="timeout">The timeout parameter is expressed in seconds. For more information, see <a href="
 377            /// <param name="leaseId">If specified, the operation only succeeds if the resource's lease is active and ma
 378            /// <param name="deleteSnapshots">Required if the blob has associated snapshots. Specify one of the followin
 379            /// <param name="ifModifiedSince">Specify this header value to operate only on a blob if it has been modifie
 380            /// <param name="ifUnmodifiedSince">Specify this header value to operate only on a blob if it has not been m
 381            /// <param name="ifMatch">Specify an ETag value to operate only on blobs with a matching value.</param>
 382            /// <param name="ifNoneMatch">Specify an ETag value to operate only on blobs without a matching value.</para
 383            /// <param name="requestId">Provides a client-generated, opaque value with a 1 KB character limit that is re
 384            /// <param name="async">Whether to invoke the operation asynchronously.  The default value is true.</param>
 385            /// <param name="operationName">Operation name.</param>
 386            /// <param name="cancellationToken">Cancellation token.</param>
 387            /// <returns>Azure.Response</returns>
 388            public static async System.Threading.Tasks.ValueTask<Azure.Response> DeleteAsync(
 389                Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics,
 390                Azure.Core.Pipeline.HttpPipeline pipeline,
 391                System.Uri resourceUri,
 392                string version,
 393                string snapshot = default,
 394                int? timeout = default,
 395                string leaseId = default,
 396                Azure.Storage.Blobs.Models.DeleteSnapshotsOption? deleteSnapshots = default,
 397                System.DateTimeOffset? ifModifiedSince = default,
 398                System.DateTimeOffset? ifUnmodifiedSince = default,
 399                Azure.ETag? ifMatch = default,
 400                Azure.ETag? ifNoneMatch = default,
 401                string requestId = default,
 402                bool async = true,
 403                string operationName = "BlobClient.Delete",
 404                System.Threading.CancellationToken cancellationToken = default)
 405            {
 406                Azure.Core.Pipeline.DiagnosticScope _scope = clientDiagnostics.CreateScope(operationName);
 407                try
 408                {
 409                    _scope.AddAttribute("url", resourceUri);
 410                    _scope.Start();
 411                    using (Azure.Core.HttpMessage _message = DeleteAsync_CreateMessage(
 412                        pipeline,
 413                        resourceUri,
 414                        version,
 415                        snapshot,
 416                        timeout,
 417                        leaseId,
 418                        deleteSnapshots,
 419                        ifModifiedSince,
 420                        ifUnmodifiedSince,
 421                        ifMatch,
 422                        ifNoneMatch,
 423                        requestId))
 424                    {
 425                        if (async)
 426                        {
 427                            // Send the request asynchronously if we're being called via an async path
 428                            await pipeline.SendAsync(_message, cancellationToken).ConfigureAwait(false);
 429                        }
 430                        else
 431                        {
 432                            // Send the request synchronously through the API that blocks if we're being called via a sy
 433                            // (this is safe because the Task will complete before the user can call Wait)
 434                            pipeline.Send(_message, cancellationToken);
 435                        }
 436                        Azure.Response _response = _message.Response;
 437                        cancellationToken.ThrowIfCancellationRequested();
 438                        return DeleteAsync_CreateResponse(clientDiagnostics, _response);
 439                    }
 440                }
 441                catch (System.Exception ex)
 442                {
 443                    _scope.Failed(ex);
 444                    throw;
 445                }
 446                finally
 447                {
 448                    _scope.Dispose();
 449                }
 450            }
 451
 452            /// <summary>
 453            /// Create the Blob.DeleteAsync request.
 454            /// </summary>
 455            /// <param name="pipeline">The pipeline used for sending requests.</param>
 456            /// <param name="resourceUri">The URL of the service account, container, or blob that is the targe of the de
 457            /// <param name="version">Specifies the version of the operation to use for this request.</param>
 458            /// <param name="snapshot">The snapshot parameter is an opaque DateTime value that, when present, specifies 
 459            /// <param name="timeout">The timeout parameter is expressed in seconds. For more information, see <a href="
 460            /// <param name="leaseId">If specified, the operation only succeeds if the resource's lease is active and ma
 461            /// <param name="deleteSnapshots">Required if the blob has associated snapshots. Specify one of the followin
 462            /// <param name="ifModifiedSince">Specify this header value to operate only on a blob if it has been modifie
 463            /// <param name="ifUnmodifiedSince">Specify this header value to operate only on a blob if it has not been m
 464            /// <param name="ifMatch">Specify an ETag value to operate only on blobs with a matching value.</param>
 465            /// <param name="ifNoneMatch">Specify an ETag value to operate only on blobs without a matching value.</para
 466            /// <param name="requestId">Provides a client-generated, opaque value with a 1 KB character limit that is re
 467            /// <returns>The Blob.DeleteAsync Message.</returns>
 468            internal static Azure.Core.HttpMessage DeleteAsync_CreateMessage(
 469                Azure.Core.Pipeline.HttpPipeline pipeline,
 470                System.Uri resourceUri,
 471                string version,
 472                string snapshot = default,
 473                int? timeout = default,
 474                string leaseId = default,
 475                Azure.Storage.Blobs.Models.DeleteSnapshotsOption? deleteSnapshots = default,
 476                System.DateTimeOffset? ifModifiedSince = default,
 477                System.DateTimeOffset? ifUnmodifiedSince = default,
 478                Azure.ETag? ifMatch = default,
 479                Azure.ETag? ifNoneMatch = default,
 480                string requestId = default)
 481            {
 482                // Validation
 483                if (resourceUri == null)
 484                {
 485                    throw new System.ArgumentNullException(nameof(resourceUri));
 486                }
 487                if (version == null)
 488                {
 489                    throw new System.ArgumentNullException(nameof(version));
 490                }
 491
 492                // Create the request
 493                Azure.Core.HttpMessage _message = pipeline.CreateMessage();
 494                Azure.Core.Request _request = _message.Request;
 495
 496                // Set the endpoint
 497                _request.Method = Azure.Core.RequestMethod.Delete;
 498                _request.Uri.Reset(resourceUri);
 499                if (snapshot != null) { _request.Uri.AppendQuery("snapshot", snapshot); }
 500                if (timeout != null) { _request.Uri.AppendQuery("timeout", timeout.Value.ToString(System.Globalization.C
 501
 502                // Add request headers
 503                _request.Headers.SetValue("x-ms-version", version);
 504                if (leaseId != null) { _request.Headers.SetValue("x-ms-lease-id", leaseId); }
 505                if (deleteSnapshots != null) { _request.Headers.SetValue("x-ms-delete-snapshots", Azure.Storage.Blobs.Ba
 506                if (ifModifiedSince != null) { _request.Headers.SetValue("If-Modified-Since", ifModifiedSince.Value.ToSt
 507                if (ifUnmodifiedSince != null) { _request.Headers.SetValue("If-Unmodified-Since", ifUnmodifiedSince.Valu
 508                if (ifMatch != null) { _request.Headers.SetValue("If-Match", ifMatch.Value.ToString()); }
 509                if (ifNoneMatch != null) { _request.Headers.SetValue("If-None-Match", ifNoneMatch.Value.ToString()); }
 510                if (requestId != null) { _request.Headers.SetValue("x-ms-client-request-id", requestId); }
 511
 512                return _message;
 513            }
 514
 515            /// <summary>
 516            /// Create the Blob.DeleteAsync response or throw a failure exception.
 517            /// </summary>
 518            /// <param name="clientDiagnostics">The ClientDiagnostics instance to use.</param>
 519            /// <param name="response">The raw Response.</param>
 520            /// <returns>The Blob.DeleteAsync Azure.Response.</returns>
 521            internal static Azure.Response DeleteAsync_CreateResponse(
 522                Azure.Core.Pipeline.ClientDiagnostics clientDiagnostics,
 523                Azure.Response response)
 524            {
 525                // Process the response
 526                switch (response.Status)
 527                {
 528                    case 202:
 529                    {
 530                        return response;
 531                    }
 532                    default:
 533                    {
 534                        // Create the result
 535                        System.Xml.Linq.XDocument _xml = System.Xml.Linq.XDocument.Load(response.ContentStream, System.X
 536                        Azure.Storage.Blobs.Models.StorageError _value = Azure.Storage.Blobs.Models.StorageError.FromXml
 537
 538                        throw _value.CreateException(clientDiagnostics, response);
 539                    }
 540                }
 541            }
 542            #endregion Blob.DeleteAsync
 543        }
 544        #endregion Blob operations
 545    }
 546}
 547#endregion Service
 548
 549#region Models
 550
 551#region class BlobBatchResult
 552namespace Azure.Storage.Blobs.Models
 553{
 554    /// <summary>
 555    /// BlobBatchResult
 556    /// </summary>
 557    internal partial class BlobBatchResult
 558    {
 559        /// <summary>
 560        /// The media type of the body of the response. For batch requests, this is multipart/mixed; boundary=batchrespo
 561        /// </summary>
 562        public string ContentType { get; internal set; }
 563
 564        /// <summary>
 565        /// Content
 566        /// </summary>
 567        public System.IO.Stream Content { get; internal set; }
 568
 569        /// <summary>
 570        /// Prevent direct instantiation of BlobBatchResult instances.
 571        /// You can use BlobsModelFactory.BlobBatchResult instead.
 572        /// </summary>
 573        internal BlobBatchResult() { }
 574    }
 575}
 576#endregion class BlobBatchResult
 577
 578#region enum DeleteSnapshotsOption
 579
 580namespace Azure.Storage.Blobs
 581{
 582    internal static partial class BatchRestClient
 583    {
 584        public static partial class Serialization
 585        {
 586            public static string ToString(Azure.Storage.Blobs.Models.DeleteSnapshotsOption value)
 587            {
 588                return value switch
 589                {
 590                    Azure.Storage.Blobs.Models.DeleteSnapshotsOption.None => null,
 591                    Azure.Storage.Blobs.Models.DeleteSnapshotsOption.IncludeSnapshots => "include",
 592                    Azure.Storage.Blobs.Models.DeleteSnapshotsOption.OnlySnapshots => "only",
 593                    _ => throw new System.ArgumentOutOfRangeException(nameof(value), value, "Unknown Azure.Storage.Blobs
 594                };
 595            }
 596
 597            public static Azure.Storage.Blobs.Models.DeleteSnapshotsOption ParseDeleteSnapshotsOption(string value)
 598            {
 599                return value switch
 600                {
 601                    null => Azure.Storage.Blobs.Models.DeleteSnapshotsOption.None,
 602                    "include" => Azure.Storage.Blobs.Models.DeleteSnapshotsOption.IncludeSnapshots,
 603                    "only" => Azure.Storage.Blobs.Models.DeleteSnapshotsOption.OnlySnapshots,
 604                    _ => throw new System.ArgumentOutOfRangeException(nameof(value), value, "Unknown Azure.Storage.Blobs
 605                };
 606            }
 607        }
 608    }
 609}
 610#endregion enum DeleteSnapshotsOption
 611
 612#region enum RehydratePriority
 613#endregion enum RehydratePriority
 614
 615#region class StorageError
 616namespace Azure.Storage.Blobs.Models
 617{
 618    /// <summary>
 619    /// StorageError
 620    /// </summary>
 621    internal partial class StorageError
 622    {
 623        /// <summary>
 624        /// Message
 625        /// </summary>
 112626        public string Message { get; internal set; }
 627
 628        /// <summary>
 629        /// Code
 630        /// </summary>
 112631        public string Code { get; internal set; }
 632
 633        /// <summary>
 634        /// Prevent direct instantiation of StorageError instances.
 635        /// You can use BlobsModelFactory.StorageError instead.
 636        /// </summary>
 112637        internal StorageError() { }
 638
 639        /// <summary>
 640        /// Deserializes XML into a new StorageError instance.
 641        /// </summary>
 642        /// <param name="element">The XML element to deserialize.</param>
 643        /// <returns>A deserialized StorageError instance.</returns>
 644        internal static Azure.Storage.Blobs.Models.StorageError FromXml(System.Xml.Linq.XElement element)
 645        {
 646            System.Diagnostics.Debug.Assert(element != null);
 647            System.Xml.Linq.XElement _child;
 56648            Azure.Storage.Blobs.Models.StorageError _value = new Azure.Storage.Blobs.Models.StorageError();
 56649            _child = element.Element(System.Xml.Linq.XName.Get("Message", ""));
 56650            if (_child != null)
 651            {
 56652                _value.Message = _child.Value;
 653            }
 56654            _child = element.Element(System.Xml.Linq.XName.Get("Code", ""));
 56655            if (_child != null)
 656            {
 56657                _value.Code = _child.Value;
 658            }
 56659            CustomizeFromXml(element, _value);
 56660            return _value;
 661        }
 662
 663        static partial void CustomizeFromXml(System.Xml.Linq.XElement element, Azure.Storage.Blobs.Models.StorageError v
 664    }
 665}
 666#endregion class StorageError
 667#endregion Models
 668

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.Batch\src\Models\StorageError.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Xml.Linq;
 7using Azure.Core.Pipeline;
 8
 9namespace Azure.Storage.Blobs.Models
 10{
 11    /// <summary>
 12    /// Convert StorageErrors into StorageRequestFailedExceptions.
 13    /// </summary>
 14    internal partial class StorageError
 15    {
 16        /// <summary>
 17        /// Additional error information.
 18        /// </summary>
 11619        public IDictionary<string, string> AdditionalInformation { get; } = new Dictionary<string, string>();
 20
 21        /// <summary>
 22        /// Get any additional XML elements for the error.
 23        /// </summary>
 24        /// <param name="root">The XML element</param>
 25        /// <param name="error">The StorageError</param>
 26        static partial void CustomizeFromXml(XElement root, StorageError error)
 27        {
 34428            foreach (XElement element in root.Elements())
 29            {
 11630                switch (element.Name.LocalName)
 31                {
 32                    case Constants.Xml.Code:
 33                    case Constants.Xml.Message:
 34                        continue;
 35                    default:
 436                        error.AdditionalInformation[element.Name.LocalName] = element.Value;
 37                        break;
 38                }
 39            }
 5640        }
 41
 42        /// <summary>
 43        /// Create an exception corresponding to the StorageError.
 44        /// </summary>
 45        /// <param name="clientDiagnostics">The <see cref="ClientDiagnostics"/> instance to use.</param>
 46        /// <param name="response">The failed response.</param>
 47        /// <returns>A RequestFailedException.</returns>
 48        public Exception CreateException(ClientDiagnostics clientDiagnostics, Azure.Response response)
 5649            => clientDiagnostics.CreateRequestFailedExceptionWithContent(response, message: Message, content: null, erro
 50    }
 51}