| | 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 BlobContainersRestOperations |
| | 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 BlobContainersRestOperations. </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 BlobContainersRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscript |
| | 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, string maxpagesize, string |
| | 54 | | { |
| 12 | 55 | | var message = _pipeline.CreateMessage(); |
| 12 | 56 | | var request = message.Request; |
| 12 | 57 | | request.Method = RequestMethod.Get; |
| 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("/resourceGroups/", false); |
| 12 | 63 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 64 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 12 | 65 | | uri.AppendPath(accountName, true); |
| 12 | 66 | | uri.AppendPath("/blobServices/default/containers", false); |
| 12 | 67 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 68 | | if (maxpagesize != null) |
| | 69 | | { |
| 4 | 70 | | uri.AppendQuery("$maxpagesize", maxpagesize, true); |
| | 71 | | } |
| 12 | 72 | | if (filter != null) |
| | 73 | | { |
| 0 | 74 | | uri.AppendQuery("$filter", filter, true); |
| | 75 | | } |
| 12 | 76 | | uri.AppendQuery("$include", "deleted", true); |
| 12 | 77 | | request.Uri = uri; |
| 12 | 78 | | return message; |
| | 79 | | } |
| | 80 | |
|
| | 81 | | /// <summary> Lists all containers and does not support a prefix like data plane. Also SRP today does not return |
| | 82 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 83 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 84 | | /// <param name="maxpagesize"> Optional. Specified maximum number of containers that can be included in the list |
| | 85 | | /// <param name="filter"> Optional. When specified, only container names starting with the filter will be listed |
| | 86 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 87 | | public async Task<Response<ListContainerItems>> ListAsync(string resourceGroupName, string accountName, string m |
| | 88 | | { |
| 6 | 89 | | if (resourceGroupName == null) |
| | 90 | | { |
| 0 | 91 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 92 | | } |
| 6 | 93 | | if (accountName == null) |
| | 94 | | { |
| 0 | 95 | | throw new ArgumentNullException(nameof(accountName)); |
| | 96 | | } |
| | 97 | |
|
| 6 | 98 | | using var message = CreateListRequest(resourceGroupName, accountName, maxpagesize, filter); |
| 6 | 99 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 100 | | switch (message.Response.Status) |
| | 101 | | { |
| | 102 | | case 200: |
| | 103 | | { |
| 6 | 104 | | ListContainerItems value = default; |
| 6 | 105 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 106 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 107 | | { |
| 0 | 108 | | value = null; |
| | 109 | | } |
| | 110 | | else |
| | 111 | | { |
| 6 | 112 | | value = ListContainerItems.DeserializeListContainerItems(document.RootElement); |
| | 113 | | } |
| 6 | 114 | | return Response.FromValue(value, message.Response); |
| | 115 | | } |
| | 116 | | default: |
| 0 | 117 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 118 | | } |
| 6 | 119 | | } |
| | 120 | |
|
| | 121 | | /// <summary> Lists all containers and does not support a prefix like data plane. Also SRP today does not return |
| | 122 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 123 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 124 | | /// <param name="maxpagesize"> Optional. Specified maximum number of containers that can be included in the list |
| | 125 | | /// <param name="filter"> Optional. When specified, only container names starting with the filter will be listed |
| | 126 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 127 | | public Response<ListContainerItems> List(string resourceGroupName, string accountName, string maxpagesize = null |
| | 128 | | { |
| 6 | 129 | | if (resourceGroupName == null) |
| | 130 | | { |
| 0 | 131 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 132 | | } |
| 6 | 133 | | if (accountName == null) |
| | 134 | | { |
| 0 | 135 | | throw new ArgumentNullException(nameof(accountName)); |
| | 136 | | } |
| | 137 | |
|
| 6 | 138 | | using var message = CreateListRequest(resourceGroupName, accountName, maxpagesize, filter); |
| 6 | 139 | | _pipeline.Send(message, cancellationToken); |
| 6 | 140 | | switch (message.Response.Status) |
| | 141 | | { |
| | 142 | | case 200: |
| | 143 | | { |
| 6 | 144 | | ListContainerItems value = default; |
| 6 | 145 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 146 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 147 | | { |
| 0 | 148 | | value = null; |
| | 149 | | } |
| | 150 | | else |
| | 151 | | { |
| 6 | 152 | | value = ListContainerItems.DeserializeListContainerItems(document.RootElement); |
| | 153 | | } |
| 6 | 154 | | return Response.FromValue(value, message.Response); |
| | 155 | | } |
| | 156 | | default: |
| 0 | 157 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 158 | | } |
| 6 | 159 | | } |
| | 160 | |
|
| | 161 | | internal HttpMessage CreateCreateRequest(string resourceGroupName, string accountName, string containerName, Blo |
| | 162 | | { |
| 68 | 163 | | var message = _pipeline.CreateMessage(); |
| 68 | 164 | | var request = message.Request; |
| 68 | 165 | | request.Method = RequestMethod.Put; |
| 68 | 166 | | var uri = new RawRequestUriBuilder(); |
| 68 | 167 | | uri.Reset(endpoint); |
| 68 | 168 | | uri.AppendPath("/subscriptions/", false); |
| 68 | 169 | | uri.AppendPath(subscriptionId, true); |
| 68 | 170 | | uri.AppendPath("/resourceGroups/", false); |
| 68 | 171 | | uri.AppendPath(resourceGroupName, true); |
| 68 | 172 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 68 | 173 | | uri.AppendPath(accountName, true); |
| 68 | 174 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 68 | 175 | | uri.AppendPath(containerName, true); |
| 68 | 176 | | uri.AppendQuery("api-version", apiVersion, true); |
| 68 | 177 | | request.Uri = uri; |
| 68 | 178 | | request.Headers.Add("Content-Type", "application/json"); |
| 68 | 179 | | var content = new Utf8JsonRequestContent(); |
| 68 | 180 | | content.JsonWriter.WriteObjectValue(blobContainer); |
| 68 | 181 | | request.Content = content; |
| 68 | 182 | | return message; |
| | 183 | | } |
| | 184 | |
|
| | 185 | | /// <summary> Creates a new container under the specified account as described by request body. The container re |
| | 186 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 187 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 188 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 189 | | /// <param name="blobContainer"> Properties of the blob container to create. </param> |
| | 190 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 191 | | public async Task<Response<BlobContainer>> CreateAsync(string resourceGroupName, string accountName, string cont |
| | 192 | | { |
| 34 | 193 | | if (resourceGroupName == null) |
| | 194 | | { |
| 0 | 195 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 196 | | } |
| 34 | 197 | | if (accountName == null) |
| | 198 | | { |
| 0 | 199 | | throw new ArgumentNullException(nameof(accountName)); |
| | 200 | | } |
| 34 | 201 | | if (containerName == null) |
| | 202 | | { |
| 0 | 203 | | throw new ArgumentNullException(nameof(containerName)); |
| | 204 | | } |
| 34 | 205 | | if (blobContainer == null) |
| | 206 | | { |
| 0 | 207 | | throw new ArgumentNullException(nameof(blobContainer)); |
| | 208 | | } |
| | 209 | |
|
| 34 | 210 | | using var message = CreateCreateRequest(resourceGroupName, accountName, containerName, blobContainer); |
| 34 | 211 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 34 | 212 | | switch (message.Response.Status) |
| | 213 | | { |
| | 214 | | case 200: |
| | 215 | | case 201: |
| | 216 | | { |
| 34 | 217 | | BlobContainer value = default; |
| 34 | 218 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 34 | 219 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 220 | | { |
| 0 | 221 | | value = null; |
| | 222 | | } |
| | 223 | | else |
| | 224 | | { |
| 34 | 225 | | value = BlobContainer.DeserializeBlobContainer(document.RootElement); |
| | 226 | | } |
| 34 | 227 | | return Response.FromValue(value, message.Response); |
| | 228 | | } |
| | 229 | | default: |
| 0 | 230 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 231 | | } |
| 34 | 232 | | } |
| | 233 | |
|
| | 234 | | /// <summary> Creates a new container under the specified account as described by request body. The container re |
| | 235 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 236 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 237 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 238 | | /// <param name="blobContainer"> Properties of the blob container to create. </param> |
| | 239 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 240 | | public Response<BlobContainer> Create(string resourceGroupName, string accountName, string containerName, BlobCo |
| | 241 | | { |
| 34 | 242 | | if (resourceGroupName == null) |
| | 243 | | { |
| 0 | 244 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 245 | | } |
| 34 | 246 | | if (accountName == null) |
| | 247 | | { |
| 0 | 248 | | throw new ArgumentNullException(nameof(accountName)); |
| | 249 | | } |
| 34 | 250 | | if (containerName == null) |
| | 251 | | { |
| 0 | 252 | | throw new ArgumentNullException(nameof(containerName)); |
| | 253 | | } |
| 34 | 254 | | if (blobContainer == null) |
| | 255 | | { |
| 0 | 256 | | throw new ArgumentNullException(nameof(blobContainer)); |
| | 257 | | } |
| | 258 | |
|
| 34 | 259 | | using var message = CreateCreateRequest(resourceGroupName, accountName, containerName, blobContainer); |
| 34 | 260 | | _pipeline.Send(message, cancellationToken); |
| 34 | 261 | | switch (message.Response.Status) |
| | 262 | | { |
| | 263 | | case 200: |
| | 264 | | case 201: |
| | 265 | | { |
| 34 | 266 | | BlobContainer value = default; |
| 34 | 267 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 34 | 268 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 269 | | { |
| 0 | 270 | | value = null; |
| | 271 | | } |
| | 272 | | else |
| | 273 | | { |
| 34 | 274 | | value = BlobContainer.DeserializeBlobContainer(document.RootElement); |
| | 275 | | } |
| 34 | 276 | | return Response.FromValue(value, message.Response); |
| | 277 | | } |
| | 278 | | default: |
| 0 | 279 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 280 | | } |
| 34 | 281 | | } |
| | 282 | |
|
| | 283 | | internal HttpMessage CreateUpdateRequest(string resourceGroupName, string accountName, string containerName, Blo |
| | 284 | | { |
| 12 | 285 | | var message = _pipeline.CreateMessage(); |
| 12 | 286 | | var request = message.Request; |
| 12 | 287 | | request.Method = RequestMethod.Patch; |
| 12 | 288 | | var uri = new RawRequestUriBuilder(); |
| 12 | 289 | | uri.Reset(endpoint); |
| 12 | 290 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 291 | | uri.AppendPath(subscriptionId, true); |
| 12 | 292 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 293 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 294 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 12 | 295 | | uri.AppendPath(accountName, true); |
| 12 | 296 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 12 | 297 | | uri.AppendPath(containerName, true); |
| 12 | 298 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 299 | | request.Uri = uri; |
| 12 | 300 | | request.Headers.Add("Content-Type", "application/json"); |
| 12 | 301 | | var content = new Utf8JsonRequestContent(); |
| 12 | 302 | | content.JsonWriter.WriteObjectValue(blobContainer); |
| 12 | 303 | | request.Content = content; |
| 12 | 304 | | return message; |
| | 305 | | } |
| | 306 | |
|
| | 307 | | /// <summary> Updates container properties as specified in request body. Properties not mentioned in the request |
| | 308 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 309 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 310 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 311 | | /// <param name="blobContainer"> Properties to update for the blob container. </param> |
| | 312 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 313 | | public async Task<Response<BlobContainer>> UpdateAsync(string resourceGroupName, string accountName, string cont |
| | 314 | | { |
| 6 | 315 | | if (resourceGroupName == null) |
| | 316 | | { |
| 0 | 317 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 318 | | } |
| 6 | 319 | | if (accountName == null) |
| | 320 | | { |
| 0 | 321 | | throw new ArgumentNullException(nameof(accountName)); |
| | 322 | | } |
| 6 | 323 | | if (containerName == null) |
| | 324 | | { |
| 0 | 325 | | throw new ArgumentNullException(nameof(containerName)); |
| | 326 | | } |
| 6 | 327 | | if (blobContainer == null) |
| | 328 | | { |
| 0 | 329 | | throw new ArgumentNullException(nameof(blobContainer)); |
| | 330 | | } |
| | 331 | |
|
| 6 | 332 | | using var message = CreateUpdateRequest(resourceGroupName, accountName, containerName, blobContainer); |
| 6 | 333 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 334 | | switch (message.Response.Status) |
| | 335 | | { |
| | 336 | | case 200: |
| | 337 | | { |
| 6 | 338 | | BlobContainer value = default; |
| 6 | 339 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 340 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 341 | | { |
| 0 | 342 | | value = null; |
| | 343 | | } |
| | 344 | | else |
| | 345 | | { |
| 6 | 346 | | value = BlobContainer.DeserializeBlobContainer(document.RootElement); |
| | 347 | | } |
| 6 | 348 | | return Response.FromValue(value, message.Response); |
| | 349 | | } |
| | 350 | | default: |
| 0 | 351 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 352 | | } |
| 6 | 353 | | } |
| | 354 | |
|
| | 355 | | /// <summary> Updates container properties as specified in request body. Properties not mentioned in the request |
| | 356 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 357 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 358 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 359 | | /// <param name="blobContainer"> Properties to update for the blob container. </param> |
| | 360 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 361 | | public Response<BlobContainer> Update(string resourceGroupName, string accountName, string containerName, BlobCo |
| | 362 | | { |
| 6 | 363 | | if (resourceGroupName == null) |
| | 364 | | { |
| 0 | 365 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 366 | | } |
| 6 | 367 | | if (accountName == null) |
| | 368 | | { |
| 0 | 369 | | throw new ArgumentNullException(nameof(accountName)); |
| | 370 | | } |
| 6 | 371 | | if (containerName == null) |
| | 372 | | { |
| 0 | 373 | | throw new ArgumentNullException(nameof(containerName)); |
| | 374 | | } |
| 6 | 375 | | if (blobContainer == null) |
| | 376 | | { |
| 0 | 377 | | throw new ArgumentNullException(nameof(blobContainer)); |
| | 378 | | } |
| | 379 | |
|
| 6 | 380 | | using var message = CreateUpdateRequest(resourceGroupName, accountName, containerName, blobContainer); |
| 6 | 381 | | _pipeline.Send(message, cancellationToken); |
| 6 | 382 | | switch (message.Response.Status) |
| | 383 | | { |
| | 384 | | case 200: |
| | 385 | | { |
| 6 | 386 | | BlobContainer value = default; |
| 6 | 387 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 388 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 389 | | { |
| 0 | 390 | | value = null; |
| | 391 | | } |
| | 392 | | else |
| | 393 | | { |
| 6 | 394 | | value = BlobContainer.DeserializeBlobContainer(document.RootElement); |
| | 395 | | } |
| 6 | 396 | | return Response.FromValue(value, message.Response); |
| | 397 | | } |
| | 398 | | default: |
| 0 | 399 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 400 | | } |
| 6 | 401 | | } |
| | 402 | |
|
| | 403 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string accountName, string containerName) |
| | 404 | | { |
| 12 | 405 | | var message = _pipeline.CreateMessage(); |
| 12 | 406 | | var request = message.Request; |
| 12 | 407 | | request.Method = RequestMethod.Get; |
| 12 | 408 | | var uri = new RawRequestUriBuilder(); |
| 12 | 409 | | uri.Reset(endpoint); |
| 12 | 410 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 411 | | uri.AppendPath(subscriptionId, true); |
| 12 | 412 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 413 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 414 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 12 | 415 | | uri.AppendPath(accountName, true); |
| 12 | 416 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 12 | 417 | | uri.AppendPath(containerName, true); |
| 12 | 418 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 419 | | request.Uri = uri; |
| 12 | 420 | | return message; |
| | 421 | | } |
| | 422 | |
|
| | 423 | | /// <summary> Gets properties of a specified container. </summary> |
| | 424 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 425 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 426 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 427 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 428 | | public async Task<Response<BlobContainer>> GetAsync(string resourceGroupName, string accountName, string contain |
| | 429 | | { |
| 6 | 430 | | if (resourceGroupName == null) |
| | 431 | | { |
| 0 | 432 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 433 | | } |
| 6 | 434 | | if (accountName == null) |
| | 435 | | { |
| 0 | 436 | | throw new ArgumentNullException(nameof(accountName)); |
| | 437 | | } |
| 6 | 438 | | if (containerName == null) |
| | 439 | | { |
| 0 | 440 | | throw new ArgumentNullException(nameof(containerName)); |
| | 441 | | } |
| | 442 | |
|
| 6 | 443 | | using var message = CreateGetRequest(resourceGroupName, accountName, containerName); |
| 6 | 444 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 445 | | switch (message.Response.Status) |
| | 446 | | { |
| | 447 | | case 200: |
| | 448 | | { |
| 6 | 449 | | BlobContainer value = default; |
| 6 | 450 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 451 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 452 | | { |
| 0 | 453 | | value = null; |
| | 454 | | } |
| | 455 | | else |
| | 456 | | { |
| 6 | 457 | | value = BlobContainer.DeserializeBlobContainer(document.RootElement); |
| | 458 | | } |
| 6 | 459 | | return Response.FromValue(value, message.Response); |
| | 460 | | } |
| | 461 | | default: |
| 0 | 462 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 463 | | } |
| 6 | 464 | | } |
| | 465 | |
|
| | 466 | | /// <summary> Gets properties of a specified container. </summary> |
| | 467 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 468 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 469 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 470 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 471 | | public Response<BlobContainer> Get(string resourceGroupName, string accountName, string containerName, Cancellat |
| | 472 | | { |
| 6 | 473 | | if (resourceGroupName == null) |
| | 474 | | { |
| 0 | 475 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 476 | | } |
| 6 | 477 | | if (accountName == null) |
| | 478 | | { |
| 0 | 479 | | throw new ArgumentNullException(nameof(accountName)); |
| | 480 | | } |
| 6 | 481 | | if (containerName == null) |
| | 482 | | { |
| 0 | 483 | | throw new ArgumentNullException(nameof(containerName)); |
| | 484 | | } |
| | 485 | |
|
| 6 | 486 | | using var message = CreateGetRequest(resourceGroupName, accountName, containerName); |
| 6 | 487 | | _pipeline.Send(message, cancellationToken); |
| 6 | 488 | | switch (message.Response.Status) |
| | 489 | | { |
| | 490 | | case 200: |
| | 491 | | { |
| 6 | 492 | | BlobContainer value = default; |
| 6 | 493 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 494 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 495 | | { |
| 0 | 496 | | value = null; |
| | 497 | | } |
| | 498 | | else |
| | 499 | | { |
| 6 | 500 | | value = BlobContainer.DeserializeBlobContainer(document.RootElement); |
| | 501 | | } |
| 6 | 502 | | return Response.FromValue(value, message.Response); |
| | 503 | | } |
| | 504 | | default: |
| 0 | 505 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 506 | | } |
| 6 | 507 | | } |
| | 508 | |
|
| | 509 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string accountName, string containerName) |
| | 510 | | { |
| 20 | 511 | | var message = _pipeline.CreateMessage(); |
| 20 | 512 | | var request = message.Request; |
| 20 | 513 | | request.Method = RequestMethod.Delete; |
| 20 | 514 | | var uri = new RawRequestUriBuilder(); |
| 20 | 515 | | uri.Reset(endpoint); |
| 20 | 516 | | uri.AppendPath("/subscriptions/", false); |
| 20 | 517 | | uri.AppendPath(subscriptionId, true); |
| 20 | 518 | | uri.AppendPath("/resourceGroups/", false); |
| 20 | 519 | | uri.AppendPath(resourceGroupName, true); |
| 20 | 520 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 20 | 521 | | uri.AppendPath(accountName, true); |
| 20 | 522 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 20 | 523 | | uri.AppendPath(containerName, true); |
| 20 | 524 | | uri.AppendQuery("api-version", apiVersion, true); |
| 20 | 525 | | request.Uri = uri; |
| 20 | 526 | | return message; |
| | 527 | | } |
| | 528 | |
|
| | 529 | | /// <summary> Deletes specified container under its account. </summary> |
| | 530 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 531 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 532 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 533 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 534 | | public async Task<Response> DeleteAsync(string resourceGroupName, string accountName, string containerName, Canc |
| | 535 | | { |
| 10 | 536 | | if (resourceGroupName == null) |
| | 537 | | { |
| 0 | 538 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 539 | | } |
| 10 | 540 | | if (accountName == null) |
| | 541 | | { |
| 0 | 542 | | throw new ArgumentNullException(nameof(accountName)); |
| | 543 | | } |
| 10 | 544 | | if (containerName == null) |
| | 545 | | { |
| 0 | 546 | | throw new ArgumentNullException(nameof(containerName)); |
| | 547 | | } |
| | 548 | |
|
| 10 | 549 | | using var message = CreateDeleteRequest(resourceGroupName, accountName, containerName); |
| 10 | 550 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 10 | 551 | | switch (message.Response.Status) |
| | 552 | | { |
| | 553 | | case 200: |
| | 554 | | case 204: |
| 10 | 555 | | return message.Response; |
| | 556 | | default: |
| 0 | 557 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 558 | | } |
| 10 | 559 | | } |
| | 560 | |
|
| | 561 | | /// <summary> Deletes specified container under its account. </summary> |
| | 562 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 563 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 564 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 565 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 566 | | public Response Delete(string resourceGroupName, string accountName, string containerName, CancellationToken can |
| | 567 | | { |
| 10 | 568 | | if (resourceGroupName == null) |
| | 569 | | { |
| 0 | 570 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 571 | | } |
| 10 | 572 | | if (accountName == null) |
| | 573 | | { |
| 0 | 574 | | throw new ArgumentNullException(nameof(accountName)); |
| | 575 | | } |
| 10 | 576 | | if (containerName == null) |
| | 577 | | { |
| 0 | 578 | | throw new ArgumentNullException(nameof(containerName)); |
| | 579 | | } |
| | 580 | |
|
| 10 | 581 | | using var message = CreateDeleteRequest(resourceGroupName, accountName, containerName); |
| 10 | 582 | | _pipeline.Send(message, cancellationToken); |
| 10 | 583 | | switch (message.Response.Status) |
| | 584 | | { |
| | 585 | | case 200: |
| | 586 | | case 204: |
| 10 | 587 | | return message.Response; |
| | 588 | | default: |
| 0 | 589 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 590 | | } |
| 10 | 591 | | } |
| | 592 | |
|
| | 593 | | internal HttpMessage CreateSetLegalHoldRequest(string resourceGroupName, string accountName, string containerNam |
| | 594 | | { |
| 8 | 595 | | var message = _pipeline.CreateMessage(); |
| 8 | 596 | | var request = message.Request; |
| 8 | 597 | | request.Method = RequestMethod.Post; |
| 8 | 598 | | var uri = new RawRequestUriBuilder(); |
| 8 | 599 | | uri.Reset(endpoint); |
| 8 | 600 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 601 | | uri.AppendPath(subscriptionId, true); |
| 8 | 602 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 603 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 604 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 8 | 605 | | uri.AppendPath(accountName, true); |
| 8 | 606 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 8 | 607 | | uri.AppendPath(containerName, true); |
| 8 | 608 | | uri.AppendPath("/setLegalHold", false); |
| 8 | 609 | | uri.AppendQuery("api-version", apiVersion, true); |
| 8 | 610 | | request.Uri = uri; |
| 8 | 611 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 612 | | var content = new Utf8JsonRequestContent(); |
| 8 | 613 | | content.JsonWriter.WriteObjectValue(legalHold); |
| 8 | 614 | | request.Content = content; |
| 8 | 615 | | return message; |
| | 616 | | } |
| | 617 | |
|
| | 618 | | /// <summary> Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follow |
| | 619 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 620 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 621 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 622 | | /// <param name="legalHold"> The LegalHold property that will be set to a blob container. </param> |
| | 623 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 624 | | public async Task<Response<LegalHold>> SetLegalHoldAsync(string resourceGroupName, string accountName, string co |
| | 625 | | { |
| 4 | 626 | | if (resourceGroupName == null) |
| | 627 | | { |
| 0 | 628 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 629 | | } |
| 4 | 630 | | if (accountName == null) |
| | 631 | | { |
| 0 | 632 | | throw new ArgumentNullException(nameof(accountName)); |
| | 633 | | } |
| 4 | 634 | | if (containerName == null) |
| | 635 | | { |
| 0 | 636 | | throw new ArgumentNullException(nameof(containerName)); |
| | 637 | | } |
| 4 | 638 | | if (legalHold == null) |
| | 639 | | { |
| 0 | 640 | | throw new ArgumentNullException(nameof(legalHold)); |
| | 641 | | } |
| | 642 | |
|
| 4 | 643 | | using var message = CreateSetLegalHoldRequest(resourceGroupName, accountName, containerName, legalHold); |
| 4 | 644 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 645 | | switch (message.Response.Status) |
| | 646 | | { |
| | 647 | | case 200: |
| | 648 | | { |
| 4 | 649 | | LegalHold value = default; |
| 4 | 650 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 651 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 652 | | { |
| 0 | 653 | | value = null; |
| | 654 | | } |
| | 655 | | else |
| | 656 | | { |
| 4 | 657 | | value = LegalHold.DeserializeLegalHold(document.RootElement); |
| | 658 | | } |
| 4 | 659 | | return Response.FromValue(value, message.Response); |
| | 660 | | } |
| | 661 | | default: |
| 0 | 662 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 663 | | } |
| 4 | 664 | | } |
| | 665 | |
|
| | 666 | | /// <summary> Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follow |
| | 667 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 668 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 669 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 670 | | /// <param name="legalHold"> The LegalHold property that will be set to a blob container. </param> |
| | 671 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 672 | | public Response<LegalHold> SetLegalHold(string resourceGroupName, string accountName, string containerName, Lega |
| | 673 | | { |
| 4 | 674 | | if (resourceGroupName == null) |
| | 675 | | { |
| 0 | 676 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 677 | | } |
| 4 | 678 | | if (accountName == null) |
| | 679 | | { |
| 0 | 680 | | throw new ArgumentNullException(nameof(accountName)); |
| | 681 | | } |
| 4 | 682 | | if (containerName == null) |
| | 683 | | { |
| 0 | 684 | | throw new ArgumentNullException(nameof(containerName)); |
| | 685 | | } |
| 4 | 686 | | if (legalHold == null) |
| | 687 | | { |
| 0 | 688 | | throw new ArgumentNullException(nameof(legalHold)); |
| | 689 | | } |
| | 690 | |
|
| 4 | 691 | | using var message = CreateSetLegalHoldRequest(resourceGroupName, accountName, containerName, legalHold); |
| 4 | 692 | | _pipeline.Send(message, cancellationToken); |
| 4 | 693 | | switch (message.Response.Status) |
| | 694 | | { |
| | 695 | | case 200: |
| | 696 | | { |
| 4 | 697 | | LegalHold value = default; |
| 4 | 698 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 699 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 700 | | { |
| 0 | 701 | | value = null; |
| | 702 | | } |
| | 703 | | else |
| | 704 | | { |
| 4 | 705 | | value = LegalHold.DeserializeLegalHold(document.RootElement); |
| | 706 | | } |
| 4 | 707 | | return Response.FromValue(value, message.Response); |
| | 708 | | } |
| | 709 | | default: |
| 0 | 710 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 711 | | } |
| 4 | 712 | | } |
| | 713 | |
|
| | 714 | | internal HttpMessage CreateClearLegalHoldRequest(string resourceGroupName, string accountName, string containerN |
| | 715 | | { |
| 8 | 716 | | var message = _pipeline.CreateMessage(); |
| 8 | 717 | | var request = message.Request; |
| 8 | 718 | | request.Method = RequestMethod.Post; |
| 8 | 719 | | var uri = new RawRequestUriBuilder(); |
| 8 | 720 | | uri.Reset(endpoint); |
| 8 | 721 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 722 | | uri.AppendPath(subscriptionId, true); |
| 8 | 723 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 724 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 725 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 8 | 726 | | uri.AppendPath(accountName, true); |
| 8 | 727 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 8 | 728 | | uri.AppendPath(containerName, true); |
| 8 | 729 | | uri.AppendPath("/clearLegalHold", false); |
| 8 | 730 | | uri.AppendQuery("api-version", apiVersion, true); |
| 8 | 731 | | request.Uri = uri; |
| 8 | 732 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 733 | | var content = new Utf8JsonRequestContent(); |
| 8 | 734 | | content.JsonWriter.WriteObjectValue(legalHold); |
| 8 | 735 | | request.Content = content; |
| 8 | 736 | | return message; |
| | 737 | | } |
| | 738 | |
|
| | 739 | | /// <summary> Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. |
| | 740 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 741 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 742 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 743 | | /// <param name="legalHold"> The LegalHold property that will be clear from a blob container. </param> |
| | 744 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 745 | | public async Task<Response<LegalHold>> ClearLegalHoldAsync(string resourceGroupName, string accountName, string |
| | 746 | | { |
| 4 | 747 | | if (resourceGroupName == null) |
| | 748 | | { |
| 0 | 749 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 750 | | } |
| 4 | 751 | | if (accountName == null) |
| | 752 | | { |
| 0 | 753 | | throw new ArgumentNullException(nameof(accountName)); |
| | 754 | | } |
| 4 | 755 | | if (containerName == null) |
| | 756 | | { |
| 0 | 757 | | throw new ArgumentNullException(nameof(containerName)); |
| | 758 | | } |
| 4 | 759 | | if (legalHold == null) |
| | 760 | | { |
| 0 | 761 | | throw new ArgumentNullException(nameof(legalHold)); |
| | 762 | | } |
| | 763 | |
|
| 4 | 764 | | using var message = CreateClearLegalHoldRequest(resourceGroupName, accountName, containerName, legalHold); |
| 4 | 765 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 766 | | switch (message.Response.Status) |
| | 767 | | { |
| | 768 | | case 200: |
| | 769 | | { |
| 4 | 770 | | LegalHold value = default; |
| 4 | 771 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 772 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 773 | | { |
| 0 | 774 | | value = null; |
| | 775 | | } |
| | 776 | | else |
| | 777 | | { |
| 4 | 778 | | value = LegalHold.DeserializeLegalHold(document.RootElement); |
| | 779 | | } |
| 4 | 780 | | return Response.FromValue(value, message.Response); |
| | 781 | | } |
| | 782 | | default: |
| 0 | 783 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 784 | | } |
| 4 | 785 | | } |
| | 786 | |
|
| | 787 | | /// <summary> Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. |
| | 788 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 789 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 790 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 791 | | /// <param name="legalHold"> The LegalHold property that will be clear from a blob container. </param> |
| | 792 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 793 | | public Response<LegalHold> ClearLegalHold(string resourceGroupName, string accountName, string containerName, Le |
| | 794 | | { |
| 4 | 795 | | if (resourceGroupName == null) |
| | 796 | | { |
| 0 | 797 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 798 | | } |
| 4 | 799 | | if (accountName == null) |
| | 800 | | { |
| 0 | 801 | | throw new ArgumentNullException(nameof(accountName)); |
| | 802 | | } |
| 4 | 803 | | if (containerName == null) |
| | 804 | | { |
| 0 | 805 | | throw new ArgumentNullException(nameof(containerName)); |
| | 806 | | } |
| 4 | 807 | | if (legalHold == null) |
| | 808 | | { |
| 0 | 809 | | throw new ArgumentNullException(nameof(legalHold)); |
| | 810 | | } |
| | 811 | |
|
| 4 | 812 | | using var message = CreateClearLegalHoldRequest(resourceGroupName, accountName, containerName, legalHold); |
| 4 | 813 | | _pipeline.Send(message, cancellationToken); |
| 4 | 814 | | switch (message.Response.Status) |
| | 815 | | { |
| | 816 | | case 200: |
| | 817 | | { |
| 4 | 818 | | LegalHold value = default; |
| 4 | 819 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 820 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 821 | | { |
| 0 | 822 | | value = null; |
| | 823 | | } |
| | 824 | | else |
| | 825 | | { |
| 4 | 826 | | value = LegalHold.DeserializeLegalHold(document.RootElement); |
| | 827 | | } |
| 4 | 828 | | return Response.FromValue(value, message.Response); |
| | 829 | | } |
| | 830 | | default: |
| 0 | 831 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 832 | | } |
| 4 | 833 | | } |
| | 834 | |
|
| | 835 | | internal HttpMessage CreateCreateOrUpdateImmutabilityPolicyRequest(string resourceGroupName, string accountName, |
| | 836 | | { |
| 32 | 837 | | var message = _pipeline.CreateMessage(); |
| 32 | 838 | | var request = message.Request; |
| 32 | 839 | | request.Method = RequestMethod.Put; |
| 32 | 840 | | var uri = new RawRequestUriBuilder(); |
| 32 | 841 | | uri.Reset(endpoint); |
| 32 | 842 | | uri.AppendPath("/subscriptions/", false); |
| 32 | 843 | | uri.AppendPath(subscriptionId, true); |
| 32 | 844 | | uri.AppendPath("/resourceGroups/", false); |
| 32 | 845 | | uri.AppendPath(resourceGroupName, true); |
| 32 | 846 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 32 | 847 | | uri.AppendPath(accountName, true); |
| 32 | 848 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 32 | 849 | | uri.AppendPath(containerName, true); |
| 32 | 850 | | uri.AppendPath("/immutabilityPolicies/", false); |
| 32 | 851 | | uri.AppendPath("default", true); |
| 32 | 852 | | uri.AppendQuery("api-version", apiVersion, true); |
| 32 | 853 | | request.Uri = uri; |
| 32 | 854 | | if (ifMatch != null) |
| | 855 | | { |
| 8 | 856 | | request.Headers.Add("If-Match", ifMatch); |
| | 857 | | } |
| 32 | 858 | | request.Headers.Add("Content-Type", "application/json"); |
| 32 | 859 | | if (parameters != null) |
| | 860 | | { |
| 32 | 861 | | var content = new Utf8JsonRequestContent(); |
| 32 | 862 | | content.JsonWriter.WriteObjectValue(parameters); |
| 32 | 863 | | request.Content = content; |
| | 864 | | } |
| 32 | 865 | | return message; |
| | 866 | | } |
| | 867 | |
|
| | 868 | | /// <summary> Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not r |
| | 869 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 870 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 871 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 872 | | /// <param name="ifMatch"> The entity state (ETag) version of the immutability policy to update. A value of &quo |
| | 873 | | /// <param name="parameters"> The ImmutabilityPolicy Properties that will be created or updated to a blob contai |
| | 874 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 875 | | public async Task<Response<ImmutabilityPolicy>> CreateOrUpdateImmutabilityPolicyAsync(string resourceGroupName, |
| | 876 | | { |
| 16 | 877 | | if (resourceGroupName == null) |
| | 878 | | { |
| 0 | 879 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 880 | | } |
| 16 | 881 | | if (accountName == null) |
| | 882 | | { |
| 0 | 883 | | throw new ArgumentNullException(nameof(accountName)); |
| | 884 | | } |
| 16 | 885 | | if (containerName == null) |
| | 886 | | { |
| 0 | 887 | | throw new ArgumentNullException(nameof(containerName)); |
| | 888 | | } |
| | 889 | |
|
| 16 | 890 | | using var message = CreateCreateOrUpdateImmutabilityPolicyRequest(resourceGroupName, accountName, containerN |
| 16 | 891 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 16 | 892 | | switch (message.Response.Status) |
| | 893 | | { |
| | 894 | | case 200: |
| | 895 | | { |
| 16 | 896 | | ImmutabilityPolicy value = default; |
| 16 | 897 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 16 | 898 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 899 | | { |
| 0 | 900 | | value = null; |
| | 901 | | } |
| | 902 | | else |
| | 903 | | { |
| 16 | 904 | | value = ImmutabilityPolicy.DeserializeImmutabilityPolicy(document.RootElement); |
| | 905 | | } |
| 16 | 906 | | return Response.FromValue(value, message.Response); |
| | 907 | | } |
| | 908 | | default: |
| 0 | 909 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 910 | | } |
| 16 | 911 | | } |
| | 912 | |
|
| | 913 | | /// <summary> Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not r |
| | 914 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 915 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 916 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 917 | | /// <param name="ifMatch"> The entity state (ETag) version of the immutability policy to update. A value of &quo |
| | 918 | | /// <param name="parameters"> The ImmutabilityPolicy Properties that will be created or updated to a blob contai |
| | 919 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 920 | | public Response<ImmutabilityPolicy> CreateOrUpdateImmutabilityPolicy(string resourceGroupName, string accountNam |
| | 921 | | { |
| 16 | 922 | | if (resourceGroupName == null) |
| | 923 | | { |
| 0 | 924 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 925 | | } |
| 16 | 926 | | if (accountName == null) |
| | 927 | | { |
| 0 | 928 | | throw new ArgumentNullException(nameof(accountName)); |
| | 929 | | } |
| 16 | 930 | | if (containerName == null) |
| | 931 | | { |
| 0 | 932 | | throw new ArgumentNullException(nameof(containerName)); |
| | 933 | | } |
| | 934 | |
|
| 16 | 935 | | using var message = CreateCreateOrUpdateImmutabilityPolicyRequest(resourceGroupName, accountName, containerN |
| 16 | 936 | | _pipeline.Send(message, cancellationToken); |
| 16 | 937 | | switch (message.Response.Status) |
| | 938 | | { |
| | 939 | | case 200: |
| | 940 | | { |
| 16 | 941 | | ImmutabilityPolicy value = default; |
| 16 | 942 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 16 | 943 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 944 | | { |
| 0 | 945 | | value = null; |
| | 946 | | } |
| | 947 | | else |
| | 948 | | { |
| 16 | 949 | | value = ImmutabilityPolicy.DeserializeImmutabilityPolicy(document.RootElement); |
| | 950 | | } |
| 16 | 951 | | return Response.FromValue(value, message.Response); |
| | 952 | | } |
| | 953 | | default: |
| 0 | 954 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 955 | | } |
| 16 | 956 | | } |
| | 957 | |
|
| | 958 | | internal HttpMessage CreateGetImmutabilityPolicyRequest(string resourceGroupName, string accountName, string con |
| | 959 | | { |
| 8 | 960 | | var message = _pipeline.CreateMessage(); |
| 8 | 961 | | var request = message.Request; |
| 8 | 962 | | request.Method = RequestMethod.Get; |
| 8 | 963 | | var uri = new RawRequestUriBuilder(); |
| 8 | 964 | | uri.Reset(endpoint); |
| 8 | 965 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 966 | | uri.AppendPath(subscriptionId, true); |
| 8 | 967 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 968 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 969 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 8 | 970 | | uri.AppendPath(accountName, true); |
| 8 | 971 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 8 | 972 | | uri.AppendPath(containerName, true); |
| 8 | 973 | | uri.AppendPath("/immutabilityPolicies/", false); |
| 8 | 974 | | uri.AppendPath("default", true); |
| 8 | 975 | | uri.AppendQuery("api-version", apiVersion, true); |
| 8 | 976 | | request.Uri = uri; |
| 8 | 977 | | if (ifMatch != null) |
| | 978 | | { |
| 0 | 979 | | request.Headers.Add("If-Match", ifMatch); |
| | 980 | | } |
| 8 | 981 | | return message; |
| | 982 | | } |
| | 983 | |
|
| | 984 | | /// <summary> Gets the existing immutability policy along with the corresponding ETag in response headers and bo |
| | 985 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 986 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 987 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 988 | | /// <param name="ifMatch"> The entity state (ETag) version of the immutability policy to update. A value of &quo |
| | 989 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 990 | | public async Task<Response<ImmutabilityPolicy>> GetImmutabilityPolicyAsync(string resourceGroupName, string acco |
| | 991 | | { |
| 4 | 992 | | if (resourceGroupName == null) |
| | 993 | | { |
| 0 | 994 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 995 | | } |
| 4 | 996 | | if (accountName == null) |
| | 997 | | { |
| 0 | 998 | | throw new ArgumentNullException(nameof(accountName)); |
| | 999 | | } |
| 4 | 1000 | | if (containerName == null) |
| | 1001 | | { |
| 0 | 1002 | | throw new ArgumentNullException(nameof(containerName)); |
| | 1003 | | } |
| | 1004 | |
|
| 4 | 1005 | | using var message = CreateGetImmutabilityPolicyRequest(resourceGroupName, accountName, containerName, ifMatc |
| 4 | 1006 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 1007 | | switch (message.Response.Status) |
| | 1008 | | { |
| | 1009 | | case 200: |
| | 1010 | | { |
| 4 | 1011 | | ImmutabilityPolicy value = default; |
| 4 | 1012 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 1013 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1014 | | { |
| 0 | 1015 | | value = null; |
| | 1016 | | } |
| | 1017 | | else |
| | 1018 | | { |
| 4 | 1019 | | value = ImmutabilityPolicy.DeserializeImmutabilityPolicy(document.RootElement); |
| | 1020 | | } |
| 4 | 1021 | | return Response.FromValue(value, message.Response); |
| | 1022 | | } |
| | 1023 | | default: |
| 0 | 1024 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1025 | | } |
| 4 | 1026 | | } |
| | 1027 | |
|
| | 1028 | | /// <summary> Gets the existing immutability policy along with the corresponding ETag in response headers and bo |
| | 1029 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1030 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1031 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 1032 | | /// <param name="ifMatch"> The entity state (ETag) version of the immutability policy to update. A value of &quo |
| | 1033 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1034 | | public Response<ImmutabilityPolicy> GetImmutabilityPolicy(string resourceGroupName, string accountName, string c |
| | 1035 | | { |
| 4 | 1036 | | if (resourceGroupName == null) |
| | 1037 | | { |
| 0 | 1038 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1039 | | } |
| 4 | 1040 | | if (accountName == null) |
| | 1041 | | { |
| 0 | 1042 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1043 | | } |
| 4 | 1044 | | if (containerName == null) |
| | 1045 | | { |
| 0 | 1046 | | throw new ArgumentNullException(nameof(containerName)); |
| | 1047 | | } |
| | 1048 | |
|
| 4 | 1049 | | using var message = CreateGetImmutabilityPolicyRequest(resourceGroupName, accountName, containerName, ifMatc |
| 4 | 1050 | | _pipeline.Send(message, cancellationToken); |
| 4 | 1051 | | switch (message.Response.Status) |
| | 1052 | | { |
| | 1053 | | case 200: |
| | 1054 | | { |
| 4 | 1055 | | ImmutabilityPolicy value = default; |
| 4 | 1056 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 1057 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1058 | | { |
| 0 | 1059 | | value = null; |
| | 1060 | | } |
| | 1061 | | else |
| | 1062 | | { |
| 4 | 1063 | | value = ImmutabilityPolicy.DeserializeImmutabilityPolicy(document.RootElement); |
| | 1064 | | } |
| 4 | 1065 | | return Response.FromValue(value, message.Response); |
| | 1066 | | } |
| | 1067 | | default: |
| 0 | 1068 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1069 | | } |
| 4 | 1070 | | } |
| | 1071 | |
|
| | 1072 | | internal HttpMessage CreateDeleteImmutabilityPolicyRequest(string resourceGroupName, string accountName, string |
| | 1073 | | { |
| 4 | 1074 | | var message = _pipeline.CreateMessage(); |
| 4 | 1075 | | var request = message.Request; |
| 4 | 1076 | | request.Method = RequestMethod.Delete; |
| 4 | 1077 | | var uri = new RawRequestUriBuilder(); |
| 4 | 1078 | | uri.Reset(endpoint); |
| 4 | 1079 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 1080 | | uri.AppendPath(subscriptionId, true); |
| 4 | 1081 | | uri.AppendPath("/resourceGroups/", false); |
| 4 | 1082 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 1083 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 4 | 1084 | | uri.AppendPath(accountName, true); |
| 4 | 1085 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 4 | 1086 | | uri.AppendPath(containerName, true); |
| 4 | 1087 | | uri.AppendPath("/immutabilityPolicies/", false); |
| 4 | 1088 | | uri.AppendPath("default", true); |
| 4 | 1089 | | uri.AppendQuery("api-version", apiVersion, true); |
| 4 | 1090 | | request.Uri = uri; |
| 4 | 1091 | | request.Headers.Add("If-Match", ifMatch); |
| 4 | 1092 | | return message; |
| | 1093 | | } |
| | 1094 | |
|
| | 1095 | | /// <summary> Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreation |
| | 1096 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1097 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1098 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 1099 | | /// <param name="ifMatch"> The entity state (ETag) version of the immutability policy to update. A value of &quo |
| | 1100 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1101 | | public async Task<Response<ImmutabilityPolicy>> DeleteImmutabilityPolicyAsync(string resourceGroupName, string a |
| | 1102 | | { |
| 2 | 1103 | | if (resourceGroupName == null) |
| | 1104 | | { |
| 0 | 1105 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1106 | | } |
| 2 | 1107 | | if (accountName == null) |
| | 1108 | | { |
| 0 | 1109 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1110 | | } |
| 2 | 1111 | | if (containerName == null) |
| | 1112 | | { |
| 0 | 1113 | | throw new ArgumentNullException(nameof(containerName)); |
| | 1114 | | } |
| 2 | 1115 | | if (ifMatch == null) |
| | 1116 | | { |
| 0 | 1117 | | throw new ArgumentNullException(nameof(ifMatch)); |
| | 1118 | | } |
| | 1119 | |
|
| 2 | 1120 | | using var message = CreateDeleteImmutabilityPolicyRequest(resourceGroupName, accountName, containerName, ifM |
| 2 | 1121 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1122 | | switch (message.Response.Status) |
| | 1123 | | { |
| | 1124 | | case 200: |
| | 1125 | | { |
| 2 | 1126 | | ImmutabilityPolicy value = default; |
| 2 | 1127 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 1128 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1129 | | { |
| 0 | 1130 | | value = null; |
| | 1131 | | } |
| | 1132 | | else |
| | 1133 | | { |
| 2 | 1134 | | value = ImmutabilityPolicy.DeserializeImmutabilityPolicy(document.RootElement); |
| | 1135 | | } |
| 2 | 1136 | | return Response.FromValue(value, message.Response); |
| | 1137 | | } |
| | 1138 | | default: |
| 0 | 1139 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1140 | | } |
| 2 | 1141 | | } |
| | 1142 | |
|
| | 1143 | | /// <summary> Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreation |
| | 1144 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1145 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1146 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 1147 | | /// <param name="ifMatch"> The entity state (ETag) version of the immutability policy to update. A value of &quo |
| | 1148 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1149 | | public Response<ImmutabilityPolicy> DeleteImmutabilityPolicy(string resourceGroupName, string accountName, strin |
| | 1150 | | { |
| 2 | 1151 | | if (resourceGroupName == null) |
| | 1152 | | { |
| 0 | 1153 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1154 | | } |
| 2 | 1155 | | if (accountName == null) |
| | 1156 | | { |
| 0 | 1157 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1158 | | } |
| 2 | 1159 | | if (containerName == null) |
| | 1160 | | { |
| 0 | 1161 | | throw new ArgumentNullException(nameof(containerName)); |
| | 1162 | | } |
| 2 | 1163 | | if (ifMatch == null) |
| | 1164 | | { |
| 0 | 1165 | | throw new ArgumentNullException(nameof(ifMatch)); |
| | 1166 | | } |
| | 1167 | |
|
| 2 | 1168 | | using var message = CreateDeleteImmutabilityPolicyRequest(resourceGroupName, accountName, containerName, ifM |
| 2 | 1169 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1170 | | switch (message.Response.Status) |
| | 1171 | | { |
| | 1172 | | case 200: |
| | 1173 | | { |
| 2 | 1174 | | ImmutabilityPolicy value = default; |
| 2 | 1175 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 1176 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1177 | | { |
| 0 | 1178 | | value = null; |
| | 1179 | | } |
| | 1180 | | else |
| | 1181 | | { |
| 2 | 1182 | | value = ImmutabilityPolicy.DeserializeImmutabilityPolicy(document.RootElement); |
| | 1183 | | } |
| 2 | 1184 | | return Response.FromValue(value, message.Response); |
| | 1185 | | } |
| | 1186 | | default: |
| 0 | 1187 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1188 | | } |
| 2 | 1189 | | } |
| | 1190 | |
|
| | 1191 | | internal HttpMessage CreateLockImmutabilityPolicyRequest(string resourceGroupName, string accountName, string co |
| | 1192 | | { |
| 12 | 1193 | | var message = _pipeline.CreateMessage(); |
| 12 | 1194 | | var request = message.Request; |
| 12 | 1195 | | request.Method = RequestMethod.Post; |
| 12 | 1196 | | var uri = new RawRequestUriBuilder(); |
| 12 | 1197 | | uri.Reset(endpoint); |
| 12 | 1198 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 1199 | | uri.AppendPath(subscriptionId, true); |
| 12 | 1200 | | uri.AppendPath("/resourceGroups/", false); |
| 12 | 1201 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 1202 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 12 | 1203 | | uri.AppendPath(accountName, true); |
| 12 | 1204 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 12 | 1205 | | uri.AppendPath(containerName, true); |
| 12 | 1206 | | uri.AppendPath("/immutabilityPolicies/default/lock", false); |
| 12 | 1207 | | uri.AppendQuery("api-version", apiVersion, true); |
| 12 | 1208 | | request.Uri = uri; |
| 12 | 1209 | | request.Headers.Add("If-Match", ifMatch); |
| 12 | 1210 | | return message; |
| | 1211 | | } |
| | 1212 | |
|
| | 1213 | | /// <summary> Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendI |
| | 1214 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1215 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1216 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 1217 | | /// <param name="ifMatch"> The entity state (ETag) version of the immutability policy to update. A value of &quo |
| | 1218 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1219 | | public async Task<Response<ImmutabilityPolicy>> LockImmutabilityPolicyAsync(string resourceGroupName, string acc |
| | 1220 | | { |
| 6 | 1221 | | if (resourceGroupName == null) |
| | 1222 | | { |
| 0 | 1223 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1224 | | } |
| 6 | 1225 | | if (accountName == null) |
| | 1226 | | { |
| 0 | 1227 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1228 | | } |
| 6 | 1229 | | if (containerName == null) |
| | 1230 | | { |
| 0 | 1231 | | throw new ArgumentNullException(nameof(containerName)); |
| | 1232 | | } |
| 6 | 1233 | | if (ifMatch == null) |
| | 1234 | | { |
| 0 | 1235 | | throw new ArgumentNullException(nameof(ifMatch)); |
| | 1236 | | } |
| | 1237 | |
|
| 6 | 1238 | | using var message = CreateLockImmutabilityPolicyRequest(resourceGroupName, accountName, containerName, ifMat |
| 6 | 1239 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 1240 | | switch (message.Response.Status) |
| | 1241 | | { |
| | 1242 | | case 200: |
| | 1243 | | { |
| 6 | 1244 | | ImmutabilityPolicy value = default; |
| 6 | 1245 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 1246 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1247 | | { |
| 0 | 1248 | | value = null; |
| | 1249 | | } |
| | 1250 | | else |
| | 1251 | | { |
| 6 | 1252 | | value = ImmutabilityPolicy.DeserializeImmutabilityPolicy(document.RootElement); |
| | 1253 | | } |
| 6 | 1254 | | return Response.FromValue(value, message.Response); |
| | 1255 | | } |
| | 1256 | | default: |
| 0 | 1257 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1258 | | } |
| 6 | 1259 | | } |
| | 1260 | |
|
| | 1261 | | /// <summary> Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendI |
| | 1262 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1263 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1264 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 1265 | | /// <param name="ifMatch"> The entity state (ETag) version of the immutability policy to update. A value of &quo |
| | 1266 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1267 | | public Response<ImmutabilityPolicy> LockImmutabilityPolicy(string resourceGroupName, string accountName, string |
| | 1268 | | { |
| 6 | 1269 | | if (resourceGroupName == null) |
| | 1270 | | { |
| 0 | 1271 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1272 | | } |
| 6 | 1273 | | if (accountName == null) |
| | 1274 | | { |
| 0 | 1275 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1276 | | } |
| 6 | 1277 | | if (containerName == null) |
| | 1278 | | { |
| 0 | 1279 | | throw new ArgumentNullException(nameof(containerName)); |
| | 1280 | | } |
| 6 | 1281 | | if (ifMatch == null) |
| | 1282 | | { |
| 0 | 1283 | | throw new ArgumentNullException(nameof(ifMatch)); |
| | 1284 | | } |
| | 1285 | |
|
| 6 | 1286 | | using var message = CreateLockImmutabilityPolicyRequest(resourceGroupName, accountName, containerName, ifMat |
| 6 | 1287 | | _pipeline.Send(message, cancellationToken); |
| 6 | 1288 | | switch (message.Response.Status) |
| | 1289 | | { |
| | 1290 | | case 200: |
| | 1291 | | { |
| 6 | 1292 | | ImmutabilityPolicy value = default; |
| 6 | 1293 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 1294 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1295 | | { |
| 0 | 1296 | | value = null; |
| | 1297 | | } |
| | 1298 | | else |
| | 1299 | | { |
| 6 | 1300 | | value = ImmutabilityPolicy.DeserializeImmutabilityPolicy(document.RootElement); |
| | 1301 | | } |
| 6 | 1302 | | return Response.FromValue(value, message.Response); |
| | 1303 | | } |
| | 1304 | | default: |
| 0 | 1305 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1306 | | } |
| 6 | 1307 | | } |
| | 1308 | |
|
| | 1309 | | internal HttpMessage CreateExtendImmutabilityPolicyRequest(string resourceGroupName, string accountName, string |
| | 1310 | | { |
| 8 | 1311 | | var message = _pipeline.CreateMessage(); |
| 8 | 1312 | | var request = message.Request; |
| 8 | 1313 | | request.Method = RequestMethod.Post; |
| 8 | 1314 | | var uri = new RawRequestUriBuilder(); |
| 8 | 1315 | | uri.Reset(endpoint); |
| 8 | 1316 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 1317 | | uri.AppendPath(subscriptionId, true); |
| 8 | 1318 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 1319 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 1320 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 8 | 1321 | | uri.AppendPath(accountName, true); |
| 8 | 1322 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 8 | 1323 | | uri.AppendPath(containerName, true); |
| 8 | 1324 | | uri.AppendPath("/immutabilityPolicies/default/extend", false); |
| 8 | 1325 | | uri.AppendQuery("api-version", apiVersion, true); |
| 8 | 1326 | | request.Uri = uri; |
| 8 | 1327 | | request.Headers.Add("If-Match", ifMatch); |
| 8 | 1328 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 1329 | | if (parameters != null) |
| | 1330 | | { |
| 8 | 1331 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1332 | | content.JsonWriter.WriteObjectValue(parameters); |
| 8 | 1333 | | request.Content = content; |
| | 1334 | | } |
| 8 | 1335 | | return message; |
| | 1336 | | } |
| | 1337 | |
|
| | 1338 | | /// <summary> Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action |
| | 1339 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1340 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1341 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 1342 | | /// <param name="ifMatch"> The entity state (ETag) version of the immutability policy to update. A value of &quo |
| | 1343 | | /// <param name="parameters"> The ImmutabilityPolicy Properties that will be extended for a blob container. </pa |
| | 1344 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1345 | | public async Task<Response<ImmutabilityPolicy>> ExtendImmutabilityPolicyAsync(string resourceGroupName, string a |
| | 1346 | | { |
| 4 | 1347 | | if (resourceGroupName == null) |
| | 1348 | | { |
| 0 | 1349 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1350 | | } |
| 4 | 1351 | | if (accountName == null) |
| | 1352 | | { |
| 0 | 1353 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1354 | | } |
| 4 | 1355 | | if (containerName == null) |
| | 1356 | | { |
| 0 | 1357 | | throw new ArgumentNullException(nameof(containerName)); |
| | 1358 | | } |
| 4 | 1359 | | if (ifMatch == null) |
| | 1360 | | { |
| 0 | 1361 | | throw new ArgumentNullException(nameof(ifMatch)); |
| | 1362 | | } |
| | 1363 | |
|
| 4 | 1364 | | using var message = CreateExtendImmutabilityPolicyRequest(resourceGroupName, accountName, containerName, ifM |
| 4 | 1365 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 1366 | | switch (message.Response.Status) |
| | 1367 | | { |
| | 1368 | | case 200: |
| | 1369 | | { |
| 4 | 1370 | | ImmutabilityPolicy value = default; |
| 4 | 1371 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 1372 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1373 | | { |
| 0 | 1374 | | value = null; |
| | 1375 | | } |
| | 1376 | | else |
| | 1377 | | { |
| 4 | 1378 | | value = ImmutabilityPolicy.DeserializeImmutabilityPolicy(document.RootElement); |
| | 1379 | | } |
| 4 | 1380 | | return Response.FromValue(value, message.Response); |
| | 1381 | | } |
| | 1382 | | default: |
| 0 | 1383 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1384 | | } |
| 4 | 1385 | | } |
| | 1386 | |
|
| | 1387 | | /// <summary> Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action |
| | 1388 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1389 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1390 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 1391 | | /// <param name="ifMatch"> The entity state (ETag) version of the immutability policy to update. A value of &quo |
| | 1392 | | /// <param name="parameters"> The ImmutabilityPolicy Properties that will be extended for a blob container. </pa |
| | 1393 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1394 | | public Response<ImmutabilityPolicy> ExtendImmutabilityPolicy(string resourceGroupName, string accountName, strin |
| | 1395 | | { |
| 4 | 1396 | | if (resourceGroupName == null) |
| | 1397 | | { |
| 0 | 1398 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1399 | | } |
| 4 | 1400 | | if (accountName == null) |
| | 1401 | | { |
| 0 | 1402 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1403 | | } |
| 4 | 1404 | | if (containerName == null) |
| | 1405 | | { |
| 0 | 1406 | | throw new ArgumentNullException(nameof(containerName)); |
| | 1407 | | } |
| 4 | 1408 | | if (ifMatch == null) |
| | 1409 | | { |
| 0 | 1410 | | throw new ArgumentNullException(nameof(ifMatch)); |
| | 1411 | | } |
| | 1412 | |
|
| 4 | 1413 | | using var message = CreateExtendImmutabilityPolicyRequest(resourceGroupName, accountName, containerName, ifM |
| 4 | 1414 | | _pipeline.Send(message, cancellationToken); |
| 4 | 1415 | | switch (message.Response.Status) |
| | 1416 | | { |
| | 1417 | | case 200: |
| | 1418 | | { |
| 4 | 1419 | | ImmutabilityPolicy value = default; |
| 4 | 1420 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 1421 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1422 | | { |
| 0 | 1423 | | value = null; |
| | 1424 | | } |
| | 1425 | | else |
| | 1426 | | { |
| 4 | 1427 | | value = ImmutabilityPolicy.DeserializeImmutabilityPolicy(document.RootElement); |
| | 1428 | | } |
| 4 | 1429 | | return Response.FromValue(value, message.Response); |
| | 1430 | | } |
| | 1431 | | default: |
| 0 | 1432 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1433 | | } |
| 4 | 1434 | | } |
| | 1435 | |
|
| | 1436 | | internal HttpMessage CreateLeaseRequest(string resourceGroupName, string accountName, string containerName, Leas |
| | 1437 | | { |
| 0 | 1438 | | var message = _pipeline.CreateMessage(); |
| 0 | 1439 | | var request = message.Request; |
| 0 | 1440 | | request.Method = RequestMethod.Post; |
| 0 | 1441 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1442 | | uri.Reset(endpoint); |
| 0 | 1443 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1444 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1445 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1446 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1447 | | uri.AppendPath("/providers/Microsoft.Storage/storageAccounts/", false); |
| 0 | 1448 | | uri.AppendPath(accountName, true); |
| 0 | 1449 | | uri.AppendPath("/blobServices/default/containers/", false); |
| 0 | 1450 | | uri.AppendPath(containerName, true); |
| 0 | 1451 | | uri.AppendPath("/lease", false); |
| 0 | 1452 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 1453 | | request.Uri = uri; |
| 0 | 1454 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1455 | | if (parameters != null) |
| | 1456 | | { |
| 0 | 1457 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1458 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1459 | | request.Content = content; |
| | 1460 | | } |
| 0 | 1461 | | return message; |
| | 1462 | | } |
| | 1463 | |
|
| | 1464 | | /// <summary> The Lease Container operation establishes and manages a lock on a container for delete operations. |
| | 1465 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1466 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1467 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 1468 | | /// <param name="parameters"> Lease Container request body. </param> |
| | 1469 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1470 | | public async Task<Response<LeaseContainerResponse>> LeaseAsync(string resourceGroupName, string accountName, str |
| | 1471 | | { |
| 0 | 1472 | | if (resourceGroupName == null) |
| | 1473 | | { |
| 0 | 1474 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1475 | | } |
| 0 | 1476 | | if (accountName == null) |
| | 1477 | | { |
| 0 | 1478 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1479 | | } |
| 0 | 1480 | | if (containerName == null) |
| | 1481 | | { |
| 0 | 1482 | | throw new ArgumentNullException(nameof(containerName)); |
| | 1483 | | } |
| | 1484 | |
|
| 0 | 1485 | | using var message = CreateLeaseRequest(resourceGroupName, accountName, containerName, parameters); |
| 0 | 1486 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1487 | | switch (message.Response.Status) |
| | 1488 | | { |
| | 1489 | | case 200: |
| | 1490 | | { |
| 0 | 1491 | | LeaseContainerResponse value = default; |
| 0 | 1492 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1493 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1494 | | { |
| 0 | 1495 | | value = null; |
| | 1496 | | } |
| | 1497 | | else |
| | 1498 | | { |
| 0 | 1499 | | value = LeaseContainerResponse.DeserializeLeaseContainerResponse(document.RootElement); |
| | 1500 | | } |
| 0 | 1501 | | return Response.FromValue(value, message.Response); |
| | 1502 | | } |
| | 1503 | | default: |
| 0 | 1504 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1505 | | } |
| 0 | 1506 | | } |
| | 1507 | |
|
| | 1508 | | /// <summary> The Lease Container operation establishes and manages a lock on a container for delete operations. |
| | 1509 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1510 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1511 | | /// <param name="containerName"> The name of the blob container within the specified storage account. Blob conta |
| | 1512 | | /// <param name="parameters"> Lease Container request body. </param> |
| | 1513 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1514 | | public Response<LeaseContainerResponse> Lease(string resourceGroupName, string accountName, string containerName |
| | 1515 | | { |
| 0 | 1516 | | if (resourceGroupName == null) |
| | 1517 | | { |
| 0 | 1518 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1519 | | } |
| 0 | 1520 | | if (accountName == null) |
| | 1521 | | { |
| 0 | 1522 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1523 | | } |
| 0 | 1524 | | if (containerName == null) |
| | 1525 | | { |
| 0 | 1526 | | throw new ArgumentNullException(nameof(containerName)); |
| | 1527 | | } |
| | 1528 | |
|
| 0 | 1529 | | using var message = CreateLeaseRequest(resourceGroupName, accountName, containerName, parameters); |
| 0 | 1530 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1531 | | switch (message.Response.Status) |
| | 1532 | | { |
| | 1533 | | case 200: |
| | 1534 | | { |
| 0 | 1535 | | LeaseContainerResponse value = default; |
| 0 | 1536 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1537 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1538 | | { |
| 0 | 1539 | | value = null; |
| | 1540 | | } |
| | 1541 | | else |
| | 1542 | | { |
| 0 | 1543 | | value = LeaseContainerResponse.DeserializeLeaseContainerResponse(document.RootElement); |
| | 1544 | | } |
| 0 | 1545 | | return Response.FromValue(value, message.Response); |
| | 1546 | | } |
| | 1547 | | default: |
| 0 | 1548 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1549 | | } |
| 0 | 1550 | | } |
| | 1551 | |
|
| | 1552 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string accountName, st |
| | 1553 | | { |
| 4 | 1554 | | var message = _pipeline.CreateMessage(); |
| 4 | 1555 | | var request = message.Request; |
| 4 | 1556 | | request.Method = RequestMethod.Get; |
| 4 | 1557 | | var uri = new RawRequestUriBuilder(); |
| 4 | 1558 | | uri.Reset(endpoint); |
| 4 | 1559 | | uri.AppendRawNextLink(nextLink, false); |
| 4 | 1560 | | request.Uri = uri; |
| 4 | 1561 | | return message; |
| | 1562 | | } |
| | 1563 | |
|
| | 1564 | | /// <summary> Lists all containers and does not support a prefix like data plane. Also SRP today does not return |
| | 1565 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1566 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1567 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1568 | | /// <param name="maxpagesize"> Optional. Specified maximum number of containers that can be included in the list |
| | 1569 | | /// <param name="filter"> Optional. When specified, only container names starting with the filter will be listed |
| | 1570 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1571 | | public async Task<Response<ListContainerItems>> ListNextPageAsync(string nextLink, string resourceGroupName, str |
| | 1572 | | { |
| 2 | 1573 | | if (nextLink == null) |
| | 1574 | | { |
| 0 | 1575 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1576 | | } |
| 2 | 1577 | | if (resourceGroupName == null) |
| | 1578 | | { |
| 0 | 1579 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1580 | | } |
| 2 | 1581 | | if (accountName == null) |
| | 1582 | | { |
| 0 | 1583 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1584 | | } |
| | 1585 | |
|
| 2 | 1586 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, accountName, maxpagesize, filter) |
| 2 | 1587 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1588 | | switch (message.Response.Status) |
| | 1589 | | { |
| | 1590 | | case 200: |
| | 1591 | | { |
| 2 | 1592 | | ListContainerItems value = default; |
| 2 | 1593 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 1594 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1595 | | { |
| 0 | 1596 | | value = null; |
| | 1597 | | } |
| | 1598 | | else |
| | 1599 | | { |
| 2 | 1600 | | value = ListContainerItems.DeserializeListContainerItems(document.RootElement); |
| | 1601 | | } |
| 2 | 1602 | | return Response.FromValue(value, message.Response); |
| | 1603 | | } |
| | 1604 | | default: |
| 0 | 1605 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1606 | | } |
| 2 | 1607 | | } |
| | 1608 | |
|
| | 1609 | | /// <summary> Lists all containers and does not support a prefix like data plane. Also SRP today does not return |
| | 1610 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1611 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 1612 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 1613 | | /// <param name="maxpagesize"> Optional. Specified maximum number of containers that can be included in the list |
| | 1614 | | /// <param name="filter"> Optional. When specified, only container names starting with the filter will be listed |
| | 1615 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1616 | | public Response<ListContainerItems> ListNextPage(string nextLink, string resourceGroupName, string accountName, |
| | 1617 | | { |
| 2 | 1618 | | if (nextLink == null) |
| | 1619 | | { |
| 0 | 1620 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1621 | | } |
| 2 | 1622 | | if (resourceGroupName == null) |
| | 1623 | | { |
| 0 | 1624 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1625 | | } |
| 2 | 1626 | | if (accountName == null) |
| | 1627 | | { |
| 0 | 1628 | | throw new ArgumentNullException(nameof(accountName)); |
| | 1629 | | } |
| | 1630 | |
|
| 2 | 1631 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, accountName, maxpagesize, filter) |
| 2 | 1632 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1633 | | switch (message.Response.Status) |
| | 1634 | | { |
| | 1635 | | case 200: |
| | 1636 | | { |
| 2 | 1637 | | ListContainerItems value = default; |
| 2 | 1638 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 1639 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1640 | | { |
| 0 | 1641 | | value = null; |
| | 1642 | | } |
| | 1643 | | else |
| | 1644 | | { |
| 2 | 1645 | | value = ListContainerItems.DeserializeListContainerItems(document.RootElement); |
| | 1646 | | } |
| 2 | 1647 | | return Response.FromValue(value, message.Response); |
| | 1648 | | } |
| | 1649 | | default: |
| 0 | 1650 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1651 | | } |
| 2 | 1652 | | } |
| | 1653 | | } |
| | 1654 | | } |