Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

feat: Introduce automatic LRO polling, integrate latest compute API definitions #583

Merged
merged 10 commits into from
Dec 7, 2021
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker:
digest: sha256:5b8c790f57cca57e6b37ba25f79291265c218cea3e6ba9714b001910ab3f1419
image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest
33 changes: 33 additions & 0 deletions .github/.OwlBot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

docker:
image: "gcr.io/cloud-devrel-public-resources/owlbot-java:latest"

deep-remove-regex:
- "/grpc-google-.*/src"
- "/proto-google-.*/src"
- "/google-.*/src"

deep-preserve-regex:
- "/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java"
- "/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration"

deep-copy-regex:
- source: "/google/cloud/compute/(v\\d)/.*-java/proto-google-.*/src"
dest: "/owl-bot-staging/$1/proto-google-cloud-compute-$1/src"
- source: "/google/cloud/compute/(v\\d)/.*-java/grpc-google-.*/src"
dest: "/owl-bot-staging/$1/grpc-google-cloud-compute-$1/src"
- source: "/google/cloud/compute/(v\\d)/.*-java/gapic-google-.*/src"
dest: "/owl-bot-staging/$1/google-cloud-compute/src"
4 changes: 3 additions & 1 deletion .repo-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
"api_id": "compute.googleapis.com",
"requires_billing": true,
"codeowner_team": "@googleapis/actools-java",
"library_type": "GAPIC_AUTO"
"library_type": "GAPIC_AUTO",
"excluded_dependencies": "grpc-google-cloud-compute-v1",
"excluded_poms": "grpc-google-cloud-compute-v1"
}
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ If you are using Maven, add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-compute</artifactId>
<version>1.4.1-alpha</version>
<version>1.5.0-alpha</version>
</dependency>

```

If you are using Gradle without BOM, add this to your dependencies

```Groovy
implementation 'com.google.cloud:google-cloud-compute:1.4.1-alpha'
implementation 'com.google.cloud:google-cloud-compute:1.5.0-alpha'
```

If you are using SBT, add this to your dependencies

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-compute" % "1.4.1-alpha"
libraryDependencies += "com.google.cloud" % "google-cloud-compute" % "1.5.0-alpha"
```

## Authentication
Expand Down Expand Up @@ -138,7 +138,7 @@ Compute Engine uses HTTP/JSON for the transport layer.

## Supported Java Versions

Java 7 or above is required for using this client.
Java 8 or above is required for using this client.

Google's Java client libraries,
[Google Cloud Client Libraries][cloudlibs]
Expand Down Expand Up @@ -210,7 +210,6 @@ Apache 2.0 - See [LICENSE][license] for more information.

Java Version | Status
------------ | ------
Java 7 | [![Kokoro CI][kokoro-badge-image-1]][kokoro-badge-link-1]
Java 8 | [![Kokoro CI][kokoro-badge-image-2]][kokoro-badge-link-2]
Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3]
Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4]
Expand All @@ -219,7 +218,7 @@ Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5]
Java is a registered trademark of Oracle and/or its affiliates.

[product-docs]: https://cloud.google.com/compute/
[javadocs]: https://googleapis.dev/java/google-cloud-compute/latest/index.html
[javadocs]: https://cloud.google.com/java/docs/reference/google-cloud-compute/latest/history
[kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-compute/java7.svg
[kokoro-badge-link-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-compute/java7.html
[kokoro-badge-image-2]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-compute/java8.svg
Expand Down
5 changes: 2 additions & 3 deletions google-cloud-compute-bom/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
Expand Down Expand Up @@ -49,7 +49,6 @@

<dependencyManagement>
<dependencies>

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-compute</artifactId>
Expand All @@ -74,4 +73,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
6 changes: 2 additions & 4 deletions google-cloud-compute/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-compute</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.compute.v1.stub.AddressesStub;
Expand All @@ -46,7 +48,7 @@
* String project = "project-309310695";
* String region = "region-934795532";
* String address = "address-1147692044";
* Operation response = addressesClient.delete(project, region, address);
* Address response = addressesClient.get(project, region, address);
* }
* }</pre>
*
Expand Down Expand Up @@ -285,7 +287,7 @@ public final AggregatedListPagedResponse aggregatedList(AggregatedListAddressesR
* String project = "project-309310695";
* String region = "region-934795532";
* String address = "address-1147692044";
* Operation response = addressesClient.delete(project, region, address);
* Operation response = addressesClient.deleteAsync(project, region, address).get();
* }
* }</pre>
*
Expand All @@ -294,14 +296,15 @@ public final AggregatedListPagedResponse aggregatedList(AggregatedListAddressesR
* @param address Name of the address resource to delete.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Operation delete(String project, String region, String address) {
public final OperationFuture<Operation, Operation> deleteAsync(
String project, String region, String address) {
DeleteAddressRequest request =
DeleteAddressRequest.newBuilder()
.setProject(project)
.setRegion(region)
.setAddress(address)
.build();
return delete(request);
return deleteAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
Expand All @@ -319,15 +322,44 @@ public final Operation delete(String project, String region, String address) {
* .setRegion("region-934795532")
* .setRequestId("requestId693933066")
* .build();
* Operation response = addressesClient.delete(request);
* Operation response = addressesClient.deleteAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Operation delete(DeleteAddressRequest request) {
return deleteCallable().call(request);
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Operation, Operation> deleteAsync(DeleteAddressRequest request) {
return deleteOperationCallable().futureCall(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes the specified address resource.
*
* <p>Sample code:
*
* <pre>{@code
* try (AddressesClient addressesClient = AddressesClient.create()) {
* DeleteAddressRequest request =
* DeleteAddressRequest.newBuilder()
* .setAddress("address-1147692044")
* .setProject("project-309310695")
* .setRegion("region-934795532")
* .setRequestId("requestId693933066")
* .build();
* OperationFuture<Operation, Operation> future =
* addressesClient.deleteOperationCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final OperationCallable<DeleteAddressRequest, Operation, Operation>
deleteOperationCallable() {
return stub.deleteOperationCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
Expand Down Expand Up @@ -445,7 +477,7 @@ public final UnaryCallable<GetAddressRequest, Address> getCallable() {
* String project = "project-309310695";
* String region = "region-934795532";
* Address addressResource = Address.newBuilder().build();
* Operation response = addressesClient.insert(project, region, addressResource);
* Operation response = addressesClient.insertAsync(project, region, addressResource).get();
* }
* }</pre>
*
Expand All @@ -454,14 +486,15 @@ public final UnaryCallable<GetAddressRequest, Address> getCallable() {
* @param addressResource The body resource for this request
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Operation insert(String project, String region, Address addressResource) {
public final OperationFuture<Operation, Operation> insertAsync(
String project, String region, Address addressResource) {
InsertAddressRequest request =
InsertAddressRequest.newBuilder()
.setProject(project)
.setRegion(region)
.setAddressResource(addressResource)
.build();
return insert(request);
return insertAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
Expand All @@ -479,15 +512,44 @@ public final Operation insert(String project, String region, Address addressReso
* .setRegion("region-934795532")
* .setRequestId("requestId693933066")
* .build();
* Operation response = addressesClient.insert(request);
* Operation response = addressesClient.insertAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Operation insert(InsertAddressRequest request) {
return insertCallable().call(request);
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Operation, Operation> insertAsync(InsertAddressRequest request) {
return insertOperationCallable().futureCall(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates an address resource in the specified project by using the data included in the request.
*
* <p>Sample code:
*
* <pre>{@code
* try (AddressesClient addressesClient = AddressesClient.create()) {
* InsertAddressRequest request =
* InsertAddressRequest.newBuilder()
* .setAddressResource(Address.newBuilder().build())
* .setProject("project-309310695")
* .setRegion("region-934795532")
* .setRequestId("requestId693933066")
* .build();
* OperationFuture<Operation, Operation> future =
* addressesClient.insertOperationCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final OperationCallable<InsertAddressRequest, Operation, Operation>
insertOperationCallable() {
return stub.insertOperationCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.OperationCallSettings;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
Expand All @@ -50,15 +51,15 @@
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object.
*
* <p>For example, to set the total timeout of delete to 30 seconds:
* <p>For example, to set the total timeout of get to 30 seconds:
*
* <pre>{@code
* AddressesSettings.Builder addressesSettingsBuilder = AddressesSettings.newBuilder();
* addressesSettingsBuilder
* .deleteSettings()
* .getSettings()
* .setRetrySettings(
* addressesSettingsBuilder
* .deleteSettings()
* .getSettings()
* .getRetrySettings()
* .toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30))
Expand All @@ -81,6 +82,12 @@ public UnaryCallSettings<DeleteAddressRequest, Operation> deleteSettings() {
return ((AddressesStubSettings) getStubSettings()).deleteSettings();
}

/** Returns the object with the settings used for calls to delete. */
public OperationCallSettings<DeleteAddressRequest, Operation, Operation>
deleteOperationSettings() {
return ((AddressesStubSettings) getStubSettings()).deleteOperationSettings();
}

/** Returns the object with the settings used for calls to get. */
public UnaryCallSettings<GetAddressRequest, Address> getSettings() {
return ((AddressesStubSettings) getStubSettings()).getSettings();
Expand All @@ -91,6 +98,12 @@ public UnaryCallSettings<InsertAddressRequest, Operation> insertSettings() {
return ((AddressesStubSettings) getStubSettings()).insertSettings();
}

/** Returns the object with the settings used for calls to insert. */
public OperationCallSettings<InsertAddressRequest, Operation, Operation>
insertOperationSettings() {
return ((AddressesStubSettings) getStubSettings()).insertOperationSettings();
}

/** Returns the object with the settings used for calls to list. */
public PagedCallSettings<ListAddressesRequest, AddressList, ListPagedResponse> listSettings() {
return ((AddressesStubSettings) getStubSettings()).listSettings();
Expand Down Expand Up @@ -205,6 +218,12 @@ public UnaryCallSettings.Builder<DeleteAddressRequest, Operation> deleteSettings
return getStubSettingsBuilder().deleteSettings();
}

/** Returns the builder for the settings used for calls to delete. */
public OperationCallSettings.Builder<DeleteAddressRequest, Operation, Operation>
deleteOperationSettings() {
return getStubSettingsBuilder().deleteOperationSettings();
}

/** Returns the builder for the settings used for calls to get. */
public UnaryCallSettings.Builder<GetAddressRequest, Address> getSettings() {
return getStubSettingsBuilder().getSettings();
Expand All @@ -215,6 +234,12 @@ public UnaryCallSettings.Builder<InsertAddressRequest, Operation> insertSettings
return getStubSettingsBuilder().insertSettings();
}

/** Returns the builder for the settings used for calls to insert. */
public OperationCallSettings.Builder<InsertAddressRequest, Operation, Operation>
insertOperationSettings() {
return getStubSettingsBuilder().insertOperationSettings();
}

/** Returns the builder for the settings used for calls to list. */
public PagedCallSettings.Builder<ListAddressesRequest, AddressList, ListPagedResponse>
listSettings() {
Expand Down
Loading