Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
71fe8ff
Update msrest and regenerate swagger. (#7308)
Sep 19, 2019
ad3edc9
Fix to have no content type when request body is empty (#7343)
Sep 19, 2019
e544514
[Blob] Set tier and rehydrate (#7269)
xiafu-msft Sep 23, 2019
075d8a1
[Blob] Echo client (#7350)
xiafu-msft Sep 23, 2019
13c9f08
Refactor max_connections to max_concurrency (#7531)
Oct 1, 2019
564722b
Use generated version as constant API version (#7547)
Oct 1, 2019
1979c89
Merge remote-tracking branch 'upstream/master' into feature/storage-p…
lmazuel Oct 2, 2019
f6d32d0
Re-recording from #7555 (#7585)
lmazuel Oct 3, 2019
a80734c
Storage batch API (#7387)
lmazuel Oct 3, 2019
0451790
Batch ChangeLog (#7593)
lmazuel Oct 3, 2019
f49eba3
[Storage Blob] Regenerate Swagger (#7572)
Oct 3, 2019
bc932a7
Merge remote-tracking branch 'origin/master' into feature/storage-pre…
lmazuel Oct 3, 2019
8b6ebaf
adjusts literalincludes for msft docs (#7599)
kristapratico Oct 3, 2019
e9ef9cf
Download sparse blob (#7555)
xiafu-msft Oct 3, 2019
cb7cfdc
Breaking Changes - Permission models (#7517)
Oct 4, 2019
637535e
Fix batch docstrings (#7600)
lmazuel Oct 4, 2019
61b6388
[Rename]rename max_connections to max_concurrency (#7606)
xiafu-msft Oct 4, 2019
ed20b58
small edits to lease client docs (#7550)
bryevdv Oct 4, 2019
215bb9a
Add a from_blob_url method (#7567)
Oct 4, 2019
9a527ff
Doc imprvment for Storage (#7601)
lmazuel Oct 4, 2019
62774eb
Revert "small edits to lease client docs (#7550)" (#7631)
bryevdv Oct 4, 2019
0b284c8
kwarg-ify methods (#7611)
Oct 5, 2019
716c141
Merge branch 'master' into feature/storage-preview4
Oct 5, 2019
b969b5e
[Storage] Consolidate offset and range parameters (#7598)
annatisch Oct 5, 2019
727e08e
Some Final tweaks (#7653)
Oct 7, 2019
e617ee2
Fix live tests (#7665)
Oct 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Breaking Changes - Permission models (#7517)
* Rename Permission related models to SasPermissions

* Rewrite Permission Models

* refactor tests

* some tests

* comment changes

* remove length checks

* QueuePermissions

* File Permissions

* blobs minor tweaks

* minor fix

* pylint fix

* pylint
  • Loading branch information
Rakshith Bhyravabhotla authored Oct 4, 2019
commit cb7cfdc7162763e720050daeb80d786589e3d947
12 changes: 6 additions & 6 deletions sdk/storage/azure-storage-blob/azure/storage/blob/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ._shared.models import(
LocationMode,
ResourceTypes,
AccountPermissions,
AccountSasPermissions,
StorageErrorCode
)
from .models import (
Expand All @@ -43,8 +43,8 @@
BlobBlock,
PageRange,
AccessPolicy,
ContainerPermissions,
BlobPermissions,
ContainerSasPermissions,
BlobSasPermissions,
)

__version__ = VERSION
Expand Down Expand Up @@ -82,10 +82,10 @@
'BlobBlock',
'PageRange',
'AccessPolicy',
'ContainerPermissions',
'BlobPermissions',
'ContainerSasPermissions',
'BlobSasPermissions',
'ResourceTypes',
'AccountPermissions',
'AccountSasPermissions',
'StorageStreamDownloader',
]

Expand Down
101 changes: 34 additions & 67 deletions sdk/storage/azure-storage-blob/azure/storage/blob/_shared/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def __str__(self):
ResourceTypes.OBJECT = ResourceTypes(object=True)


class AccountPermissions(object):
class AccountSasPermissions(object):
"""
:class:`~ResourceTypes` class to be used with generate_shared_access_signature
method and for the AccessPolicies used with set_*_acl. There are two types of
Expand All @@ -286,25 +286,6 @@ class AccountPermissions(object):
entire service for a specific account and allow certain operations based on
perms found here.

:cvar AccountPermissions AccountPermissions.ADD:
Valid for the following Object resource types only: queue messages and append blobs.
:cvar AccountPermissions AccountPermissions.CREATE:
Valid for the following Object resource types only: blobs and files. Users
can create new blobs or files, but may not overwrite existing blobs or files.
:cvar AccountPermissions AccountPermissions.DELETE:
Valid for Container and Object resource types, except for queue messages.
:cvar AccountPermissions AccountPermissions.LIST:
Valid for Service and Container resource types only.
:cvar AccountPermissions AccountPermissions.PROCESS:
Valid for the following Object resource type only: queue messages.
:cvar AccountPermissions AccountPermissions.READ:
Valid for all signed resources types (Service, Container, and Object).
Permits read permissions to the specified resource type.
:cvar AccountPermissions AccountPermissions.UPDATE:
Valid for the following Object resource types only: queue messages.
:cvar AccountPermissions AccountPermissions.WRITE:
Valid for all signed resources types (Service, Container, and Object).
Permits write permissions to the specified resource type.
:param bool read:
Valid for all signed resources types (Service, Container, and Object).
Permits read permissions to the specified resource type.
Expand All @@ -325,57 +306,43 @@ class AccountPermissions(object):
Valid for the following Object resource types only: queue messages.
:param bool process:
Valid for the following Object resource type only: queue messages.
:param str _str:
A string representing the permissions.
"""

READ = None # type: AccountPermissions
WRITE = None # type: AccountPermissions
DELETE = None # type: AccountPermissions
LIST = None # type: AccountPermissions
ADD = None # type: AccountPermissions
CREATE = None # type: AccountPermissions
UPDATE = None # type: AccountPermissions
PROCESS = None # type: AccountPermissions

def __init__(self, read=False, write=False, delete=False, list=False, # pylint: disable=redefined-builtin
add=False, create=False, update=False, process=False, _str=None):
if not _str:
_str = ''
self.read = read or ('r' in _str)
self.write = write or ('w' in _str)
self.delete = delete or ('d' in _str)
self.list = list or ('l' in _str)
self.add = add or ('a' in _str)
self.create = create or ('c' in _str)
self.update = update or ('u' in _str)
self.process = process or ('p' in _str)

def __or__(self, other):
return AccountPermissions(_str=str(self) + str(other))

def __add__(self, other):
return AccountPermissions(_str=str(self) + str(other))
add=False, create=False, update=False, process=False):
self.read = read
self.write = write
self.delete = delete
self.list = list
self.add = add
self.create = create
self.update = update
self.process = process
self._str = (('r' if self.read else '') +
('w' if self.write else '') +
('d' if self.delete else '') +
('l' if self.list else '') +
('a' if self.add else '') +
('c' if self.create else '') +
('u' if self.update else '') +
('p' if self.process else ''))

def __str__(self):
return (('r' if self.read else '') +
('w' if self.write else '') +
('d' if self.delete else '') +
('l' if self.list else '') +
('a' if self.add else '') +
('c' if self.create else '') +
('u' if self.update else '') +
('p' if self.process else ''))


AccountPermissions.READ = AccountPermissions(read=True)
AccountPermissions.WRITE = AccountPermissions(write=True)
AccountPermissions.DELETE = AccountPermissions(delete=True)
AccountPermissions.LIST = AccountPermissions(list=True)
AccountPermissions.ADD = AccountPermissions(add=True)
AccountPermissions.CREATE = AccountPermissions(create=True)
AccountPermissions.UPDATE = AccountPermissions(update=True)
AccountPermissions.PROCESS = AccountPermissions(process=True)
return self._str

@classmethod
def from_string(cls, permission):
p_read = 'r' in permission
p_write = 'w' in permission
p_delete = 'd' in permission
p_list = 'l' in permission
p_add = 'a' in permission
p_create = 'c' in permission
p_update = 'u' in permission
p_process = 'p' in permission

parsed = cls(p_read, p_write, p_delete, p_list, p_add, p_create, p_update, p_process)
parsed._str = permission # pylint: disable = protected-access
return parsed


class Services(object):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def generate_account(self, services, resource_types, permission, expiry, start=N
Specifies the resource types that are accessible with the account
SAS. You can combine values to provide access to more than one
resource type.
:param AccountPermissions permission:
:param AccountSasPermissions permission:
The permissions associated with the shared access signature. The
user is restricted to operations allowed by the permissions.
Required unless an id is given referencing a stored access policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def generate_blob(self, container_name, blob_name, snapshot=None, permission=Non
:param str snapshot:
The snapshot parameter is an opaque DateTime value that,
when present, specifies the blob snapshot to grant permission.
:param BlobPermissions permission:
:param BlobSasPermissions permission:
The permissions associated with the shared access signature. The
user is restricted to operations allowed by the permissions.
Permissions must be ordered read, write, delete, list.
Expand Down Expand Up @@ -129,7 +129,7 @@ def generate_container(self, container_name, permission=None, expiry=None,

:param str container_name:
Name of container.
:param ContainerPermissions permission:
:param ContainerSasPermissions permission:
The permissions associated with the shared access signature. The
user is restricted to operations allowed by the permissions.
Permissions must be ordered read, write, delete, list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .._shared.models import(
LocationMode,
ResourceTypes,
AccountPermissions,
AccountSasPermissions,
StorageErrorCode
)
from ..models import (
Expand All @@ -31,8 +31,8 @@
BlobBlock,
PageRange,
AccessPolicy,
ContainerPermissions,
BlobPermissions,
ContainerSasPermissions,
BlobSasPermissions,
)
from .models import (
ContainerPropertiesPaged,
Expand Down Expand Up @@ -78,9 +78,9 @@
'BlobBlock',
'PageRange',
'AccessPolicy',
'ContainerPermissions',
'BlobPermissions',
'ContainerSasPermissions',
'BlobSasPermissions',
'ResourceTypes',
'AccountPermissions',
'AccountSasPermissions',
'StorageStreamDownloader',
]
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from ..models import ( # pylint: disable=unused-import
ContainerProperties,
BlobProperties,
BlobPermissions,
BlobSasPermissions,
ContentSettings,
PremiumPageBlobTier,
StandardBlobTier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from datetime import datetime
from azure.core.pipeline.transport import HttpTransport
from azure.core.pipeline.policies import HTTPPolicy
from .._shared.models import AccountPermissions, ResourceTypes
from .._shared.models import AccountSasPermissions, ResourceTypes
from .lease_async import LeaseClient
from ..models import (
BlobProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
if TYPE_CHECKING:
from azure.core.pipeline.transport import HttpTransport
from azure.core.pipeline.policies import HTTPPolicy
from ..models import ContainerPermissions, PublicAccess
from ..models import ContainerSasPermissions, PublicAccess
from datetime import datetime
from ..models import ( # pylint: disable=unused-import
AccessPolicy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
from .models import ( # pylint: disable=unused-import
ContainerProperties,
BlobProperties,
BlobPermissions,
BlobSasPermissions,
ContentSettings,
PremiumPageBlobTier,
StandardBlobTier,
Expand Down Expand Up @@ -227,7 +227,7 @@ def from_connection_string(
account_url, container=container, blob=blob, snapshot=snapshot, credential=credential, **kwargs)

def generate_shared_access_signature(
self, permission=None, # type: Optional[Union[BlobPermissions, str]]
self, permission=None, # type: Optional[Union[BlobSasPermissions, str]]
expiry=None, # type: Optional[Union[datetime, str]]
start=None, # type: Optional[Union[datetime, str]]
policy_id=None, # type: Optional[str]
Expand All @@ -254,7 +254,7 @@ def generate_shared_access_signature(
Required unless an id is given referencing a stored access policy
which contains this field. This field must be omitted if it has been
specified in an associated stored access policy.
:type permission: str or ~azure.storage.blob.models.BlobPermissions
:type permission: str or ~azure.storage.blob.models.BlobSasPermissions
:param expiry:
The time at which the shared access signature becomes invalid.
Required unless an id is given referencing a stored access policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from datetime import datetime
from azure.core.pipeline.transport import HttpTransport
from azure.core.pipeline.policies import HTTPPolicy
from ._shared.models import AccountPermissions, ResourceTypes
from ._shared.models import AccountSasPermissions, ResourceTypes
from .lease import LeaseClient
from .models import (
BlobProperties,
Expand Down Expand Up @@ -159,7 +159,7 @@ def from_connection_string(

def generate_shared_access_signature(
self, resource_types, # type: Union[ResourceTypes, str]
permission, # type: Union[AccountPermissions, str]
permission, # type: Union[AccountSasPermissions, str]
expiry, # type: Optional[Union[datetime, str]]
start=None, # type: Optional[Union[datetime, str]]
ip=None, # type: Optional[str]
Expand All @@ -179,7 +179,7 @@ def generate_shared_access_signature(
Required unless an id is given referencing a stored access policy
which contains this field. This field must be omitted if it has been
specified in an associated stored access policy.
:type permission: str or ~azure.storage.blob.models.AccountPermissions
:type permission: str or ~azure.storage.blob.models.AccountSasPermissions
:param expiry:
The time at which the shared access signature becomes invalid.
Required unless an id is given referencing a stored access policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
if TYPE_CHECKING:
from azure.core.pipeline.transport import HttpTransport # pylint: disable=ungrouped-imports
from azure.core.pipeline.policies import HTTPPolicy # pylint: disable=ungrouped-imports
from .models import ContainerPermissions, PublicAccess
from .models import ContainerSasPermissions, PublicAccess
from datetime import datetime
from .models import ( # pylint: disable=unused-import
AccessPolicy,
Expand Down Expand Up @@ -187,7 +187,7 @@ def from_connection_string(
account_url, container=container, credential=credential, **kwargs)

def generate_shared_access_signature(
self, permission=None, # type: Optional[Union[ContainerPermissions, str]]
self, permission=None, # type: Optional[Union[ContainerSasPermissions, str]]
expiry=None, # type: Optional[Union[datetime, str]]
start=None, # type: Optional[Union[datetime, str]]
policy_id=None, # type: Optional[str]
Expand All @@ -213,7 +213,7 @@ def generate_shared_access_signature(
Required unless an id is given referencing a stored access policy
which contains this field. This field must be omitted if it has been
specified in an associated stored access policy.
:type permission: str or ~azure.storage.blob.models.ContainerPermissions
:type permission: str or ~azure.storage.blob.models.ContainerSasPermissions
:param expiry:
The time at which the shared access signature becomes invalid.
Required unless an id is given referencing a stored access policy
Expand Down
Loading