Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share Lease Feature #13567

Merged
merged 43 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4023b8c
added needed parameters for shares
tasherif-msft Sep 4, 2020
89bd0b9
added async methods
tasherif-msft Sep 4, 2020
b869c88
added more methods for interacting with the API
tasherif-msft Sep 4, 2020
c82d692
fixed small mistake with elif
tasherif-msft Sep 10, 2020
1df00f3
added tests and access conditions
tasherif-msft Sep 10, 2020
95642ec
added more tests for leases
tasherif-msft Sep 11, 2020
cc9a1ff
fixed tests
tasherif-msft Sep 11, 2020
9391ee6
async changes
tasherif-msft Sep 11, 2020
86e2afc
added await
tasherif-msft Sep 11, 2020
9a71f09
corrected import
tasherif-msft Sep 11, 2020
c0509d8
fixed async imports and wrote all tests
tasherif-msft Sep 11, 2020
1393a4d
linting
tasherif-msft Sep 11, 2020
fde4b0d
share renaming
tasherif-msft Sep 11, 2020
c96f6d0
added file lease sample
tasherif-msft Sep 15, 2020
98d516f
added sample for share
tasherif-msft Sep 15, 2020
1457d32
fixed samples
tasherif-msft Sep 15, 2020
8f1733c
added docs
tasherif-msft Sep 24, 2020
2bfb563
removed checks
tasherif-msft Sep 24, 2020
d2ad99d
lease change
tasherif-msft Sep 24, 2020
d7a2e71
lease change
tasherif-msft Sep 24, 2020
e11d418
added correct lease durations
tasherif-msft Sep 24, 2020
bf66330
removed spacing
tasherif-msft Sep 24, 2020
3c03bc1
version correction
tasherif-msft Sep 24, 2020
83a70f1
fixed snapshot
tasherif-msft Sep 25, 2020
f3df73e
added snapshot tests
tasherif-msft Sep 25, 2020
f5ea020
added snapshot tests
tasherif-msft Sep 25, 2020
b72cc88
changed version
tasherif-msft Sep 25, 2020
5350e11
test
tasherif-msft Sep 25, 2020
5e4c34d
test
tasherif-msft Sep 25, 2020
98c4ea4
more docstrings
tasherif-msft Sep 25, 2020
40651b4
fixed docstrings
tasherif-msft Sep 26, 2020
3c5cc0c
more docstring changes
tasherif-msft Sep 26, 2020
725ba49
removed etag
tasherif-msft Sep 26, 2020
84d86e7
added exta check on test
tasherif-msft Sep 26, 2020
a94c9e9
fixed tests
tasherif-msft Sep 28, 2020
d524b59
added more tests for file
tasherif-msft Sep 28, 2020
b11489d
added tests for list shares
tasherif-msft Sep 29, 2020
4920a90
unused import
tasherif-msft Sep 29, 2020
e12f3f1
Merge branch 'feature/storage-stg74' into share-lease
xiafu-msft Sep 30, 2020
5677bd5
changed method signitures
tasherif-msft Sep 30, 2020
c03fba4
Merge branch 'share-lease' of github.com:tasherif-msft/azure-sdk-for-…
tasherif-msft Sep 30, 2020
60b263e
fixed kwargs
tasherif-msft Oct 1, 2020
8e83837
linter
tasherif-msft Oct 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ interactions:
Content-Length:
- '0'
User-Agent:
- azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0)
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Fri, 25 Oct 2019 17:59:36 GMT
- Mon, 28 Sep 2020 14:59:47 GMT
x-ms-version:
- '2019-02-02'
- '2020-02-10'
method: PUT
uri: https://storagename.blob.core.windows.net/container73941128?restype=container
response:
Expand All @@ -25,15 +25,15 @@ interactions:
content-length:
- '0'
date:
- Fri, 25 Oct 2019 17:59:35 GMT
- Mon, 28 Sep 2020 14:59:47 GMT
etag:
- '"0x8D7597518ECA775"'
- '"0x8D863BF24A1824F"'
last-modified:
- Fri, 25 Oct 2019 17:59:36 GMT
- Mon, 28 Sep 2020 14:59:47 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-version:
- '2019-02-02'
- '2020-02-10'
status:
code: 201
message: Created
Expand All @@ -53,13 +53,13 @@ interactions:
If-None-Match:
- '*'
User-Agent:
- azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0)
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-blob-type:
- BlockBlob
x-ms-date:
- Fri, 25 Oct 2019 17:59:36 GMT
- Mon, 28 Sep 2020 14:59:47 GMT
x-ms-version:
- '2019-02-02'
- '2020-02-10'
method: PUT
uri: https://storagename.blob.core.windows.net/container73941128/blob1
response:
Expand All @@ -71,19 +71,19 @@ interactions:
content-md5:
- XrY7u+Ae7tCTyyK7j1rNww==
date:
- Fri, 25 Oct 2019 17:59:35 GMT
- Mon, 28 Sep 2020 14:59:47 GMT
etag:
- '"0x8D7597518F66CB6"'
- '"0x8D863BF24BA54AE"'
last-modified:
- Fri, 25 Oct 2019 17:59:36 GMT
- Mon, 28 Sep 2020 14:59:47 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-content-crc64:
- vo7q9sPVKY0=
x-ms-request-server-encrypted:
- 'true'
x-ms-version:
- '2019-02-02'
- '2020-02-10'
status:
code: 201
message: Created
Expand All @@ -99,17 +99,17 @@ interactions:
Content-Length:
- '0'
User-Agent:
- azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0)
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Fri, 25 Oct 2019 17:59:36 GMT
- Mon, 28 Sep 2020 14:59:47 GMT
x-ms-lease-action:
- acquire
x-ms-lease-duration:
- '-1'
x-ms-proposed-lease-id:
- 7c0a3856-5a7b-41a9-b2ea-46c007922f6c
- 7252b40b-7746-4557-be21-82f42dd16067
x-ms-version:
- '2019-02-02'
- '2020-02-10'
method: PUT
uri: https://storagename.blob.core.windows.net/container73941128/blob1?comp=lease
response:
Expand All @@ -119,17 +119,17 @@ interactions:
content-length:
- '0'
date:
- Fri, 25 Oct 2019 17:59:35 GMT
- Mon, 28 Sep 2020 14:59:48 GMT
etag:
- '"0x8D7597518F66CB6"'
- '"0x8D863BF24BA54AE"'
last-modified:
- Fri, 25 Oct 2019 17:59:36 GMT
- Mon, 28 Sep 2020 14:59:47 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-lease-id:
- 7c0a3856-5a7b-41a9-b2ea-46c007922f6c
- 7252b40b-7746-4557-be21-82f42dd16067
x-ms-version:
- '2019-02-02'
- '2020-02-10'
status:
code: 201
message: Created
Expand All @@ -143,33 +143,33 @@ interactions:
Connection:
- keep-alive
User-Agent:
- azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0)
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Fri, 25 Oct 2019 17:59:36 GMT
- Mon, 28 Sep 2020 14:59:48 GMT
x-ms-version:
- '2019-02-02'
- '2020-02-10'
method: GET
uri: https://storagename.blob.core.windows.net/container73941128?restype=container&comp=list
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults
ServiceEndpoint=\"https://storagename.blob.core.windows.net/\" ContainerName=\"container73941128\"><Blobs><Blob><Name>blob1</Name><Properties><Creation-Time>Fri,
25 Oct 2019 17:59:36 GMT</Creation-Time><Last-Modified>Fri, 25 Oct 2019 17:59:36
GMT</Last-Modified><Etag>0x8D7597518F66CB6</Etag><Content-Length>11</Content-Length><Content-Type>application/octet-stream</Content-Type><Content-Encoding
ServiceEndpoint=\"https://storagename.blob.core.windows.net/\" ContainerName=\"container73941128\"><Blobs><Blob><Name>blob1</Name><Properties><Creation-Time>Mon,
28 Sep 2020 14:59:47 GMT</Creation-Time><Last-Modified>Mon, 28 Sep 2020 14:59:47
GMT</Last-Modified><Etag>0x8D863BF24BA54AE</Etag><Content-Length>11</Content-Length><Content-Type>application/octet-stream</Content-Type><Content-Encoding
/><Content-Language /><Content-CRC64 /><Content-MD5>XrY7u+Ae7tCTyyK7j1rNww==</Content-MD5><Cache-Control
/><Content-Disposition /><BlobType>BlockBlob</BlobType><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><LeaseStatus>locked</LeaseStatus><LeaseState>leased</LeaseState><LeaseDuration>infinite</LeaseDuration><ServerEncrypted>true</ServerEncrypted></Properties></Blob></Blobs><NextMarker
/></EnumerationResults>"
/><Content-Disposition /><LastAccessTime>Mon, 28 Sep 2020 14:59:47 GMT</LastAccessTime><BlobType>BlockBlob</BlobType><AccessTier>Hot</AccessTier><AccessTierInferred>true</AccessTierInferred><LeaseStatus>locked</LeaseStatus><LeaseState>leased</LeaseState><LeaseDuration>infinite</LeaseDuration><ServerEncrypted>true</ServerEncrypted></Properties><OrMetadata
/></Blob></Blobs><NextMarker /></EnumerationResults>"
headers:
content-type:
- application/xml
date:
- Fri, 25 Oct 2019 17:59:35 GMT
- Mon, 28 Sep 2020 14:59:48 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
- chunked
x-ms-version:
- '2019-02-02'
- '2020-02-10'
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from azure.storage.blob import DelimitedTextDialect as BlobDelimitedTextDialect
from azure.storage.blob import DelimitedJsonDialect as BlobDelimitedJSON
from azure.storage.blob import ArrowDialect as BlobArrowDialect
from azure.storage.blob._generated.models import StorageErrorException
from azure.storage.blob._models import ContainerPropertiesPaged
from ._shared.models import DictMixin

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def from_connection_string(

@distributed_trace
def acquire_lease(self, lease_id=None, **kwargs):
# type: (int, Optional[str], **Any) -> BlobLeaseClient
# type: (Optional[str], **Any) -> ShareLeaseClient
tasherif-msft marked this conversation as resolved.
Show resolved Hide resolved
"""Requests a new lease.

If the file does not have an active lease, the File
Expand All @@ -283,13 +283,14 @@ def acquire_lease(self, lease_id=None, **kwargs):

.. admonition:: Example:

.. literalinclude:: ../samples/blob_samples_common.py
:start-after: [START acquire_lease_on_blob]
:end-before: [END acquire_lease_on_blob]
.. literalinclude:: ../samples/file_samples_client.py
:start-after: [START acquire_and_release_lease_on_file]
:end-before: [END acquire_and_release_lease_on_file]
:language: python
:dedent: 8
:caption: Acquiring a lease on a blob.
:dedent: 12
:caption: Acquiring a lease on a file.
"""
kwargs['lease_duration'] = -1
lease = ShareLeaseClient(self, lease_id=lease_id) # type: ignore
lease.acquire(**kwargs)
return lease
Expand Down