Repository: googleapis/java-storage
Pull request #444 (2020-08-01 02:46:42)

Add cloud-RAD for Java
This PR was generated using Autosynth. :rainbow:

Synth log will be available here:
https://source.cloud.google.com/results/invocations/8638e33c-a69f-4129-ba08-261bc7fc6763/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: https://github.com/googleapis/synthtool/commit/dd230c816f88d0141fcd0be83498986287220d1b

codecov[bot]: # [Codecov](https://codecov.io/gh/googleapis/java-storage/pull/444?src=pr&el=h1) Report
> Merging [#444](https://codecov.io/gh/googleapis/java-storage/pull/444?src=pr&el=desc) into [master](https://codecov.io/gh/googleapis/java-storage/commit/0ce82ccf1e6ed8f46aeda92fe5f17eb427c3a7d9&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/googleapis/java-storage/pull/444/graphs/tree.svg?width=650&height=150&src=pr&token=ssm139YOdp)](https://codecov.io/gh/googleapis/java-storage/pull/444?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master     #444   +/-   ##
=========================================
  Coverage     63.12%   63.12%           
  Complexity      610      610           
=========================================
  Files            32       32           
  Lines          5133     5133           
  Branches        490      490           
=========================================
  Hits           3240     3240           
  Misses         1729     1729           
  Partials        164      164           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/googleapis/java-storage/pull/444?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/googleapis/java-storage/pull/444?src=pr&el=footer). Last update [0ce82cc...e65836f](https://codecov.io/gh/googleapis/java-storage/pull/444?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/.kokoro/release/publish_javadoc.cfg b/.kokoro/release/publish_javadoc.cfg
index 82745e58..c4cb5521 100644
--- a/.kokoro/release/publish_javadoc.cfg
+++ b/.kokoro/release/publish_javadoc.cfg
@@ -1,14 +1,24 @@
 # Format: //devtools/kokoro/config/proto/build.proto
+
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/doc-templates/"
+
 env_vars: {
   key: "STAGING_BUCKET"
   value: "docs-staging"
 }
 
+env_vars: {
+  key: "STAGING_BUCKET_V2"
+  value: "docs-staging-v2-staging"
+  # Production will be at: docs-staging-v2
+}
+
 env_vars: {
   key: "TRAMPOLINE_BUILD_FILE"
   value: "github/java-storage/.kokoro/release/publish_javadoc.sh"
 }
 
+
 before_action {
   fetch_keystore {
     keystore_resource {
diff --git a/.kokoro/release/publish_javadoc.sh b/.kokoro/release/publish_javadoc.sh
index 219d37c6..6b592014 100755
--- a/.kokoro/release/publish_javadoc.sh
+++ b/.kokoro/release/publish_javadoc.sh
@@ -24,6 +24,11 @@ if [[ -z "${STAGING_BUCKET}" ]]; then
   exit 1
 fi
 
+if [[ -z "${STAGING_BUCKET_V2}" ]]; then
+  echo "Need to set STAGING_BUCKET_V2 environment variable"
+  exit 1
+fi
+
 # work from the git root directory
 pushd $(dirname "$0")/../../
 
@@ -31,13 +36,13 @@ pushd $(dirname "$0")/../../
 python3 -m pip install gcp-docuploader
 
 # compile all packages
-mvn clean install -B -DskipTests=true
+mvn clean install -B -q -DskipTests=true
 
 NAME=google-cloud-storage
 VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3)
 
 # build the docs
-mvn site -B
+mvn site -B -q
 
 pushd target/site/apidocs
 
@@ -53,3 +58,19 @@ python3 -m docuploader upload . \
   --staging-bucket ${STAGING_BUCKET}
 
 popd
+
+# V2
+mvn clean site -B -q -Ddevsite.template="${KOKORO_GFILE_DIR}/java/"
+
+pushd target/devsite
+
+# create metadata
+python3 -m docuploader create-metadata \
+  --name ${NAME} \
+  --version ${VERSION} \
+  --language java
+
+# upload docs
+python3 -m docuploader upload . \
+  --credentials ${CREDENTIALS} \
+  --staging-bucket ${STAGING_BUCKET_V2}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f2dbdee0..39d1c88d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -48,6 +48,7 @@ integration tests.
 
 ```bash
 export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account.json
+export IT_SERVICE_ACCOUNT_EMAIL=my-service-account@my-project.gserviceaccount.com
 mvn -Penable-integration-tests clean verify
 ```
 
diff --git a/google-cloud-storage/clirr-ignored-differences.xml b/google-cloud-storage/clirr-ignored-differences.xml
index bca2faaf..114310c6 100644
--- a/google-cloud-storage/clirr-ignored-differences.xml
+++ b/google-cloud-storage/clirr-ignored-differences.xml
@@ -21,4 +21,9 @@
         <method>com.google.cloud.storage.BucketInfo$Builder deleteLifecycleRules()</method>
         <differenceType>7013</differenceType>
     </difference>
+    <difference>
+        <className>com/google/cloud/storage/BucketInfo$Builder</className>
+        <method>com.google.cloud.storage.BucketInfo$Builder setUpdateTime(java.lang.Long)</method>
+        <differenceType>7013</differenceType>
+    </difference>
 </differences>
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java
index c64a3dc5..3714e6e9 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/Bucket.java
@@ -601,6 +601,12 @@ public class Bucket extends BucketInfo {
       return this;
     }
 
+    @Override
+    Builder setUpdateTime(Long updateTime) {
+      infoBuilder.setUpdateTime(updateTime);
+      return this;
+    }
+
     @Override
     Builder setMetageneration(Long metageneration) {
       infoBuilder.setMetageneration(metageneration);
diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java
index 36136363..b3e96113 100644
--- a/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java
+++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java
@@ -84,6 +84,7 @@ public class BucketInfo implements Serializable {
   private final List<LifecycleRule> lifecycleRules;
   private final String etag;
   private final Long createTime;
+  private final Long updateTime;
   private final Long metageneration;
   private final List<Cors> cors;
   private final List<Acl> acl;
@@ -1005,6 +1006,8 @@ public class BucketInfo implements Serializable {
 
     abstract Builder setCreateTime(Long createTime);
 
+    abstract Builder setUpdateTime(Long updateTime);
+
     abstract Builder setMetageneration(Long metageneration);
 
     abstract Builder setLocationType(String locationType);
@@ -1090,6 +1093,7 @@ public class BucketInfo implements Serializable {
     private String location;
     private String etag;
     private Long createTime;
+    private Long updateTime;
     private Long metageneration;
     private List<Cors> cors;
     private List<Acl> acl;
@@ -1113,6 +1117,7 @@ public class BucketInfo implements Serializable {
       name = bucketInfo.name;
       etag = bucketInfo.etag;
       createTime = bucketInfo.createTime;
+      updateTime = bucketInfo.updateTime;
       metageneration = bucketInfo.metageneration;
       location = bucketInfo.location;
       storageClass = bucketInfo.storageClass;
@@ -1232,6 +1237,12 @@ public class BucketInfo implements Serializable {
       return this;
     }
 
+    @Override
+    Builder setUpdateTime(Long updateTime) {
+      this.updateTime = updateTime;
+      return this;
+    }
+
     @Override
     Builder setMetageneration(Long metageneration) {
       this.metageneration = metageneration;
@@ -1337,6 +1348,7 @@ public class BucketInfo implements Serializable {
     name = builder.name;
     etag = builder.etag;
     createTime = builder.createTime;
+    updateTime = builder.updateTime;
     metageneration = builder.metageneration;
     location = builder.location;
     storageClass = builder.storageClass;
@@ -1468,6 +1480,14 @@ public class BucketInfo implements Serializable {
     return createTime;
   }
 
+  /**
+   * Returns the last modification time of the bucket's metadata expressed as the number of
+   * milliseconds since the Unix epoch.
+   */
+  public Long getUpdateTime() {
+    return updateTime;
+  }
+
   /** Returns the metadata generation of this bucket. */
   public Long getMetageneration() {
     return metageneration;
@@ -1650,6 +1670,9 @@ public class BucketInfo implements Serializable {
     if (createTime != null) {
       bucketPb.setTimeCreated(new DateTime(createTime));
     }
+    if (updateTime != null) {
+      bucketPb.setUpdated(new DateTime(updateTime));
+    }
     if (metageneration != null) {
       bucketPb.setMetageneration(metageneration);
     }
@@ -1797,6 +1820,9 @@ public class BucketInfo implements Serializable {
     if (bucketPb.getTimeCreated() != null) {
       builder.setCreateTime(bucketPb.getTimeCreated().getValue());
     }
+    if (bucketPb.getUpdated() != null) {
+      builder.setUpdateTime(bucketPb.getUpdated().getValue());
+    }
     if (bucketPb.getLocation() != null) {
       builder.setLocation(bucketPb.getLocation());
     }
diff --git a/pom.xml b/pom.xml
index 256dc915..ba836071 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,7 +70,7 @@
       <dependency>
         <groupId>com.google.cloud</groupId>
         <artifactId>google-cloud-shared-dependencies</artifactId>
-        <version>0.8.3</version>
+        <version>0.8.4</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
diff --git a/synth.metadata b/synth.metadata
index f19c30e8..da1556f2 100644
--- a/synth.metadata
+++ b/synth.metadata
@@ -4,14 +4,14 @@
       "git": {
         "name": ".",
         "remote": "https://github.com/googleapis/java-storage.git",
-        "sha": "f8a4b12517c661881d7b7c65f796c1c8f1cf3ae9"
+        "sha": "0ce82ccf1e6ed8f46aeda92fe5f17eb427c3a7d9"
       }
     },
     {
       "git": {
         "name": "synthtool",
         "remote": "https://github.com/googleapis/synthtool.git",
-        "sha": "4f2c9f752a94042472fc03c5bd9e06e89817d2bd"
+        "sha": "dd230c816f88d0141fcd0be83498986287220d1b"
       }
     }
   ],
diff --git a/synth.py b/synth.py
index 7e8a9a3d..23c93c7c 100644
--- a/synth.py
+++ b/synth.py
@@ -19,6 +19,7 @@ import synthtool.languages.java as java
 AUTOSYNTH_MULTIPLE_COMMITS = True
 
 java.common_templates(excludes=[
-  '.kokoro/presubmit/integration.cfg'
+  '.kokoro/presubmit/integration.cfg',
+  'CONTRIBUTING.md'
 ])
 


Test patch:
diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java
index b1083942..425cfb70 100644
--- a/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java
+++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java
@@ -56,6 +56,7 @@ public class BucketInfoTest {
   private static final User OWNER = new User("user@gmail.com");
   private static final String SELF_LINK = "http://storage/b/n";
   private static final Long CREATE_TIME = System.currentTimeMillis();
+  private static final Long UPDATE_TIME = CREATE_TIME;
   private static final List<Cors> CORS = Collections.singletonList(Cors.newBuilder().build());
   private static final List<Acl> DEFAULT_ACL =
       Collections.singletonList(Acl.of(User.ofAllAuthenticatedUsers(), Role.WRITER));
@@ -117,6 +118,7 @@ public class BucketInfoTest {
           .setSelfLink(SELF_LINK)
           .setCors(CORS)
           .setCreateTime(CREATE_TIME)
+          .setUpdateTime(UPDATE_TIME)
           .setDefaultAcl(DEFAULT_ACL)
           .setDeleteRules(DELETE_RULES)
           .setLifecycleRules(LIFECYCLE_RULES)
@@ -148,6 +150,7 @@ public class BucketInfoTest {
           .setSelfLink(SELF_LINK)
           .setCors(CORS)
           .setCreateTime(CREATE_TIME)
+          .setUpdateTime(UPDATE_TIME)
           .setDefaultAcl(DEFAULT_ACL)
           .setDeleteRules(DELETE_RULES)
           .setLifecycleRules(LIFECYCLE_RULES)
@@ -202,6 +205,7 @@ public class BucketInfoTest {
     assertEquals(OWNER, BUCKET_INFO.getOwner());
     assertEquals(SELF_LINK, BUCKET_INFO.getSelfLink());
     assertEquals(CREATE_TIME, BUCKET_INFO.getCreateTime());
+    assertEquals(UPDATE_TIME, BUCKET_INFO.getUpdateTime());
     assertEquals(CORS, BUCKET_INFO.getCors());
     assertEquals(DEFAULT_ACL, BUCKET_INFO.getDefaultAcl());
     assertEquals(DELETE_RULES, BUCKET_INFO.getDeleteRules());
@@ -223,6 +227,7 @@ public class BucketInfoTest {
   }
 
   @Test
+  @SuppressWarnings({"unchecked", "deprecation"})
   public void testToPbAndFromPb() {
     compareBuckets(BUCKET_INFO, BucketInfo.fromPb(BUCKET_INFO.toPb()));
     BucketInfo bucketInfo =
@@ -245,6 +250,7 @@ public class BucketInfoTest {
     assertEquals(expected.getOwner(), value.getOwner());
     assertEquals(expected.getSelfLink(), value.getSelfLink());
     assertEquals(expected.getCreateTime(), value.getCreateTime());
+    assertEquals(expected.getUpdateTime(), value.getUpdateTime());
     assertEquals(expected.getCors(), value.getCors());
     assertEquals(expected.getDefaultAcl(), value.getDefaultAcl());
     assertEquals(expected.getDeleteRules(), value.getDeleteRules());
diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketTest.java
index 862fbb35..e8a8e3f4 100644
--- a/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketTest.java
+++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketTest.java
@@ -69,6 +69,7 @@ public class BucketTest {
   private static final User OWNER = new User("user@gmail.com");
   private static final String SELF_LINK = "http://storage/b/n";
   private static final Long CREATE_TIME = System.currentTimeMillis();
+  private static final Long UPDATE_TIME = CREATE_TIME - 1L;
   private static final List<Cors> CORS = Collections.singletonList(Cors.newBuilder().build());
   private static final List<Acl> DEFAULT_ACL =
       Collections.singletonList(Acl.of(User.ofAllAuthenticatedUsers(), WRITER));
@@ -111,6 +112,7 @@ public class BucketTest {
           .setSelfLink(SELF_LINK)
           .setCors(CORS)
           .setCreateTime(CREATE_TIME)
+          .setUpdateTime(UPDATE_TIME)
           .setDefaultAcl(DEFAULT_ACL)
           .setDeleteRules(DELETE_RULES)
           .setLifecycleRules(LIFECYCLE_RULES)
@@ -803,6 +805,7 @@ public class BucketTest {
             .setSelfLink(SELF_LINK)
             .setCors(CORS)
             .setCreateTime(CREATE_TIME)
+            .setUpdateTime(UPDATE_TIME)
             .setDefaultAcl(DEFAULT_ACL)
             .setDeleteRules(DELETE_RULES)
             .setLifecycleRules(LIFECYCLE_RULES)
@@ -828,6 +831,7 @@ public class BucketTest {
     assertEquals(OWNER, bucket.getOwner());
     assertEquals(SELF_LINK, bucket.getSelfLink());
     assertEquals(CREATE_TIME, bucket.getCreateTime());
+    assertEquals(UPDATE_TIME, bucket.getUpdateTime());
     assertEquals(CORS, bucket.getCors());
     assertEquals(DEFAULT_ACL, bucket.getDefaultAcl());
     assertEquals(DELETE_RULES, bucket.getDeleteRules());
diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
index 59000a07..a741f3eb 100644
--- a/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
+++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/it/ITStorageTest.java
@@ -3535,4 +3535,26 @@ public class ITStorageTest {
       RemoteStorageHelper.forceDelete(storage, bucketName, 5, TimeUnit.SECONDS);
     }
   }
+
+  @Test
+  public void testBucketUpdateTime() throws ExecutionException, InterruptedException {
+    String bucketName = RemoteStorageHelper.generateBucketName();
+    BucketInfo bucketInfo =
+        BucketInfo.newBuilder(bucketName).setLocation("us").setVersioningEnabled(true).build();
+    try {
+      Bucket bucket = storage.create(bucketInfo);
+      assertThat(bucket).isNotNull();
+      assertThat(bucket.versioningEnabled()).isTrue();
+      assertThat(bucket.getCreateTime()).isNotNull();
+      assertThat(bucket.getUpdateTime()).isEqualTo(bucket.getCreateTime());
+
+      Bucket updatedBucket = bucket.toBuilder().setVersioningEnabled(false).build().update();
+      assertThat(updatedBucket.versioningEnabled()).isFalse();
+      assertThat(updatedBucket.getUpdateTime()).isNotNull();
+      assertThat(updatedBucket.getCreateTime()).isEqualTo(bucket.getCreateTime());
+      assertThat(updatedBucket.getUpdateTime()).isGreaterThan(bucket.getCreateTime());
+    } finally {
+      RemoteStorageHelper.forceDelete(storage, bucketName, 5, TimeUnit.SECONDS);
+    }
+  }
 }