diff --git a/sdk/storage/azure-storage-blob/HISTORY.md b/sdk/storage/azure-storage-blob/HISTORY.md
index 19adb3fc1c4d..c1a63491eb3c 100644
--- a/sdk/storage/azure-storage-blob/HISTORY.md
+++ b/sdk/storage/azure-storage-blob/HISTORY.md
@@ -7,6 +7,9 @@
- `set_container_access_policy` has required parameter `signed_identifiers`.
- NoRetry policy has been removed. Use keyword argument `retry_total=0` for no retries.
+**New features**
+
+- `ResourceTypes`, and `Services` now have method `from_string` which takes parameters as a string.
## Version 12.0.0b4:
@@ -44,6 +47,8 @@ changed include:
- Add support for set_premium_page_blob_tier_blobs to ContainerClient (Python 3 only)
- Added support to set rehydrate blob priority for Block Blob, including Set Standard Blob Tier/Copy Blob APIs
- Added blob tier support for Block Blob, including Upload Blob/Commit Block List/Copy Blob APIs.
+- `AccountSasPermissions`, `BlobSasPermissions`, `ContainerSasPermissions` now have method `from_string`
+which takes parameters as a string.
**Fixes and improvements**
- Downloading page blobs now take advantage of their sparseness.
diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/models.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/models.py
index c42edbc3745f..80c4d22a6b2f 100644
--- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/models.py
+++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/models.py
@@ -225,16 +225,6 @@ class ResourceTypes(object):
"""
Specifies the resource types that are accessible with the account SAS.
- :cvar ResourceTypes ResourceTypes.CONTAINER:
- Access to container-level APIs (e.g., Create/Delete Container,
- Create/Delete Queue, Create/Delete Share,
- List Blobs/Files and Directories)
- :cvar ResourceTypes ResourceTypes.OBJECT:
- Access to object-level APIs for blobs, queue messages, and
- files(e.g. Put Blob, Query Entity, Get Messages, Create File, etc.)
- :cvar ResourceTypes ResourceTypes.SERVICE:
- Access to service-level APIs (e.g., Get/Set Service Properties,
- Get Service Stats, List Containers/Queues/Shares)
:param bool service:
Access to service-level APIs (e.g., Get/Set Service Properties,
Get Service Stats, List Containers/Queues/Shares)
@@ -245,36 +235,28 @@ class ResourceTypes(object):
:param bool object:
Access to object-level APIs for blobs, queue messages, and
files(e.g. Put Blob, Query Entity, Get Messages, Create File, etc.)
- :param str _str:
- A string representing the resource types.
"""
- SERVICE = None # type: ResourceTypes
- CONTAINER = None # type: ResourceTypes
- OBJECT = None # type: ResourceTypes
-
- def __init__(self, service=False, container=False, object=False, _str=None): # pylint: disable=redefined-builtin
- if not _str:
- _str = ''
- self.service = service or ('s' in _str)
- self.container = container or ('c' in _str)
- self.object = object or ('o' in _str)
-
- def __or__(self, other):
- return ResourceTypes(_str=str(self) + str(other))
-
- def __add__(self, other):
- return ResourceTypes(_str=str(self) + str(other))
-
- def __str__(self):
- return (('s' if self.service else '') +
+ def __init__(self, service=False, container=False, object=False): # pylint: disable=redefined-builtin
+ self.service = service
+ self.container = container
+ self.object = object
+ self._str = (('s' if self.service else '') +
('c' if self.container else '') +
('o' if self.object else ''))
+ def __str__(self):
+ return self._str
+
+ @classmethod
+ def from_string(cls, string):
+ res_service = 's' in string
+ res_container = 'c' in string
+ res_object = 'o' in string
-ResourceTypes.SERVICE = ResourceTypes(service=True)
-ResourceTypes.CONTAINER = ResourceTypes(container=True)
-ResourceTypes.OBJECT = ResourceTypes(object=True)
+ parsed = cls(res_service, res_container, res_object)
+ parsed._str = string # pylint: disable = protected-access
+ return parsed
class AccountSasPermissions(object):
@@ -348,46 +330,34 @@ def from_string(cls, permission):
class Services(object):
"""Specifies the services accessible with the account SAS.
- :cvar Services Services.BLOB: The blob service.
- :cvar Services Services.FILE: The file service
- :cvar Services Services.QUEUE: The queue service.
:param bool blob:
Access for the `~azure.storage.blob.blob_service_client.BlobServiceClient`
:param bool queue:
Access for the `~azure.storage.queue.queue_service_client.QueueServiceClient`
:param bool file:
Access for the `~azure.storage.file.file_service_client.FileServiceClient`
- :param str _str:
- A string representing the services.
"""
- BLOB = None # type: Services
- QUEUE = None # type: Services
- FILE = None # type: Services
-
- def __init__(self, blob=False, queue=False, file=False, _str=None):
- if not _str:
- _str = ''
- self.blob = blob or ('b' in _str)
- self.queue = queue or ('q' in _str)
- self.file = file or ('f' in _str)
-
- def __or__(self, other):
- return Services(_str=str(self) + str(other))
-
- def __add__(self, other):
- return Services(_str=str(self) + str(other))
-
- def __str__(self):
- return (('b' if self.blob else '') +
+ def __init__(self, blob=False, queue=False, file=False):
+ self.blob = blob
+ self.queue = queue
+ self.file = file
+ self._str = (('b' if self.blob else '') +
('q' if self.queue else '') +
('f' if self.file else ''))
+ def __str__(self):
+ return self._str
-Services.BLOB = Services(blob=True)
-Services.QUEUE = Services(queue=True)
-Services.FILE = Services(file=True)
+ @classmethod
+ def from_string(cls, string):
+ res_blob = 'b' in string
+ res_queue = 'q' in string
+ res_file = 'f' in string
+ parsed = cls(res_blob, res_queue, res_file)
+ parsed._str = string # pylint: disable = protected-access
+ return parsed
class UserDelegationKey(object):
"""
diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/blob_service_client.py b/sdk/storage/azure-storage-blob/azure/storage/blob/blob_service_client.py
index dff7cbf0dfa0..7293401b7baa 100644
--- a/sdk/storage/azure-storage-blob/azure/storage/blob/blob_service_client.py
+++ b/sdk/storage/azure-storage-blob/azure/storage/blob/blob_service_client.py
@@ -221,7 +221,7 @@ def generate_shared_access_signature(
sas = SharedAccessSignature(self.credential.account_name, self.credential.account_key)
return sas.generate_account(
- services=Services.BLOB,
+ services=Services(blob=True),
resource_types=resource_types,
permission=permission,
expiry=expiry,
diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_samples_authentication.py b/sdk/storage/azure-storage-blob/tests/test_blob_samples_authentication.py
index 930fd8c666a3..780c7660823b 100644
--- a/sdk/storage/azure-storage-blob/tests/test_blob_samples_authentication.py
+++ b/sdk/storage/azure-storage-blob/tests/test_blob_samples_authentication.py
@@ -118,7 +118,7 @@ def test_auth_shared_access_signature(self):
from azure.storage.blob import ResourceTypes, AccountSasPermissions
sas_token = blob_service_client.generate_shared_access_signature(
- resource_types=ResourceTypes.OBJECT,
+ resource_types=ResourceTypes(object=True),
permission=AccountSasPermissions(read=True),
expiry=datetime.utcnow() + timedelta(hours=1)
)
diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_samples_authentication_async.py b/sdk/storage/azure-storage-blob/tests/test_blob_samples_authentication_async.py
index f9783f26ad36..817a75882e76 100644
--- a/sdk/storage/azure-storage-blob/tests/test_blob_samples_authentication_async.py
+++ b/sdk/storage/azure-storage-blob/tests/test_blob_samples_authentication_async.py
@@ -143,7 +143,7 @@ async def _test_auth_shared_access_signature_async(self):
from azure.storage.blob import ResourceTypes, AccountSasPermissions
sas_token = blob_service_client.generate_shared_access_signature(
- resource_types=ResourceTypes.OBJECT,
+ resource_types=ResourceTypes(object=True),
permission=AccountSasPermissions(read=True),
expiry=datetime.utcnow() + timedelta(hours=1)
)
diff --git a/sdk/storage/azure-storage-file/HISTORY.md b/sdk/storage/azure-storage-file/HISTORY.md
index c5ed88ae81e1..90469ea1e899 100644
--- a/sdk/storage/azure-storage-file/HISTORY.md
+++ b/sdk/storage/azure-storage-file/HISTORY.md
@@ -6,8 +6,11 @@
- `file_permission_key` parameter has been renamed to `permission_key`
- `set_share_access_policy` has required parameter `signed_identifiers`.
-- NoRetry policy has been removed. Use keyword argument `retry_total=0` for no retries.
+- NoRetry policy has been removed. Use keyword argument `retry_total=0` for no retries.
+**New features**
+
+- `ResourceTypes`, `NTFSAttributes`, and `Services` now have method `from_string` which takes parameters as a string.
## Version 12.0.0b4:
@@ -20,6 +23,11 @@
- `__add__` and `__or__` methods are removed.
- `max_connections` is now renamed to `max_concurrency`.
+**New features**
+
+- `AccountSasPermissions`, `FileSasPermissions`, `ShareSasPermissions` now have method `from_string` which
+takes parameters as a string.
+
## Version 12.0.0b3:
**New features**
diff --git a/sdk/storage/azure-storage-file/azure/storage/file/_shared/models.py b/sdk/storage/azure-storage-file/azure/storage/file/_shared/models.py
index 3234c72b534f..943842ced4c2 100644
--- a/sdk/storage/azure-storage-file/azure/storage/file/_shared/models.py
+++ b/sdk/storage/azure-storage-file/azure/storage/file/_shared/models.py
@@ -225,16 +225,6 @@ class ResourceTypes(object):
"""
Specifies the resource types that are accessible with the account SAS.
- :cvar ResourceTypes ResourceTypes.CONTAINER:
- Access to container-level APIs (e.g., Create/Delete Container,
- Create/Delete Queue, Create/Delete Share,
- List Blobs/Files and Directories)
- :cvar ResourceTypes ResourceTypes.OBJECT:
- Access to object-level APIs for blobs, queue messages, and
- files(e.g. Put Blob, Query Entity, Get Messages, Create File, etc.)
- :cvar ResourceTypes ResourceTypes.SERVICE:
- Access to service-level APIs (e.g., Get/Set Service Properties,
- Get Service Stats, List Containers/Queues/Shares)
:param bool service:
Access to service-level APIs (e.g., Get/Set Service Properties,
Get Service Stats, List Containers/Queues/Shares)
@@ -245,36 +235,28 @@ class ResourceTypes(object):
:param bool object:
Access to object-level APIs for blobs, queue messages, and
files(e.g. Put Blob, Query Entity, Get Messages, Create File, etc.)
- :param str _str:
- A string representing the resource types.
"""
- SERVICE = None # type: ResourceTypes
- CONTAINER = None # type: ResourceTypes
- OBJECT = None # type: ResourceTypes
-
- def __init__(self, service=False, container=False, object=False, _str=None): # pylint: disable=redefined-builtin
- if not _str:
- _str = ''
- self.service = service or ('s' in _str)
- self.container = container or ('c' in _str)
- self.object = object or ('o' in _str)
-
- def __or__(self, other):
- return ResourceTypes(_str=str(self) + str(other))
-
- def __add__(self, other):
- return ResourceTypes(_str=str(self) + str(other))
-
- def __str__(self):
- return (('s' if self.service else '') +
+ def __init__(self, service=False, container=False, object=False): # pylint: disable=redefined-builtin
+ self.service = service
+ self.container = container
+ self.object = object
+ self._str = (('s' if self.service else '') +
('c' if self.container else '') +
('o' if self.object else ''))
+ def __str__(self):
+ return self._str
+
+ @classmethod
+ def from_string(cls, string):
+ res_service = 's' in string
+ res_container = 'c' in string
+ res_object = 'o' in string
-ResourceTypes.SERVICE = ResourceTypes(service=True)
-ResourceTypes.CONTAINER = ResourceTypes(container=True)
-ResourceTypes.OBJECT = ResourceTypes(object=True)
+ parsed = cls(res_service, res_container, res_object)
+ parsed._str = string # pylint: disable = protected-access
+ return parsed
class AccountSasPermissions(object):
@@ -285,6 +267,7 @@ class AccountSasPermissions(object):
specific resource (resource-specific). Another is to grant access to the
entire service for a specific account and allow certain operations based on
perms found here.
+
:param bool read:
Valid for all signed resources types (Service, Container, and Object).
Permits read permissions to the specified resource type.
@@ -346,45 +329,34 @@ def from_string(cls, permission):
class Services(object):
"""Specifies the services accessible with the account SAS.
- :cvar Services Services.BLOB: The blob service.
- :cvar Services Services.FILE: The file service
- :cvar Services Services.QUEUE: The queue service.
:param bool blob:
Access for the `~azure.storage.blob.blob_service_client.BlobServiceClient`
:param bool queue:
Access for the `~azure.storage.queue.queue_service_client.QueueServiceClient`
:param bool file:
Access for the `~azure.storage.file.file_service_client.FileServiceClient`
- :param str _str:
- A string representing the services.
"""
- BLOB = None # type: Services
- QUEUE = None # type: Services
- FILE = None # type: Services
-
- def __init__(self, blob=False, queue=False, file=False, _str=None):
- if not _str:
- _str = ''
- self.blob = blob or ('b' in _str)
- self.queue = queue or ('q' in _str)
- self.file = file or ('f' in _str)
-
- def __or__(self, other):
- return Services(_str=str(self) + str(other))
-
- def __add__(self, other):
- return Services(_str=str(self) + str(other))
-
- def __str__(self):
- return (('b' if self.blob else '') +
+ def __init__(self, blob=False, queue=False, file=False):
+ self.blob = blob
+ self.queue = queue
+ self.file = file
+ self._str = (('b' if self.blob else '') +
('q' if self.queue else '') +
('f' if self.file else ''))
+ def __str__(self):
+ return self._str
-Services.BLOB = Services(blob=True)
-Services.QUEUE = Services(queue=True)
-Services.FILE = Services(file=True)
+ @classmethod
+ def from_string(cls, string):
+ res_blob = 'b' in string
+ res_queue = 'q' in string
+ res_file = 'f' in string
+
+ parsed = cls(res_blob, res_queue, res_file)
+ parsed._str = string # pylint: disable = protected-access
+ return parsed
class UserDelegationKey(object):
diff --git a/sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py b/sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py
index f2d6ee41666a..434de64c3654 100644
--- a/sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py
+++ b/sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py
@@ -198,7 +198,7 @@ def generate_shared_access_signature(
sas = SharedAccessSignature(self.credential.account_name, self.credential.account_key)
return sas.generate_account(
- services=Services.FILE,
+ services=Services(file=True),
resource_types=resource_types,
permission=permission,
expiry=expiry,
diff --git a/sdk/storage/azure-storage-file/azure/storage/file/models.py b/sdk/storage/azure-storage-file/azure/storage/file/models.py
index 67aa5967a0e4..de65f213a916 100644
--- a/sdk/storage/azure-storage-file/azure/storage/file/models.py
+++ b/sdk/storage/azure-storage-file/azure/storage/file/models.py
@@ -742,28 +742,19 @@ class NTFSAttributes(object):
Enable/disable 'NoScrubData' attribute for DIRECTORY or FILE
"""
def __init__(self, read_only=False, hidden=False, system=False, none=False, directory=False, archive=False,
- temporary=False, offline=False, not_content_indexed=False, no_scrub_data=False, _str=None):
- if not _str:
- _str = ''
- self.read_only = read_only or ('ReadOnly' in _str)
- self.hidden = hidden or ('Hidden' in _str)
- self.system = system or ('System' in _str)
- self.none = none or ('None' in _str)
- self.directory = directory or ('Directory' in _str)
- self.archive = archive or ('Archive' in _str)
- self.temporary = temporary or ('Temporary' in _str)
- self.offline = offline or ('Offline' in _str)
- self.not_content_indexed = not_content_indexed or ('NotContentIndexed' in _str)
- self.no_scrub_data = no_scrub_data or ('NoScrubData' in _str)
-
- def __or__(self, other):
- return NTFSAttributes(_str=str(self) + str(other))
-
- def __add__(self, other):
- return NTFSAttributes(_str=str(self) + str(other))
-
- def __str__(self):
- concatenated_params = (('ReadOnly|' if self.read_only else '') +
+ temporary=False, offline=False, not_content_indexed=False, no_scrub_data=False):
+
+ self.read_only = read_only
+ self.hidden = hidden
+ self.system = system
+ self.none = none
+ self.directory = directory
+ self.archive = archive
+ self.temporary = temporary
+ self.offline = offline
+ self.not_content_indexed = not_content_indexed
+ self.no_scrub_data = no_scrub_data
+ self._str = (('ReadOnly|' if self.read_only else '') +
('Hidden|' if self.hidden else '') +
('System|' if self.system else '') +
('None|' if self.none else '') +
@@ -774,16 +765,24 @@ def __str__(self):
('NotContentIndexed|' if self.not_content_indexed else '') +
('NoScrubData|' if self.no_scrub_data else ''))
+ def __str__(self):
+ concatenated_params = self._str
return concatenated_params.strip('|')
-
-NTFSAttributes.READ_ONLY = NTFSAttributes(read_only=True)
-NTFSAttributes.HIDDEN = NTFSAttributes(hidden=True)
-NTFSAttributes.SYSTEM = NTFSAttributes(system=True)
-NTFSAttributes.NONE = NTFSAttributes(none=True)
-NTFSAttributes.DIRECTORY = NTFSAttributes(directory=True)
-NTFSAttributes.ARCHIVE = NTFSAttributes(archive=True)
-NTFSAttributes.TEMPORARY = NTFSAttributes(temporary=True)
-NTFSAttributes.OFFLINE = NTFSAttributes(offline=True)
-NTFSAttributes.NOT_CONTENT_INDEXED = NTFSAttributes(not_content_indexed=True)
-NTFSAttributes.NO_SCRUB_DATA = NTFSAttributes(no_scrub_data=True)
+ @classmethod
+ def from_string(cls, string):
+ read_only = "ReadOnly" in string
+ hidden = "Hidden" in string
+ system = "System" in string
+ none = "None" in string
+ directory = "Directory" in string
+ archive = "Archive" in string
+ temporary = "Temporary" in string
+ offline = "Offline" in string
+ not_content_indexed = "NotContentIndexed" in string
+ no_scrub_data = "NoScrubData" in string
+
+ parsed = cls(read_only, hidden, system, none, directory, archive, temporary, offline, not_content_indexed,
+ no_scrub_data)
+ parsed._str = string # pylint: disable = protected-access
+ return parsed
diff --git a/sdk/storage/azure-storage-file/tests/test_file.py b/sdk/storage/azure-storage-file/tests/test_file.py
index 97d677dbd3d3..47441500d4c5 100644
--- a/sdk/storage/azure-storage-file/tests/test_file.py
+++ b/sdk/storage/azure-storage-file/tests/test_file.py
@@ -1456,7 +1456,7 @@ def test_account_sas(self):
# Arrange
file_client = self._create_file()
token = self.fsc.generate_shared_access_signature(
- ResourceTypes.OBJECT,
+ ResourceTypes(object=True),
AccountSasPermissions(read=True),
datetime.utcnow() + timedelta(hours=1),
)
diff --git a/sdk/storage/azure-storage-file/tests/test_file_async.py b/sdk/storage/azure-storage-file/tests/test_file_async.py
index 68a29bd49f03..f866d92fc012 100644
--- a/sdk/storage/azure-storage-file/tests/test_file_async.py
+++ b/sdk/storage/azure-storage-file/tests/test_file_async.py
@@ -1797,7 +1797,7 @@ async def _test_account_sas_async(self):
# Arrange
file_client = await self._create_file()
token = self.fsc.generate_shared_access_signature(
- ResourceTypes.OBJECT,
+ ResourceTypes(object=True),
AccountSasPermissions(read=True),
datetime.utcnow() + timedelta(hours=1),
)
diff --git a/sdk/storage/azure-storage-queue/HISTORY.md b/sdk/storage/azure-storage-queue/HISTORY.md
index ff0243385bdf..9d9ead72bb17 100644
--- a/sdk/storage/azure-storage-queue/HISTORY.md
+++ b/sdk/storage/azure-storage-queue/HISTORY.md
@@ -5,7 +5,11 @@
**Breaking changes**
- `set_queue_access_policy` has required parameter `signed_identifiers`.
-- NoRetry policy has been removed. Use keyword argument `retry_total=0` for no retries.
+- NoRetry policy has been removed. Use keyword argument `retry_total=0` for no retries.
+
+ **New features**
+
+- `ResourceTypes`, and `Services` now have method `from_string` which takes parameters as a string.
## Version 12.0.0b4:
@@ -19,6 +23,10 @@
- `__add__` and `__or__` methods are removed.
- `max_connections` is now renamed to `max_concurrency`.
+**New features**
+
+- `AccountSasPermissions`, `QueueSasPermissions` now have method `from_string` which takes parameters as a string.
+
## Version 12.0.0b3:
**Dependency updates**
diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/models.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/models.py
index 0fd6d4de786c..b8078927e0de 100644
--- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/models.py
+++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/models.py
@@ -225,16 +225,6 @@ class ResourceTypes(object):
"""
Specifies the resource types that are accessible with the account SAS.
- :cvar ResourceTypes ResourceTypes.CONTAINER:
- Access to container-level APIs (e.g., Create/Delete Container,
- Create/Delete Queue, Create/Delete Share,
- List Blobs/Files and Directories)
- :cvar ResourceTypes ResourceTypes.OBJECT:
- Access to object-level APIs for blobs, queue messages, and
- files(e.g. Put Blob, Query Entity, Get Messages, Create File, etc.)
- :cvar ResourceTypes ResourceTypes.SERVICE:
- Access to service-level APIs (e.g., Get/Set Service Properties,
- Get Service Stats, List Containers/Queues/Shares)
:param bool service:
Access to service-level APIs (e.g., Get/Set Service Properties,
Get Service Stats, List Containers/Queues/Shares)
@@ -245,36 +235,28 @@ class ResourceTypes(object):
:param bool object:
Access to object-level APIs for blobs, queue messages, and
files(e.g. Put Blob, Query Entity, Get Messages, Create File, etc.)
- :param str _str:
- A string representing the resource types.
"""
- SERVICE = None # type: ResourceTypes
- CONTAINER = None # type: ResourceTypes
- OBJECT = None # type: ResourceTypes
-
- def __init__(self, service=False, container=False, object=False, _str=None): # pylint: disable=redefined-builtin
- if not _str:
- _str = ''
- self.service = service or ('s' in _str)
- self.container = container or ('c' in _str)
- self.object = object or ('o' in _str)
-
- def __or__(self, other):
- return ResourceTypes(_str=str(self) + str(other))
-
- def __add__(self, other):
- return ResourceTypes(_str=str(self) + str(other))
-
- def __str__(self):
- return (('s' if self.service else '') +
+ def __init__(self, service=False, container=False, object=False): # pylint: disable=redefined-builtin
+ self.service = service
+ self.container = container
+ self.object = object
+ self._str = (('s' if self.service else '') +
('c' if self.container else '') +
('o' if self.object else ''))
+ def __str__(self):
+ return self._str
-ResourceTypes.SERVICE = ResourceTypes(service=True)
-ResourceTypes.CONTAINER = ResourceTypes(container=True)
-ResourceTypes.OBJECT = ResourceTypes(object=True)
+ @classmethod
+ def from_string(cls, string):
+ res_service = 's' in string
+ res_container = 'c' in string
+ res_object = 'o' in string
+
+ parsed = cls(res_service, res_container, res_object)
+ parsed._str = string # pylint: disable = protected-access
+ return parsed
class AccountSasPermissions(object):
@@ -347,45 +329,34 @@ def from_string(cls, permission):
class Services(object):
"""Specifies the services accessible with the account SAS.
- :cvar Services Services.BLOB: The blob service.
- :cvar Services Services.FILE: The file service
- :cvar Services Services.QUEUE: The queue service.
:param bool blob:
Access for the `~azure.storage.blob.blob_service_client.BlobServiceClient`
:param bool queue:
Access for the `~azure.storage.queue.queue_service_client.QueueServiceClient`
:param bool file:
Access for the `~azure.storage.file.file_service_client.FileServiceClient`
- :param str _str:
- A string representing the services.
"""
- BLOB = None # type: Services
- QUEUE = None # type: Services
- FILE = None # type: Services
-
- def __init__(self, blob=False, queue=False, file=False, _str=None):
- if not _str:
- _str = ''
- self.blob = blob or ('b' in _str)
- self.queue = queue or ('q' in _str)
- self.file = file or ('f' in _str)
-
- def __or__(self, other):
- return Services(_str=str(self) + str(other))
-
- def __add__(self, other):
- return Services(_str=str(self) + str(other))
-
- def __str__(self):
- return (('b' if self.blob else '') +
+ def __init__(self, blob=False, queue=False, file=False):
+ self.blob = blob
+ self.queue = queue
+ self.file = file
+ self._str = (('b' if self.blob else '') +
('q' if self.queue else '') +
('f' if self.file else ''))
+ def __str__(self):
+ return self._str
+
+ @classmethod
+ def from_string(cls, string):
+ res_blob = 'b' in string
+ res_queue = 'q' in string
+ res_file = 'f' in string
-Services.BLOB = Services(blob=True)
-Services.QUEUE = Services(queue=True)
-Services.FILE = Services(file=True)
+ parsed = cls(res_blob, res_queue, res_file)
+ parsed._str = string # pylint: disable = protected-access
+ return parsed
class UserDelegationKey(object):
diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/queue_service_client.py b/sdk/storage/azure-storage-queue/azure/storage/queue/queue_service_client.py
index 7c04e38d4813..edd0c4f0ed33 100644
--- a/sdk/storage/azure-storage-queue/azure/storage/queue/queue_service_client.py
+++ b/sdk/storage/azure-storage-queue/azure/storage/queue/queue_service_client.py
@@ -198,7 +198,7 @@ def generate_shared_access_signature(
sas = SharedAccessSignature(self.credential.account_name, self.credential.account_key)
return sas.generate_account(
- services=Services.QUEUE,
+ services=Services(queue=True),
resource_types=resource_types,
permission=permission,
expiry=expiry,
diff --git a/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_account_sas.yaml b/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_account_sas.yaml
index 78d0219d19e0..82ff167df112 100644
--- a/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_account_sas.yaml
+++ b/sdk/storage/azure-storage-queue/tests/recordings/test_queue.test_account_sas.yaml
@@ -11,11 +11,9 @@ interactions:
Content-Length:
- '0'
User-Agent:
- - azsdk-python-storage-queue/12.0.0b2 Python/3.7.3 (Windows-10-10.0.17763-SP0)
- content-type:
- - application/xml; charset=utf-8
+ - azsdk-python-storage-queue/12.0.0b4 Python/3.7.3 (Windows-10-10.0.18362-SP0)
x-ms-date:
- - Fri, 06 Sep 2019 21:52:03 GMT
+ - Mon, 14 Oct 2019 17:42:19 GMT
x-ms-version:
- '2018-03-28'
method: PUT
@@ -27,7 +25,7 @@ interactions:
content-length:
- '0'
date:
- - Fri, 06 Sep 2019 21:52:02 GMT
+ - Mon, 14 Oct 2019 17:42:15 GMT
server:
- Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0
x-ms-version:
@@ -51,24 +49,24 @@ interactions:
Content-Type:
- application/xml; charset=utf-8
User-Agent:
- - azsdk-python-storage-queue/12.0.0b2 Python/3.7.3 (Windows-10-10.0.17763-SP0)
+ - azsdk-python-storage-queue/12.0.0b4 Python/3.7.3 (Windows-10-10.0.18362-SP0)
x-ms-date:
- - Fri, 06 Sep 2019 21:52:04 GMT
+ - Mon, 14 Oct 2019 17:42:20 GMT
x-ms-version:
- '2018-03-28'
method: POST
uri: https://pyacrstorage9c250b25.queue.core.windows.net/pythonqueue9c250b25/messages
response:
body:
- string: "\uFEFFb4d0220c-ce49-4953-86fd-871e34eb269fFri,
- 06 Sep 2019 21:52:02 GMTFri, 13 Sep 2019 21:52:02
- GMTAgAAAAMAAAAAAAAAZasDUf1k1QE=Fri,
- 06 Sep 2019 21:52:02 GMT"
+ string: "\uFEFF2ed39c4e-3a6a-4328-b26e-3d47ef45067aMon,
+ 14 Oct 2019 17:42:16 GMTMon, 21 Oct 2019 17:42:16
+ GMTAgAAAAMAAAAAAAAA1PYYuLaC1QE=Mon,
+ 14 Oct 2019 17:42:16 GMT"
headers:
content-type:
- application/xml
date:
- - Fri, 06 Sep 2019 21:52:02 GMT
+ - Mon, 14 Oct 2019 17:42:16 GMT
server:
- Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
@@ -88,17 +86,17 @@ interactions:
Connection:
- keep-alive
User-Agent:
- - azsdk-python-storage-queue/12.0.0b2 Python/3.7.3 (Windows-10-10.0.17763-SP0)
+ - azsdk-python-storage-queue/12.0.0b4 Python/3.7.3 (Windows-10-10.0.18362-SP0)
x-ms-date:
- - Fri, 06 Sep 2019 21:52:04 GMT
+ - Mon, 14 Oct 2019 17:42:20 GMT
x-ms-version:
- '2018-03-28'
method: GET
- uri: https://pyacrstorage9c250b25.queue.core.windows.net/pythonqueue9c250b25/messages?peekonly=true&st=2019-09-06T21%3A47%3A04Z&se=2019-09-06T22%3A52%3A04Z&sp=r&sv=2018-03-28&ss=q&srt=o&sig=SpqwtmOiwSKHBHaK2lrd5QSOc3KluM8DYlG2iZn6YE0%3D
+ uri: https://pyacrstorage9c250b25.queue.core.windows.net/pythonqueue9c250b25/messages?peekonly=true&st=2019-10-14T17%3A37%3A20Z&se=2019-10-14T18%3A42%3A20Z&sp=r&sv=2018-03-28&ss=q&srt=o&sig=KlW5dNogfEs3vFfAVtYWPKqJrAIF2GerVf8APb/Zf5I%3D
response:
body:
- string: "\uFEFFb4d0220c-ce49-4953-86fd-871e34eb269fFri,
- 06 Sep 2019 21:52:02 GMTFri, 13 Sep 2019 21:52:02
+ string: "\uFEFF2ed39c4e-3a6a-4328-b26e-3d47ef45067aMon,
+ 14 Oct 2019 17:42:16 GMTMon, 21 Oct 2019 17:42:16
GMT0message1"
headers:
cache-control:
@@ -106,7 +104,7 @@ interactions:
content-type:
- application/xml
date:
- - Fri, 06 Sep 2019 21:52:02 GMT
+ - Mon, 14 Oct 2019 17:42:16 GMT
server:
- Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
diff --git a/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_account_sas.yaml b/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_account_sas.yaml
index 4fe8f57a2aa1..19ad305a52f8 100644
--- a/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_account_sas.yaml
+++ b/sdk/storage/azure-storage-queue/tests/recordings/test_queue_async.test_account_sas.yaml
@@ -3,11 +3,9 @@ interactions:
body: null
headers:
User-Agent:
- - azsdk-python-storage-queue/12.0.0b2 Python/3.7.3 (Windows-10-10.0.17763-SP0)
- content-type:
- - application/xml; charset=utf-8
+ - azsdk-python-storage-queue/12.0.0b4 Python/3.7.3 (Windows-10-10.0.18362-SP0)
x-ms-date:
- - Fri, 06 Sep 2019 21:53:39 GMT
+ - Mon, 14 Oct 2019 17:44:45 GMT
x-ms-version:
- '2018-03-28'
method: PUT
@@ -17,7 +15,7 @@ interactions:
string: ''
headers:
content-length: '0'
- date: Fri, 06 Sep 2019 21:53:37 GMT
+ date: Mon, 14 Oct 2019 17:44:40 GMT
server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0
x-ms-version: '2018-03-28'
status:
@@ -43,22 +41,22 @@ interactions:
Content-Type:
- application/xml; charset=utf-8
User-Agent:
- - azsdk-python-storage-queue/12.0.0b2 Python/3.7.3 (Windows-10-10.0.17763-SP0)
+ - azsdk-python-storage-queue/12.0.0b4 Python/3.7.3 (Windows-10-10.0.18362-SP0)
x-ms-date:
- - Fri, 06 Sep 2019 21:53:39 GMT
+ - Mon, 14 Oct 2019 17:44:45 GMT
x-ms-version:
- '2018-03-28'
method: POST
uri: https://pyacrstoragee8a50da2.queue.core.windows.net/pythonqueuee8a50da2/messages
response:
body:
- string: "\uFEFFfe3f5187-bf2b-4aac-9a72-0aba99faaa04Fri,
- 06 Sep 2019 21:53:38 GMTFri, 13 Sep 2019 21:53:38
- GMTAgAAAAMAAAAAAAAAnlnxif1k1QE=Fri,
- 06 Sep 2019 21:53:38 GMT"
+ string: "\uFEFFbc87b9aa-0be1-41f8-abc0-9be61c68e3ddMon,
+ 14 Oct 2019 17:44:41 GMTMon, 21 Oct 2019 17:44:41
+ GMTAgAAAAMAAAAAAAAA2E2XDreC1QE=Mon,
+ 14 Oct 2019 17:44:41 GMT"
headers:
content-type: application/xml
- date: Fri, 06 Sep 2019 21:53:37 GMT
+ date: Mon, 14 Oct 2019 17:44:40 GMT
server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding: chunked
x-ms-version: '2018-03-28'
@@ -79,22 +77,22 @@ interactions:
Accept:
- application/xml
User-Agent:
- - azsdk-python-storage-queue/12.0.0b2 Python/3.7.3 (Windows-10-10.0.17763-SP0)
+ - azsdk-python-storage-queue/12.0.0b4 Python/3.7.3 (Windows-10-10.0.18362-SP0)
x-ms-date:
- - Fri, 06 Sep 2019 21:53:39 GMT
+ - Mon, 14 Oct 2019 17:44:45 GMT
x-ms-version:
- '2018-03-28'
method: GET
- uri: https://pyacrstoragee8a50da2.queue.core.windows.net/pythonqueuee8a50da2/messages?peekonly=true&st=2019-09-06T21:48:39Z&se=2019-09-06T22:53:39Z&sp=r&sv=2018-03-28&ss=q&srt=o&sig=y8ZamgWfnbV2cUmmOOoFvuy51HcnBXg4Ad%2Bl3u2VrFE%3D
+ uri: https://pyacrstoragee8a50da2.queue.core.windows.net/pythonqueuee8a50da2/messages?peekonly=true&st=2019-10-14T17:39:45Z&se=2019-10-14T18:44:45Z&sp=r&sv=2018-03-28&ss=q&srt=o&sig=bjMPAcJl2ocuk6f%2B%2B65rR8Dd6f9c5QnRuS0ELCJVwuo%3D
response:
body:
- string: "\uFEFFfe3f5187-bf2b-4aac-9a72-0aba99faaa04Fri,
- 06 Sep 2019 21:53:38 GMTFri, 13 Sep 2019 21:53:38
+ string: "\uFEFFbc87b9aa-0be1-41f8-abc0-9be61c68e3ddMon,
+ 14 Oct 2019 17:44:41 GMTMon, 21 Oct 2019 17:44:41
GMT0message1"
headers:
cache-control: no-cache
content-type: application/xml
- date: Fri, 06 Sep 2019 21:53:37 GMT
+ date: Mon, 14 Oct 2019 17:44:40 GMT
server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding: chunked
x-ms-version: '2018-03-28'
@@ -107,6 +105,6 @@ interactions:
- https
- pyacrstoragee8a50da2.queue.core.windows.net
- /pythonqueuee8a50da2/messages
- - peekonly=true&st=2019-09-06T21:48:39Z&se=2019-09-06T22:53:39Z&sp=r&sv=2018-03-28&ss=q&srt=o&sig=y8ZamgWfnbV2cUmmOOoFvuy51HcnBXg4Ad%2Bl3u2VrFE%3D
+ - peekonly=true&st=2019-10-14T17:39:45Z&se=2019-10-14T18:44:45Z&sp=r&sv=2018-03-28&ss=q&srt=o&sig=bjMPAcJl2ocuk6f%2B%2B65rR8Dd6f9c5QnRuS0ELCJVwuo%3D
- ''
version: 1
diff --git a/sdk/storage/azure-storage-queue/tests/test_queue.py b/sdk/storage/azure-storage-queue/tests/test_queue.py
index 54f68f1fd929..c1a1e40b15e0 100644
--- a/sdk/storage/azure-storage-queue/tests/test_queue.py
+++ b/sdk/storage/azure-storage-queue/tests/test_queue.py
@@ -542,7 +542,7 @@ def test_account_sas(self, resource_group, location, storage_account, storage_ac
queue_client.create_queue()
queue_client.enqueue_message(u'message1')
token = qsc.generate_shared_access_signature(
- ResourceTypes.OBJECT,
+ ResourceTypes(object=True),
AccountSasPermissions(read=True),
datetime.utcnow() + timedelta(hours=1),
datetime.utcnow() - timedelta(minutes=5)
diff --git a/sdk/storage/azure-storage-queue/tests/test_queue_async.py b/sdk/storage/azure-storage-queue/tests/test_queue_async.py
index f09ff148da2c..a287e3dd9a91 100644
--- a/sdk/storage/azure-storage-queue/tests/test_queue_async.py
+++ b/sdk/storage/azure-storage-queue/tests/test_queue_async.py
@@ -584,7 +584,7 @@ async def test_account_sas(self, resource_group, location, storage_account, stor
queue_client = await self._create_queue(qsc)
await queue_client.enqueue_message(u'message1')
token = qsc.generate_shared_access_signature(
- ResourceTypes.OBJECT,
+ ResourceTypes(object=True),
AccountSasPermissions(read=True),
datetime.utcnow() + timedelta(hours=1),
datetime.utcnow() - timedelta(minutes=5)