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

Implemented list deleted root blob with versions #21996

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions sdk/storage/azure-storage-blob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 12.13.0-beta.1 (Unreleased)
- Added support to get a blob client that uses an encryption scope and customer provided key.
- Added support for the 2020-10-02 service version.
- Added support to list blobs deleted with versioning enabled.
- Added support to specify Parquet Input Serialization when querying a blob.

## 12.12.0 (2021-06-09)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ public static BlobItem populateBlobItem(BlobItemInternal blobItemInternal) {
blobItem.setObjectReplicationSourcePolicies(
transformObjectReplicationMetadata(blobItemInternal.getObjectReplicationMetadata()));

blobItem.setHasVersionsOnly(blobItemInternal.isHasVersionsOnly());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isHasVersionsOnly 😱 . The generator's code is very idiomatic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - it's kinda bad about booleans


return blobItem;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public final class BlobItem {
@JsonProperty(value = "IsPrefix")
private Boolean isPrefix;

/*
* The HasVersionsOnly property.
*/
@JsonProperty(value = "HasVersionsOnly")
private Boolean hasVersionsOnly;

/**
* Get the name property: The name property.
*
Expand Down Expand Up @@ -253,6 +259,26 @@ public BlobItem setObjectReplicationSourcePolicies(List<ObjectReplicationPolicy>
return this;
}

/**
* Get the hasVersionsOnly property: The HasVersionsOnly property.
*
* @return the hasVersionsOnly value.
*/
public Boolean hasVersionsOnly() {
return this.hasVersionsOnly;
}

/**
* Set the hasVersionsOnly property: The HasVersionsOnly property.
*
* @param hasVersionsOnly the hasVersionsOnly value to set.
* @return the BlobItemInternal object itself.
*/
public BlobItem setHasVersionsOnly(Boolean hasVersionsOnly) {
this.hasVersionsOnly = hasVersionsOnly;
return this;
}

/**
* Get the isPrefix property: The isPrefix property.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public final class BlobListDetails {
private boolean retrieveUncommittedBlobs;
private boolean retrieveDeletedBlobs;
private boolean retrieveVersions;
private boolean retrieveDeletedWithVersions;
private boolean retrieveImmutabilityPolicy;
private boolean retrieveLegalHold;

Expand Down Expand Up @@ -174,6 +175,26 @@ public BlobListDetails setRetrieveDeletedBlobs(boolean retrieveDeletedBlobs) {
return this;
}

/**
* Whether blobs which have been deleted with versioning.
*
* @return a flag indicating if deleted blobs with versioning will be returned in the listing
*/
public boolean getRetrieveDeletedBlobsWithVersions() {
return retrieveDeletedWithVersions;
}

/**
* Whether blobs which have been deleted with versioning should be returned.
*
* @param retrieveDeletedWithVersions Flag indicating whether deleted blobs with versioning should be returned
* @return the updated BlobListDetails object
*/
public BlobListDetails setRetrieveDeletedBlobsWithVersions(boolean retrieveDeletedWithVersions) {
this.retrieveDeletedWithVersions = retrieveDeletedWithVersions;
return this;
}

/**
* Whether immutability policy for the blob should be returned.
*
Expand Down Expand Up @@ -240,6 +261,9 @@ public ArrayList<ListBlobsIncludeItem> toList() {
if (this.retrieveVersions) {
details.add(ListBlobsIncludeItem.VERSIONS);
}
if (this.retrieveDeletedWithVersions) {
details.add(ListBlobsIncludeItem.DELETEDWITHVERSIONS);
}
if (this.retrieveImmutabilityPolicy) {
details.add(ListBlobsIncludeItem.IMMUTABILITYPOLICY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@

package com.azure.storage.blob

import com.azure.core.http.rest.PagedIterable
import com.azure.core.http.rest.PagedResponse

import com.azure.core.http.rest.Response
import com.azure.identity.DefaultAzureCredentialBuilder
import com.azure.storage.blob.models.AccessTier
import com.azure.storage.blob.models.AppendBlobItem
import com.azure.storage.blob.models.BlobAccessPolicy
import com.azure.storage.blob.models.BlobErrorCode
import com.azure.storage.blob.models.BlobItem
import com.azure.storage.blob.models.BlobListDetails
import com.azure.storage.blob.models.BlobProperties
import com.azure.storage.blob.models.BlobRequestConditions
Expand All @@ -31,14 +29,10 @@ import com.azure.storage.blob.options.BlobSetAccessTierOptions
import com.azure.storage.blob.options.PageBlobCreateOptions
import com.azure.storage.blob.specialized.AppendBlobClient
import com.azure.storage.blob.specialized.BlobClientBase
import com.azure.storage.common.StorageSharedKeyCredential
import com.azure.storage.common.Utility
import com.azure.storage.common.implementation.StorageImplUtils
import com.azure.storage.common.test.shared.extensions.PlaybackOnly
import com.azure.storage.common.test.shared.extensions.RequiredServiceVersion
import reactor.test.StepVerifier
import spock.lang.Requires
import spock.lang.ResourceLock
import spock.lang.Unroll

import java.time.Duration
Expand Down Expand Up @@ -921,6 +915,29 @@ class ContainerAPITest extends APISpec {
.verifyComplete()
}

@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02")
def "list blobs flat options deleted with versions"() {
setup:
def blobName = generateBlobName()
def blob = cc.getBlobClient(blobName).getAppendBlobClient()
blob.create()
def metadata = new HashMap<String, String>()
metadata.put("foo", "bar")
blob.setMetadata(metadata)
blob.delete()
def options = new ListBlobsOptions().setPrefix(blobName)
.setDetails(new BlobListDetails().setRetrieveDeletedBlobsWithVersions(true))

when:
def blobs = cc.listBlobs(options, null).iterator()

then:
def b = blobs.next()
!blobs.hasNext()
b.getName() == blobName
b.hasVersionsOnly()
}

def "List blobs prefix with comma"() {
setup:
def prefix = generateBlobName() + ", " + generateBlobName()
Expand Down Expand Up @@ -1303,6 +1320,29 @@ class ContainerAPITest extends APISpec {
}
}

@RequiredServiceVersion(clazz = BlobServiceVersion.class, min = "V2020_10_02")
def "list blobs hier options deleted with versions"() {
setup:
def blobName = generateBlobName()
def blob = cc.getBlobClient(blobName).getAppendBlobClient()
blob.create()
def metadata = new HashMap<String, String>()
metadata.put("foo", "bar")
blob.setMetadata(metadata)
blob.delete()
def options = new ListBlobsOptions().setPrefix(blobName)
.setDetails(new BlobListDetails().setRetrieveDeletedBlobsWithVersions(true))

when:
def blobs = cc.listBlobsByHierarchy("", options, null).iterator()

then:
def b = blobs.next()
!blobs.hasNext()
b.getName() == blobName
b.hasVersionsOnly()
}

@Unroll
def "List blobs hier options fail"() {
when:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"networkCallRecords" : [ {
"Method" : "PUT",
"Uri" : "https://REDACTED.blob.core.windows.net/8295186e08295186e76780860dbc07e929472486d90d?restype=container",
"Headers" : {
"x-ms-version" : "2020-10-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "230a2772-1c69-4408-9f21-2424e9a84d78"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-10-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"eTag" : "0x8D9252E3D6FD9CB",
"Last-Modified" : "Tue, 01 Jun 2021 18:51:17 GMT",
"retry-after" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "6d10ded9-c01e-0014-6917-5792ad000000",
"x-ms-client-request-id" : "230a2772-1c69-4408-9f21-2424e9a84d78",
"Date" : "Tue, 01 Jun 2021 18:51:17 GMT"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://REDACTED.blob.core.windows.net/8295186e08295186e76780860dbc07e929472486d90d/8295186e18295186e767817414aac029851164b3b9b8",
"Headers" : {
"x-ms-version" : "2020-10-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "4c66d24b-834b-4a3f-845f-996c3121ba78"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-10-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"eTag" : "0x8D9252E3DB29E26",
"Last-Modified" : "Tue, 01 Jun 2021 18:51:18 GMT",
"x-ms-version-id" : "2021-06-01T18:51:18.3475238Z",
"retry-after" : "0",
"StatusCode" : "201",
"x-ms-request-id" : "6d10dfab-c01e-0014-5c17-5792ad000000",
"x-ms-request-server-encrypted" : "true",
"x-ms-client-request-id" : "4c66d24b-834b-4a3f-845f-996c3121ba78",
"Date" : "Tue, 01 Jun 2021 18:51:18 GMT"
},
"Exception" : null
}, {
"Method" : "PUT",
"Uri" : "https://REDACTED.blob.core.windows.net/8295186e08295186e76780860dbc07e929472486d90d/8295186e18295186e767817414aac029851164b3b9b8?comp=metadata",
"Headers" : {
"x-ms-version" : "2020-10-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "eb48934a-df4c-47bf-90c5-945199f73eb1"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-10-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"eTag" : "0x8D9252E3DCCBA9B",
"Last-Modified" : "Tue, 01 Jun 2021 18:51:18 GMT",
"x-ms-version-id" : "2021-06-01T18:51:18.5196459Z",
"retry-after" : "0",
"StatusCode" : "200",
"x-ms-request-id" : "6d10dfdc-c01e-0014-7c17-5792ad000000",
"x-ms-request-server-encrypted" : "true",
"x-ms-client-request-id" : "eb48934a-df4c-47bf-90c5-945199f73eb1",
"Date" : "Tue, 01 Jun 2021 18:51:18 GMT"
},
"Exception" : null
}, {
"Method" : "DELETE",
"Uri" : "https://REDACTED.blob.core.windows.net/8295186e08295186e76780860dbc07e929472486d90d/8295186e18295186e767817414aac029851164b3b9b8",
"Headers" : {
"x-ms-version" : "2020-10-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "6d85a718-b07e-4d6e-ac99-3b622bdf53b3"
},
"Response" : {
"content-length" : "0",
"x-ms-version" : "2020-10-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"x-ms-delete-type-permanent" : "false",
"retry-after" : "0",
"StatusCode" : "202",
"x-ms-request-id" : "6d10e00a-c01e-0014-1317-5792ad000000",
"x-ms-client-request-id" : "6d85a718-b07e-4d6e-ac99-3b622bdf53b3",
"Date" : "Tue, 01 Jun 2021 18:51:18 GMT"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.blob.core.windows.net/8295186e08295186e76780860dbc07e929472486d90d?restype=container&comp=list&prefix=8295186e18295186e767817414aac029851164b3b9b8&include=deletedwithversions",
"Headers" : {
"x-ms-version" : "2020-10-02",
"User-Agent" : "azsdk-java-azure-storage-blob/12.12.0-beta.2 (11.0.7; Windows 10; 10.0)",
"x-ms-client-request-id" : "7bf450cd-e0d3-45a1-b672-6e34f25fa9d2"
},
"Response" : {
"Transfer-Encoding" : "chunked",
"x-ms-version" : "2020-10-02",
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
"retry-after" : "0",
"StatusCode" : "200",
"x-ms-request-id" : "6d10e03a-c01e-0014-2a17-5792ad000000",
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults ServiceEndpoint=\"https://seanmcccanary3.blob.core.windows.net/\" ContainerName=\"8295186e08295186e76780860dbc07e929472486d90d\"><Prefix>8295186e18295186e767817414aac029851164b3b9b8</Prefix><Blobs><Blob><Name>8295186e18295186e767817414aac029851164b3b9b8</Name><HasVersionsOnly>true</HasVersionsOnly><Properties><Creation-Time>Tue, 01 Jun 2021 18:51:18 GMT</Creation-Time><Last-Modified>Tue, 01 Jun 2021 18:51:18 GMT</Last-Modified><Etag>0x8D9252E3DCCBA9B</Etag><Content-Length>0</Content-Length><Content-Type>application/octet-stream</Content-Type><Content-Encoding /><Content-Language /><Content-CRC64 /><Content-MD5 /><Cache-Control /><Content-Disposition /><BlobType>AppendBlob</BlobType><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><ServerEncrypted>true</ServerEncrypted></Properties><OrMetadata /></Blob></Blobs><NextMarker /></EnumerationResults>",
"x-ms-client-request-id" : "7bf450cd-e0d3-45a1-b672-6e34f25fa9d2",
"Date" : "Tue, 01 Jun 2021 18:51:18 GMT",
"Content-Type" : "application/xml"
},
"Exception" : null
} ],
"variables" : [ "8295186e08295186e76780860dbc07e929472486d90d", "8295186e18295186e767817414aac029851164b3b9b8" ]
}
Loading