Skip to content

Commit

Permalink
Added Last Access Time Feature (#13433)
Browse files Browse the repository at this point in the history
* converted BlobItemInternal to BlobProperties and added the attribute in model's BlobProperties

* removed none default

* added unit test for get properties with lat

* more unit tests

* fixed failing test

* added docstrings and addeed extra test

* Update sdk/storage/azure-storage-blob/azure/storage/blob/_models.py

Co-authored-by: Xiaoxi Fu <49707495+xiafu-msft@users.noreply.github.com>

Co-authored-by: Xiaoxi Fu <49707495+xiafu-msft@users.noreply.github.com>
  • Loading branch information
tasherif-msft and xiafu-msft authored Sep 4, 2020
1 parent a0a2be8 commit 64a3f14
Show file tree
Hide file tree
Showing 7 changed files with 633 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def get_blob_properties_from_generated_code(generated):
blob.tag_count = generated.properties.tag_count
blob.tags = parse_tags(generated.blob_tags) # pylint: disable=protected-access
blob.object_replication_source_properties = deserialize_ors_policies(generated.object_replication_metadata)
blob.last_accessed_on = generated.properties.last_accessed_on
return blob


Expand Down
6 changes: 6 additions & 0 deletions sdk/storage/azure-storage-blob/azure/storage/blob/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,11 @@ class BlobProperties(DictMixin):
.. versionadded:: 12.4.0
:ivar ~datetime.datetime last_accessed_on:
Indicates when the last Read/Write operation was performed on a Blob.
.. versionadded:: 12.6.0
:ivar int tag_count:
Tags count on this blob.
Expand Down Expand Up @@ -548,6 +553,7 @@ def __init__(self, **kwargs):
self.request_server_encrypted = kwargs.get('x-ms-server-encrypted')
self.object_replication_source_properties = kwargs.get('object_replication_source_properties')
self.object_replication_destination_policy = kwargs.get('x-ms-or-policy-id')
self.last_accessed_on = kwargs.get('x-ms-last-access-time')
self.tag_count = kwargs.get('x-ms-tag-count')
self.tags = None

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,346 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '0'
User-Agent:
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-date:
- Fri, 04 Sep 2020 20:06:53 GMT
x-ms-version:
- '2020-02-10'
method: PUT
uri: https://storagename.blob.core.windows.net/utcontainer56131a54?restype=container
response:
body:
string: ''
headers:
content-length:
- '0'
date:
- Fri, 04 Sep 2020 20:06:53 GMT
etag:
- '"0x8D8510E11772436"'
last-modified:
- Fri, 04 Sep 2020 20:06:53 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-version:
- '2020-02-10'
status:
code: 201
message: Created
- request:
body: hello world
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '11'
Content-Type:
- application/octet-stream
If-None-Match:
- '*'
User-Agent:
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-blob-type:
- BlockBlob
x-ms-date:
- Fri, 04 Sep 2020 20:06:54 GMT
x-ms-version:
- '2020-02-10'
method: PUT
uri: https://storagename.blob.core.windows.net/utcontainer56131a54/blob1
response:
body:
string: ''
headers:
content-length:
- '0'
content-md5:
- XrY7u+Ae7tCTyyK7j1rNww==
date:
- Fri, 04 Sep 2020 20:06:53 GMT
etag:
- '"0x8D8510E118A992E"'
last-modified:
- Fri, 04 Sep 2020 20:06:53 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:
- '2020-02-10'
status:
code: 201
message: Created
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-date:
- Fri, 04 Sep 2020 20:06:54 GMT
x-ms-version:
- '2020-02-10'
method: HEAD
uri: https://storagename.blob.core.windows.net/utcontainer56131a54/blob1
response:
body:
string: ''
headers:
accept-ranges:
- bytes
content-length:
- '11'
content-md5:
- XrY7u+Ae7tCTyyK7j1rNww==
content-type:
- application/octet-stream
date:
- Fri, 04 Sep 2020 20:06:53 GMT
etag:
- '"0x8D8510E118A992E"'
last-modified:
- Fri, 04 Sep 2020 20:06:53 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-access-tier:
- Hot
x-ms-access-tier-inferred:
- 'true'
x-ms-blob-type:
- BlockBlob
x-ms-creation-time:
- Fri, 04 Sep 2020 20:06:53 GMT
x-ms-last-access-time:
- Fri, 04 Sep 2020 20:06:53 GMT
x-ms-lease-state:
- available
x-ms-lease-status:
- unlocked
x-ms-server-encrypted:
- 'true'
x-ms-version:
- '2020-02-10'
status:
code: 200
message: OK
- request:
body: this is test content
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '20'
Content-Type:
- application/octet-stream
User-Agent:
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-date:
- Fri, 04 Sep 2020 20:08:03 GMT
x-ms-version:
- '2020-02-10'
method: PUT
uri: https://storagename.blob.core.windows.net/utcontainer56131a54/blob1?blockid=MQ%3D%3D&comp=block
response:
body:
string: ''
headers:
content-length:
- '0'
date:
- Fri, 04 Sep 2020 20:08:02 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-content-crc64:
- wae/Ns62JRA=
x-ms-request-server-encrypted:
- 'true'
x-ms-version:
- '2020-02-10'
status:
code: 201
message: Created
- request:
body: '<?xml version=''1.0'' encoding=''utf-8''?>
<BlockList><Latest>MQ==</Latest></BlockList>'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '83'
Content-Type:
- application/xml; charset=utf-8
User-Agent:
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-date:
- Fri, 04 Sep 2020 20:08:04 GMT
x-ms-version:
- '2020-02-10'
method: PUT
uri: https://storagename.blob.core.windows.net/utcontainer56131a54/blob1?comp=blocklist
response:
body:
string: ''
headers:
content-length:
- '0'
date:
- Fri, 04 Sep 2020 20:08:03 GMT
etag:
- '"0x8D8510E3B9B72BB"'
last-modified:
- Fri, 04 Sep 2020 20:08:04 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-content-crc64:
- iEgKfcNWGmY=
x-ms-request-server-encrypted:
- 'true'
x-ms-version:
- '2020-02-10'
status:
code: 201
message: Created
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-date:
- Fri, 04 Sep 2020 20:08:08 GMT
x-ms-version:
- '2020-02-10'
method: HEAD
uri: https://storagename.blob.core.windows.net/utcontainer56131a54/blob1
response:
body:
string: ''
headers:
accept-ranges:
- bytes
content-length:
- '20'
content-type:
- application/octet-stream
date:
- Fri, 04 Sep 2020 20:08:07 GMT
etag:
- '"0x8D8510E3B9B72BB"'
last-modified:
- Fri, 04 Sep 2020 20:08:04 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-access-tier:
- Hot
x-ms-access-tier-inferred:
- 'true'
x-ms-blob-type:
- BlockBlob
x-ms-creation-time:
- Fri, 04 Sep 2020 20:06:53 GMT
x-ms-last-access-time:
- Fri, 04 Sep 2020 20:08:04 GMT
x-ms-lease-state:
- available
x-ms-lease-status:
- unlocked
x-ms-server-encrypted:
- 'true'
x-ms-version:
- '2020-02-10'
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/xml
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- azsdk-python-storage-blob/12.4.0 Python/3.8.5 (Windows-10-10.0.18362-SP0)
x-ms-date:
- Fri, 04 Sep 2020 20:08:20 GMT
x-ms-range:
- bytes=0-33554431
x-ms-version:
- '2020-02-10'
method: GET
uri: https://storagename.blob.core.windows.net/utcontainer56131a54/blob1
response:
body:
string: this is test content
headers:
accept-ranges:
- bytes
content-length:
- '20'
content-range:
- bytes 0-19/20
content-type:
- application/octet-stream
date:
- Fri, 04 Sep 2020 20:08:19 GMT
etag:
- '"0x8D8510E3B9B72BB"'
last-modified:
- Fri, 04 Sep 2020 20:08:04 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-blob-type:
- BlockBlob
x-ms-creation-time:
- Fri, 04 Sep 2020 20:06:53 GMT
x-ms-last-access-time:
- Fri, 04 Sep 2020 20:08:04 GMT
x-ms-lease-state:
- available
x-ms-lease-status:
- unlocked
x-ms-server-encrypted:
- 'true'
x-ms-version:
- '2020-02-10'
status:
code: 206
message: Partial Content
version: 1
Loading

0 comments on commit 64a3f14

Please sign in to comment.