@@ -408,6 +408,7 @@ def _upload_blob_options( # pylint:disable=too-many-statements
408408 kwargs ['blob_settings' ] = self ._config
409409 kwargs ['max_concurrency' ] = max_concurrency
410410 kwargs ['encryption_options' ] = encryption_options
411+
411412 if blob_type == BlobType .BlockBlob :
412413 kwargs ['client' ] = self ._client .block_blob
413414 kwargs ['data' ] = data
@@ -649,6 +650,20 @@ def upload_blob( # pylint: disable=too-many-locals
649650 :keyword ~azure.storage.blob.StandardBlobTier standard_blob_tier:
650651 A standard blob tier value to set the blob to. For this version of the library,
651652 this is only applicable to block blobs on standard storage accounts.
653+ :keyword ~azure.storage.blob.ImmutabilityPolicy immutability_policy:
654+ Specifies the immutability policy of a blob, blob snapshot or blob version.
655+ Currently this parameter of upload_blob() API is for BlockBlob only.
656+
657+ .. versionadded:: 12.10.0
658+ This was introduced in API version '2020-10-02'.
659+
660+ :keyword bool legal_hold:
661+ Specified if a legal hold should be set on the blob.
662+ Currently this parameter of upload_blob() API is for BlockBlob only.
663+
664+ .. versionadded:: 12.10.0
665+ This was introduced in API version '2020-10-02'.
666+
652667 :keyword int maxsize_condition:
653668 Optional conditional header. The max length in bytes permitted for
654669 the append blob. If the Append Block operation would cause the blob
@@ -1389,6 +1404,64 @@ def set_blob_metadata(self, metadata=None, **kwargs):
13891404 except HttpResponseError as error :
13901405 process_storage_error (error )
13911406
1407+ @distributed_trace
1408+ def set_immutability_policy (self , immutability_policy , ** kwargs ):
1409+ # type: (**Any) -> Dict[str, str]
1410+ """The Set Immutability Policy operation sets the immutability policy on the blob.
1411+
1412+ .. versionadded:: 12.10.0
1413+ This operation was introduced in API version '2020-10-02'.
1414+
1415+ :param ~azure.storage.blob.ImmutabilityPolicy immutability_policy:
1416+ Specifies the immutability policy of a blob, blob snapshot or blob version.
1417+
1418+ .. versionadded:: 12.10.0
1419+ This was introduced in API version '2020-10-02'.
1420+
1421+ :keyword int timeout:
1422+ The timeout parameter is expressed in seconds.
1423+ :returns: Key value pairs of blob tags.
1424+ :rtype: Dict[str, str]
1425+ """
1426+
1427+ kwargs ['immutability_policy_expiry' ] = immutability_policy .expiry_time
1428+ kwargs ['immutability_policy_mode' ] = immutability_policy .policy_mode
1429+ return self ._client .blob .set_immutability_policy (cls = return_response_headers , ** kwargs )
1430+
1431+ @distributed_trace
1432+ def delete_immutability_policy (self , ** kwargs ):
1433+ # type: (**Any) -> None
1434+ """The Delete Immutability Policy operation deletes the immutability policy on the blob.
1435+
1436+ .. versionadded:: 12.10.0
1437+ This operation was introduced in API version '2020-10-02'.
1438+
1439+ :keyword int timeout:
1440+ The timeout parameter is expressed in seconds.
1441+ :returns: Key value pairs of blob tags.
1442+ :rtype: Dict[str, str]
1443+ """
1444+
1445+ self ._client .blob .delete_immutability_policy (** kwargs )
1446+
1447+ @distributed_trace
1448+ def set_legal_hold (self , legal_hold , ** kwargs ):
1449+ # type: (**Any) -> Dict[str, Union[str, datetime, bool]]
1450+ """The Set Legal Hold operation sets a legal hold on the blob.
1451+
1452+ .. versionadded:: 12.10.0
1453+ This operation was introduced in API version '2020-10-02'.
1454+
1455+ :param bool legal_hold:
1456+ Specified if a legal hold should be set on the blob.
1457+ :keyword int timeout:
1458+ The timeout parameter is expressed in seconds.
1459+ :returns: Key value pairs of blob tags.
1460+ :rtype: Dict[str, str]
1461+ """
1462+
1463+ return self ._client .blob .set_legal_hold (legal_hold , cls = return_response_headers , ** kwargs )
1464+
13921465 def _create_page_blob_options ( # type: ignore
13931466 self , size , # type: int
13941467 content_settings = None , # type: Optional[ContentSettings]
@@ -1424,6 +1497,11 @@ def _create_page_blob_options( # type: ignore
14241497 cpk_info = CpkInfo (encryption_key = cpk .key_value , encryption_key_sha256 = cpk .key_hash ,
14251498 encryption_algorithm = cpk .algorithm )
14261499
1500+ immutability_policy = kwargs .pop ('immutability_policy' , None )
1501+ if immutability_policy :
1502+ kwargs ['immutability_policy_expiry' ] = immutability_policy .expiry_time
1503+ kwargs ['immutability_policy_mode' ] = immutability_policy .policy_mode
1504+
14271505 if premium_page_blob_tier :
14281506 try :
14291507 headers ['x-ms-access-tier' ] = premium_page_blob_tier .value # type: ignore
@@ -1490,6 +1568,18 @@ def create_page_blob( # type: ignore
14901568 Required if the blob has an active lease. Value can be a BlobLeaseClient object
14911569 or the lease ID as a string.
14921570 :paramtype lease: ~azure.storage.blob.BlobLeaseClient or str
1571+ :keyword ~azure.storage.blob.ImmutabilityPolicy immutability_policy:
1572+ Specifies the immutability policy of a blob, blob snapshot or blob version.
1573+
1574+ .. versionadded:: 12.10.0
1575+ This was introduced in API version '2020-10-02'.
1576+
1577+ :keyword bool legal_hold:
1578+ Specified if a legal hold should be set on the blob.
1579+
1580+ .. versionadded:: 12.10.0
1581+ This was introduced in API version '2020-10-02'.
1582+
14931583 :keyword ~datetime.datetime if_modified_since:
14941584 A DateTime value. Azure expects the date value passed in to be UTC.
14951585 If timezone is included, any non-UTC datetimes will be converted to UTC.
@@ -1563,6 +1653,12 @@ def _create_append_blob_options(self, content_settings=None, metadata=None, **kw
15631653 raise ValueError ("Customer provided encryption key must be used over HTTPS." )
15641654 cpk_info = CpkInfo (encryption_key = cpk .key_value , encryption_key_sha256 = cpk .key_hash ,
15651655 encryption_algorithm = cpk .algorithm )
1656+
1657+ immutability_policy = kwargs .pop ('immutability_policy' , None )
1658+ if immutability_policy :
1659+ kwargs ['immutability_policy_expiry' ] = immutability_policy .expiry_time
1660+ kwargs ['immutability_policy_mode' ] = immutability_policy .policy_mode
1661+
15661662 blob_tags_string = serialize_blob_tags_header (kwargs .pop ('tags' , None ))
15671663
15681664 options = {
@@ -1604,6 +1700,18 @@ def create_append_blob(self, content_settings=None, metadata=None, **kwargs):
16041700 Required if the blob has an active lease. Value can be a BlobLeaseClient object
16051701 or the lease ID as a string.
16061702 :paramtype lease: ~azure.storage.blob.BlobLeaseClient or str
1703+ :keyword ~azure.storage.blob.ImmutabilityPolicy immutability_policy:
1704+ Specifies the immutability policy of a blob, blob snapshot or blob version.
1705+
1706+ .. versionadded:: 12.10.0
1707+ This was introduced in API version '2020-10-02'.
1708+
1709+ :keyword bool legal_hold:
1710+ Specified if a legal hold should be set on the blob.
1711+
1712+ .. versionadded:: 12.10.0
1713+ This was introduced in API version '2020-10-02'.
1714+
16071715 :keyword ~datetime.datetime if_modified_since:
16081716 A DateTime value. Azure expects the date value passed in to be UTC.
16091717 If timezone is included, any non-UTC datetimes will be converted to UTC.
@@ -1776,6 +1884,11 @@ def _start_copy_from_url_options(self, source_url, metadata=None, incremental_co
17761884 dest_mod_conditions = get_modify_conditions (kwargs )
17771885 blob_tags_string = serialize_blob_tags_header (kwargs .pop ('tags' , None ))
17781886
1887+ immutability_policy = kwargs .pop ('immutability_policy' , None )
1888+ if immutability_policy :
1889+ kwargs ['immutability_policy_expiry' ] = immutability_policy .expiry_time
1890+ kwargs ['immutability_policy_mode' ] = immutability_policy .policy_mode
1891+
17791892 options = {
17801893 'copy_source' : source_url ,
17811894 'seal_blob' : kwargs .pop ('seal_destination_blob' , None ),
@@ -1863,6 +1976,18 @@ def start_copy_from_url(self, source_url, metadata=None, incremental_copy=False,
18631976 .. versionadded:: 12.4.0
18641977
18651978 :paramtype tags: dict(str, str)
1979+ :keyword ~azure.storage.blob.ImmutabilityPolicy immutability_policy:
1980+ Specifies the immutability policy of a blob, blob snapshot or blob version.
1981+
1982+ .. versionadded:: 12.10.0
1983+ This was introduced in API version '2020-10-02'.
1984+
1985+ :keyword bool legal_hold:
1986+ Specified if a legal hold should be set on the blob.
1987+
1988+ .. versionadded:: 12.10.0
1989+ This was introduced in API version '2020-10-02'.
1990+
18661991 :keyword ~datetime.datetime source_if_modified_since:
18671992 A DateTime value. Azure expects the date value passed in to be UTC.
18681993 If timezone is included, any non-UTC datetimes will be converted to UTC.
@@ -1933,7 +2058,7 @@ def start_copy_from_url(self, source_url, metadata=None, incremental_copy=False,
19332058 the prefix of the source_authorization string. This option is only available when `incremental_copy` is
19342059 set to False and `requires_sync` is set to True.
19352060 :returns: A dictionary of copy properties (etag, last_modified, copy_id, copy_status).
1936- :rtype: dict[str, str or ~datetime.datetime]
2061+ :rtype: dict[str, Union[ str, ~datetime.datetime] ]
19372062
19382063 .. admonition:: Example:
19392064
@@ -2415,6 +2540,11 @@ def _commit_block_list_options( # type: ignore
24152540 cpk_info = CpkInfo (encryption_key = cpk .key_value , encryption_key_sha256 = cpk .key_hash ,
24162541 encryption_algorithm = cpk .algorithm )
24172542
2543+ immutability_policy = kwargs .pop ('immutability_policy' , None )
2544+ if immutability_policy :
2545+ kwargs ['immutability_policy_expiry' ] = immutability_policy .expiry_time
2546+ kwargs ['immutability_policy_mode' ] = immutability_policy .policy_mode
2547+
24182548 tier = kwargs .pop ('standard_blob_tier' , None )
24192549 blob_tags_string = serialize_blob_tags_header (kwargs .pop ('tags' , None ))
24202550
@@ -2468,6 +2598,18 @@ def commit_block_list( # type: ignore
24682598 Required if the blob has an active lease. Value can be a BlobLeaseClient object
24692599 or the lease ID as a string.
24702600 :paramtype lease: ~azure.storage.blob.BlobLeaseClient or str
2601+ :keyword ~azure.storage.blob.ImmutabilityPolicy immutability_policy:
2602+ Specifies the immutability policy of a blob, blob snapshot or blob version.
2603+
2604+ .. versionadded:: 12.10.0
2605+ This was introduced in API version '2020-10-02'.
2606+
2607+ :keyword bool legal_hold:
2608+ Specified if a legal hold should be set on the blob.
2609+
2610+ .. versionadded:: 12.10.0
2611+ This was introduced in API version '2020-10-02'.
2612+
24712613 :keyword bool validate_content:
24722614 If true, calculates an MD5 hash of the page content. The storage
24732615 service checks the hash of the content that has arrived
0 commit comments