| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Storage.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Storage |
| | 18 | | { |
| | 19 | | internal partial class BlobServicesRestOperations |
| | 20 | | { |
| | 21 | | private string subscriptionId; |
| | 22 | | private Uri endpoint; |
| | 23 | | private string apiVersion; |
| | 24 | | private ClientDiagnostics _clientDiagnostics; |
| | 25 | | private HttpPipeline _pipeline; |
| | 26 | |
|
| | 27 | | /// <summary> Initializes a new instance of BlobServicesRestOperations. </summary> |
| | 28 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 29 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 30 | | /// <param name="subscriptionId"> The ID of the target subscription. </param> |
| | 31 | | /// <param name="endpoint"> server parameter. </param> |
| | 32 | | /// <param name="apiVersion"> Api Version. </param> |
| | 33 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 240 | 34 | | public BlobServicesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio |
| | 35 | | { |
| 240 | 36 | | if (subscriptionId == null) |
| | 37 | | { |
| 0 | 38 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 39 | | } |
| 240 | 40 | | endpoint ??= new Uri("https://management.azure.com"); |
| 240 | 41 | | if (apiVersion == null) |
| | 42 | | { |
| 0 | 43 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 44 | | } |
| | 45 | |
|
| 240 | 46 | | this.subscriptionId = subscriptionId; |
| 240 | 47 | | this.endpoint = endpoint; |
| 240 | 48 | | this.apiVersion = apiVersion; |
| 240 | 49 | | _clientDiagnostics = clientDiagnostics; |
| 240 | 50 | | _pipeline = pipeline; |
| 240 | 51 | | } |
| | 52 | |
|
| | 53 | | internal HttpMessage CreateListRequest(string resourceGroupName, string accountName) |
| | 54 | | { |
| 4 | 55 | | var message = _pipeline.CreateMessage(); |
| 4 | 56 | | var request = message.Request; |
| 4 | 57 | | request.Method = RequestMethod.Get; |
| 4 | 58 | | var uri = new RawRequestUriBuilder(); |
| 4 | 59 | | uri.Reset(endpoint); |
| 4 | 60 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 61 | | uri.AppendPath(subscriptionId, true); |
| 4 | 62 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 63 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 64 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 4 | 65 | | uri.AppendPath(accountName, true); |
| 4 | 66 | | uri.AppendPath("/blobServices", false); |
| 4 | 67 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 68 | | request.Uri = uri; |
| 4 | 69 | | return message; |
| | 70 | | } |
| | 71 | |
|
| | 72 | | /// <summary> List blob services of storage account. It returns a collection of one object named default. </summ |
| | 73 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 74 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 75 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 76 | | public async Task<Response<BlobServiceItems>> ListAsync(string resourceGroupName, string accountName, Cancellati |
| | 77 | | { |
| 2 | 78 | | if (resourceGroupName == null) |
| | 79 | | { |
| 0 | 80 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 81 | | } |
| 2 | 82 | | if (accountName == null) |
| | 83 | | { |
| 0 | 84 | | throw new ArgumentNullException(nameof(accountName)); |
| | 85 | | } |
| | 86 | |
|
| 2 | 87 | | using var message = CreateListRequest(resourceGroupName, accountName); |
| 2 | 88 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 89 | | switch (message.Response.Status) |
| | 90 | | { |
| | 91 | | case 200: |
| | 92 | | { |
| 2 | 93 | | BlobServiceItems value = default; |
| 2 | 94 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 95 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 96 | | { |
| 0 | 97 | | value = null; |
| | 98 | | } |
| | 99 | | else |
| | 100 | | { |
| 2 | 101 | | value = BlobServiceItems.DeserializeBlobServiceItems(document.RootElement); |
| | 102 | | } |
| 2 | 103 | | return Response.FromValue(value, message.Response); |
| | 104 | | } |
| | 105 | | default: |
| 0 | 106 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 107 | | } |
| 2 | 108 | | } |
| | 109 | |
|
| | 110 | | /// <summary> List blob services of storage account. It returns a collection of one object named default. </summ |
| | 111 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 112 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 113 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 114 | | public Response<BlobServiceItems> List(string resourceGroupName, string accountName, CancellationToken cancellat |
| | 115 | | { |
| 2 | 116 | | if (resourceGroupName == null) |
| | 117 | | { |
| 0 | 118 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 119 | | } |
| 2 | 120 | | if (accountName == null) |
| | 121 | | { |
| 0 | 122 | | throw new ArgumentNullException(nameof(accountName)); |
| | 123 | | } |
| | 124 | |
|
| 2 | 125 | | using var message = CreateListRequest(resourceGroupName, accountName); |
| 2 | 126 | | _pipeline.Send(message, cancellationToken); |
| 2 | 127 | | switch (message.Response.Status) |
| | 128 | | { |
| | 129 | | case 200: |
| | 130 | | { |
| 2 | 131 | | BlobServiceItems value = default; |
| 2 | 132 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 133 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 134 | | { |
| 0 | 135 | | value = null; |
| | 136 | | } |
| | 137 | | else |
| | 138 | | { |
| 2 | 139 | | value = BlobServiceItems.DeserializeBlobServiceItems(document.RootElement); |
| | 140 | | } |
| 2 | 141 | | return Response.FromValue(value, message.Response); |
| | 142 | | } |
| | 143 | | default: |
| 0 | 144 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 145 | | } |
| 2 | 146 | | } |
| | 147 | |
|
| | 148 | | internal HttpMessage CreateSetServicePropertiesRequest(string resourceGroupName, string accountName, BlobService |
| | 149 | | { |
| 16 | 150 | | var message = _pipeline.CreateMessage(); |
| 16 | 151 | | var request = message.Request; |
| 16 | 152 | | request.Method = RequestMethod.Put; |
| 16 | 153 | | var uri = new RawRequestUriBuilder(); |
| 16 | 154 | | uri.Reset(endpoint); |
| 16 | 155 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 156 | | uri.AppendPath(subscriptionId, true); |
| 16 | 157 | | uri.AppendPath("/resourceGroups/", false); |
| 16 | 158 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 159 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 16 | 160 | | uri.AppendPath(accountName, true); |
| 16 | 161 | | uri.AppendPath("/blobServices/", false); |
| 16 | 162 | | uri.AppendPath("default", true); |
| 16 | 163 | | uri.AppendQuery("api-version", apiVersion, true); |
| 16 | 164 | | request.Uri = uri; |
| 16 | 165 | | request.Headers.Add("Content-Type", "application/json"); |
| 16 | 166 | | var content = new Utf8JsonRequestContent(); |
| 16 | 167 | | content.JsonWriter.WriteObjectValue(parameters); |
| 16 | 168 | | request.Content = content; |
| 16 | 169 | | return message; |
| | 170 | | } |
| | 171 | |
|
| | 172 | | /// <summary> Sets the properties of a storage account’s Blob service, including properties for Storage Analytic |
| | 173 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 174 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 175 | | /// <param name="parameters"> The properties of a storage account’s Blob service, including properties for Stora |
| | 176 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 177 | | public async Task<Response<BlobServiceProperties>> SetServicePropertiesAsync(string resourceGroupName, string ac |
| | 178 | | { |
| 8 | 179 | | if (resourceGroupName == null) |
| | 180 | | { |
| 0 | 181 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 182 | | } |
| 8 | 183 | | if (accountName == null) |
| | 184 | | { |
| 0 | 185 | | throw new ArgumentNullException(nameof(accountName)); |
| | 186 | | } |
| 8 | 187 | | if (parameters == null) |
| | 188 | | { |
| 0 | 189 | | throw new ArgumentNullException(nameof(parameters)); |
| | 190 | | } |
| | 191 | |
|
| 8 | 192 | | using var message = CreateSetServicePropertiesRequest(resourceGroupName, accountName, parameters); |
| 8 | 193 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 8 | 194 | | switch (message.Response.Status) |
| | 195 | | { |
| | 196 | | case 200: |
| | 197 | | { |
| 8 | 198 | | BlobServiceProperties value = default; |
| 8 | 199 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 8 | 200 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 201 | | { |
| 0 | 202 | | value = null; |
| | 203 | | } |
| | 204 | | else |
| | 205 | | { |
| 8 | 206 | | value = BlobServiceProperties.DeserializeBlobServiceProperties(document.RootElement); |
| | 207 | | } |
| 8 | 208 | | return Response.FromValue(value, message.Response); |
| | 209 | | } |
| | 210 | | default: |
| 0 | 211 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 212 | | } |
| 8 | 213 | | } |
| | 214 | |
|
| | 215 | | /// <summary> Sets the properties of a storage account’s Blob service, including properties for Storage Analytic |
| | 216 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 217 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 218 | | /// <param name="parameters"> The properties of a storage account’s Blob service, including properties for Stora |
| | 219 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 220 | | public Response<BlobServiceProperties> SetServiceProperties(string resourceGroupName, string accountName, BlobSe |
| | 221 | | { |
| 8 | 222 | | if (resourceGroupName == null) |
| | 223 | | { |
| 0 | 224 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 225 | | } |
| 8 | 226 | | if (accountName == null) |
| | 227 | | { |
| 0 | 228 | | throw new ArgumentNullException(nameof(accountName)); |
| | 229 | | } |
| 8 | 230 | | if (parameters == null) |
| | 231 | | { |
| 0 | 232 | | throw new ArgumentNullException(nameof(parameters)); |
| | 233 | | } |
| | 234 | |
|
| 8 | 235 | | using var message = CreateSetServicePropertiesRequest(resourceGroupName, accountName, parameters); |
| 8 | 236 | | _pipeline.Send(message, cancellationToken); |
| 8 | 237 | | switch (message.Response.Status) |
| | 238 | | { |
| | 239 | | case 200: |
| | 240 | | { |
| 8 | 241 | | BlobServiceProperties value = default; |
| 8 | 242 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 8 | 243 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 244 | | { |
| 0 | 245 | | value = null; |
| | 246 | | } |
| | 247 | | else |
| | 248 | | { |
| 8 | 249 | | value = BlobServiceProperties.DeserializeBlobServiceProperties(document.RootElement); |
| | 250 | | } |
| 8 | 251 | | return Response.FromValue(value, message.Response); |
| | 252 | | } |
| | 253 | | default: |
| 0 | 254 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 255 | | } |
| 8 | 256 | | } |
| | 257 | |
|
| | 258 | | internal HttpMessage CreateGetServicePropertiesRequest(string resourceGroupName, string accountName) |
| | 259 | | { |
| 32 | 260 | | var message = _pipeline.CreateMessage(); |
| 32 | 261 | | var request = message.Request; |
| 32 | 262 | | request.Method = RequestMethod.Get; |
| 32 | 263 | | var uri = new RawRequestUriBuilder(); |
| 32 | 264 | | uri.Reset(endpoint); |
| 32 | 265 | | uri.AppendPath("/subscriptions/", false); |
| 32 | 266 | | uri.AppendPath(subscriptionId, true); |
| 32 | 267 | | uri.AppendPath("/resourceGroups/", false); |
| 32 | 268 | | uri.AppendPath(resourceGroupName, true); |
| 32 | 269 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 32 | 270 | | uri.AppendPath(accountName, true); |
| 32 | 271 | | uri.AppendPath("/blobServices/", false); |
| 32 | 272 | | uri.AppendPath("default", true); |
| 32 | 273 | | uri.AppendQuery("api-version", apiVersion, true); |
| 32 | 274 | | request.Uri = uri; |
| 32 | 275 | | return message; |
| | 276 | | } |
| | 277 | |
|
| | 278 | | /// <summary> Gets the properties of a storage account’s Blob service, including properties for Storage Analytic |
| | 279 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 280 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 281 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 282 | | public async Task<Response<BlobServiceProperties>> GetServicePropertiesAsync(string resourceGroupName, string ac |
| | 283 | | { |
| 16 | 284 | | if (resourceGroupName == null) |
| | 285 | | { |
| 0 | 286 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 287 | | } |
| 16 | 288 | | if (accountName == null) |
| | 289 | | { |
| 0 | 290 | | throw new ArgumentNullException(nameof(accountName)); |
| | 291 | | } |
| | 292 | |
|
| 16 | 293 | | using var message = CreateGetServicePropertiesRequest(resourceGroupName, accountName); |
| 16 | 294 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 16 | 295 | | switch (message.Response.Status) |
| | 296 | | { |
| | 297 | | case 200: |
| | 298 | | { |
| 16 | 299 | | BlobServiceProperties value = default; |
| 16 | 300 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 16 | 301 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 302 | | { |
| 0 | 303 | | value = null; |
| | 304 | | } |
| | 305 | | else |
| | 306 | | { |
| 16 | 307 | | value = BlobServiceProperties.DeserializeBlobServiceProperties(document.RootElement); |
| | 308 | | } |
| 16 | 309 | | return Response.FromValue(value, message.Response); |
| | 310 | | } |
| | 311 | | default: |
| 0 | 312 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 313 | | } |
| 16 | 314 | | } |
| | 315 | |
|
| | 316 | | /// <summary> Gets the properties of a storage account’s Blob service, including properties for Storage Analytic |
| | 317 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 318 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 319 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 320 | | public Response<BlobServiceProperties> GetServiceProperties(string resourceGroupName, string accountName, Cancel |
| | 321 | | { |
| 16 | 322 | | if (resourceGroupName == null) |
| | 323 | | { |
| 0 | 324 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 325 | | } |
| 16 | 326 | | if (accountName == null) |
| | 327 | | { |
| 0 | 328 | | throw new ArgumentNullException(nameof(accountName)); |
| | 329 | | } |
| | 330 | |
|
| 16 | 331 | | using var message = CreateGetServicePropertiesRequest(resourceGroupName, accountName); |
| 16 | 332 | | _pipeline.Send(message, cancellationToken); |
| 16 | 333 | | switch (message.Response.Status) |
| | 334 | | { |
| | 335 | | case 200: |
| | 336 | | { |
| 16 | 337 | | BlobServiceProperties value = default; |
| 16 | 338 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 16 | 339 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 340 | | { |
| 0 | 341 | | value = null; |
| | 342 | | } |
| | 343 | | else |
| | 344 | | { |
| 16 | 345 | | value = BlobServiceProperties.DeserializeBlobServiceProperties(document.RootElement); |
| | 346 | | } |
| 16 | 347 | | return Response.FromValue(value, message.Response); |
| | 348 | | } |
| | 349 | | default: |
| 0 | 350 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 351 | | } |
| 16 | 352 | | } |
| | 353 | | } |
| | 354 | | } |