Skip to content

Commit ff51954

Browse files
authored
Merge pull request #467 from Azure/dev
March 18 service release
2 parents 22bebfe + 86eec8b commit ff51954

File tree

602 files changed

+24290
-40381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

602 files changed

+24290
-40381
lines changed

BreakingChanges.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> See the [Change Log](ChangeLog.md) for a summary of storage library changes.
44
5-
**Note: This changelog is deprecated starting with version XX.XX.XX, please refer to the ChangeLog.md in each package for future change logs.**
5+
**Note: This changelog is deprecated starting with version 0.37.0, please refer to the ChangeLog.md in each package for future change logs.**
66

77
## Version 0.37.0:
88

azure-storage-blob/ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
> See [BreakingChanges](BreakingChanges.md) for a detailed list of API breaks.
44
5+
## Version 1.3.0:
6+
7+
- Support for 2018-03-28 REST version. Please see our REST API documentation and blog for information about the related added features.
8+
- Added support for setting static website service properties.
9+
- Added support for getting account information, such as SKU name and account kind.
10+
- Added support for put block from URL(synchronously).
11+
512
## Version 1.2.0rc1:
613

714
- Support for 2017-11-09 REST version. Please see our REST API documentation and blog for information about the related added features.

azure-storage-blob/azure/storage/blob/_constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
# --------------------------------------------------------------------------
66

77
__author__ = 'Microsoft Corp. <ptvshelp@microsoft.com>'
8-
__version__ = '1.2.0rc1'
8+
__version__ = '1.3.0'
99

1010
# x-ms-version for storage service.
11-
X_MS_VERSION = '2017-11-09'
11+
X_MS_VERSION = '2018-03-28'
1212

1313
# internal configurations, should not be changed
1414
_LARGE_BLOB_UPLOAD_MAX_READ_BUFFER_SIZE = 4 * 1024 * 1024

azure-storage-blob/azure/storage/blob/_deserialization.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
PageBlobProperties,
3636
ResourceProperties,
3737
BlobPrefix,
38+
AccountInformation,
3839
)
3940
from ._encryption import _decrypt_blob
4041
from azure.storage.common.models import _list
@@ -440,3 +441,11 @@ def _convert_xml_to_page_ranges(response):
440441
)
441442

442443
return page_list
444+
445+
446+
def _parse_account_information(response):
447+
account_info = AccountInformation()
448+
account_info.sku_name = response.headers['x-ms-sku-name']
449+
account_info.account_kind = response.headers['x-ms-account-kind']
450+
451+
return account_info

azure-storage-blob/azure/storage/blob/baseblobservice.py

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
_parse_lease,
6464
_convert_xml_to_signed_identifiers_and_access,
6565
_parse_base_properties,
66+
_parse_account_information,
6667
)
6768
from ._download_chunking import _download_blob_chunks
6869
from ._error import (
@@ -85,6 +86,10 @@
8586
__version__ as package_version,
8687
)
8788

89+
_CONTAINER_ALREADY_EXISTS_ERROR_CODE = 'ContainerAlreadyExists'
90+
_BLOB_NOT_FOUND_ERROR_CODE = 'BlobNotFound'
91+
_CONTAINER_NOT_FOUND_ERROR_CODE = 'ContainerNotFound'
92+
8893
if sys.version_info >= (3,):
8994
from io import BytesIO
9095
else:
@@ -622,7 +627,7 @@ def create_container(self, container_name, metadata=None,
622627

623628
if not fail_on_exist:
624629
try:
625-
self._perform_request(request)
630+
self._perform_request(request, expected_errors=[_CONTAINER_ALREADY_EXISTS_ERROR_CODE])
626631
return True
627632
except AzureHttpError as ex:
628633
_dont_fail_on_exist(ex)
@@ -873,7 +878,7 @@ def delete_container(self, container_name, fail_not_exist=False,
873878

874879
if not fail_not_exist:
875880
try:
876-
self._perform_request(request)
881+
self._perform_request(request, expected_errors=[_CONTAINER_NOT_FOUND_ERROR_CODE])
877882
return True
878883
except AzureHttpError as ex:
879884
_dont_fail_not_exist(ex)
@@ -1316,6 +1321,33 @@ def _list_blobs(self, container_name, prefix=None, marker=None,
13161321

13171322
return self._perform_request(request, _convert_xml_to_blob_list, operation_context=_context)
13181323

1324+
def get_blob_account_information(self, container_name=None, blob_name=None, timeout=None):
1325+
"""
1326+
Gets information related to the storage account.
1327+
The information can also be retrieved if the user has a SAS to a container or blob.
1328+
1329+
:param str container_name:
1330+
Name of existing container.
1331+
Optional, unless using a SAS token to a specific container or blob, in which case it's required.
1332+
:param str blob_name:
1333+
Name of existing blob.
1334+
Optional, unless using a SAS token to a specific blob, in which case it's required.
1335+
:param int timeout:
1336+
The timeout parameter is expressed in seconds.
1337+
:return: The :class:`~azure.storage.blob.models.AccountInformation`.
1338+
"""
1339+
request = HTTPRequest()
1340+
request.method = 'HEAD'
1341+
request.host_locations = self._get_host_locations(secondary=True)
1342+
request.path = _get_path(container_name, blob_name)
1343+
request.query = {
1344+
'restype': 'account',
1345+
'comp': 'properties',
1346+
'timeout': _int_to_str(timeout),
1347+
}
1348+
1349+
return self._perform_request(request, _parse_account_information)
1350+
13191351
def get_blob_service_stats(self, timeout=None):
13201352
'''
13211353
Retrieves statistics related to replication for the Blob service. It is
@@ -1354,7 +1386,7 @@ def get_blob_service_stats(self, timeout=None):
13541386

13551387
def set_blob_service_properties(
13561388
self, logging=None, hour_metrics=None, minute_metrics=None,
1357-
cors=None, target_version=None, timeout=None, delete_retention_policy=None):
1389+
cors=None, target_version=None, timeout=None, delete_retention_policy=None, static_website=None):
13581390
'''
13591391
Sets the properties of a storage account's Blob service, including
13601392
Azure Storage Analytics. If an element (ex Logging) is left as None, the
@@ -1389,6 +1421,11 @@ def set_blob_service_properties(
13891421
It also specifies the number of days and versions of blob to keep.
13901422
:type delete_retention_policy:
13911423
:class:`~azure.storage.common.models.DeleteRetentionPolicy`
1424+
:param static_website:
1425+
Specifies whether the static website feature is enabled,
1426+
and if yes, indicates the index document and 404 error document to use.
1427+
:type static_website:
1428+
:class:`~azure.storage.common.models.StaticWebsite`
13921429
'''
13931430
request = HTTPRequest()
13941431
request.method = 'PUT'
@@ -1401,7 +1438,7 @@ def set_blob_service_properties(
14011438
}
14021439
request.body = _get_request_body(
14031440
_convert_service_properties_to_xml(logging, hour_metrics, minute_metrics,
1404-
cors, target_version, delete_retention_policy))
1441+
cors, target_version, delete_retention_policy, static_website))
14051442

14061443
self._perform_request(request)
14071444

@@ -1575,10 +1612,21 @@ def exists(self, container_name, blob_name=None, snapshot=None, timeout=None):
15751612
'''
15761613
_validate_not_none('container_name', container_name)
15771614
try:
1578-
if blob_name is None:
1579-
self.get_container_properties(container_name, timeout=timeout)
1580-
else:
1581-
self.get_blob_properties(container_name, blob_name, snapshot=snapshot, timeout=timeout)
1615+
# make head request to see if container/blob/snapshot exists
1616+
request = HTTPRequest()
1617+
request.method = 'GET' if blob_name is None else 'HEAD'
1618+
request.host_locations = self._get_host_locations(secondary=True)
1619+
request.path = _get_path(container_name, blob_name)
1620+
request.query = {
1621+
'snapshot': _to_str(snapshot),
1622+
'timeout': _int_to_str(timeout),
1623+
'restype': 'container' if blob_name is None else None,
1624+
}
1625+
1626+
expected_errors = [_CONTAINER_NOT_FOUND_ERROR_CODE] if blob_name is None \
1627+
else [_CONTAINER_NOT_FOUND_ERROR_CODE, _BLOB_NOT_FOUND_ERROR_CODE]
1628+
self._perform_request(request, expected_errors=expected_errors)
1629+
15821630
return True
15831631
except AzureHttpError as ex:
15841632
_dont_fail_not_exist(ex)

azure-storage-blob/azure/storage/blob/blockblobservice.py

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def put_block(self, container_name, blob_name, block, block_id,
152152
:param str container_name:
153153
Name of existing container.
154154
:param str blob_name:
155-
Name of existing blob.
155+
Name of blob.
156156
:param block: Content of the block.
157157
:type block: io.IOBase or bytes
158158
Content of the block.
@@ -315,6 +315,61 @@ def get_block_list(self, container_name, blob_name, snapshot=None,
315315

316316
return self._perform_request(request, _convert_xml_to_block_list)
317317

318+
def put_block_from_url(self, container_name, blob_name, copy_source_url, source_range_start, source_range_end,
319+
block_id, source_content_md5=None, lease_id=None, timeout=None):
320+
"""
321+
Creates a new block to be committed as part of a blob.
322+
323+
:param str container_name:
324+
Name of existing container.
325+
:param str blob_name:
326+
Name of blob.
327+
:param str copy_source_url:
328+
The URL of the source data. It can point to any Azure Blob or File, that is either public or has a
329+
shared access signature attached.
330+
:param int source_range_start:
331+
This indicates the start of the range of bytes(inclusive) that has to be taken from the copy source.
332+
:param int source_range_end:
333+
This indicates the end of the range of bytes(inclusive) that has to be taken from the copy source.
334+
:param str block_id:
335+
A valid Base64 string value that identifies the block. Prior to
336+
encoding, the string must be less than or equal to 64 bytes in size.
337+
For a given blob, the length of the value specified for the blockid
338+
parameter must be the same size for each block. Note that the Base64
339+
string must be URL-encoded.
340+
:param str source_content_md5:
341+
If given, the service will calculate the MD5 hash of the block content and compare against this value.
342+
:param str lease_id:
343+
Required if the blob has an active lease.
344+
:param int timeout:
345+
The timeout parameter is expressed in seconds.
346+
"""
347+
_validate_encryption_unsupported(self.require_encryption, self.key_encryption_key)
348+
_validate_not_none('container_name', container_name)
349+
_validate_not_none('blob_name', blob_name)
350+
_validate_not_none('copy_source_url', copy_source_url)
351+
_validate_not_none('source_range_start', source_range_start)
352+
_validate_not_none('source_range_end', source_range_end)
353+
_validate_not_none('block_id', block_id)
354+
355+
request = HTTPRequest()
356+
request.method = 'PUT'
357+
request.host_locations = self._get_host_locations()
358+
request.path = _get_path(container_name, blob_name)
359+
request.query = {
360+
'comp': 'block',
361+
'blockid': _encode_base64(_to_str(block_id)),
362+
'timeout': _int_to_str(timeout),
363+
}
364+
request.headers = {
365+
'x-ms-lease-id': _to_str(lease_id),
366+
'x-ms-copy-source': copy_source_url,
367+
'x-ms-source-range': 'bytes=' + _to_str(source_range_start) + '-' + _to_str(source_range_end),
368+
'x-ms-source-content-md5': source_content_md5,
369+
}
370+
371+
self._perform_request(request)
372+
318373
# ----Convenience APIs-----------------------------------------------------
319374

320375
def create_blob_from_path(
@@ -791,7 +846,7 @@ def create_blob_from_text(
791846
timeout=timeout)
792847

793848
def set_standard_blob_tier(
794-
self, container_name, blob_name, standard_blob_tier, timeout=None):
849+
self, container_name, blob_name, standard_blob_tier, timeout=None):
795850
'''
796851
Sets the block blob tiers on the blob. This API is only supported for block blobs on standard storage accounts.
797852

azure-storage-blob/azure/storage/blob/models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,3 +762,19 @@ class StandardBlobTier(object):
762762

763763
Hot = 'Hot'
764764
''' Hot '''
765+
766+
767+
class AccountInformation(object):
768+
"""
769+
Holds information related to the storage account.
770+
771+
:ivar str sku_name:
772+
Name of the storage SKU, also known as account type.
773+
Example: Standard_LRS, Standard_ZRS, Standard_GRS, Standard_RAGRS, Premium_LRS, Premium_ZRS
774+
:ivar str account_kind:
775+
Describes the flavour of the storage account, also known as account kind.
776+
Example: Storage, StorageV2, BlobStorage
777+
"""
778+
def __init__(self):
779+
self.sku_name = None
780+
self.account_kind = None

azure-storage-blob/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
setup(
5353
name='azure-storage-blob',
54-
version='1.2.0rc1',
54+
version='1.3.0',
5555
description='Microsoft Azure Storage Blob Client Library for Python',
5656
long_description=open('README.rst', 'r').read(),
5757
license='MIT License',
@@ -74,7 +74,7 @@
7474
packages=find_packages(),
7575
install_requires=[
7676
'azure-common>=1.1.5',
77-
'azure-storage-common>=1.2.0rc1,<1.3.0'
77+
'azure-storage-common>=1.3.0,<1.4.0'
7878
],
7979
extras_require={
8080
":python_version<'3.0'": ['futures'],

azure-storage-common/ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
> See [BreakingChanges](BreakingChanges.md) for a detailed list of API breaks.
44
5+
## Version 1.3.0:
6+
7+
- Support for 2018-03-28 REST version. Please see our REST API documentation and blog for information about the related added features.
8+
59
## Version 1.2.0rc1:
610

711
- Increased default socket timeout to a more reasonable number for Python 3.5+.

azure-storage-common/azure/storage/common/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Metrics,
1616
CorsRule,
1717
DeleteRetentionPolicy,
18+
StaticWebsite,
1819
ServiceProperties,
1920
AccessPolicy,
2021
ResourceTypes,

0 commit comments

Comments
 (0)