Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default
Copy link
Member

Choose a reason for hiding this comment

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

? is this required for this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

From running tests, will make a fix to that test and remove this in another PR

Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,7 @@ public BlobOutputStream getBlobOutputStream(AppendBlobAccessConditions accessCon
* @return The information of the created appended blob.
*/
public AppendBlobItem create() {
return create(null, null, null, null);
}

/**
* Creates a 0-length append blob. Call appendBlock to append data to an append blob.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.blob.AppendBlobClient.create#BlobHTTPHeaders-Metadata-BlobAccessConditions-Duration}
*
* @param headers {@link BlobHTTPHeaders}
* @param metadata {@link Metadata}
* @param accessConditions {@link BlobAccessConditions}
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
* @return The information of the created appended blob.
*/
public AppendBlobItem create(BlobHTTPHeaders headers, Metadata metadata,
BlobAccessConditions accessConditions, Duration timeout) {
return createWithResponse(headers, metadata, accessConditions, timeout, Context.NONE).getValue();
return createWithResponse(null, null, null, null, Context.NONE).getValue();
}

/**
Expand Down Expand Up @@ -203,33 +185,7 @@ public Response<AppendBlobItem> appendBlockWithResponse(InputStream data, long l
* @return The information of the append blob operation.
*/
public AppendBlobItem appendBlockFromUrl(URL sourceURL, BlobRange sourceRange) {
return appendBlockFromUrl(sourceURL, sourceRange, null, null, null, null);
}

/**
* Commits a new block of data from another blob to the end of this append blob.
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.blob.AppendBlobClient.appendBlockFromUrl#URL-BlobRange-byte-AppendBlobAccessConditions-SourceModifiedAccessConditions-Duration}
*
* @param sourceURL The url to the blob that will be the source of the copy. A source blob in the same storage
* account can be authenticated via Shared Key. However, if the source is a blob in another account, the source blob
* must either be public or must be authenticated via a shared access signature. If the source blob is public, no
* authentication is required to perform the operation.
* @param sourceRange {@link BlobRange}
* @param sourceContentMD5 An MD5 hash of the block content from the source blob. If specified, the service will
* calculate the MD5 of the received data and fail the request if it does not match the provided MD5.
* @param destAccessConditions {@link AppendBlobAccessConditions}
* @param sourceAccessConditions {@link SourceModifiedAccessConditions}
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
* @return The information of the append blob operation.
*/
public AppendBlobItem appendBlockFromUrl(URL sourceURL, BlobRange sourceRange,
byte[] sourceContentMD5, AppendBlobAccessConditions destAccessConditions,
SourceModifiedAccessConditions sourceAccessConditions, Duration timeout) {
return this.appendBlockFromUrlWithResponse(sourceURL, sourceRange, sourceContentMD5, destAccessConditions,
sourceAccessConditions, timeout, Context.NONE).getValue();
return appendBlockFromUrlWithResponse(sourceURL, sourceRange, null, null, null, null, Context.NONE).getValue();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ public final class PageBlobAsyncClient extends BlobAsyncClient {
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.blob.PageBlobAsyncClient.setCreate#long}
* {@codesnippet com.azure.storage.blob.PageBlobAsyncClient.create#long}
*
* @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a
* 512-byte boundary.
* @return A reactive response containing the information of the created page blob.
*/
public Mono<PageBlobItem> setCreate(long size) {
public Mono<PageBlobItem> create(long size) {
return createWithResponse(size, null, null, null, null).flatMap(FluxUtil::toMono);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ public BlobOutputStream getBlobOutputStream(long length, BlobAccessConditions ac
*
* <p><strong>Code Samples</strong></p>
*
* {@codesnippet com.azure.storage.blob.PageBlobClient.setCreate#long}
* {@codesnippet com.azure.storage.blob.PageBlobClient.create#long}
*
* @param size Specifies the maximum size for the page blob, up to 8 TB. The page blob size must be aligned to a
* 512-byte boundary.
* @return The information of the created page blob.
*/
public PageBlobItem setCreate(long size) {
public PageBlobItem create(long size) {
return createWithResponse(size, null, null, null, null, null, Context.NONE).getValue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,17 @@ public class AppendBlobClientJavaDocCodeSnippets {
/**
* Code snippet for {@link AppendBlobClient#create()}
*/
public void setCreate() {
public void create() {
// BEGIN: com.azure.storage.blob.AppendBlobClient.create
System.out.printf("Created AppendBlob at %s%n", client.create().getLastModified());
// END: com.azure.storage.blob.AppendBlobClient.create
}

/**
* Code snippet for {@link AppendBlobClient#create(BlobHTTPHeaders, Metadata, BlobAccessConditions, Duration)}
*/
public void create2() {
// BEGIN: com.azure.storage.blob.AppendBlobClient.create#BlobHTTPHeaders-Metadata-BlobAccessConditions-Duration
BlobHTTPHeaders headers = new BlobHTTPHeaders()
.setBlobContentType("binary")
.setBlobContentLanguage("en-US");
Metadata metadata = new Metadata(Collections.singletonMap("metadata", "value"));
BlobAccessConditions accessConditions = new BlobAccessConditions()
.setLeaseAccessConditions(new LeaseAccessConditions().setLeaseId(leaseId))
.setModifiedAccessConditions(new ModifiedAccessConditions()
.setIfUnmodifiedSince(OffsetDateTime.now().minusDays(3)));

System.out.printf("Created AppendBlob at %s%n",
client.create(headers, metadata, accessConditions, timeout).getLastModified());
// END: com.azure.storage.blob.AppendBlobClient.create#BlobHTTPHeaders-Metadata-BlobAccessConditions-Duration
}

/**
* Code snippet for {@link AppendBlobClient#createWithResponse(BlobHTTPHeaders, Metadata, BlobAccessConditions,
* Duration, Context)}
*/
public void create3() {
public void createWithResponse() {
// BEGIN: com.azure.storage.blob.AppendBlobClient.createWithResponse#BlobHTTPHeaders-Metadata-BlobAccessConditions-Duration-Context
BlobHTTPHeaders headers = new BlobHTTPHeaders()
.setBlobContentType("binary")
Expand Down Expand Up @@ -133,31 +114,11 @@ public void appendBlockFromUrl() {
// END: com.azure.storage.blob.AppendBlobClient.appendBlockFromUrl#URL-BlobRange
}

/**
* Code snippet for {@link AppendBlobClient#appendBlockFromUrl(URL, BlobRange, byte[], AppendBlobAccessConditions,
* SourceModifiedAccessConditions, Duration)}
*/
public void appendBlockFromUrl2() {
// BEGIN: com.azure.storage.blob.AppendBlobClient.appendBlockFromUrl#URL-BlobRange-byte-AppendBlobAccessConditions-SourceModifiedAccessConditions-Duration
AppendBlobAccessConditions appendBlobAccessConditions = new AppendBlobAccessConditions()
.setAppendPositionAccessConditions(new AppendPositionAccessConditions()
.setAppendPosition(POSITION)
.setMaxSize(maxSize));

SourceModifiedAccessConditions modifiedAccessConditions = new SourceModifiedAccessConditions()
.setSourceIfUnmodifiedSince(OffsetDateTime.now().minusDays(3));

System.out.printf("AppendBlob has %d committed blocks%n",
client.appendBlockFromUrl(sourceUrl, new BlobRange(offset, count), null,
appendBlobAccessConditions, modifiedAccessConditions, timeout).getBlobCommittedBlockCount());
// END: com.azure.storage.blob.AppendBlobClient.appendBlockFromUrl#URL-BlobRange-byte-AppendBlobAccessConditions-SourceModifiedAccessConditions-Duration
}

/**
* Code snippet for {@link AppendBlobClient#appendBlockFromUrlWithResponse(URL, BlobRange, byte[],
* AppendBlobAccessConditions, SourceModifiedAccessConditions, Duration, Context)}
*/
public void appendBlockFromUrl3() {
public void appendBlockFromUrlWithResponse() {
// BEGIN: com.azure.storage.blob.AppendBlobClient.appendBlockFromUrlWithResponse#URL-BlobRange-byte-AppendBlobAccessConditions-SourceModifiedAccessConditions-Duration-Context
AppendBlobAccessConditions appendBlobAccessConditions = new AppendBlobAccessConditions()
.setAppendPositionAccessConditions(new AppendPositionAccessConditions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public class PageBlobAsyncClientJavaDocCodeSnippets {
private long offset = 0;

/**
* Code snippets for {@link PageBlobAsyncClient#setCreate(long)}
* Code snippets for {@link PageBlobAsyncClient#create(long)}
*/
public void setCreateCodeSnippet() {
// BEGIN: com.azure.storage.blob.PageBlobAsyncClient.setCreate#long
client.setCreate(size).subscribe(response -> System.out.printf(
// BEGIN: com.azure.storage.blob.PageBlobAsyncClient.create#long
client.create(size).subscribe(response -> System.out.printf(
"Created page blob with sequence number %s%n", response.getBlobSequenceNumber()));
// END: com.azure.storage.blob.PageBlobAsyncClient.setCreate#long
// END: com.azure.storage.blob.PageBlobAsyncClient.create#long
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public class PageBlobClientJavaDocCodeSnippets {
private URL url = JavaDocCodeSnippetsHelpers.generateURL("https://sample.com");

/**
* Code snippets for {@link PageBlobClient#setCreate(long)}
* Code snippets for {@link PageBlobClient#create(long)}
*/
public void setCreateCodeSnippet() {
// BEGIN: com.azure.storage.blob.PageBlobClient.setCreate#long
PageBlobItem pageBlob = client.setCreate(size);
// BEGIN: com.azure.storage.blob.PageBlobClient.create#long
PageBlobItem pageBlob = client.create(size);
System.out.printf("Created page blob with sequence number %s%n", pageBlob.getBlobSequenceNumber());
// END: com.azure.storage.blob.PageBlobClient.setCreate#long
// END: com.azure.storage.blob.PageBlobClient.create#long
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

package com.azure.storage.blob

import com.azure.core.http.rest.Response
import com.azure.core.exception.UnexpectedLengthException
import com.azure.core.http.rest.Response
import com.azure.core.util.Context
import com.azure.storage.blob.models.AppendBlobAccessConditions
import com.azure.storage.blob.models.AppendBlobItem
import com.azure.storage.blob.models.AppendPositionAccessConditions
Expand Down Expand Up @@ -49,9 +50,8 @@ class AppendBlobAPITest extends APISpec {

def "Create error"() {
when:
bc.create(null, null,
new BlobAccessConditions().setModifiedAccessConditions(new ModifiedAccessConditions().setIfMatch("garbage")),
null)
bc.createWithResponse(null, null, new BlobAccessConditions()
.setModifiedAccessConditions(new ModifiedAccessConditions().setIfMatch("garbage")), null, Context.NONE)

then:
thrown(StorageException)
Expand Down Expand Up @@ -95,7 +95,7 @@ class AppendBlobAPITest extends APISpec {
}

when:
bc.create(null, metadata, null, null)
bc.createWithResponse(null, metadata, null, null, Context.NONE)
def response = bc.getProperties()

then:
Expand Down Expand Up @@ -146,7 +146,7 @@ class AppendBlobAPITest extends APISpec {
.setIfNoneMatch(noneMatch))

when:
bc.create(null, null, bac, null)
bc.createWithResponse(null, null, bac, null, Context.NONE)

then:
thrown(StorageException)
Expand Down Expand Up @@ -342,8 +342,8 @@ class AppendBlobAPITest extends APISpec {
destURL.create()

when:
destURL.appendBlockFromUrl(bc.getBlobUrl(), null, MessageDigest.getInstance("MD5").digest(data),
null, null, null)
destURL.appendBlockFromUrlWithResponse(bc.getBlobUrl(), null, MessageDigest.getInstance("MD5").digest(data),
null, null, null, Context.NONE)

then:
notThrown(StorageException)
Expand All @@ -359,8 +359,8 @@ class AppendBlobAPITest extends APISpec {
destURL.create()

when:
destURL.appendBlockFromUrl(bc.getBlobUrl(), null, MessageDigest.getInstance("MD5").digest("garbage".getBytes()),
null, null, null)
destURL.appendBlockFromUrlWithResponse(bc.getBlobUrl(), null, MessageDigest.getInstance("MD5").digest("garbage".getBytes()),
null, null, null, Context.NONE)

then:
thrown(StorageException)
Expand Down Expand Up @@ -425,7 +425,7 @@ class AppendBlobAPITest extends APISpec {
sourceURL.appendBlockWithResponse(defaultInputStream.get(), defaultDataSize, null, null, null).getStatusCode()

when:
bc.appendBlockFromUrl(sourceURL.getBlobUrl(), null, null, bac, null, null)
bc.appendBlockFromUrlWithResponse(sourceURL.getBlobUrl(), null, null, bac, null, null, Context.NONE)

then:
thrown(StorageException)
Expand Down Expand Up @@ -484,7 +484,7 @@ class AppendBlobAPITest extends APISpec {
.setSourceIfNoneMatch(setupBlobMatchCondition(sourceURL, sourceIfNoneMatch))

when:
bc.appendBlockFromUrl(sourceURL.getBlobUrl(), null, null, null, smac, null)
bc.appendBlockFromUrlWithResponse(sourceURL.getBlobUrl(), null, null, null, smac, null, Context.NONE)

then:
thrown(StorageException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ class BlobAPITest extends APISpec {
ContainerClient cc = premiumBlobServiceClient.createContainer(generateContainerName())

def bc = cc.getPageBlobClient(generateBlobName())
bc.setCreate(512)
bc.create(512)

when:
bc.setTier(tier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BlobOutputStreamTest extends APISpec {
setup:
byte[] data = getRandomByteArray(1024 * Constants.MB - 512)
PageBlobClient pageBlobClient = cc.getPageBlobClient(generateBlobName())
pageBlobClient.setCreate(data.length)
pageBlobClient.create(data.length)


when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class CPKTest extends APISpec {

def "Put page with CPK"() {
setup:
cpkPageBlob.setCreate(PageBlobClient.PAGE_BYTES)
cpkPageBlob.create(PageBlobClient.PAGE_BYTES)

when:
def response = cpkPageBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1),
Expand All @@ -130,11 +130,11 @@ class CPKTest extends APISpec {
def "Put page from URL wih CPK"() {
setup:
def sourceBlob = cc.getPageBlobClient(generateBlobName())
sourceBlob.setCreate(PageBlobClient.PAGE_BYTES)
sourceBlob.create(PageBlobClient.PAGE_BYTES)
sourceBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1),
new ByteArrayInputStream(getRandomByteArray(PageBlobClient.PAGE_BYTES)), null, null, null)

cpkPageBlob.setCreate(PageBlobClient.PAGE_BYTES)
cpkPageBlob.create(PageBlobClient.PAGE_BYTES)

when:
def response = cpkPageBlob.uploadPagesFromURLWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES - 1),
Expand All @@ -150,7 +150,7 @@ class CPKTest extends APISpec {

def "Put multiple pages with CPK"() {
setup:
cpkPageBlob.setCreate(PageBlobClient.PAGE_BYTES * 2)
cpkPageBlob.create(PageBlobClient.PAGE_BYTES * 2)

when:
def response = cpkPageBlob.uploadPagesWithResponse(new PageRange().setStart(0).setEnd(PageBlobClient.PAGE_BYTES * 2 - 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class ContainerAPITest extends APISpec {
setup:
String name = generateBlobName()
PageBlobClient bu = cc.getPageBlobClient(name)
bu.setCreate(512)
bu.create(512)

when:
Iterator<BlobItem> blobs = cc.listBlobsFlat().iterator()
Expand Down Expand Up @@ -622,7 +622,7 @@ class ContainerAPITest extends APISpec {

def setupListBlobsTest(String normalName, String copyName, String metadataName, String uncommittedName) {
def normal = cc.getPageBlobClient(normalName)
normal.setCreate(512)
normal.create(512)

def copyBlob = cc.getPageBlobClient(copyName)

Expand Down Expand Up @@ -809,7 +809,7 @@ class ContainerAPITest extends APISpec {
def PAGE_SIZE = 6
for (int i = 0; i < NUM_BLOBS ; i++) {
PageBlobClient bc = cc.getPageBlobClient(generateBlobName())
bc.setCreate(512)
bc.create(512)
}

when: "list blobs with sync client"
Expand Down Expand Up @@ -887,7 +887,7 @@ class ContainerAPITest extends APISpec {
setup:
String name = generateBlobName()
PageBlobClient bu = cc.getPageBlobClient(name)
bu.setCreate(512)
bu.create(512)

when:
Iterator<BlobItem> blobs = cc.listBlobsHierarchy(null).iterator()
Expand Down Expand Up @@ -1080,7 +1080,7 @@ class ContainerAPITest extends APISpec {
def PAGE_SIZE = 6
for (int i = 0; i < NUM_BLOBS; i++) {
PageBlobClient bc = cc.getPageBlobClient(generateBlobName())
bc.setCreate(512)
bc.create(512)
}

def blobs = cc.listBlobsHierarchy("/", new ListBlobsOptions().setMaxResults(PAGE_SIZE), null)
Expand All @@ -1106,7 +1106,7 @@ class ContainerAPITest extends APISpec {
def PAGE_SIZE = 3
for (int i = 0; i < NUM_BLOBS; i++) {
def bc = cc.getPageBlobClient(generateBlobName())
bc.setCreate(512)
bc.create(512)
}

expect: "listing operation will fetch all 10 blobs, despite page size being smaller than 10"
Expand Down
Loading