| | 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 StorageAccountsRestOperations |
| | 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 StorageAccountsRestOperations. </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 StorageAccountsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscrip |
| | 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 CreateCheckNameAvailabilityRequest(StorageAccountCheckNameAvailabilityParameters accountNam |
| | 54 | | { |
| 12 | 55 | | var message = _pipeline.CreateMessage(); |
| 12 | 56 | | var request = message.Request; |
| 12 | 57 | | request.Method = RequestMethod.Post; |
| 12 | 58 | | var uri = new RawRequestUriBuilder(); |
| 12 | 59 | | uri.Reset(endpoint); |
| 12 | 60 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 61 | | uri.AppendPath(subscriptionId, true); |
| 12 | 62 | | uri.AppendPath("/providers/Microsoft.Storage/checkNameAvailability", false); |
| 12 | 63 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 64 | | request.Uri = uri; |
| 12 | 65 | | request.Headers.Add("Content-Type", "application/json"); |
| 12 | 66 | | var content = new Utf8JsonRequestContent(); |
| 12 | 67 | | content.JsonWriter.WriteObjectValue(accountName); |
| 12 | 68 | | request.Content = content; |
| 12 | 69 | | return message; |
| | 70 | | } |
| | 71 | |
|
| | 72 | | /// <summary> Checks that the storage account name is valid and is not already in use. </summary> |
| | 73 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 74 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 75 | | public async Task<Response<CheckNameAvailabilityResult>> CheckNameAvailabilityAsync(StorageAccountCheckNameAvail |
| | 76 | | { |
| 6 | 77 | | if (accountName == null) |
| | 78 | | { |
| 0 | 79 | | throw new ArgumentNullException(nameof(accountName)); |
| | 80 | | } |
| | 81 | |
|
| 6 | 82 | | using var message = CreateCheckNameAvailabilityRequest(accountName); |
| 6 | 83 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 84 | | switch (message.Response.Status) |
| | 85 | | { |
| | 86 | | case 200: |
| | 87 | | { |
| 6 | 88 | | CheckNameAvailabilityResult value = default; |
| 6 | 89 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 90 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 91 | | { |
| 0 | 92 | | value = null; |
| | 93 | | } |
| | 94 | | else |
| | 95 | | { |
| 6 | 96 | | value = CheckNameAvailabilityResult.DeserializeCheckNameAvailabilityResult(document.RootElem |
| | 97 | | } |
| 6 | 98 | | return Response.FromValue(value, message.Response); |
| | 99 | | } |
| | 100 | | default: |
| 0 | 101 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 102 | | } |
| 6 | 103 | | } |
| | 104 | |
|
| | 105 | | /// <summary> Checks that the storage account name is valid and is not already in use. </summary> |
| | 106 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 107 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 108 | | public Response<CheckNameAvailabilityResult> CheckNameAvailability(StorageAccountCheckNameAvailabilityParameters |
| | 109 | | { |
| 6 | 110 | | if (accountName == null) |
| | 111 | | { |
| 0 | 112 | | throw new ArgumentNullException(nameof(accountName)); |
| | 113 | | } |
| | 114 | |
|
| 6 | 115 | | using var message = CreateCheckNameAvailabilityRequest(accountName); |
| 6 | 116 | | _pipeline.Send(message, cancellationToken); |
| 6 | 117 | | switch (message.Response.Status) |
| | 118 | | { |
| | 119 | | case 200: |
| | 120 | | { |
| 6 | 121 | | CheckNameAvailabilityResult value = default; |
| 6 | 122 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 123 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 124 | | { |
| 0 | 125 | | value = null; |
| | 126 | | } |
| | 127 | | else |
| | 128 | | { |
| 6 | 129 | | value = CheckNameAvailabilityResult.DeserializeCheckNameAvailabilityResult(document.RootElem |
| | 130 | | } |
| 6 | 131 | | return Response.FromValue(value, message.Response); |
| | 132 | | } |
| | 133 | | default: |
| 0 | 134 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 135 | | } |
| 6 | 136 | | } |
| | 137 | |
|
| | 138 | | internal HttpMessage CreateCreateRequest(string resourceGroupName, string accountName, StorageAccountCreateParam |
| | 139 | | { |
| 588 | 140 | | var message = _pipeline.CreateMessage(); |
| 588 | 141 | | var request = message.Request; |
| 588 | 142 | | request.Method = RequestMethod.Put; |
| 588 | 143 | | var uri = new RawRequestUriBuilder(); |
| 588 | 144 | | uri.Reset(endpoint); |
| 588 | 145 | | uri.AppendPath("/subscriptions/", false); |
| 588 | 146 | | uri.AppendPath(subscriptionId, true); |
| 588 | 147 | | uri.AppendPath("/resourceGroups/", false); |
| 588 | 148 | | uri.AppendPath(resourceGroupName, true); |
| 588 | 149 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 588 | 150 | | uri.AppendPath(accountName, true); |
| 588 | 151 | | uri.AppendQuery("api-version", apiVersion, true); |
| 588 | 152 | | request.Uri = uri; |
| 588 | 153 | | request.Headers.Add("Content-Type", "application/json"); |
| 588 | 154 | | var content = new Utf8JsonRequestContent(); |
| 588 | 155 | | content.JsonWriter.WriteObjectValue(parameters); |
| 588 | 156 | | request.Content = content; |
| 588 | 157 | | return message; |
| | 158 | | } |
| | 159 | |
|
| | 160 | | /// <summary> Asynchronously creates a new storage account with the specified parameters. If an account is alrea |
| | 161 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 162 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 163 | | /// <param name="parameters"> The parameters to provide for the created account. </param> |
| | 164 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 165 | | public async Task<Response> CreateAsync(string resourceGroupName, string accountName, StorageAccountCreateParame |
| | 166 | | { |
| 148 | 167 | | if (resourceGroupName == null) |
| | 168 | | { |
| 0 | 169 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 170 | | } |
| 148 | 171 | | if (accountName == null) |
| | 172 | | { |
| 0 | 173 | | throw new ArgumentNullException(nameof(accountName)); |
| | 174 | | } |
| 148 | 175 | | if (parameters == null) |
| | 176 | | { |
| 0 | 177 | | throw new ArgumentNullException(nameof(parameters)); |
| | 178 | | } |
| | 179 | |
|
| 148 | 180 | | using var message = CreateCreateRequest(resourceGroupName, accountName, parameters); |
| 148 | 181 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 148 | 182 | | switch (message.Response.Status) |
| | 183 | | { |
| | 184 | | case 200: |
| | 185 | | case 202: |
| 146 | 186 | | return message.Response; |
| | 187 | | default: |
| 2 | 188 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 189 | | } |
| 146 | 190 | | } |
| | 191 | |
|
| | 192 | | /// <summary> Asynchronously creates a new storage account with the specified parameters. If an account is alrea |
| | 193 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 194 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 195 | | /// <param name="parameters"> The parameters to provide for the created account. </param> |
| | 196 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 197 | | public Response Create(string resourceGroupName, string accountName, StorageAccountCreateParameters parameters, |
| | 198 | | { |
| 148 | 199 | | if (resourceGroupName == null) |
| | 200 | | { |
| 0 | 201 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 202 | | } |
| 148 | 203 | | if (accountName == null) |
| | 204 | | { |
| 0 | 205 | | throw new ArgumentNullException(nameof(accountName)); |
| | 206 | | } |
| 148 | 207 | | if (parameters == null) |
| | 208 | | { |
| 0 | 209 | | throw new ArgumentNullException(nameof(parameters)); |
| | 210 | | } |
| | 211 | |
|
| 148 | 212 | | using var message = CreateCreateRequest(resourceGroupName, accountName, parameters); |
| 148 | 213 | | _pipeline.Send(message, cancellationToken); |
| 148 | 214 | | switch (message.Response.Status) |
| | 215 | | { |
| | 216 | | case 200: |
| | 217 | | case 202: |
| 146 | 218 | | return message.Response; |
| | 219 | | default: |
| 2 | 220 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 221 | | } |
| 146 | 222 | | } |
| | 223 | |
|
| | 224 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string accountName) |
| | 225 | | { |
| 12 | 226 | | var message = _pipeline.CreateMessage(); |
| 12 | 227 | | var request = message.Request; |
| 12 | 228 | | request.Method = RequestMethod.Delete; |
| 12 | 229 | | var uri = new RawRequestUriBuilder(); |
| 12 | 230 | | uri.Reset(endpoint); |
| 12 | 231 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 232 | | uri.AppendPath(subscriptionId, true); |
| 12 | 233 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 234 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 235 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 12 | 236 | | uri.AppendPath(accountName, true); |
| 12 | 237 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 238 | | request.Uri = uri; |
| 12 | 239 | | return message; |
| | 240 | | } |
| | 241 | |
|
| | 242 | | /// <summary> Deletes a storage account in Microsoft Azure. </summary> |
| | 243 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 244 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 245 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 246 | | public async Task<Response> DeleteAsync(string resourceGroupName, string accountName, CancellationToken cancella |
| | 247 | | { |
| 6 | 248 | | if (resourceGroupName == null) |
| | 249 | | { |
| 0 | 250 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 251 | | } |
| 6 | 252 | | if (accountName == null) |
| | 253 | | { |
| 0 | 254 | | throw new ArgumentNullException(nameof(accountName)); |
| | 255 | | } |
| | 256 | |
|
| 6 | 257 | | using var message = CreateDeleteRequest(resourceGroupName, accountName); |
| 6 | 258 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 259 | | switch (message.Response.Status) |
| | 260 | | { |
| | 261 | | case 200: |
| | 262 | | case 204: |
| 6 | 263 | | return message.Response; |
| | 264 | | default: |
| 0 | 265 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 266 | | } |
| 6 | 267 | | } |
| | 268 | |
|
| | 269 | | /// <summary> Deletes a storage account in Microsoft Azure. </summary> |
| | 270 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 271 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 272 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 273 | | public Response Delete(string resourceGroupName, string accountName, CancellationToken cancellationToken = defau |
| | 274 | | { |
| 6 | 275 | | if (resourceGroupName == null) |
| | 276 | | { |
| 0 | 277 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 278 | | } |
| 6 | 279 | | if (accountName == null) |
| | 280 | | { |
| 0 | 281 | | throw new ArgumentNullException(nameof(accountName)); |
| | 282 | | } |
| | 283 | |
|
| 6 | 284 | | using var message = CreateDeleteRequest(resourceGroupName, accountName); |
| 6 | 285 | | _pipeline.Send(message, cancellationToken); |
| 6 | 286 | | switch (message.Response.Status) |
| | 287 | | { |
| | 288 | | case 200: |
| | 289 | | case 204: |
| 6 | 290 | | return message.Response; |
| | 291 | | default: |
| 0 | 292 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 293 | | } |
| 6 | 294 | | } |
| | 295 | |
|
| | 296 | | internal HttpMessage CreateGetPropertiesRequest(string resourceGroupName, string accountName, StorageAccountExpa |
| | 297 | | { |
| 116 | 298 | | var message = _pipeline.CreateMessage(); |
| 116 | 299 | | var request = message.Request; |
| 116 | 300 | | request.Method = RequestMethod.Get; |
| 116 | 301 | | var uri = new RawRequestUriBuilder(); |
| 116 | 302 | | uri.Reset(endpoint); |
| 116 | 303 | | uri.AppendPath("/subscriptions/", false); |
| 116 | 304 | | uri.AppendPath(subscriptionId, true); |
| 116 | 305 | | uri.AppendPath("/resourceGroups/", false); |
| 116 | 306 | | uri.AppendPath(resourceGroupName, true); |
| 116 | 307 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 116 | 308 | | uri.AppendPath(accountName, true); |
| 116 | 309 | | uri.AppendQuery("api-version", apiVersion, true); |
| 116 | 310 | | if (expand != null) |
| | 311 | | { |
| 4 | 312 | | uri.AppendQuery("$expand", expand.Value.ToSerialString(), true); |
| | 313 | | } |
| 116 | 314 | | request.Uri = uri; |
| 116 | 315 | | return message; |
| | 316 | | } |
| | 317 | |
|
| | 318 | | /// <summary> Returns the properties for the specified storage account including but not limited to name, SKU na |
| | 319 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 320 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 321 | | /// <param name="expand"> May be used to expand the properties within account's properties. By default, dat |
| | 322 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 323 | | public async Task<Response<StorageAccount>> GetPropertiesAsync(string resourceGroupName, string accountName, Sto |
| | 324 | | { |
| 58 | 325 | | if (resourceGroupName == null) |
| | 326 | | { |
| 0 | 327 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 328 | | } |
| 58 | 329 | | if (accountName == null) |
| | 330 | | { |
| 0 | 331 | | throw new ArgumentNullException(nameof(accountName)); |
| | 332 | | } |
| | 333 | |
|
| 58 | 334 | | using var message = CreateGetPropertiesRequest(resourceGroupName, accountName, expand); |
| 58 | 335 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 58 | 336 | | switch (message.Response.Status) |
| | 337 | | { |
| | 338 | | case 200: |
| | 339 | | { |
| 58 | 340 | | StorageAccount value = default; |
| 58 | 341 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 58 | 342 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 343 | | { |
| 0 | 344 | | value = null; |
| | 345 | | } |
| | 346 | | else |
| | 347 | | { |
| 58 | 348 | | value = StorageAccount.DeserializeStorageAccount(document.RootElement); |
| | 349 | | } |
| 58 | 350 | | return Response.FromValue(value, message.Response); |
| | 351 | | } |
| | 352 | | default: |
| 0 | 353 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 354 | | } |
| 58 | 355 | | } |
| | 356 | |
|
| | 357 | | /// <summary> Returns the properties for the specified storage account including but not limited to name, SKU na |
| | 358 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 359 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 360 | | /// <param name="expand"> May be used to expand the properties within account's properties. By default, dat |
| | 361 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 362 | | public Response<StorageAccount> GetProperties(string resourceGroupName, string accountName, StorageAccountExpand |
| | 363 | | { |
| 58 | 364 | | if (resourceGroupName == null) |
| | 365 | | { |
| 0 | 366 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 367 | | } |
| 58 | 368 | | if (accountName == null) |
| | 369 | | { |
| 0 | 370 | | throw new ArgumentNullException(nameof(accountName)); |
| | 371 | | } |
| | 372 | |
|
| 58 | 373 | | using var message = CreateGetPropertiesRequest(resourceGroupName, accountName, expand); |
| 58 | 374 | | _pipeline.Send(message, cancellationToken); |
| 58 | 375 | | switch (message.Response.Status) |
| | 376 | | { |
| | 377 | | case 200: |
| | 378 | | { |
| 58 | 379 | | StorageAccount value = default; |
| 58 | 380 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 58 | 381 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 382 | | { |
| 0 | 383 | | value = null; |
| | 384 | | } |
| | 385 | | else |
| | 386 | | { |
| 58 | 387 | | value = StorageAccount.DeserializeStorageAccount(document.RootElement); |
| | 388 | | } |
| 58 | 389 | | return Response.FromValue(value, message.Response); |
| | 390 | | } |
| | 391 | | default: |
| 0 | 392 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 393 | | } |
| 58 | 394 | | } |
| | 395 | |
|
| | 396 | | internal HttpMessage CreateUpdateRequest(string resourceGroupName, string accountName, StorageAccountUpdateParam |
| | 397 | | { |
| 60 | 398 | | var message = _pipeline.CreateMessage(); |
| 60 | 399 | | var request = message.Request; |
| 60 | 400 | | request.Method = RequestMethod.Patch; |
| 60 | 401 | | var uri = new RawRequestUriBuilder(); |
| 60 | 402 | | uri.Reset(endpoint); |
| 60 | 403 | | uri.AppendPath("/subscriptions/", false); |
| 60 | 404 | | uri.AppendPath(subscriptionId, true); |
| 60 | 405 | | uri.AppendPath("/resourceGroups/", false); |
| 60 | 406 | | uri.AppendPath(resourceGroupName, true); |
| 60 | 407 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 60 | 408 | | uri.AppendPath(accountName, true); |
| 60 | 409 | | uri.AppendQuery("api-version", apiVersion, true); |
| 60 | 410 | | request.Uri = uri; |
| 60 | 411 | | request.Headers.Add("Content-Type", "application/json"); |
| 60 | 412 | | var content = new Utf8JsonRequestContent(); |
| 60 | 413 | | content.JsonWriter.WriteObjectValue(parameters); |
| 60 | 414 | | request.Content = content; |
| 60 | 415 | | return message; |
| | 416 | | } |
| | 417 | |
|
| | 418 | | /// <summary> The update operation can be used to update the SKU, encryption, access tier, or tags for a storage |
| | 419 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 420 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 421 | | /// <param name="parameters"> The parameters to provide for the updated account. </param> |
| | 422 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 423 | | public async Task<Response<StorageAccount>> UpdateAsync(string resourceGroupName, string accountName, StorageAcc |
| | 424 | | { |
| 30 | 425 | | if (resourceGroupName == null) |
| | 426 | | { |
| 0 | 427 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 428 | | } |
| 30 | 429 | | if (accountName == null) |
| | 430 | | { |
| 0 | 431 | | throw new ArgumentNullException(nameof(accountName)); |
| | 432 | | } |
| 30 | 433 | | if (parameters == null) |
| | 434 | | { |
| 0 | 435 | | throw new ArgumentNullException(nameof(parameters)); |
| | 436 | | } |
| | 437 | |
|
| 30 | 438 | | using var message = CreateUpdateRequest(resourceGroupName, accountName, parameters); |
| 30 | 439 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 30 | 440 | | switch (message.Response.Status) |
| | 441 | | { |
| | 442 | | case 200: |
| | 443 | | { |
| 28 | 444 | | StorageAccount value = default; |
| 28 | 445 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 28 | 446 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 447 | | { |
| 0 | 448 | | value = null; |
| | 449 | | } |
| | 450 | | else |
| | 451 | | { |
| 28 | 452 | | value = StorageAccount.DeserializeStorageAccount(document.RootElement); |
| | 453 | | } |
| 28 | 454 | | return Response.FromValue(value, message.Response); |
| | 455 | | } |
| | 456 | | default: |
| 2 | 457 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 458 | | } |
| 28 | 459 | | } |
| | 460 | |
|
| | 461 | | /// <summary> The update operation can be used to update the SKU, encryption, access tier, or tags for a storage |
| | 462 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 463 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 464 | | /// <param name="parameters"> The parameters to provide for the updated account. </param> |
| | 465 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 466 | | public Response<StorageAccount> Update(string resourceGroupName, string accountName, StorageAccountUpdateParamet |
| | 467 | | { |
| 30 | 468 | | if (resourceGroupName == null) |
| | 469 | | { |
| 0 | 470 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 471 | | } |
| 30 | 472 | | if (accountName == null) |
| | 473 | | { |
| 0 | 474 | | throw new ArgumentNullException(nameof(accountName)); |
| | 475 | | } |
| 30 | 476 | | if (parameters == null) |
| | 477 | | { |
| 0 | 478 | | throw new ArgumentNullException(nameof(parameters)); |
| | 479 | | } |
| | 480 | |
|
| 30 | 481 | | using var message = CreateUpdateRequest(resourceGroupName, accountName, parameters); |
| 30 | 482 | | _pipeline.Send(message, cancellationToken); |
| 30 | 483 | | switch (message.Response.Status) |
| | 484 | | { |
| | 485 | | case 200: |
| | 486 | | { |
| 28 | 487 | | StorageAccount value = default; |
| 28 | 488 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 28 | 489 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 490 | | { |
| 0 | 491 | | value = null; |
| | 492 | | } |
| | 493 | | else |
| | 494 | | { |
| 28 | 495 | | value = StorageAccount.DeserializeStorageAccount(document.RootElement); |
| | 496 | | } |
| 28 | 497 | | return Response.FromValue(value, message.Response); |
| | 498 | | } |
| | 499 | | default: |
| 2 | 500 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 501 | | } |
| 28 | 502 | | } |
| | 503 | |
|
| | 504 | | internal HttpMessage CreateListRequest() |
| | 505 | | { |
| 4 | 506 | | var message = _pipeline.CreateMessage(); |
| 4 | 507 | | var request = message.Request; |
| 4 | 508 | | request.Method = RequestMethod.Get; |
| 4 | 509 | | var uri = new RawRequestUriBuilder(); |
| 4 | 510 | | uri.Reset(endpoint); |
| 4 | 511 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 512 | | uri.AppendPath(subscriptionId, true); |
| 4 | 513 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts", false); |
| 4 | 514 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 515 | | request.Uri = uri; |
| 4 | 516 | | return message; |
| | 517 | | } |
| | 518 | |
|
| | 519 | | /// <summary> Lists all the storage accounts available under the subscription. Note that storage keys are not re |
| | 520 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 521 | | public async Task<Response<StorageAccountListResult>> ListAsync(CancellationToken cancellationToken = default) |
| | 522 | | { |
| 2 | 523 | | using var message = CreateListRequest(); |
| 2 | 524 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 525 | | switch (message.Response.Status) |
| | 526 | | { |
| | 527 | | case 200: |
| | 528 | | { |
| 2 | 529 | | StorageAccountListResult value = default; |
| 2 | 530 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 531 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 532 | | { |
| 0 | 533 | | value = null; |
| | 534 | | } |
| | 535 | | else |
| | 536 | | { |
| 2 | 537 | | value = StorageAccountListResult.DeserializeStorageAccountListResult(document.RootElement); |
| | 538 | | } |
| 2 | 539 | | return Response.FromValue(value, message.Response); |
| | 540 | | } |
| | 541 | | default: |
| 0 | 542 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 543 | | } |
| 2 | 544 | | } |
| | 545 | |
|
| | 546 | | /// <summary> Lists all the storage accounts available under the subscription. Note that storage keys are not re |
| | 547 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 548 | | public Response<StorageAccountListResult> List(CancellationToken cancellationToken = default) |
| | 549 | | { |
| 2 | 550 | | using var message = CreateListRequest(); |
| 2 | 551 | | _pipeline.Send(message, cancellationToken); |
| 2 | 552 | | switch (message.Response.Status) |
| | 553 | | { |
| | 554 | | case 200: |
| | 555 | | { |
| 2 | 556 | | StorageAccountListResult value = default; |
| 2 | 557 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 558 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 559 | | { |
| 0 | 560 | | value = null; |
| | 561 | | } |
| | 562 | | else |
| | 563 | | { |
| 2 | 564 | | value = StorageAccountListResult.DeserializeStorageAccountListResult(document.RootElement); |
| | 565 | | } |
| 2 | 566 | | return Response.FromValue(value, message.Response); |
| | 567 | | } |
| | 568 | | default: |
| 0 | 569 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 570 | | } |
| 2 | 571 | | } |
| | 572 | |
|
| | 573 | | internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName) |
| | 574 | | { |
| 12 | 575 | | var message = _pipeline.CreateMessage(); |
| 12 | 576 | | var request = message.Request; |
| 12 | 577 | | request.Method = RequestMethod.Get; |
| 12 | 578 | | var uri = new RawRequestUriBuilder(); |
| 12 | 579 | | uri.Reset(endpoint); |
| 12 | 580 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 581 | | uri.AppendPath(subscriptionId, true); |
| 12 | 582 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 583 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 584 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts", false); |
| 12 | 585 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 586 | | request.Uri = uri; |
| 12 | 587 | | return message; |
| | 588 | | } |
| | 589 | |
|
| | 590 | | /// <summary> Lists all the storage accounts available under the given resource group. Note that storage keys ar |
| | 591 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 592 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 593 | | public async Task<Response<StorageAccountListResult>> ListByResourceGroupAsync(string resourceGroupName, Cancell |
| | 594 | | { |
| 6 | 595 | | if (resourceGroupName == null) |
| | 596 | | { |
| 0 | 597 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 598 | | } |
| | 599 | |
|
| 6 | 600 | | using var message = CreateListByResourceGroupRequest(resourceGroupName); |
| 6 | 601 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 602 | | switch (message.Response.Status) |
| | 603 | | { |
| | 604 | | case 200: |
| | 605 | | { |
| 6 | 606 | | StorageAccountListResult value = default; |
| 6 | 607 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 608 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 609 | | { |
| 0 | 610 | | value = null; |
| | 611 | | } |
| | 612 | | else |
| | 613 | | { |
| 6 | 614 | | value = StorageAccountListResult.DeserializeStorageAccountListResult(document.RootElement); |
| | 615 | | } |
| 6 | 616 | | return Response.FromValue(value, message.Response); |
| | 617 | | } |
| | 618 | | default: |
| 0 | 619 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 620 | | } |
| 6 | 621 | | } |
| | 622 | |
|
| | 623 | | /// <summary> Lists all the storage accounts available under the given resource group. Note that storage keys ar |
| | 624 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 625 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 626 | | public Response<StorageAccountListResult> ListByResourceGroup(string resourceGroupName, CancellationToken cancel |
| | 627 | | { |
| 6 | 628 | | if (resourceGroupName == null) |
| | 629 | | { |
| 0 | 630 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 631 | | } |
| | 632 | |
|
| 6 | 633 | | using var message = CreateListByResourceGroupRequest(resourceGroupName); |
| 6 | 634 | | _pipeline.Send(message, cancellationToken); |
| 6 | 635 | | switch (message.Response.Status) |
| | 636 | | { |
| | 637 | | case 200: |
| | 638 | | { |
| 6 | 639 | | StorageAccountListResult value = default; |
| 6 | 640 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 641 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 642 | | { |
| 0 | 643 | | value = null; |
| | 644 | | } |
| | 645 | | else |
| | 646 | | { |
| 6 | 647 | | value = StorageAccountListResult.DeserializeStorageAccountListResult(document.RootElement); |
| | 648 | | } |
| 6 | 649 | | return Response.FromValue(value, message.Response); |
| | 650 | | } |
| | 651 | | default: |
| 0 | 652 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 653 | | } |
| 6 | 654 | | } |
| | 655 | |
|
| | 656 | | internal HttpMessage CreateListKeysRequest(string resourceGroupName, string accountName) |
| | 657 | | { |
| 8 | 658 | | var message = _pipeline.CreateMessage(); |
| 8 | 659 | | var request = message.Request; |
| 8 | 660 | | request.Method = RequestMethod.Post; |
| 8 | 661 | | var uri = new RawRequestUriBuilder(); |
| 8 | 662 | | uri.Reset(endpoint); |
| 8 | 663 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 664 | | uri.AppendPath(subscriptionId, true); |
| 8 | 665 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 666 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 667 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 8 | 668 | | uri.AppendPath(accountName, true); |
| 8 | 669 | | uri.AppendPath("/listKeys", false); |
| 8 | 670 | | uri.AppendQuery("api-version", apiVersion, true); |
| 8 | 671 | | uri.AppendQuery("$expand", "kerb", true); |
| 8 | 672 | | request.Uri = uri; |
| 8 | 673 | | return message; |
| | 674 | | } |
| | 675 | |
|
| | 676 | | /// <summary> Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage acc |
| | 677 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 678 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 679 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 680 | | public async Task<Response<StorageAccountListKeysResult>> ListKeysAsync(string resourceGroupName, string account |
| | 681 | | { |
| 4 | 682 | | if (resourceGroupName == null) |
| | 683 | | { |
| 0 | 684 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 685 | | } |
| 4 | 686 | | if (accountName == null) |
| | 687 | | { |
| 0 | 688 | | throw new ArgumentNullException(nameof(accountName)); |
| | 689 | | } |
| | 690 | |
|
| 4 | 691 | | using var message = CreateListKeysRequest(resourceGroupName, accountName); |
| 4 | 692 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 693 | | switch (message.Response.Status) |
| | 694 | | { |
| | 695 | | case 200: |
| | 696 | | { |
| 4 | 697 | | StorageAccountListKeysResult value = default; |
| 4 | 698 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 699 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 700 | | { |
| 0 | 701 | | value = null; |
| | 702 | | } |
| | 703 | | else |
| | 704 | | { |
| 4 | 705 | | value = StorageAccountListKeysResult.DeserializeStorageAccountListKeysResult(document.RootEl |
| | 706 | | } |
| 4 | 707 | | return Response.FromValue(value, message.Response); |
| | 708 | | } |
| | 709 | | default: |
| 0 | 710 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 711 | | } |
| 4 | 712 | | } |
| | 713 | |
|
| | 714 | | /// <summary> Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage acc |
| | 715 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 716 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 717 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 718 | | public Response<StorageAccountListKeysResult> ListKeys(string resourceGroupName, string accountName, Cancellatio |
| | 719 | | { |
| 4 | 720 | | if (resourceGroupName == null) |
| | 721 | | { |
| 0 | 722 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 723 | | } |
| 4 | 724 | | if (accountName == null) |
| | 725 | | { |
| 0 | 726 | | throw new ArgumentNullException(nameof(accountName)); |
| | 727 | | } |
| | 728 | |
|
| 4 | 729 | | using var message = CreateListKeysRequest(resourceGroupName, accountName); |
| 4 | 730 | | _pipeline.Send(message, cancellationToken); |
| 4 | 731 | | switch (message.Response.Status) |
| | 732 | | { |
| | 733 | | case 200: |
| | 734 | | { |
| 4 | 735 | | StorageAccountListKeysResult value = default; |
| 4 | 736 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 737 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 738 | | { |
| 0 | 739 | | value = null; |
| | 740 | | } |
| | 741 | | else |
| | 742 | | { |
| 4 | 743 | | value = StorageAccountListKeysResult.DeserializeStorageAccountListKeysResult(document.RootEl |
| | 744 | | } |
| 4 | 745 | | return Response.FromValue(value, message.Response); |
| | 746 | | } |
| | 747 | | default: |
| 0 | 748 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 749 | | } |
| 4 | 750 | | } |
| | 751 | |
|
| | 752 | | internal HttpMessage CreateRegenerateKeyRequest(string resourceGroupName, string accountName, StorageAccountRege |
| | 753 | | { |
| 4 | 754 | | var message = _pipeline.CreateMessage(); |
| 4 | 755 | | var request = message.Request; |
| 4 | 756 | | request.Method = RequestMethod.Post; |
| 4 | 757 | | var uri = new RawRequestUriBuilder(); |
| 4 | 758 | | uri.Reset(endpoint); |
| 4 | 759 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 760 | | uri.AppendPath(subscriptionId, true); |
| 4 | 761 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 762 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 763 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 4 | 764 | | uri.AppendPath(accountName, true); |
| 4 | 765 | | uri.AppendPath("/regenerateKey", false); |
| 4 | 766 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 767 | | request.Uri = uri; |
| 4 | 768 | | request.Headers.Add("Content-Type", "application/json"); |
| 4 | 769 | | var content = new Utf8JsonRequestContent(); |
| 4 | 770 | | content.JsonWriter.WriteObjectValue(regenerateKey); |
| 4 | 771 | | request.Content = content; |
| 4 | 772 | | return message; |
| | 773 | | } |
| | 774 | |
|
| | 775 | | /// <summary> Regenerates one of the access keys or Kerberos keys for the specified storage account. </summary> |
| | 776 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 777 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 778 | | /// <param name="regenerateKey"> Specifies name of the key which should be regenerated -- key1, key2, kerb1, ker |
| | 779 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 780 | | public async Task<Response<StorageAccountListKeysResult>> RegenerateKeyAsync(string resourceGroupName, string ac |
| | 781 | | { |
| 2 | 782 | | if (resourceGroupName == null) |
| | 783 | | { |
| 0 | 784 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 785 | | } |
| 2 | 786 | | if (accountName == null) |
| | 787 | | { |
| 0 | 788 | | throw new ArgumentNullException(nameof(accountName)); |
| | 789 | | } |
| 2 | 790 | | if (regenerateKey == null) |
| | 791 | | { |
| 0 | 792 | | throw new ArgumentNullException(nameof(regenerateKey)); |
| | 793 | | } |
| | 794 | |
|
| 2 | 795 | | using var message = CreateRegenerateKeyRequest(resourceGroupName, accountName, regenerateKey); |
| 2 | 796 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 797 | | switch (message.Response.Status) |
| | 798 | | { |
| | 799 | | case 200: |
| | 800 | | { |
| 2 | 801 | | StorageAccountListKeysResult value = default; |
| 2 | 802 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 803 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 804 | | { |
| 0 | 805 | | value = null; |
| | 806 | | } |
| | 807 | | else |
| | 808 | | { |
| 2 | 809 | | value = StorageAccountListKeysResult.DeserializeStorageAccountListKeysResult(document.RootEl |
| | 810 | | } |
| 2 | 811 | | return Response.FromValue(value, message.Response); |
| | 812 | | } |
| | 813 | | default: |
| 0 | 814 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 815 | | } |
| 2 | 816 | | } |
| | 817 | |
|
| | 818 | | /// <summary> Regenerates one of the access keys or Kerberos keys for the specified storage account. </summary> |
| | 819 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 820 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 821 | | /// <param name="regenerateKey"> Specifies name of the key which should be regenerated -- key1, key2, kerb1, ker |
| | 822 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 823 | | public Response<StorageAccountListKeysResult> RegenerateKey(string resourceGroupName, string accountName, Storag |
| | 824 | | { |
| 2 | 825 | | if (resourceGroupName == null) |
| | 826 | | { |
| 0 | 827 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 828 | | } |
| 2 | 829 | | if (accountName == null) |
| | 830 | | { |
| 0 | 831 | | throw new ArgumentNullException(nameof(accountName)); |
| | 832 | | } |
| 2 | 833 | | if (regenerateKey == null) |
| | 834 | | { |
| 0 | 835 | | throw new ArgumentNullException(nameof(regenerateKey)); |
| | 836 | | } |
| | 837 | |
|
| 2 | 838 | | using var message = CreateRegenerateKeyRequest(resourceGroupName, accountName, regenerateKey); |
| 2 | 839 | | _pipeline.Send(message, cancellationToken); |
| 2 | 840 | | switch (message.Response.Status) |
| | 841 | | { |
| | 842 | | case 200: |
| | 843 | | { |
| 2 | 844 | | StorageAccountListKeysResult value = default; |
| 2 | 845 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 846 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 847 | | { |
| 0 | 848 | | value = null; |
| | 849 | | } |
| | 850 | | else |
| | 851 | | { |
| 2 | 852 | | value = StorageAccountListKeysResult.DeserializeStorageAccountListKeysResult(document.RootEl |
| | 853 | | } |
| 2 | 854 | | return Response.FromValue(value, message.Response); |
| | 855 | | } |
| | 856 | | default: |
| 0 | 857 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 858 | | } |
| 2 | 859 | | } |
| | 860 | |
|
| | 861 | | internal HttpMessage CreateListAccountSASRequest(string resourceGroupName, string accountName, AccountSasParamet |
| | 862 | | { |
| 12 | 863 | | var message = _pipeline.CreateMessage(); |
| 12 | 864 | | var request = message.Request; |
| 12 | 865 | | request.Method = RequestMethod.Post; |
| 12 | 866 | | var uri = new RawRequestUriBuilder(); |
| 12 | 867 | | uri.Reset(endpoint); |
| 12 | 868 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 869 | | uri.AppendPath(subscriptionId, true); |
| 12 | 870 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 871 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 872 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 12 | 873 | | uri.AppendPath(accountName, true); |
| 12 | 874 | | uri.AppendPath("/ListAccountSas", false); |
| 12 | 875 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 876 | | request.Uri = uri; |
| 12 | 877 | | request.Headers.Add("Content-Type", "application/json"); |
| 12 | 878 | | var content = new Utf8JsonRequestContent(); |
| 12 | 879 | | content.JsonWriter.WriteObjectValue(parameters); |
| 12 | 880 | | request.Content = content; |
| 12 | 881 | | return message; |
| | 882 | | } |
| | 883 | |
|
| | 884 | | /// <summary> List SAS credentials of a storage account. </summary> |
| | 885 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 886 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 887 | | /// <param name="parameters"> The parameters to provide to list SAS credentials for the storage account. </param |
| | 888 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 889 | | public async Task<Response<ListAccountSasResponse>> ListAccountSASAsync(string resourceGroupName, string account |
| | 890 | | { |
| 6 | 891 | | if (resourceGroupName == null) |
| | 892 | | { |
| 0 | 893 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 894 | | } |
| 6 | 895 | | if (accountName == null) |
| | 896 | | { |
| 0 | 897 | | throw new ArgumentNullException(nameof(accountName)); |
| | 898 | | } |
| 6 | 899 | | if (parameters == null) |
| | 900 | | { |
| 0 | 901 | | throw new ArgumentNullException(nameof(parameters)); |
| | 902 | | } |
| | 903 | |
|
| 6 | 904 | | using var message = CreateListAccountSASRequest(resourceGroupName, accountName, parameters); |
| 6 | 905 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 906 | | switch (message.Response.Status) |
| | 907 | | { |
| | 908 | | case 200: |
| | 909 | | { |
| 4 | 910 | | ListAccountSasResponse value = default; |
| 4 | 911 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 912 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 913 | | { |
| 0 | 914 | | value = null; |
| | 915 | | } |
| | 916 | | else |
| | 917 | | { |
| 4 | 918 | | value = ListAccountSasResponse.DeserializeListAccountSasResponse(document.RootElement); |
| | 919 | | } |
| 4 | 920 | | return Response.FromValue(value, message.Response); |
| | 921 | | } |
| | 922 | | default: |
| 2 | 923 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 924 | | } |
| 4 | 925 | | } |
| | 926 | |
|
| | 927 | | /// <summary> List SAS credentials of a storage account. </summary> |
| | 928 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 929 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 930 | | /// <param name="parameters"> The parameters to provide to list SAS credentials for the storage account. </param |
| | 931 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 932 | | public Response<ListAccountSasResponse> ListAccountSAS(string resourceGroupName, string accountName, AccountSasP |
| | 933 | | { |
| 6 | 934 | | if (resourceGroupName == null) |
| | 935 | | { |
| 0 | 936 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 937 | | } |
| 6 | 938 | | if (accountName == null) |
| | 939 | | { |
| 0 | 940 | | throw new ArgumentNullException(nameof(accountName)); |
| | 941 | | } |
| 6 | 942 | | if (parameters == null) |
| | 943 | | { |
| 0 | 944 | | throw new ArgumentNullException(nameof(parameters)); |
| | 945 | | } |
| | 946 | |
|
| 6 | 947 | | using var message = CreateListAccountSASRequest(resourceGroupName, accountName, parameters); |
| 6 | 948 | | _pipeline.Send(message, cancellationToken); |
| 6 | 949 | | switch (message.Response.Status) |
| | 950 | | { |
| | 951 | | case 200: |
| | 952 | | { |
| 4 | 953 | | ListAccountSasResponse value = default; |
| 4 | 954 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 955 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 956 | | { |
| 0 | 957 | | value = null; |
| | 958 | | } |
| | 959 | | else |
| | 960 | | { |
| 4 | 961 | | value = ListAccountSasResponse.DeserializeListAccountSasResponse(document.RootElement); |
| | 962 | | } |
| 4 | 963 | | return Response.FromValue(value, message.Response); |
| | 964 | | } |
| | 965 | | default: |
| 2 | 966 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 967 | | } |
| 4 | 968 | | } |
| | 969 | |
|
| | 970 | | internal HttpMessage CreateListServiceSASRequest(string resourceGroupName, string accountName, ServiceSasParamet |
| | 971 | | { |
| 12 | 972 | | var message = _pipeline.CreateMessage(); |
| 12 | 973 | | var request = message.Request; |
| 12 | 974 | | request.Method = RequestMethod.Post; |
| 12 | 975 | | var uri = new RawRequestUriBuilder(); |
| 12 | 976 | | uri.Reset(endpoint); |
| 12 | 977 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 978 | | uri.AppendPath(subscriptionId, true); |
| 12 | 979 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 980 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 981 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 12 | 982 | | uri.AppendPath(accountName, true); |
| 12 | 983 | | uri.AppendPath("/ListServiceSas", false); |
| 12 | 984 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 985 | | request.Uri = uri; |
| 12 | 986 | | request.Headers.Add("Content-Type", "application/json"); |
| 12 | 987 | | var content = new Utf8JsonRequestContent(); |
| 12 | 988 | | content.JsonWriter.WriteObjectValue(parameters); |
| 12 | 989 | | request.Content = content; |
| 12 | 990 | | return message; |
| | 991 | | } |
| | 992 | |
|
| | 993 | | /// <summary> List service SAS credentials of a specific resource. </summary> |
| | 994 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 995 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 996 | | /// <param name="parameters"> The parameters to provide to list service SAS credentials. </param> |
| | 997 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 998 | | public async Task<Response<ListServiceSasResponse>> ListServiceSASAsync(string resourceGroupName, string account |
| | 999 | | { |
| 6 | 1000 | | if (resourceGroupName == null) |
| | 1001 | | { |
| 0 | 1002 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1003 | | } |
| 6 | 1004 | | if (accountName == null) |
| | 1005 | | { |
| 0 | 1006 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1007 | | } |
| 6 | 1008 | | if (parameters == null) |
| | 1009 | | { |
| 0 | 1010 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1011 | | } |
| | 1012 | |
|
| 6 | 1013 | | using var message = CreateListServiceSASRequest(resourceGroupName, accountName, parameters); |
| 6 | 1014 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 1015 | | switch (message.Response.Status) |
| | 1016 | | { |
| | 1017 | | case 200: |
| | 1018 | | { |
| 4 | 1019 | | ListServiceSasResponse value = default; |
| 4 | 1020 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 1021 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1022 | | { |
| 0 | 1023 | | value = null; |
| | 1024 | | } |
| | 1025 | | else |
| | 1026 | | { |
| 4 | 1027 | | value = ListServiceSasResponse.DeserializeListServiceSasResponse(document.RootElement); |
| | 1028 | | } |
| 4 | 1029 | | return Response.FromValue(value, message.Response); |
| | 1030 | | } |
| | 1031 | | default: |
| 2 | 1032 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1033 | | } |
| 4 | 1034 | | } |
| | 1035 | |
|
| | 1036 | | /// <summary> List service SAS credentials of a specific resource. </summary> |
| | 1037 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1038 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1039 | | /// <param name="parameters"> The parameters to provide to list service SAS credentials. </param> |
| | 1040 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1041 | | public Response<ListServiceSasResponse> ListServiceSAS(string resourceGroupName, string accountName, ServiceSasP |
| | 1042 | | { |
| 6 | 1043 | | if (resourceGroupName == null) |
| | 1044 | | { |
| 0 | 1045 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1046 | | } |
| 6 | 1047 | | if (accountName == null) |
| | 1048 | | { |
| 0 | 1049 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1050 | | } |
| 6 | 1051 | | if (parameters == null) |
| | 1052 | | { |
| 0 | 1053 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1054 | | } |
| | 1055 | |
|
| 6 | 1056 | | using var message = CreateListServiceSASRequest(resourceGroupName, accountName, parameters); |
| 6 | 1057 | | _pipeline.Send(message, cancellationToken); |
| 6 | 1058 | | switch (message.Response.Status) |
| | 1059 | | { |
| | 1060 | | case 200: |
| | 1061 | | { |
| 4 | 1062 | | ListServiceSasResponse value = default; |
| 4 | 1063 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 1064 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1065 | | { |
| 0 | 1066 | | value = null; |
| | 1067 | | } |
| | 1068 | | else |
| | 1069 | | { |
| 4 | 1070 | | value = ListServiceSasResponse.DeserializeListServiceSasResponse(document.RootElement); |
| | 1071 | | } |
| 4 | 1072 | | return Response.FromValue(value, message.Response); |
| | 1073 | | } |
| | 1074 | | default: |
| 2 | 1075 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1076 | | } |
| 4 | 1077 | | } |
| | 1078 | |
|
| | 1079 | | internal HttpMessage CreateFailoverRequest(string resourceGroupName, string accountName) |
| | 1080 | | { |
| 0 | 1081 | | var message = _pipeline.CreateMessage(); |
| 0 | 1082 | | var request = message.Request; |
| 0 | 1083 | | request.Method = RequestMethod.Post; |
| 0 | 1084 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1085 | | uri.Reset(endpoint); |
| 0 | 1086 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1087 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1088 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1089 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1090 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 0 | 1091 | | uri.AppendPath(accountName, true); |
| 0 | 1092 | | uri.AppendPath("/failover", false); |
| 0 | 1093 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 1094 | | request.Uri = uri; |
| 0 | 1095 | | return message; |
| | 1096 | | } |
| | 1097 | |
|
| | 1098 | | /// <summary> Failover request can be triggered for a storage account in case of availability issues. The failov |
| | 1099 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1100 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1101 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1102 | | public async Task<Response> FailoverAsync(string resourceGroupName, string accountName, CancellationToken cancel |
| | 1103 | | { |
| 0 | 1104 | | if (resourceGroupName == null) |
| | 1105 | | { |
| 0 | 1106 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1107 | | } |
| 0 | 1108 | | if (accountName == null) |
| | 1109 | | { |
| 0 | 1110 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1111 | | } |
| | 1112 | |
|
| 0 | 1113 | | using var message = CreateFailoverRequest(resourceGroupName, accountName); |
| 0 | 1114 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1115 | | switch (message.Response.Status) |
| | 1116 | | { |
| | 1117 | | case 200: |
| | 1118 | | case 202: |
| 0 | 1119 | | return message.Response; |
| | 1120 | | default: |
| 0 | 1121 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1122 | | } |
| 0 | 1123 | | } |
| | 1124 | |
|
| | 1125 | | /// <summary> Failover request can be triggered for a storage account in case of availability issues. The failov |
| | 1126 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1127 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1128 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1129 | | public Response Failover(string resourceGroupName, string accountName, CancellationToken cancellationToken = def |
| | 1130 | | { |
| 0 | 1131 | | if (resourceGroupName == null) |
| | 1132 | | { |
| 0 | 1133 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1134 | | } |
| 0 | 1135 | | if (accountName == null) |
| | 1136 | | { |
| 0 | 1137 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1138 | | } |
| | 1139 | |
|
| 0 | 1140 | | using var message = CreateFailoverRequest(resourceGroupName, accountName); |
| 0 | 1141 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1142 | | switch (message.Response.Status) |
| | 1143 | | { |
| | 1144 | | case 200: |
| | 1145 | | case 202: |
| 0 | 1146 | | return message.Response; |
| | 1147 | | default: |
| 0 | 1148 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1149 | | } |
| 0 | 1150 | | } |
| | 1151 | |
|
| | 1152 | | internal HttpMessage CreateRestoreBlobRangesRequest(string resourceGroupName, string accountName, BlobRestorePar |
| | 1153 | | { |
| 0 | 1154 | | var message = _pipeline.CreateMessage(); |
| 0 | 1155 | | var request = message.Request; |
| 0 | 1156 | | request.Method = RequestMethod.Post; |
| 0 | 1157 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1158 | | uri.Reset(endpoint); |
| 0 | 1159 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1160 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1161 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1162 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1163 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 0 | 1164 | | uri.AppendPath(accountName, true); |
| 0 | 1165 | | uri.AppendPath("/restoreBlobRanges", false); |
| 0 | 1166 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 1167 | | request.Uri = uri; |
| 0 | 1168 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1169 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1170 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1171 | | request.Content = content; |
| 0 | 1172 | | return message; |
| | 1173 | | } |
| | 1174 | |
|
| | 1175 | | /// <summary> Restore blobs in the specified blob ranges. </summary> |
| | 1176 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1177 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1178 | | /// <param name="parameters"> The parameters to provide for restore blob ranges. </param> |
| | 1179 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1180 | | public async Task<Response> RestoreBlobRangesAsync(string resourceGroupName, string accountName, BlobRestorePara |
| | 1181 | | { |
| 0 | 1182 | | if (resourceGroupName == null) |
| | 1183 | | { |
| 0 | 1184 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1185 | | } |
| 0 | 1186 | | if (accountName == null) |
| | 1187 | | { |
| 0 | 1188 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1189 | | } |
| 0 | 1190 | | if (parameters == null) |
| | 1191 | | { |
| 0 | 1192 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1193 | | } |
| | 1194 | |
|
| 0 | 1195 | | using var message = CreateRestoreBlobRangesRequest(resourceGroupName, accountName, parameters); |
| 0 | 1196 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1197 | | switch (message.Response.Status) |
| | 1198 | | { |
| | 1199 | | case 200: |
| | 1200 | | case 202: |
| 0 | 1201 | | return message.Response; |
| | 1202 | | default: |
| 0 | 1203 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1204 | | } |
| 0 | 1205 | | } |
| | 1206 | |
|
| | 1207 | | /// <summary> Restore blobs in the specified blob ranges. </summary> |
| | 1208 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1209 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1210 | | /// <param name="parameters"> The parameters to provide for restore blob ranges. </param> |
| | 1211 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1212 | | public Response RestoreBlobRanges(string resourceGroupName, string accountName, BlobRestoreParameters parameters |
| | 1213 | | { |
| 0 | 1214 | | if (resourceGroupName == null) |
| | 1215 | | { |
| 0 | 1216 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1217 | | } |
| 0 | 1218 | | if (accountName == null) |
| | 1219 | | { |
| 0 | 1220 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1221 | | } |
| 0 | 1222 | | if (parameters == null) |
| | 1223 | | { |
| 0 | 1224 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1225 | | } |
| | 1226 | |
|
| 0 | 1227 | | using var message = CreateRestoreBlobRangesRequest(resourceGroupName, accountName, parameters); |
| 0 | 1228 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1229 | | switch (message.Response.Status) |
| | 1230 | | { |
| | 1231 | | case 200: |
| | 1232 | | case 202: |
| 0 | 1233 | | return message.Response; |
| | 1234 | | default: |
| 0 | 1235 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1236 | | } |
| 0 | 1237 | | } |
| | 1238 | |
|
| | 1239 | | internal HttpMessage CreateRevokeUserDelegationKeysRequest(string resourceGroupName, string accountName) |
| | 1240 | | { |
| 4 | 1241 | | var message = _pipeline.CreateMessage(); |
| 4 | 1242 | | var request = message.Request; |
| 4 | 1243 | | request.Method = RequestMethod.Post; |
| 4 | 1244 | | var uri = new RawRequestUriBuilder(); |
| 4 | 1245 | | uri.Reset(endpoint); |
| 4 | 1246 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 1247 | | uri.AppendPath(subscriptionId, true); |
| 4 | 1248 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 1249 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 1250 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 4 | 1251 | | uri.AppendPath(accountName, true); |
| 4 | 1252 | | uri.AppendPath("/revokeUserDelegationKeys", false); |
| 4 | 1253 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 1254 | | request.Uri = uri; |
| 4 | 1255 | | return message; |
| | 1256 | | } |
| | 1257 | |
|
| | 1258 | | /// <summary> Revoke user delegation keys. </summary> |
| | 1259 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1260 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1261 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1262 | | public async Task<Response> RevokeUserDelegationKeysAsync(string resourceGroupName, string accountName, Cancella |
| | 1263 | | { |
| 2 | 1264 | | if (resourceGroupName == null) |
| | 1265 | | { |
| 0 | 1266 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1267 | | } |
| 2 | 1268 | | if (accountName == null) |
| | 1269 | | { |
| 0 | 1270 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1271 | | } |
| | 1272 | |
|
| 2 | 1273 | | using var message = CreateRevokeUserDelegationKeysRequest(resourceGroupName, accountName); |
| 2 | 1274 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1275 | | switch (message.Response.Status) |
| | 1276 | | { |
| | 1277 | | case 200: |
| 2 | 1278 | | return message.Response; |
| | 1279 | | default: |
| 0 | 1280 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1281 | | } |
| 2 | 1282 | | } |
| | 1283 | |
|
| | 1284 | | /// <summary> Revoke user delegation keys. </summary> |
| | 1285 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1286 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1287 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1288 | | public Response RevokeUserDelegationKeys(string resourceGroupName, string accountName, CancellationToken cancell |
| | 1289 | | { |
| 2 | 1290 | | if (resourceGroupName == null) |
| | 1291 | | { |
| 0 | 1292 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1293 | | } |
| 2 | 1294 | | if (accountName == null) |
| | 1295 | | { |
| 0 | 1296 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1297 | | } |
| | 1298 | |
|
| 2 | 1299 | | using var message = CreateRevokeUserDelegationKeysRequest(resourceGroupName, accountName); |
| 2 | 1300 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1301 | | switch (message.Response.Status) |
| | 1302 | | { |
| | 1303 | | case 200: |
| 2 | 1304 | | return message.Response; |
| | 1305 | | default: |
| 0 | 1306 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1307 | | } |
| 2 | 1308 | | } |
| | 1309 | |
|
| | 1310 | | internal HttpMessage CreateListNextPageRequest(string nextLink) |
| | 1311 | | { |
| 0 | 1312 | | var message = _pipeline.CreateMessage(); |
| 0 | 1313 | | var request = message.Request; |
| 0 | 1314 | | request.Method = RequestMethod.Get; |
| 0 | 1315 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1316 | | uri.Reset(endpoint); |
| 0 | 1317 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 1318 | | request.Uri = uri; |
| 0 | 1319 | | return message; |
| | 1320 | | } |
| | 1321 | |
|
| | 1322 | | /// <summary> Lists all the storage accounts available under the subscription. Note that storage keys are not re |
| | 1323 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1324 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1325 | | public async Task<Response<StorageAccountListResult>> ListNextPageAsync(string nextLink, CancellationToken cance |
| | 1326 | | { |
| 0 | 1327 | | if (nextLink == null) |
| | 1328 | | { |
| 0 | 1329 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1330 | | } |
| | 1331 | |
|
| 0 | 1332 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 1333 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1334 | | switch (message.Response.Status) |
| | 1335 | | { |
| | 1336 | | case 200: |
| | 1337 | | { |
| 0 | 1338 | | StorageAccountListResult value = default; |
| 0 | 1339 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1340 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1341 | | { |
| 0 | 1342 | | value = null; |
| | 1343 | | } |
| | 1344 | | else |
| | 1345 | | { |
| 0 | 1346 | | value = StorageAccountListResult.DeserializeStorageAccountListResult(document.RootElement); |
| | 1347 | | } |
| 0 | 1348 | | return Response.FromValue(value, message.Response); |
| | 1349 | | } |
| | 1350 | | default: |
| 0 | 1351 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1352 | | } |
| 0 | 1353 | | } |
| | 1354 | |
|
| | 1355 | | /// <summary> Lists all the storage accounts available under the subscription. Note that storage keys are not re |
| | 1356 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1357 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1358 | | public Response<StorageAccountListResult> ListNextPage(string nextLink, CancellationToken cancellationToken = de |
| | 1359 | | { |
| 0 | 1360 | | if (nextLink == null) |
| | 1361 | | { |
| 0 | 1362 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1363 | | } |
| | 1364 | |
|
| 0 | 1365 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 1366 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1367 | | switch (message.Response.Status) |
| | 1368 | | { |
| | 1369 | | case 200: |
| | 1370 | | { |
| 0 | 1371 | | StorageAccountListResult value = default; |
| 0 | 1372 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1373 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1374 | | { |
| 0 | 1375 | | value = null; |
| | 1376 | | } |
| | 1377 | | else |
| | 1378 | | { |
| 0 | 1379 | | value = StorageAccountListResult.DeserializeStorageAccountListResult(document.RootElement); |
| | 1380 | | } |
| 0 | 1381 | | return Response.FromValue(value, message.Response); |
| | 1382 | | } |
| | 1383 | | default: |
| 0 | 1384 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1385 | | } |
| 0 | 1386 | | } |
| | 1387 | | } |
| | 1388 | | } |