| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using Azure.Core; |
| | 6 | | using Azure.Core.Pipeline; |
| | 7 | | using Azure.Storage.Queues.Specialized; |
| | 8 | |
|
| | 9 | | namespace Azure.Storage.Queues |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Provides the client configuration options for connecting to Azure Queue |
| | 13 | | /// Storage |
| | 14 | | /// </summary> |
| | 15 | | public class QueueClientOptions : ClientOptions |
| | 16 | | { |
| | 17 | | /// <summary> |
| | 18 | | /// The Latest service version supported by this client library. |
| | 19 | | /// </summary> |
| | 20 | | internal const ServiceVersion LatestVersion = StorageVersionExtensions.LatestVersion; |
| | 21 | |
|
| | 22 | | /// <summary> |
| | 23 | | /// The versions of Azure Queue Storage supported by this client |
| | 24 | | /// library. |
| | 25 | | /// |
| | 26 | | /// For more information, see |
| | 27 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/versioning-for-the-azure-storage-servic |
| | 28 | | /// Versioning for the Azure Storage services</see>. |
| | 29 | | /// </summary> |
| | 30 | | public enum ServiceVersion |
| | 31 | | { |
| | 32 | | #pragma warning disable CA1707 // Identifiers should not contain underscores |
| | 33 | | /// <summary> |
| | 34 | | /// The 2019-02-02 service version described at |
| | 35 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/version-2019-02-02"> |
| | 36 | | /// Version 2019-02-02</see>. |
| | 37 | | /// </summary> |
| | 38 | | V2019_02_02 = 1, |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// The 2019-07-07 service version described at |
| | 42 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/version-2019-07-07"> |
| | 43 | | /// Version 2019-07-07</see>. |
| | 44 | | /// </summary> |
| | 45 | | V2019_07_07 = 2, |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// The 2019-12-12 service version. |
| | 49 | | /// </summary> |
| | 50 | | V2019_12_12 = 3 |
| | 51 | | #pragma warning restore CA1707 // Identifiers should not contain underscores |
| | 52 | | } |
| | 53 | |
|
| | 54 | | /// <summary> |
| | 55 | | /// Gets the <see cref="ServiceVersion"/> of the service API used when |
| | 56 | | /// making requests. For more, see |
| | 57 | | /// For more information, see |
| | 58 | | /// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/versioning-for-the-azure-storage-servic |
| | 59 | | /// Versioning for the Azure Storage services</see>. |
| | 60 | | /// </summary> |
| 336 | 61 | | public ServiceVersion Version { get; } |
| | 62 | |
|
| | 63 | | /// <summary> |
| | 64 | | /// Initializes a new instance of the <see cref="QueueClientOptions"/> |
| | 65 | | /// class. |
| | 66 | | /// </summary> |
| | 67 | | /// <param name="version"> |
| | 68 | | /// The <see cref="ServiceVersion"/> of the service API used when |
| | 69 | | /// making requests. |
| | 70 | | /// </param> |
| 336 | 71 | | public QueueClientOptions(ServiceVersion version = LatestVersion) |
| | 72 | | { |
| 336 | 73 | | if (ServiceVersion.V2019_02_02 <= version |
| 336 | 74 | | && version <= LatestVersion) |
| | 75 | | { |
| 336 | 76 | | Version = version; |
| | 77 | | } |
| | 78 | | else |
| | 79 | | { |
| 0 | 80 | | throw Errors.VersionNotSupported(nameof(version)); |
| | 81 | | } |
| | 82 | |
|
| 336 | 83 | | this.Initialize(); |
| 336 | 84 | | AddHeadersAndQueryParameters(); |
| 336 | 85 | | } |
| | 86 | |
|
| | 87 | | /// <summary> |
| | 88 | | /// Gets or sets the secondary storage <see cref="Uri"/> that can be read from for the storage account if the |
| | 89 | | /// account is enabled for RA-GRS. |
| | 90 | | /// |
| | 91 | | /// If this property is set, the secondary Uri will be used for GET or HEAD requests during retries. |
| | 92 | | /// If the status of the response from the secondary Uri is a 404, then subsequent retries for |
| | 93 | | /// the request will not use the secondary Uri again, as this indicates that the resource |
| | 94 | | /// may not have propagated there yet. Otherwise, subsequent retries will alternate back and forth |
| | 95 | | /// between primary and secondary Uri. |
| | 96 | | /// </summary> |
| 376 | 97 | | public Uri GeoRedundantSecondaryUri { get; set; } |
| | 98 | |
|
| | 99 | | #region Advanced Options |
| | 100 | | internal ClientSideEncryptionOptions _clientSideEncryptionOptions; |
| | 101 | | #endregion |
| | 102 | |
|
| | 103 | | /// <summary> |
| | 104 | | /// Add headers and query parameters in <see cref="DiagnosticsOptions.LoggedHeaderNames"/> and <see cref="Diagno |
| | 105 | | /// </summary> |
| | 106 | | private void AddHeadersAndQueryParameters() |
| | 107 | | { |
| 336 | 108 | | Diagnostics.LoggedHeaderNames.Add("Access-Control-Allow-Origin"); |
| 336 | 109 | | Diagnostics.LoggedHeaderNames.Add("x-ms-date"); |
| 336 | 110 | | Diagnostics.LoggedHeaderNames.Add("x-ms-error-code"); |
| 336 | 111 | | Diagnostics.LoggedHeaderNames.Add("x-ms-request-id"); |
| 336 | 112 | | Diagnostics.LoggedHeaderNames.Add("x-ms-version"); |
| 336 | 113 | | Diagnostics.LoggedHeaderNames.Add("x-ms-approximate-messages-count"); |
| 336 | 114 | | Diagnostics.LoggedHeaderNames.Add("x-ms-popreceipt"); |
| 336 | 115 | | Diagnostics.LoggedHeaderNames.Add("x-ms-time-next-visible"); |
| | 116 | |
|
| 336 | 117 | | Diagnostics.LoggedQueryParameters.Add("comp"); |
| 336 | 118 | | Diagnostics.LoggedQueryParameters.Add("maxresults"); |
| 336 | 119 | | Diagnostics.LoggedQueryParameters.Add("rscc"); |
| 336 | 120 | | Diagnostics.LoggedQueryParameters.Add("rscd"); |
| 336 | 121 | | Diagnostics.LoggedQueryParameters.Add("rsce"); |
| 336 | 122 | | Diagnostics.LoggedQueryParameters.Add("rscl"); |
| 336 | 123 | | Diagnostics.LoggedQueryParameters.Add("rsct"); |
| 336 | 124 | | Diagnostics.LoggedQueryParameters.Add("se"); |
| 336 | 125 | | Diagnostics.LoggedQueryParameters.Add("si"); |
| 336 | 126 | | Diagnostics.LoggedQueryParameters.Add("sip"); |
| 336 | 127 | | Diagnostics.LoggedQueryParameters.Add("sp"); |
| 336 | 128 | | Diagnostics.LoggedQueryParameters.Add("spr"); |
| 336 | 129 | | Diagnostics.LoggedQueryParameters.Add("sr"); |
| 336 | 130 | | Diagnostics.LoggedQueryParameters.Add("srt"); |
| 336 | 131 | | Diagnostics.LoggedQueryParameters.Add("ss"); |
| 336 | 132 | | Diagnostics.LoggedQueryParameters.Add("st"); |
| 336 | 133 | | Diagnostics.LoggedQueryParameters.Add("sv"); |
| 336 | 134 | | Diagnostics.LoggedQueryParameters.Add("include"); |
| 336 | 135 | | Diagnostics.LoggedQueryParameters.Add("marker"); |
| 336 | 136 | | Diagnostics.LoggedQueryParameters.Add("prefix"); |
| 336 | 137 | | Diagnostics.LoggedQueryParameters.Add("messagettl"); |
| 336 | 138 | | Diagnostics.LoggedQueryParameters.Add("numofmessages"); |
| 336 | 139 | | Diagnostics.LoggedQueryParameters.Add("peekonly"); |
| 336 | 140 | | Diagnostics.LoggedQueryParameters.Add("popreceipt"); |
| 336 | 141 | | Diagnostics.LoggedQueryParameters.Add("visibilitytimeout"); |
| 336 | 142 | | } |
| | 143 | |
|
| | 144 | | /// <summary> |
| | 145 | | /// Create an HttpPipeline from QueueClientOptions. |
| | 146 | | /// </summary> |
| | 147 | | /// <param name="authentication">Optional authentication policy.</param> |
| | 148 | | /// <returns>An HttpPipeline to use for Storage requests.</returns> |
| | 149 | | internal HttpPipeline Build(HttpPipelinePolicy authentication = null) |
| | 150 | | { |
| 312 | 151 | | return this.Build(authentication, GeoRedundantSecondaryUri); |
| | 152 | | } |
| | 153 | |
|
| | 154 | | /// <summary> |
| | 155 | | /// Create an HttpPipeline from QueueClientOptions. |
| | 156 | | /// </summary> |
| | 157 | | /// <param name="credentials">Optional authentication credentials.</param> |
| | 158 | | /// <returns>An HttpPipeline to use for Storage requests.</returns> |
| | 159 | | internal HttpPipeline Build(object credentials) |
| | 160 | | { |
| 24 | 161 | | return this.Build(credentials, GeoRedundantSecondaryUri); |
| | 162 | | } |
| | 163 | | } |
| | 164 | | } |