Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit

Permalink
Requester pays: expose userProject (googleapis#2554)
Browse files Browse the repository at this point in the history
Expose the userProject parameter for the List.Buckets operation.
Bump google-api-client dependency to 1.23.0.
  • Loading branch information
andreamlin authored and schmidt-sebastian committed Nov 9, 2017
1 parent 1547dd0 commit 4f1b749
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion google-cloud-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev108-1.22.0</version>
<version>v1-rev114-1.23.0</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,15 @@ public static BucketListOption prefix(String prefix) {
return new BucketListOption(StorageRpc.Option.PREFIX, prefix);
}

/**
* Returns an option for bucket's billing user project. This option is only used by the buckets with
* 'requester_pays' flag.
*/
@GcpLaunchStage.Alpha
public static BucketListOption userProject(String userProject) {
return new BucketListOption(StorageRpc.Option.USER_PROJECT, userProject);
}

/**
* Returns an option to specify the bucket's fields to be returned by the RPC call. If this
* option is not provided all bucket's fields are returned. {@code BucketListOption.fields}) can
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public Tuple<String, Iterable<Bucket>> list(Map<Option, ?> options) {
.setMaxResults(Option.MAX_RESULTS.getLong(options))
.setPageToken(Option.PAGE_TOKEN.getString(options))
.setFields(Option.FIELDS.getString(options))
.setUserProject(Option.USER_PROJECT.getString(options))
.execute();
return Tuple.<String, Iterable<Bucket>>of(buckets.getNextPageToken(), buckets.getItems());
} catch (IOException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1519,4 +1519,22 @@ public void testUpdateBucketRequesterPays() {
assertArrayEquals(BLOB_BYTE_CONTENT, readBytes);
assertTrue(remoteBlob.delete());
}

@Test
public void testListBucketRequesterPaysFails() throws InterruptedException {
String projectId = remoteStorageHelper.getOptions().getProjectId();
Iterator<Bucket> bucketIterator = storage.list(Storage.BucketListOption.prefix(BUCKET),
Storage.BucketListOption.fields(), Storage.BucketListOption.userProject(projectId)).iterateAll().iterator();
while (!bucketIterator.hasNext()) {
Thread.sleep(500);
bucketIterator = storage.list(Storage.BucketListOption.prefix(BUCKET),
Storage.BucketListOption.fields()).iterateAll().iterator();
}
while (bucketIterator.hasNext()) {
Bucket remoteBucket = bucketIterator.next();
assertTrue(remoteBucket.getName().startsWith(BUCKET));
assertNull(remoteBucket.getCreateTime());
assertNull(remoteBucket.getSelfLink());
}
}
}
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<github.global.server>github</github.global.server>
<site.installationModule>google-cloud</site.installationModule>

<api-client.version>1.22.0</api-client.version>
<api-client.version>1.23.0</api-client.version>

<api-common.version>1.1.0</api-common.version>
<gax.version>1.9.1</gax.version>
Expand All @@ -147,7 +147,7 @@
<grpc.version>1.7.0</grpc.version>
<nettyssl.version>2.0.6.Final</nettyssl.version>
<guava.version>20.0</guava.version>
<http-client.version>1.22.0</http-client.version>
<http-client.version>1.23.0</http-client.version>
<protobuf.version>3.4.0</protobuf.version>

<easymock.version>3.4</easymock.version>
Expand Down Expand Up @@ -767,7 +767,7 @@
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.22.0</version>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
Expand Down

0 comments on commit 4f1b749

Please sign in to comment.