1# coding=utf-8 2# -------------------------------------------------------------------------- 3# Copyright (c) Microsoft Corporation. All rights reserved. 4# Licensed under the MIT License. See License.txt in the project root for license information. 5# Code generated by Microsoft (R) AutoRest Code Generator. 6# Changes may cause incorrect behavior and will be lost if the code is regenerated. 7# -------------------------------------------------------------------------- 8from typing import TYPE_CHECKING 9import warnings 10 11from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 12from azure.core.paging import ItemPaged 13from azure.core.pipeline import PipelineResponse 14from azure.core.pipeline.transport import HttpRequest, HttpResponse 15from azure.mgmt.core.exceptions import ARMErrorFormat 16 17from .. import models as _models 18 19if TYPE_CHECKING: 20 # pylint: disable=unused-import,ungrouped-imports 21 from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union 22 23 T = TypeVar('T') 24 ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] 25 26class BlobContainersOperations(object): 27 """BlobContainersOperations operations. 28 29 You should not instantiate this class directly. Instead, you should create a Client instance that 30 instantiates it for you and attaches it as an attribute. 31 32 :ivar models: Alias to model classes used in this operation group. 33 :type models: ~azure.mgmt.storage.v2020_08_01_preview.models 34 :param client: Client for service requests. 35 :param config: Configuration of service client. 36 :param serializer: An object model serializer. 37 :param deserializer: An object model deserializer. 38 """ 39 40 models = _models 41 42 def __init__(self, client, config, serializer, deserializer): 43 self._client = client 44 self._serialize = serializer 45 self._deserialize = deserializer 46 self._config = config 47 48 def list( 49 self, 50 resource_group_name, # type: str 51 account_name, # type: str 52 maxpagesize=None, # type: Optional[str] 53 filter=None, # type: Optional[str] 54 include=None, # type: Optional[Union[str, "_models.ListContainersInclude"]] 55 **kwargs # type: Any 56 ): 57 # type: (...) -> Iterable["_models.ListContainerItems"] 58 """Lists all containers and does not support a prefix like data plane. Also SRP today does not 59 return continuation token. 60 61 :param resource_group_name: The name of the resource group within the user's subscription. The 62 name is case insensitive. 63 :type resource_group_name: str 64 :param account_name: The name of the storage account within the specified resource group. 65 Storage account names must be between 3 and 24 characters in length and use numbers and 66 lower-case letters only. 67 :type account_name: str 68 :param maxpagesize: Optional. Specified maximum number of containers that can be included in 69 the list. 70 :type maxpagesize: str 71 :param filter: Optional. When specified, only container names starting with the filter will be 72 listed. 73 :type filter: str 74 :param include: Optional, used to include the properties for soft deleted blob containers. 75 :type include: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListContainersInclude 76 :keyword callable cls: A custom type or function that will be passed the direct response 77 :return: An iterator like instance of either ListContainerItems or the result of cls(response) 78 :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListContainerItems] 79 :raises: ~azure.core.exceptions.HttpResponseError 80 """ 81 cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] 82 error_map = { 83 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 84 } 85 error_map.update(kwargs.pop('error_map', {})) 86 api_version = "2020-08-01-preview" 87 accept = "application/json" 88 89 def prepare_request(next_link=None): 90 # Construct headers 91 header_parameters = {} # type: Dict[str, Any] 92 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 93 94 if not next_link: 95 # Construct URL 96 url = self.list.metadata['url'] # type: ignore 97 path_format_arguments = { 98 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 99 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 100 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 101 } 102 url = self._client.format_url(url, **path_format_arguments) 103 # Construct parameters 104 query_parameters = {} # type: Dict[str, Any] 105 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 106 if maxpagesize is not None: 107 query_parameters['$maxpagesize'] = self._serialize.query("maxpagesize", maxpagesize, 'str') 108 if filter is not None: 109 query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') 110 if include is not None: 111 query_parameters['$include'] = self._serialize.query("include", include, 'str') 112 113 request = self._client.get(url, query_parameters, header_parameters) 114 else: 115 url = next_link 116 query_parameters = {} # type: Dict[str, Any] 117 request = self._client.get(url, query_parameters, header_parameters) 118 return request 119 120 def extract_data(pipeline_response): 121 deserialized = self._deserialize('ListContainerItems', pipeline_response) 122 list_of_elem = deserialized.value 123 if cls: 124 list_of_elem = cls(list_of_elem) 125 return deserialized.next_link or None, iter(list_of_elem) 126 127 def get_next(next_link=None): 128 request = prepare_request(next_link) 129 130 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 131 response = pipeline_response.http_response 132 133 if response.status_code not in [200]: 134 map_error(status_code=response.status_code, response=response, error_map=error_map) 135 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 136 137 return pipeline_response 138 139 return ItemPaged( 140 get_next, extract_data 141 ) 142 list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore 143 144 def create( 145 self, 146 resource_group_name, # type: str 147 account_name, # type: str 148 container_name, # type: str 149 blob_container, # type: "_models.BlobContainer" 150 **kwargs # type: Any 151 ): 152 # type: (...) -> "_models.BlobContainer" 153 """Creates a new container under the specified account as described by request body. The container 154 resource includes metadata and properties for that container. It does not include a list of the 155 blobs contained by the container. 156 157 :param resource_group_name: The name of the resource group within the user's subscription. The 158 name is case insensitive. 159 :type resource_group_name: str 160 :param account_name: The name of the storage account within the specified resource group. 161 Storage account names must be between 3 and 24 characters in length and use numbers and 162 lower-case letters only. 163 :type account_name: str 164 :param container_name: The name of the blob container within the specified storage account. 165 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 166 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 167 by a letter or number. 168 :type container_name: str 169 :param blob_container: Properties of the blob container to create. 170 :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 171 :keyword callable cls: A custom type or function that will be passed the direct response 172 :return: BlobContainer, or the result of cls(response) 173 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 174 :raises: ~azure.core.exceptions.HttpResponseError 175 """ 176 cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] 177 error_map = { 178 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 179 } 180 error_map.update(kwargs.pop('error_map', {})) 181 api_version = "2020-08-01-preview" 182 content_type = kwargs.pop("content_type", "application/json") 183 accept = "application/json" 184 185 # Construct URL 186 url = self.create.metadata['url'] # type: ignore 187 path_format_arguments = { 188 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 189 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 190 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 191 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 192 } 193 url = self._client.format_url(url, **path_format_arguments) 194 195 # Construct parameters 196 query_parameters = {} # type: Dict[str, Any] 197 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 198 199 # Construct headers 200 header_parameters = {} # type: Dict[str, Any] 201 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 202 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 203 204 body_content_kwargs = {} # type: Dict[str, Any] 205 body_content = self._serialize.body(blob_container, 'BlobContainer') 206 body_content_kwargs['content'] = body_content 207 request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) 208 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 209 response = pipeline_response.http_response 210 211 if response.status_code not in [200, 201]: 212 map_error(status_code=response.status_code, response=response, error_map=error_map) 213 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 214 215 if response.status_code == 200: 216 deserialized = self._deserialize('BlobContainer', pipeline_response) 217 218 if response.status_code == 201: 219 deserialized = self._deserialize('BlobContainer', pipeline_response) 220 221 if cls: 222 return cls(pipeline_response, deserialized, {}) 223 224 return deserialized 225 create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore 226 227 def update( 228 self, 229 resource_group_name, # type: str 230 account_name, # type: str 231 container_name, # type: str 232 blob_container, # type: "_models.BlobContainer" 233 **kwargs # type: Any 234 ): 235 # type: (...) -> "_models.BlobContainer" 236 """Updates container properties as specified in request body. Properties not mentioned in the 237 request will be unchanged. Update fails if the specified container doesn't already exist. 238 239 :param resource_group_name: The name of the resource group within the user's subscription. The 240 name is case insensitive. 241 :type resource_group_name: str 242 :param account_name: The name of the storage account within the specified resource group. 243 Storage account names must be between 3 and 24 characters in length and use numbers and 244 lower-case letters only. 245 :type account_name: str 246 :param container_name: The name of the blob container within the specified storage account. 247 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 248 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 249 by a letter or number. 250 :type container_name: str 251 :param blob_container: Properties to update for the blob container. 252 :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 253 :keyword callable cls: A custom type or function that will be passed the direct response 254 :return: BlobContainer, or the result of cls(response) 255 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 256 :raises: ~azure.core.exceptions.HttpResponseError 257 """ 258 cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] 259 error_map = { 260 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 261 } 262 error_map.update(kwargs.pop('error_map', {})) 263 api_version = "2020-08-01-preview" 264 content_type = kwargs.pop("content_type", "application/json") 265 accept = "application/json" 266 267 # Construct URL 268 url = self.update.metadata['url'] # type: ignore 269 path_format_arguments = { 270 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 271 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 272 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 273 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 274 } 275 url = self._client.format_url(url, **path_format_arguments) 276 277 # Construct parameters 278 query_parameters = {} # type: Dict[str, Any] 279 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 280 281 # Construct headers 282 header_parameters = {} # type: Dict[str, Any] 283 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 284 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 285 286 body_content_kwargs = {} # type: Dict[str, Any] 287 body_content = self._serialize.body(blob_container, 'BlobContainer') 288 body_content_kwargs['content'] = body_content 289 request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) 290 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 291 response = pipeline_response.http_response 292 293 if response.status_code not in [200]: 294 map_error(status_code=response.status_code, response=response, error_map=error_map) 295 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 296 297 deserialized = self._deserialize('BlobContainer', pipeline_response) 298 299 if cls: 300 return cls(pipeline_response, deserialized, {}) 301 302 return deserialized 303 update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore 304 305 def get( 306 self, 307 resource_group_name, # type: str 308 account_name, # type: str 309 container_name, # type: str 310 **kwargs # type: Any 311 ): 312 # type: (...) -> "_models.BlobContainer" 313 """Gets properties of a specified container. 314 315 :param resource_group_name: The name of the resource group within the user's subscription. The 316 name is case insensitive. 317 :type resource_group_name: str 318 :param account_name: The name of the storage account within the specified resource group. 319 Storage account names must be between 3 and 24 characters in length and use numbers and 320 lower-case letters only. 321 :type account_name: str 322 :param container_name: The name of the blob container within the specified storage account. 323 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 324 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 325 by a letter or number. 326 :type container_name: str 327 :keyword callable cls: A custom type or function that will be passed the direct response 328 :return: BlobContainer, or the result of cls(response) 329 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 330 :raises: ~azure.core.exceptions.HttpResponseError 331 """ 332 cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] 333 error_map = { 334 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 335 } 336 error_map.update(kwargs.pop('error_map', {})) 337 api_version = "2020-08-01-preview" 338 accept = "application/json" 339 340 # Construct URL 341 url = self.get.metadata['url'] # type: ignore 342 path_format_arguments = { 343 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 344 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 345 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 346 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 347 } 348 url = self._client.format_url(url, **path_format_arguments) 349 350 # Construct parameters 351 query_parameters = {} # type: Dict[str, Any] 352 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 353 354 # Construct headers 355 header_parameters = {} # type: Dict[str, Any] 356 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 357 358 request = self._client.get(url, query_parameters, header_parameters) 359 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 360 response = pipeline_response.http_response 361 362 if response.status_code not in [200]: 363 map_error(status_code=response.status_code, response=response, error_map=error_map) 364 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 365 366 deserialized = self._deserialize('BlobContainer', pipeline_response) 367 368 if cls: 369 return cls(pipeline_response, deserialized, {}) 370 371 return deserialized 372 get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore 373 374 def delete( 375 self, 376 resource_group_name, # type: str 377 account_name, # type: str 378 container_name, # type: str 379 **kwargs # type: Any 380 ): 381 # type: (...) -> None 382 """Deletes specified container under its account. 383 384 :param resource_group_name: The name of the resource group within the user's subscription. The 385 name is case insensitive. 386 :type resource_group_name: str 387 :param account_name: The name of the storage account within the specified resource group. 388 Storage account names must be between 3 and 24 characters in length and use numbers and 389 lower-case letters only. 390 :type account_name: str 391 :param container_name: The name of the blob container within the specified storage account. 392 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 393 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 394 by a letter or number. 395 :type container_name: str 396 :keyword callable cls: A custom type or function that will be passed the direct response 397 :return: None, or the result of cls(response) 398 :rtype: None 399 :raises: ~azure.core.exceptions.HttpResponseError 400 """ 401 cls = kwargs.pop('cls', None) # type: ClsType[None] 402 error_map = { 403 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 404 } 405 error_map.update(kwargs.pop('error_map', {})) 406 api_version = "2020-08-01-preview" 407 408 # Construct URL 409 url = self.delete.metadata['url'] # type: ignore 410 path_format_arguments = { 411 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 412 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 413 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 414 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 415 } 416 url = self._client.format_url(url, **path_format_arguments) 417 418 # Construct parameters 419 query_parameters = {} # type: Dict[str, Any] 420 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 421 422 # Construct headers 423 header_parameters = {} # type: Dict[str, Any] 424 425 request = self._client.delete(url, query_parameters, header_parameters) 426 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 427 response = pipeline_response.http_response 428 429 if response.status_code not in [200, 204]: 430 map_error(status_code=response.status_code, response=response, error_map=error_map) 431 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 432 433 if cls: 434 return cls(pipeline_response, None, {}) 435 436 delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore 437 438 def set_legal_hold( 439 self, 440 resource_group_name, # type: str 441 account_name, # type: str 442 container_name, # type: str 443 legal_hold, # type: "_models.LegalHold" 444 **kwargs # type: Any 445 ): 446 # type: (...) -> "_models.LegalHold" 447 """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold 448 follows an append pattern and does not clear out the existing tags that are not specified in 449 the request. 450 451 :param resource_group_name: The name of the resource group within the user's subscription. The 452 name is case insensitive. 453 :type resource_group_name: str 454 :param account_name: The name of the storage account within the specified resource group. 455 Storage account names must be between 3 and 24 characters in length and use numbers and 456 lower-case letters only. 457 :type account_name: str 458 :param container_name: The name of the blob container within the specified storage account. 459 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 460 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 461 by a letter or number. 462 :type container_name: str 463 :param legal_hold: The LegalHold property that will be set to a blob container. 464 :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 465 :keyword callable cls: A custom type or function that will be passed the direct response 466 :return: LegalHold, or the result of cls(response) 467 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 468 :raises: ~azure.core.exceptions.HttpResponseError 469 """ 470 cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] 471 error_map = { 472 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 473 } 474 error_map.update(kwargs.pop('error_map', {})) 475 api_version = "2020-08-01-preview" 476 content_type = kwargs.pop("content_type", "application/json") 477 accept = "application/json" 478 479 # Construct URL 480 url = self.set_legal_hold.metadata['url'] # type: ignore 481 path_format_arguments = { 482 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 483 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 484 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 485 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 486 } 487 url = self._client.format_url(url, **path_format_arguments) 488 489 # Construct parameters 490 query_parameters = {} # type: Dict[str, Any] 491 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 492 493 # Construct headers 494 header_parameters = {} # type: Dict[str, Any] 495 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 496 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 497 498 body_content_kwargs = {} # type: Dict[str, Any] 499 body_content = self._serialize.body(legal_hold, 'LegalHold') 500 body_content_kwargs['content'] = body_content 501 request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) 502 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 503 response = pipeline_response.http_response 504 505 if response.status_code not in [200]: 506 map_error(status_code=response.status_code, response=response, error_map=error_map) 507 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 508 509 deserialized = self._deserialize('LegalHold', pipeline_response) 510 511 if cls: 512 return cls(pipeline_response, deserialized, {}) 513 514 return deserialized 515 set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore 516 517 def clear_legal_hold( 518 self, 519 resource_group_name, # type: str 520 account_name, # type: str 521 container_name, # type: str 522 legal_hold, # type: "_models.LegalHold" 523 **kwargs # type: Any 524 ): 525 # type: (...) -> "_models.LegalHold" 526 """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent 527 operation. ClearLegalHold clears out only the specified tags in the request. 528 529 :param resource_group_name: The name of the resource group within the user's subscription. The 530 name is case insensitive. 531 :type resource_group_name: str 532 :param account_name: The name of the storage account within the specified resource group. 533 Storage account names must be between 3 and 24 characters in length and use numbers and 534 lower-case letters only. 535 :type account_name: str 536 :param container_name: The name of the blob container within the specified storage account. 537 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 538 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 539 by a letter or number. 540 :type container_name: str 541 :param legal_hold: The LegalHold property that will be clear from a blob container. 542 :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 543 :keyword callable cls: A custom type or function that will be passed the direct response 544 :return: LegalHold, or the result of cls(response) 545 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 546 :raises: ~azure.core.exceptions.HttpResponseError 547 """ 548 cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] 549 error_map = { 550 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 551 } 552 error_map.update(kwargs.pop('error_map', {})) 553 api_version = "2020-08-01-preview" 554 content_type = kwargs.pop("content_type", "application/json") 555 accept = "application/json" 556 557 # Construct URL 558 url = self.clear_legal_hold.metadata['url'] # type: ignore 559 path_format_arguments = { 560 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 561 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 562 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 563 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 564 } 565 url = self._client.format_url(url, **path_format_arguments) 566 567 # Construct parameters 568 query_parameters = {} # type: Dict[str, Any] 569 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 570 571 # Construct headers 572 header_parameters = {} # type: Dict[str, Any] 573 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 574 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 575 576 body_content_kwargs = {} # type: Dict[str, Any] 577 body_content = self._serialize.body(legal_hold, 'LegalHold') 578 body_content_kwargs['content'] = body_content 579 request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) 580 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 581 response = pipeline_response.http_response 582 583 if response.status_code not in [200]: 584 map_error(status_code=response.status_code, response=response, error_map=error_map) 585 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 586 587 deserialized = self._deserialize('LegalHold', pipeline_response) 588 589 if cls: 590 return cls(pipeline_response, deserialized, {}) 591 592 return deserialized 593 clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore 594 595 def create_or_update_immutability_policy( 596 self, 597 resource_group_name, # type: str 598 account_name, # type: str 599 container_name, # type: str 600 if_match=None, # type: Optional[str] 601 parameters=None, # type: Optional["_models.ImmutabilityPolicy"] 602 **kwargs # type: Any 603 ): 604 # type: (...) -> "_models.ImmutabilityPolicy" 605 """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but 606 not required for this operation. 607 608 :param resource_group_name: The name of the resource group within the user's subscription. The 609 name is case insensitive. 610 :type resource_group_name: str 611 :param account_name: The name of the storage account within the specified resource group. 612 Storage account names must be between 3 and 24 characters in length and use numbers and 613 lower-case letters only. 614 :type account_name: str 615 :param container_name: The name of the blob container within the specified storage account. 616 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 617 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 618 by a letter or number. 619 :type container_name: str 620 :param if_match: The entity state (ETag) version of the immutability policy to update. A value 621 of "*" can be used to apply the operation only if the immutability policy already exists. If 622 omitted, this operation will always be applied. 623 :type if_match: str 624 :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob 625 container. 626 :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 627 :keyword callable cls: A custom type or function that will be passed the direct response 628 :return: ImmutabilityPolicy, or the result of cls(response) 629 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 630 :raises: ~azure.core.exceptions.HttpResponseError 631 """ 632 cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] 633 error_map = { 634 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 635 } 636 error_map.update(kwargs.pop('error_map', {})) 637 immutability_policy_name = "default" 638 api_version = "2020-08-01-preview" 639 content_type = kwargs.pop("content_type", "application/json") 640 accept = "application/json" 641 642 # Construct URL 643 url = self.create_or_update_immutability_policy.metadata['url'] # type: ignore 644 path_format_arguments = { 645 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 646 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 647 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 648 'immutabilityPolicyName': self._serialize.url("immutability_policy_name", immutability_policy_name, 'str'), 649 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 650 } 651 url = self._client.format_url(url, **path_format_arguments) 652 653 # Construct parameters 654 query_parameters = {} # type: Dict[str, Any] 655 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 656 657 # Construct headers 658 header_parameters = {} # type: Dict[str, Any] 659 if if_match is not None: 660 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 661 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 662 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 663 664 body_content_kwargs = {} # type: Dict[str, Any] 665 if parameters is not None: 666 body_content = self._serialize.body(parameters, 'ImmutabilityPolicy') 667 else: 668 body_content = None 669 body_content_kwargs['content'] = body_content 670 request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) 671 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 672 response = pipeline_response.http_response 673 674 if response.status_code not in [200]: 675 map_error(status_code=response.status_code, response=response, error_map=error_map) 676 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 677 678 response_headers = {} 679 response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) 680 deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) 681 682 if cls: 683 return cls(pipeline_response, deserialized, response_headers) 684 685 return deserialized 686 create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore 687 688 def get_immutability_policy( 689 self, 690 resource_group_name, # type: str 691 account_name, # type: str 692 container_name, # type: str 693 if_match=None, # type: Optional[str] 694 **kwargs # type: Any 695 ): 696 # type: (...) -> "_models.ImmutabilityPolicy" 697 """Gets the existing immutability policy along with the corresponding ETag in response headers and 698 body. 699 700 :param resource_group_name: The name of the resource group within the user's subscription. The 701 name is case insensitive. 702 :type resource_group_name: str 703 :param account_name: The name of the storage account within the specified resource group. 704 Storage account names must be between 3 and 24 characters in length and use numbers and 705 lower-case letters only. 706 :type account_name: str 707 :param container_name: The name of the blob container within the specified storage account. 708 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 709 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 710 by a letter or number. 711 :type container_name: str 712 :param if_match: The entity state (ETag) version of the immutability policy to update. A value 713 of "*" can be used to apply the operation only if the immutability policy already exists. If 714 omitted, this operation will always be applied. 715 :type if_match: str 716 :keyword callable cls: A custom type or function that will be passed the direct response 717 :return: ImmutabilityPolicy, or the result of cls(response) 718 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 719 :raises: ~azure.core.exceptions.HttpResponseError 720 """ 721 cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] 722 error_map = { 723 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 724 } 725 error_map.update(kwargs.pop('error_map', {})) 726 immutability_policy_name = "default" 727 api_version = "2020-08-01-preview" 728 accept = "application/json" 729 730 # Construct URL 731 url = self.get_immutability_policy.metadata['url'] # type: ignore 732 path_format_arguments = { 733 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 734 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 735 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 736 'immutabilityPolicyName': self._serialize.url("immutability_policy_name", immutability_policy_name, 'str'), 737 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 738 } 739 url = self._client.format_url(url, **path_format_arguments) 740 741 # Construct parameters 742 query_parameters = {} # type: Dict[str, Any] 743 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 744 745 # Construct headers 746 header_parameters = {} # type: Dict[str, Any] 747 if if_match is not None: 748 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 749 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 750 751 request = self._client.get(url, query_parameters, header_parameters) 752 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 753 response = pipeline_response.http_response 754 755 if response.status_code not in [200]: 756 map_error(status_code=response.status_code, response=response, error_map=error_map) 757 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 758 759 response_headers = {} 760 response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) 761 deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) 762 763 if cls: 764 return cls(pipeline_response, deserialized, response_headers) 765 766 return deserialized 767 get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore 768 769 def delete_immutability_policy( 770 self, 771 resource_group_name, # type: str 772 account_name, # type: str 773 container_name, # type: str 774 if_match, # type: str 775 **kwargs # type: Any 776 ): 777 # type: (...) -> "_models.ImmutabilityPolicy" 778 """Aborts an unlocked immutability policy. The response of delete has 779 immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this 780 operation. Deleting a locked immutability policy is not allowed, the only way is to delete the 781 container after deleting all expired blobs inside the policy locked container. 782 783 :param resource_group_name: The name of the resource group within the user's subscription. The 784 name is case insensitive. 785 :type resource_group_name: str 786 :param account_name: The name of the storage account within the specified resource group. 787 Storage account names must be between 3 and 24 characters in length and use numbers and 788 lower-case letters only. 789 :type account_name: str 790 :param container_name: The name of the blob container within the specified storage account. 791 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 792 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 793 by a letter or number. 794 :type container_name: str 795 :param if_match: The entity state (ETag) version of the immutability policy to update. A value 796 of "*" can be used to apply the operation only if the immutability policy already exists. If 797 omitted, this operation will always be applied. 798 :type if_match: str 799 :keyword callable cls: A custom type or function that will be passed the direct response 800 :return: ImmutabilityPolicy, or the result of cls(response) 801 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 802 :raises: ~azure.core.exceptions.HttpResponseError 803 """ 804 cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] 805 error_map = { 806 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 807 } 808 error_map.update(kwargs.pop('error_map', {})) 809 immutability_policy_name = "default" 810 api_version = "2020-08-01-preview" 811 accept = "application/json" 812 813 # Construct URL 814 url = self.delete_immutability_policy.metadata['url'] # type: ignore 815 path_format_arguments = { 816 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 817 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 818 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 819 'immutabilityPolicyName': self._serialize.url("immutability_policy_name", immutability_policy_name, 'str'), 820 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 821 } 822 url = self._client.format_url(url, **path_format_arguments) 823 824 # Construct parameters 825 query_parameters = {} # type: Dict[str, Any] 826 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 827 828 # Construct headers 829 header_parameters = {} # type: Dict[str, Any] 830 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 831 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 832 833 request = self._client.delete(url, query_parameters, header_parameters) 834 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 835 response = pipeline_response.http_response 836 837 if response.status_code not in [200]: 838 map_error(status_code=response.status_code, response=response, error_map=error_map) 839 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 840 841 response_headers = {} 842 response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) 843 deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) 844 845 if cls: 846 return cls(pipeline_response, deserialized, response_headers) 847 848 return deserialized 849 delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore 850 851 def lock_immutability_policy( 852 self, 853 resource_group_name, # type: str 854 account_name, # type: str 855 container_name, # type: str 856 if_match, # type: str 857 **kwargs # type: Any 858 ): 859 # type: (...) -> "_models.ImmutabilityPolicy" 860 """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is 861 ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. 862 863 :param resource_group_name: The name of the resource group within the user's subscription. The 864 name is case insensitive. 865 :type resource_group_name: str 866 :param account_name: The name of the storage account within the specified resource group. 867 Storage account names must be between 3 and 24 characters in length and use numbers and 868 lower-case letters only. 869 :type account_name: str 870 :param container_name: The name of the blob container within the specified storage account. 871 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 872 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 873 by a letter or number. 874 :type container_name: str 875 :param if_match: The entity state (ETag) version of the immutability policy to update. A value 876 of "*" can be used to apply the operation only if the immutability policy already exists. If 877 omitted, this operation will always be applied. 878 :type if_match: str 879 :keyword callable cls: A custom type or function that will be passed the direct response 880 :return: ImmutabilityPolicy, or the result of cls(response) 881 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 882 :raises: ~azure.core.exceptions.HttpResponseError 883 """ 884 cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] 885 error_map = { 886 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 887 } 888 error_map.update(kwargs.pop('error_map', {})) 889 api_version = "2020-08-01-preview" 890 accept = "application/json" 891 892 # Construct URL 893 url = self.lock_immutability_policy.metadata['url'] # type: ignore 894 path_format_arguments = { 895 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 896 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 897 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 898 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 899 } 900 url = self._client.format_url(url, **path_format_arguments) 901 902 # Construct parameters 903 query_parameters = {} # type: Dict[str, Any] 904 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 905 906 # Construct headers 907 header_parameters = {} # type: Dict[str, Any] 908 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 909 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 910 911 request = self._client.post(url, query_parameters, header_parameters) 912 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 913 response = pipeline_response.http_response 914 915 if response.status_code not in [200]: 916 map_error(status_code=response.status_code, response=response, error_map=error_map) 917 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 918 919 response_headers = {} 920 response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) 921 deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) 922 923 if cls: 924 return cls(pipeline_response, deserialized, response_headers) 925 926 return deserialized 927 lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore 928 929 def extend_immutability_policy( 930 self, 931 resource_group_name, # type: str 932 account_name, # type: str 933 container_name, # type: str 934 if_match, # type: str 935 parameters=None, # type: Optional["_models.ImmutabilityPolicy"] 936 **kwargs # type: Any 937 ): 938 # type: (...) -> "_models.ImmutabilityPolicy" 939 """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only 940 action allowed on a Locked policy will be this action. ETag in If-Match is required for this 941 operation. 942 943 :param resource_group_name: The name of the resource group within the user's subscription. The 944 name is case insensitive. 945 :type resource_group_name: str 946 :param account_name: The name of the storage account within the specified resource group. 947 Storage account names must be between 3 and 24 characters in length and use numbers and 948 lower-case letters only. 949 :type account_name: str 950 :param container_name: The name of the blob container within the specified storage account. 951 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 952 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 953 by a letter or number. 954 :type container_name: str 955 :param if_match: The entity state (ETag) version of the immutability policy to update. A value 956 of "*" can be used to apply the operation only if the immutability policy already exists. If 957 omitted, this operation will always be applied. 958 :type if_match: str 959 :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob 960 container. 961 :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 962 :keyword callable cls: A custom type or function that will be passed the direct response 963 :return: ImmutabilityPolicy, or the result of cls(response) 964 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 965 :raises: ~azure.core.exceptions.HttpResponseError 966 """ 967 cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] 968 error_map = { 969 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 970 } 971 error_map.update(kwargs.pop('error_map', {})) 972 api_version = "2020-08-01-preview" 973 content_type = kwargs.pop("content_type", "application/json") 974 accept = "application/json" 975 976 # Construct URL 977 url = self.extend_immutability_policy.metadata['url'] # type: ignore 978 path_format_arguments = { 979 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 980 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 981 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 982 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 983 } 984 url = self._client.format_url(url, **path_format_arguments) 985 986 # Construct parameters 987 query_parameters = {} # type: Dict[str, Any] 988 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 989 990 # Construct headers 991 header_parameters = {} # type: Dict[str, Any] 992 header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') 993 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 994 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 995 996 body_content_kwargs = {} # type: Dict[str, Any] 997 if parameters is not None: 998 body_content = self._serialize.body(parameters, 'ImmutabilityPolicy') 999 else: 1000 body_content = None 1001 body_content_kwargs['content'] = body_content 1002 request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) 1003 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1004 response = pipeline_response.http_response 1005 1006 if response.status_code not in [200]: 1007 map_error(status_code=response.status_code, response=response, error_map=error_map) 1008 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 1009 1010 response_headers = {} 1011 response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) 1012 deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) 1013 1014 if cls: 1015 return cls(pipeline_response, deserialized, response_headers) 1016 1017 return deserialized 1018 extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore 1019 1020 def lease( 1021 self, 1022 resource_group_name, # type: str 1023 account_name, # type: str 1024 container_name, # type: str 1025 parameters=None, # type: Optional["_models.LeaseContainerRequest"] 1026 **kwargs # type: Any 1027 ): 1028 # type: (...) -> "_models.LeaseContainerResponse" 1029 """The Lease Container operation establishes and manages a lock on a container for delete 1030 operations. The lock duration can be 15 to 60 seconds, or can be infinite. 1031 1032 :param resource_group_name: The name of the resource group within the user's subscription. The 1033 name is case insensitive. 1034 :type resource_group_name: str 1035 :param account_name: The name of the storage account within the specified resource group. 1036 Storage account names must be between 3 and 24 characters in length and use numbers and 1037 lower-case letters only. 1038 :type account_name: str 1039 :param container_name: The name of the blob container within the specified storage account. 1040 Blob container names must be between 3 and 63 characters in length and use numbers, lower-case 1041 letters and dash (-) only. Every dash (-) character must be immediately preceded and followed 1042 by a letter or number. 1043 :type container_name: str 1044 :param parameters: Lease Container request body. 1045 :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest 1046 :keyword callable cls: A custom type or function that will be passed the direct response 1047 :return: LeaseContainerResponse, or the result of cls(response) 1048 :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse 1049 :raises: ~azure.core.exceptions.HttpResponseError 1050 """ 1051 cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] 1052 error_map = { 1053 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 1054 } 1055 error_map.update(kwargs.pop('error_map', {})) 1056 api_version = "2020-08-01-preview" 1057 content_type = kwargs.pop("content_type", "application/json") 1058 accept = "application/json" 1059 1060 # Construct URL 1061 url = self.lease.metadata['url'] # type: ignore 1062 path_format_arguments = { 1063 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 1064 'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3), 1065 'containerName': self._serialize.url("container_name", container_name, 'str', max_length=63, min_length=3), 1066 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 1067 } 1068 url = self._client.format_url(url, **path_format_arguments) 1069 1070 # Construct parameters 1071 query_parameters = {} # type: Dict[str, Any] 1072 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 1073 1074 # Construct headers 1075 header_parameters = {} # type: Dict[str, Any] 1076 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 1077 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 1078 1079 body_content_kwargs = {} # type: Dict[str, Any] 1080 if parameters is not None: 1081 body_content = self._serialize.body(parameters, 'LeaseContainerRequest') 1082 else: 1083 body_content = None 1084 body_content_kwargs['content'] = body_content 1085 request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) 1086 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 1087 response = pipeline_response.http_response 1088 1089 if response.status_code not in [200]: 1090 map_error(status_code=response.status_code, response=response, error_map=error_map) 1091 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 1092 1093 deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) 1094 1095 if cls: 1096 return cls(pipeline_response, deserialized, {}) 1097 1098 return deserialized 1099 lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore 1100