Skip to content
Closed
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
Expand Up @@ -35,6 +35,7 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.math.BigInteger;
import java.security.Key;
import java.time.Duration;
import java.time.OffsetDateTime;
Expand Down Expand Up @@ -631,6 +632,12 @@ Builder setMetageneration(Long metageneration) {
return this;
}

@Override
Builder setProjectNumber(BigInteger projectNumber) {
infoBuilder.setProjectNumber(projectNumber);
return this;
}

@Override
public Builder setCors(Iterable<Cors> cors) {
infoBuilder.setCors(cors);
Expand Down Expand Up @@ -857,6 +864,12 @@ Builder clearMetageneration() {
return this;
}

@Override
Builder clearProjectNumber() {
infoBuilder.clearProjectNumber();
return this;
}

@Override
Builder clearCors() {
infoBuilder.clearCors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.math.BigInteger;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.util.ArrayList;
Expand Down Expand Up @@ -100,6 +101,7 @@ public class BucketInfo implements Serializable {
private final OffsetDateTime createTime;
private final OffsetDateTime updateTime;
private final Long metageneration;
private final BigInteger projectNumber;
private final List<Cors> cors;
private final List<Acl> acl;
private final List<Acl> defaultAcl;
Expand Down Expand Up @@ -1747,6 +1749,8 @@ Builder setUpdateTimeOffsetDateTime(OffsetDateTime updateTime) {
return this;
}

abstract Builder setProjectNumber(BigInteger projectNumber);

abstract Builder setMetageneration(Long metageneration);

abstract Builder setLocationType(String locationType);
Expand Down Expand Up @@ -1878,6 +1882,8 @@ public Builder setRetentionPeriodDuration(Duration retentionPeriod) {

abstract Builder clearMetageneration();

abstract Builder clearProjectNumber();

abstract Builder clearCors();

abstract Builder clearAcl();
Expand Down Expand Up @@ -1924,6 +1930,7 @@ static final class BuilderImpl extends Builder {
private OffsetDateTime createTime;
private OffsetDateTime updateTime;
private Long metageneration;
private BigInteger projectNumber;
private List<Cors> cors;
private List<Acl> acl;
private List<Acl> defaultAcl;
Expand Down Expand Up @@ -1956,6 +1963,7 @@ static final class BuilderImpl extends Builder {
createTime = bucketInfo.createTime;
updateTime = bucketInfo.updateTime;
metageneration = bucketInfo.metageneration;
projectNumber = bucketInfo.projectNumber;
location = bucketInfo.location;
rpo = bucketInfo.rpo;
storageClass = bucketInfo.storageClass;
Expand Down Expand Up @@ -2194,6 +2202,12 @@ Builder setMetageneration(Long metageneration) {
return this;
}

@Override
Builder setProjectNumber(BigInteger projectNumber) {
this.projectNumber = projectNumber;
return this;
}

@Override
public Builder setCors(Iterable<Cors> cors) {
ImmutableList<Cors> tmp = cors != null ? ImmutableList.copyOf(cors) : ImmutableList.of();
Expand Down Expand Up @@ -2483,6 +2497,12 @@ BuilderImpl clearMetageneration() {
return this;
}

@Override
BuilderImpl clearProjectNumber() {
this.projectNumber = null;
return this;
}

@Override
BuilderImpl clearCors() {
this.cors = null;
Expand Down Expand Up @@ -2582,6 +2602,7 @@ private Builder clearDeleteLifecycleRules() {
createTime = builder.createTime;
updateTime = builder.updateTime;
metageneration = builder.metageneration;
projectNumber = builder.projectNumber;
location = builder.location;
rpo = builder.rpo;
storageClass = builder.storageClass;
Expand Down Expand Up @@ -2755,6 +2776,11 @@ public Long getMetageneration() {
return metageneration;
}

/** Returns the project number of the bucket. */
public BigInteger getProjectNumber() {
return projectNumber;
}

/**
* Returns the bucket's location. Data for blobs in the bucket resides in physical storage within
* this region or regions. If specifying more than one region `customPlacementConfig` should be
Expand Down Expand Up @@ -2980,6 +3006,7 @@ public int hashCode() {
createTime,
updateTime,
metageneration,
projectNumber,
cors,
acl,
defaultAcl,
Expand Down Expand Up @@ -3023,6 +3050,7 @@ public boolean equals(Object o) {
&& Objects.equals(createTime, that.createTime)
&& Objects.equals(updateTime, that.updateTime)
&& Objects.equals(metageneration, that.metageneration)
&& Objects.equals(projectNumber, that.projectNumber)
&& Objects.equals(cors, that.cors)
&& Objects.equals(acl, that.acl)
&& Objects.equals(defaultAcl, that.defaultAcl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ private Bucket bucketInfoEncode(BucketInfo from) {
ifNonNull(from.getLocation(), to::setLocation);
ifNonNull(from.getLocationType(), to::setLocationType);
ifNonNull(from.getMetageneration(), to::setMetageneration);
ifNonNull(from.getProjectNumber(), to::setProjectNumber);
ifNonNull(
from.getOwner(),
lift(this::entityEncode).andThen(o -> new Bucket.Owner().setEntity(o)),
Expand Down Expand Up @@ -489,6 +490,7 @@ private BucketInfo bucketInfoDecode(com.google.api.services.storage.model.Bucket
ifNonNull(from.getLocation(), to::setLocation);
ifNonNull(from.getLocationType(), to::setLocationType);
ifNonNull(from.getMetageneration(), to::setMetageneration);
ifNonNull(from.getProjectNumber(), to::setProjectNumber);
ifNonNull(
from.getOwner(), lift(Bucket.Owner::getEntity).andThen(this::entityDecode), to::setOwner);
ifNonNull(from.getRpo(), Rpo::valueOf, to::setRpo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.io.StringWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -110,6 +111,7 @@ public class BucketInfoTest {
private static final List<String> LOCATION_TYPES =
ImmutableList.of("multi-region", "region", "dual-region");
private static final String LOCATION_TYPE = "multi-region";
private static final BigInteger PROJECT_NUMBER = BigInteger.valueOf(42);

@SuppressWarnings({"unchecked", "deprecation"})
private static final BucketInfo BUCKET_INFO =
Expand All @@ -118,6 +120,7 @@ public class BucketInfoTest {
.setEtag(ETAG)
.setGeneratedId(GENERATED_ID)
.setMetageneration(META_GENERATION)
.setProjectNumber(PROJECT_NUMBER)
.setOwner(OWNER)
.setSelfLink(SELF_LINK)
.setCors(CORS)
Expand Down Expand Up @@ -150,6 +153,7 @@ public class BucketInfoTest {
.setEtag(ETAG)
.setGeneratedId(GENERATED_ID)
.setMetageneration(META_GENERATION)
.setProjectNumber(PROJECT_NUMBER)
.setOwner(OWNER)
.setSelfLink(SELF_LINK)
.setCors(CORS)
Expand Down Expand Up @@ -209,6 +213,7 @@ public void testBuilder() throws Exception {
() -> assertEquals(ETAG, BUCKET_INFO.getEtag()),
() -> assertEquals(GENERATED_ID, BUCKET_INFO.getGeneratedId()),
() -> assertEquals(META_GENERATION, BUCKET_INFO.getMetageneration()),
() -> assertEquals(PROJECT_NUMBER, BUCKET_INFO.getProjectNumber()),
() -> assertEquals(OWNER, BUCKET_INFO.getOwner()),
() -> assertEquals(SELF_LINK, BUCKET_INFO.getSelfLink()),
() -> assertEquals(CREATE_TIME, BUCKET_INFO.getCreateTime()),
Expand Down Expand Up @@ -290,6 +295,7 @@ private void compareBuckets(BucketInfo expected, BucketInfo value) throws Except
assertEquals(expected.getRetentionPeriodDuration(), value.getRetentionPeriodDuration()),
() -> assertEquals(expected.retentionPolicyIsLocked(), value.retentionPolicyIsLocked()),
() -> assertEquals(expected.getLogging(), value.getLogging()),
() -> assertEquals(expected.getProjectNumber(), value.getProjectNumber()),
() -> assertEquals(expected, value));
}

Expand Down