Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Feb 8, 2024
1 parent 26326a4 commit 407af36
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 87 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ implementation 'com.google.cloud:google-cloud-storage'
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-storage:2.32.1'
implementation 'com.google.cloud:google-cloud-storage:2.33.0'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "2.32.1"
libraryDependencies += "com.google.cloud" % "google-cloud-storage" % "2.33.0"
```
<!-- {x-version-update-end} -->

Expand Down Expand Up @@ -428,7 +428,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-storage/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-storage.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-storage/2.32.1
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-storage/2.33.0
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,9 +1090,10 @@ public Blob get(String blob, BlobGetOption... options) {
}

/**
* Returns the requested blob in this bucket of a specific generation or {@code null} if not found.
* Returns the requested blob in this bucket of a specific generation or {@code null} if not
* found.
*
* <p>Example of getting a blob of a specific in the bucket.
* <p>Example of getting a blob of a specific in the bucket.
*
* <pre>{@code
* String blobName = "my_blob_name";
Expand All @@ -1106,7 +1107,7 @@ public Blob get(String blob, BlobGetOption... options) {
* @throws StorageException upon failure
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public Blob get(String blob, Long generation, BlobGetOption...options) {
public Blob get(String blob, Long generation, BlobGetOption... options) {
return storage.get(BlobId.of(getName(), blob, generation), options);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,20 @@ public boolean equals(Object o) {
}
SoftDeletePolicy that = (SoftDeletePolicy) o;
return Objects.equals(retentionDuration, that.retentionDuration)
&& Objects.equals(effectiveTime, that.effectiveTime);
&& Objects.equals(effectiveTime, that.effectiveTime);
}

@Override
public int hashCode() {
return Objects.hash(retentionDuration, effectiveTime);
}

@Override public String toString() {
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("retentionDuration", retentionDuration)
.add("effectiveTime", effectiveTime)
.toString();
.add("retentionDuration", retentionDuration)
.add("effectiveTime", effectiveTime)
.toString();
}

public static Builder newBuilder() {
Expand Down Expand Up @@ -413,17 +414,15 @@ public static final class Builder {
private Duration retentionDuration;
private OffsetDateTime effectiveTime;

/**
* Sets the length of time to retain soft-deleted objects for, expressed as a Duration
*/
/** Sets the length of time to retain soft-deleted objects for, expressed as a Duration */
public Builder setRetentionDuration(Duration retentionDuration) {
this.retentionDuration = retentionDuration;
return this;
}

/**
* Sets the time from which this soft-delete policy is effective.
* This is package-private because it can only be set by the backend.
* Sets the time from which this soft-delete policy is effective. This is package-private
* because it can only be set by the backend.
*/
Builder setEffectiveTime(OffsetDateTime effectiveTime) {
this.effectiveTime = effectiveTime;
Expand Down Expand Up @@ -2281,7 +2280,7 @@ Builder setObjectRetention(ObjectRetention objectRetention) {

@Override
public Builder setSoftDeletePolicy(SoftDeletePolicy softDeletePolicy) {
if(!Objects.equals(this.softDeletePolicy, softDeletePolicy)) {
if (!Objects.equals(this.softDeletePolicy, softDeletePolicy)) {
modifiedFields.add(BucketField.SOFT_DELETE_POLICY);
}
this.softDeletePolicy = softDeletePolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package com.google.cloud.storage;

import com.google.api.client.util.Data;
import static com.google.cloud.storage.Storage.BucketField.SOFT_DELETE_POLICY;
import static com.google.cloud.storage.Utils.*;

import com.google.api.pathtemplate.PathTemplate;
import com.google.cloud.Binding;
import com.google.cloud.Condition;
Expand Down Expand Up @@ -65,9 +67,6 @@
import java.util.Map;
import java.util.function.Function;

import static com.google.cloud.storage.Storage.BucketField.SOFT_DELETE_POLICY;
import static com.google.cloud.storage.Utils.*;

final class GrpcConversions {
static final GrpcConversions INSTANCE = new GrpcConversions();

Expand All @@ -90,7 +89,7 @@ final class GrpcConversions {
Codec.of(this::autoclassEncode, this::autoclassDecode);

private final Codec<BucketInfo.SoftDeletePolicy, Bucket.SoftDeletePolicy> softDeletePolicyCodec =
Codec.of(this::softDeletePolicyEncode, this::softDeletePolicyDecode);
Codec.of(this::softDeletePolicyEncode, this::softDeletePolicyDecode);
private final Codec<BucketInfo.LifecycleRule, Bucket.Lifecycle.Rule> lifecycleRuleCodec =
Codec.of(this::lifecycleRuleEncode, this::lifecycleRuleDecode);
private final Codec<BucketInfo, Bucket> bucketInfoCodec =
Expand Down Expand Up @@ -291,7 +290,7 @@ private BucketInfo bucketInfoDecode(Bucket from) {
if (from.hasAutoclass()) {
to.setAutoclass(autoclassCodec.decode(from.getAutoclass()));
}
if(from.hasSoftDeletePolicy()) {
if (from.hasSoftDeletePolicy()) {
to.setSoftDeletePolicy(softDeletePolicyCodec.decode(from.getSoftDeletePolicy()));
}
if (from.hasCustomPlacementConfig()) {
Expand Down Expand Up @@ -380,7 +379,8 @@ private Bucket bucketInfoEncode(BucketInfo from) {
ifNonNull(from.getIamConfiguration(), iamConfigurationCodec::encode, to::setIamConfig);
ifNonNull(from.getAutoclass(), autoclassCodec::encode, to::setAutoclass);
ifNonNull(from.getSoftDeletePolicy(), softDeletePolicyCodec::encode, to::setSoftDeletePolicy);
if(from.getModifiedFields().contains(SOFT_DELETE_POLICY) && from.getSoftDeletePolicy() == null) {
if (from.getModifiedFields().contains(SOFT_DELETE_POLICY)
&& from.getSoftDeletePolicy() == null) {
System.out.println("this is happening");
System.out.println(Bucket.SoftDeletePolicy.getDefaultInstance().toString());
to.clearSoftDeletePolicy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,22 +412,22 @@ public Blob restore(BlobId blob, BlobRestoreOption... options) {
private Blob internalObjectRestore(BlobId blobId, Opts<ObjectSourceOpt> opts) {
Opts<ObjectSourceOpt> finalOpts = opts.prepend(defaultOpts).prepend(ALL_BLOB_FIELDS);
GrpcCallContext grpcCallContext =
finalOpts.grpcMetadataMapper().apply(GrpcCallContext.createDefault());
finalOpts.grpcMetadataMapper().apply(GrpcCallContext.createDefault());
RestoreObjectRequest.Builder builder =
RestoreObjectRequest.newBuilder()
.setBucket(bucketNameCodec.encode(blobId.getBucket()))
.setObject(blobId.getName());
RestoreObjectRequest.newBuilder()
.setBucket(bucketNameCodec.encode(blobId.getBucket()))
.setObject(blobId.getName());
ifNonNull(blobId.getGeneration(), builder::setGeneration);
RestoreObjectRequest req = finalOpts.restoreObjectRequest().apply(builder).build();
GrpcCallContext merge = Utils.merge(grpcCallContext, Retrying.newCallContext());
return Retrying.run(
getOptions(),
retryAlgorithmManager.getFor(req),
() -> storageClient.restoreObjectCallable().call(req, merge),
resp -> {
BlobInfo tmp = codecs.blobInfo().decode(resp);
return finalOpts.clearBlobFields().decode(tmp).asBlob(this);
});
getOptions(),
retryAlgorithmManager.getFor(req),
() -> storageClient.restoreObjectCallable().call(req, merge),
resp -> {
BlobInfo tmp = codecs.blobInfo().decode(resp);
return finalOpts.clearBlobFields().decode(tmp).asBlob(this);
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ public ResultRetryAlgorithm<?> getForObjectsGet(
return retryStrategy.getIdempotentHandler();
}

public ResultRetryAlgorithm<?> getForObjectsRestore(StorageObject pb, Map<StorageRpc.Option, ?> optionsMap) {
public ResultRetryAlgorithm<?> getForObjectsRestore(
StorageObject pb, Map<StorageRpc.Option, ?> optionsMap) {
return retryStrategy.getIdempotentHandler();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
import com.google.cloud.storage.BucketInfo.LifecycleRule.SetStorageClassLifecycleAction;
import com.google.cloud.storage.BucketInfo.Logging;
import com.google.cloud.storage.BucketInfo.ObjectRetention;
import com.google.cloud.storage.BucketInfo.SoftDeletePolicy;
import com.google.cloud.storage.BucketInfo.PublicAccessPrevention;
import com.google.cloud.storage.BucketInfo.SoftDeletePolicy;
import com.google.cloud.storage.Conversions.Codec;
import com.google.cloud.storage.Cors.Origin;
import com.google.cloud.storage.HmacKey.HmacKeyMetadata;
Expand Down Expand Up @@ -123,7 +123,7 @@ final class JsonConversions {
Codec.of(this::objectRetentionEncode, this::objectRetentionDecode);

private final Codec<SoftDeletePolicy, Bucket.SoftDeletePolicy> softDeletePolicyCodec =
Codec.of(this::softDeletePolicyEncode, this::softDeletePolicyDecode);
Codec.of(this::softDeletePolicyEncode, this::softDeletePolicyDecode);
private final Codec<LifecycleRule, Rule> lifecycleRuleCodec =
Codec.of(this::lifecycleRuleEncode, this::lifecycleRuleDecode);
private final Codec<LifecycleCondition, Condition> lifecycleConditionCodec =
Expand Down Expand Up @@ -374,13 +374,15 @@ private Retention retentionDecode(StorageObject.Retention from) {

private Bucket.SoftDeletePolicy softDeletePolicyEncode(SoftDeletePolicy from) {
Bucket.SoftDeletePolicy to = new Bucket.SoftDeletePolicy();
ifNonNull(from.getRetentionDuration(), durationSecondsCodec::encode, to::setRetentionDurationSeconds);
ifNonNull(
from.getRetentionDuration(), durationSecondsCodec::encode, to::setRetentionDurationSeconds);
return to;
}

private SoftDeletePolicy softDeletePolicyDecode(Bucket.SoftDeletePolicy from) {
SoftDeletePolicy.Builder to = SoftDeletePolicy.newBuilder();
ifNonNull(from.getRetentionDurationSeconds(), durationSecondsCodec::decode, to::setRetentionDuration);
ifNonNull(
from.getRetentionDurationSeconds(), durationSecondsCodec::decode, to::setRetentionDuration);
ifNonNull(from.getEffectiveTime(), dateTimeCodec::decode, to::setEffectiveTime);
return to.build();
}
Expand Down Expand Up @@ -456,7 +458,8 @@ private Bucket bucketInfoEncode(BucketInfo from) {
to::setCustomPlacementConfig);
ifNonNull(from.getObjectRetention(), this::objectRetentionEncode, to::setObjectRetention);
ifNonNull(from.getSoftDeletePolicy(), this::softDeletePolicyEncode, to::setSoftDeletePolicy);
if(from.getSoftDeletePolicy() == null && from.getModifiedFields().contains(SOFT_DELETE_POLICY)) {
if (from.getSoftDeletePolicy() == null
&& from.getModifiedFields().contains(SOFT_DELETE_POLICY)) {
to.setSoftDeletePolicy(Data.nullOf(Bucket.SoftDeletePolicy.class));
}
return to;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1574,8 +1574,8 @@ public static BlobGetOption shouldReturnRawInputStream(boolean shouldReturnRawIn

/**
* Returns an option for whether the request should return a soft-deleted object. If an object
* has been soft-deleted (Deleted while a Soft Delete Policy) is in place, this must be true
* or the request will return null.
* has been soft-deleted (Deleted while a Soft Delete Policy) is in place, this must be true or
* the request will return null.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobGetOption softDeleted(boolean softDeleted) {
Expand Down Expand Up @@ -1617,7 +1617,7 @@ public static BlobGetOption[] dedupe(BlobGetOption[] array, BlobGetOption... os)
}
}

/** Class for specifying blob restore options **/
/** Class for specifying blob restore options * */
class BlobRestoreOption extends Option<ObjectSourceOpt> {

private static final long serialVersionUID = 1922118465380110958L;
Expand All @@ -1626,7 +1626,6 @@ class BlobRestoreOption extends Option<ObjectSourceOpt> {
super(opt);
}


/**
* Returns an option for blob's data generation match. If this option is used the request will
* fail if generation does not match.
Expand Down Expand Up @@ -1664,7 +1663,8 @@ public static BlobRestoreOption metagenerationNotMatch(long generation) {
}

/**
* Returns an option for whether the restored object should copy the access controls of the source object.
* Returns an option for whether the restored object should copy the access controls of the
* source object.
*/
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobRestoreOption copySourceAcl(boolean copySourceAcl) {
Expand Down Expand Up @@ -1895,9 +1895,7 @@ public static BlobListOption fields(BlobField... fields) {
return new BlobListOption(UnifiedOpts.fields(set));
}

/**
* Returns an option for whether the list result should include soft-deleted objects.
*/
/** Returns an option for whether the list result should include soft-deleted objects. */
@TransportCompatibility({Transport.HTTP, Transport.GRPC})
public static BlobListOption softDeleted(boolean softDeleted) {
return new BlobListOption(UnifiedOpts.softDeleted(softDeleted));
Expand Down Expand Up @@ -3109,8 +3107,8 @@ Blob createFrom(
Blob get(BlobId blob);

/**
* Restores a soft-deleted object to full object status and returns the object.
* Note that you must specify a generation to use this method.
* Restores a soft-deleted object to full object status and returns the object. Note that you must
* specify a generation to use this method.
*
* <p>Example of restoring an object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,23 +340,23 @@ public Blob get(BlobId blob, BlobGetOption... options) {
public Blob get(BlobId blob) {
return get(blob, new BlobGetOption[0]);
}

@Override
public Blob restore(BlobId blob, BlobRestoreOption... options) {
ImmutableMap<StorageRpc.Option, ?> optionsMap =
Opts.unwrap(options).resolveFrom(blob).getRpcOptions();
Opts.unwrap(options).resolveFrom(blob).getRpcOptions();

StorageObject obj = codecs.blobId().encode(blob);

ResultRetryAlgorithm<?> algorithm =
retryAlgorithmManager.getForObjectsRestore(obj, optionsMap);
ResultRetryAlgorithm<?> algorithm = retryAlgorithmManager.getForObjectsRestore(obj, optionsMap);

return run(
algorithm,
() -> storageRpc.restore(obj, optionsMap),
(x) -> {
BlobInfo info = Conversions.json().blobInfo().decode(x);
return info.asBlob(this);
});
algorithm,
() -> storageRpc.restore(obj, optionsMap),
(x) -> {
BlobInfo info = Conversions.json().blobInfo().decode(x);
return info.asBlob(this);
});
}

private static class BucketPageFetcher implements NextPageFetcher<Bucket> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,11 @@ static Projection projection(@NonNull String projection) {
static SoftDeleted softDeleted(boolean softDeleted) {
return new SoftDeleted(softDeleted);
}

static CopySourceAcl copySourceAcl(boolean copySourceAcl) {
return new CopySourceAcl(copySourceAcl);
}

static RequestedPolicyVersion requestedPolicyVersion(long l) {
return new RequestedPolicyVersion(l);
}
Expand Down Expand Up @@ -655,7 +657,8 @@ public Mapper<ListObjectsRequest.Builder> listObjects() {
}
}

static final class SoftDeleted extends RpcOptVal<Boolean> implements ObjectListOpt, ObjectSourceOpt {
static final class SoftDeleted extends RpcOptVal<Boolean>
implements ObjectListOpt, ObjectSourceOpt {

private static final long serialVersionUID = -8526951678111463350L;

Expand Down Expand Up @@ -1030,8 +1033,8 @@ public Mapper<GetObjectRequest.Builder> getObject() {
}

@Override
public Mapper <RestoreObjectRequest.Builder> restoreObject() {
return b-> b.setIfGenerationMatch(val);
public Mapper<RestoreObjectRequest.Builder> restoreObject() {
return b -> b.setIfGenerationMatch(val);
}

@Override
Expand Down
Loading

0 comments on commit 407af36

Please sign in to comment.