Skip to content

LRO for Compute Client [WIP] #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
70cd33f
regen'd and tested
andreamlin Feb 13, 2019
ea9a6bd
make Compute's Operation type extend OperationStatus
andreamlin Feb 14, 2019
fcdff4d
computeOperationSnapshot to implement OperationSnapshot
andreamlin Feb 14, 2019
64b7c76
add OperationSnapshotCallabe
andreamlin Feb 14, 2019
6a3c537
implemented ComputeLongRunningClinet
andreamlin Feb 14, 2019
2263af5
updates to compute.longrunning
andreamlin Feb 14, 2019
4007a2d
fix gax-java dep to latest SNAPSHOT
andreamlin Feb 14, 2019
2a14d19
save changes to HttpJsonRegionAutoscalerCallableFactory for reference
andreamlin Feb 14, 2019
9abd7c5
updates to compute.longrunning
andreamlin Feb 14, 2019
7419b45
add tests
andreamlin Feb 14, 2019
e7dc4ee
make ComputeLROClient work
andreamlin Feb 14, 2019
db12d7f
deleteFirewallTest() works
andreamlin Feb 14, 2019
682dc60
update compute.longrunning and remove unused classes
andreamlin Feb 15, 2019
997710f
javadoc
andreamlin Feb 15, 2019
a7b6911
tests pass (LRO not fully tested tho)
andreamlin Feb 15, 2019
5be778e
kinda broken, kinda workinggit st
andreamlin Feb 15, 2019
991225b
changes to LRO compute
andreamlin Feb 15, 2019
3abfff1
ITCompute Test works!
andreamlin Feb 16, 2019
fc160db
better log messages
andreamlin Feb 16, 2019
09ed792
merge in master
andreamlin Feb 21, 2019
add9d3f
move longrunning to v1.longrunning
andreamlin Feb 21, 2019
c80cad2
make GlobalLROClient the same as the RegionLRO and ZoneLRO clients
andreamlin Feb 21, 2019
9d25293
replace the separate [Scope]LongRunningClients with AutoValued factory"
andreamlin Feb 21, 2019
5945563
update ComputeOperationSnapshot
andreamlin Feb 22, 2019
632d22d
ComputeLongRunningClient ipmlements BackgroundResource
andreamlin Feb 26, 2019
0592efa
refactoring the compute longrunning files so they are generate-able
andreamlin Feb 27, 2019
c2e0107
make ComputeOperationSnapshot generatable
andreamlin Feb 27, 2019
b5ac77a
make ComputeOperationSnapshot generatable
andreamlin Feb 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions google-cloud-clients/google-cloud-compute/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<artifactId>google-api-services-compute</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<scope>provided</scope>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.httpjson.EmptyMessage;
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.AddressStub;
Expand All @@ -43,7 +46,7 @@
* <code>
* try (AddressClient addressClient = AddressClient.create()) {
* ProjectRegionAddressName address = ProjectRegionAddressName.of("[PROJECT]", "[REGION]", "[ADDRESS]");
* Operation response = addressClient.deleteAddress(address);
* Address response = addressClient.getAddress(address);
* }
* </code>
* </pre>
Expand Down Expand Up @@ -103,6 +106,7 @@
public class AddressClient implements BackgroundResource {
private final AddressSettings settings;
private final AddressStub stub;
private final RegionOperationClient operationsClient;

/** Constructs an instance of AddressClient with default settings. */
public static final AddressClient create() throws IOException {
Expand Down Expand Up @@ -133,12 +137,14 @@ public static final AddressClient create(AddressStub stub) {
protected AddressClient(AddressSettings settings) throws IOException {
this.settings = settings;
this.stub = ((AddressStubSettings) settings.getStubSettings()).createStub();
this.operationsClient = RegionOperationClient.create(this.stub.getOperationsStub());
}

@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
protected AddressClient(AddressStub stub) {
this.settings = null;
this.stub = stub;
this.operationsClient = RegionOperationClient.create(this.stub.getOperationsStub());
}

public final AddressSettings getSettings() {
Expand All @@ -150,6 +156,16 @@ public AddressStub getStub() {
return stub;
}

/**
* Returns the RegionOperationClient that can be used to query the status of a long-running
* operation returned by another API method call.
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final RegionOperationClient getOperationsClient() {
return operationsClient;
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Retrieves an aggregated list of addresses.
Expand Down Expand Up @@ -298,21 +314,23 @@ public final AggregatedListAddressesPagedResponse aggregatedListAddresses(
* <pre><code>
* try (AddressClient addressClient = AddressClient.create()) {
* ProjectRegionAddressName address = ProjectRegionAddressName.of("[PROJECT]", "[REGION]", "[ADDRESS]");
* Operation response = addressClient.deleteAddress(address);
* addressClient.deleteAddressAsync(address).get();
* }
* </code></pre>
*
* @param address Name of the address resource to delete.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final Operation deleteAddress(ProjectRegionAddressName address) {
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<EmptyMessage, Operation> deleteAddressAsync(
ProjectRegionAddressName address) {

DeleteAddressHttpRequest request =
DeleteAddressHttpRequest.newBuilder()
.setAddress(address == null ? null : address.toString())
.build();
return deleteAddress(request);
return deleteAddressAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
Expand All @@ -324,19 +342,20 @@ public final Operation deleteAddress(ProjectRegionAddressName address) {
* <pre><code>
* try (AddressClient addressClient = AddressClient.create()) {
* ProjectRegionAddressName address = ProjectRegionAddressName.of("[PROJECT]", "[REGION]", "[ADDRESS]");
* Operation response = addressClient.deleteAddress(address.toString());
* addressClient.deleteAddressAsync(address.toString()).get();
* }
* </code></pre>
*
* @param address Name of the address resource to delete.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final Operation deleteAddress(String address) {
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<EmptyMessage, Operation> deleteAddressAsync(String address) {

DeleteAddressHttpRequest request =
DeleteAddressHttpRequest.newBuilder().setAddress(address).build();
return deleteAddress(request);
return deleteAddressAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
Expand All @@ -351,16 +370,42 @@ public final Operation deleteAddress(String address) {
* DeleteAddressHttpRequest request = DeleteAddressHttpRequest.newBuilder()
* .setAddress(address.toString())
* .build();
* Operation response = addressClient.deleteAddress(request);
* addressClient.deleteAddressAsync(request).get();
* }
* </code></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
*/
@BetaApi
public final Operation deleteAddress(DeleteAddressHttpRequest request) {
return deleteAddressCallable().call(request);
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<EmptyMessage, Operation> deleteAddressAsync(
DeleteAddressHttpRequest request) {
return deleteAddressOperationCallable().futureCall(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Deletes the specified address resource.
*
* <p>Sample code:
*
* <pre><code>
* try (AddressClient addressClient = AddressClient.create()) {
* ProjectRegionAddressName address = ProjectRegionAddressName.of("[PROJECT]", "[REGION]", "[ADDRESS]");
* DeleteAddressHttpRequest request = DeleteAddressHttpRequest.newBuilder()
* .setAddress(address.toString())
* .build();
* OperationFuture&lt;EmptyMessage, Operation&gt; future = addressClient.deleteAddressOperationCallable().futureCall(request);
* // Do something
* future.get();
* }
* </code></pre>
*/
@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
public final OperationCallable<DeleteAddressHttpRequest, EmptyMessage, Operation>
deleteAddressOperationCallable() {
return stub.deleteAddressOperationCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
Expand All @@ -377,7 +422,7 @@ public final Operation deleteAddress(DeleteAddressHttpRequest request) {
* .build();
* ApiFuture&lt;Operation&gt; future = addressClient.deleteAddressCallable().futureCall(request);
* // Do something
* Operation response = future.get();
* future.get();
* }
* </code></pre>
*/
Expand Down Expand Up @@ -492,7 +537,7 @@ public final UnaryCallable<GetAddressHttpRequest, Address> getAddressCallable()
* try (AddressClient addressClient = AddressClient.create()) {
* ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
* Address addressResource = Address.newBuilder().build();
* Operation response = addressClient.insertAddress(region, addressResource);
* addressClient.insertAddressAsync(region, addressResource).get();
* }
* </code></pre>
*
Expand All @@ -502,15 +547,17 @@ public final UnaryCallable<GetAddressHttpRequest, Address> getAddressCallable()
* v1.globalAddresses ==)
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final Operation insertAddress(ProjectRegionName region, Address addressResource) {
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<EmptyMessage, Operation> insertAddressAsync(
ProjectRegionName region, Address addressResource) {

InsertAddressHttpRequest request =
InsertAddressHttpRequest.newBuilder()
.setRegion(region == null ? null : region.toString())
.setAddressResource(addressResource)
.build();
return insertAddress(request);
return insertAddressAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
Expand All @@ -523,7 +570,7 @@ public final Operation insertAddress(ProjectRegionName region, Address addressRe
* try (AddressClient addressClient = AddressClient.create()) {
* ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
* Address addressResource = Address.newBuilder().build();
* Operation response = addressClient.insertAddress(region.toString(), addressResource);
* addressClient.insertAddressAsync(region.toString(), addressResource).get();
* }
* </code></pre>
*
Expand All @@ -533,15 +580,17 @@ public final Operation insertAddress(ProjectRegionName region, Address addressRe
* v1.globalAddresses ==)
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi
public final Operation insertAddress(String region, Address addressResource) {
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<EmptyMessage, Operation> insertAddressAsync(
String region, Address addressResource) {

InsertAddressHttpRequest request =
InsertAddressHttpRequest.newBuilder()
.setRegion(region)
.setAddressResource(addressResource)
.build();
return insertAddress(request);
return insertAddressAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
Expand All @@ -558,16 +607,44 @@ public final Operation insertAddress(String region, Address addressResource) {
* .setRegion(region.toString())
* .setAddressResource(addressResource)
* .build();
* Operation response = addressClient.insertAddress(request);
* addressClient.insertAddressAsync(request).get();
* }
* </code></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
*/
@BetaApi
public final Operation insertAddress(InsertAddressHttpRequest request) {
return insertAddressCallable().call(request);
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<EmptyMessage, Operation> insertAddressAsync(
InsertAddressHttpRequest request) {
return insertAddressOperationCallable().futureCall(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Creates an address resource in the specified project using the data included in the request.
*
* <p>Sample code:
*
* <pre><code>
* try (AddressClient addressClient = AddressClient.create()) {
* ProjectRegionName region = ProjectRegionName.of("[PROJECT]", "[REGION]");
* Address addressResource = Address.newBuilder().build();
* InsertAddressHttpRequest request = InsertAddressHttpRequest.newBuilder()
* .setRegion(region.toString())
* .setAddressResource(addressResource)
* .build();
* OperationFuture&lt;EmptyMessage, Operation&gt; future = addressClient.insertAddressOperationCallable().futureCall(request);
* // Do something
* future.get();
* }
* </code></pre>
*/
@BetaApi("The surface for use by generated code is not stable yet and may change in the future.")
public final OperationCallable<InsertAddressHttpRequest, EmptyMessage, Operation>
insertAddressOperationCallable() {
return stub.insertAddressOperationCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
Expand All @@ -586,7 +663,7 @@ public final Operation insertAddress(InsertAddressHttpRequest request) {
* .build();
* ApiFuture&lt;Operation&gt; future = addressClient.insertAddressCallable().futureCall(request);
* // Do something
* Operation response = future.get();
* future.get();
* }
* </code></pre>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import com.google.api.core.BetaApi;
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
import com.google.api.gax.httpjson.EmptyMessage;
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
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 @@ -49,13 +51,13 @@
*
* <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. For
* example, to set the total timeout of deleteAddress to 30 seconds:
* example, to set the total timeout of getAddress to 30 seconds:
*
* <pre>
* <code>
* AddressSettings.Builder addressSettingsBuilder =
* AddressSettings.newBuilder();
* addressSettingsBuilder.deleteAddressSettings().getRetrySettings().toBuilder()
* addressSettingsBuilder.getAddressSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* AddressSettings addressSettings = addressSettingsBuilder.build();
* </code>
Expand All @@ -78,6 +80,14 @@ public UnaryCallSettings<DeleteAddressHttpRequest, Operation> deleteAddressSetti
return ((AddressStubSettings) getStubSettings()).deleteAddressSettings();
}

/** Returns the object with the settings used for calls to deleteAddress. */
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public OperationCallSettings<DeleteAddressHttpRequest, EmptyMessage, Operation>
deleteAddressOperationSettings() {
return ((AddressStubSettings) getStubSettings()).deleteAddressOperationSettings();
}

/** Returns the object with the settings used for calls to getAddress. */
public UnaryCallSettings<GetAddressHttpRequest, Address> getAddressSettings() {
return ((AddressStubSettings) getStubSettings()).getAddressSettings();
Expand All @@ -88,6 +98,14 @@ public UnaryCallSettings<InsertAddressHttpRequest, Operation> insertAddressSetti
return ((AddressStubSettings) getStubSettings()).insertAddressSettings();
}

/** Returns the object with the settings used for calls to insertAddress. */
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public OperationCallSettings<InsertAddressHttpRequest, EmptyMessage, Operation>
insertAddressOperationSettings() {
return ((AddressStubSettings) getStubSettings()).insertAddressOperationSettings();
}

/** Returns the object with the settings used for calls to listAddresses. */
public PagedCallSettings<ListAddressesHttpRequest, AddressList, ListAddressesPagedResponse>
listAddressesSettings() {
Expand Down Expand Up @@ -209,6 +227,14 @@ public UnaryCallSettings.Builder<DeleteAddressHttpRequest, Operation> deleteAddr
return getStubSettingsBuilder().deleteAddressSettings();
}

/** Returns the builder for the settings used for calls to deleteAddress. */
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public OperationCallSettings.Builder<DeleteAddressHttpRequest, EmptyMessage, Operation>
deleteAddressOperationSettings() {
return getStubSettingsBuilder().deleteAddressOperationSettings();
}

/** Returns the builder for the settings used for calls to getAddress. */
public UnaryCallSettings.Builder<GetAddressHttpRequest, Address> getAddressSettings() {
return getStubSettingsBuilder().getAddressSettings();
Expand All @@ -219,6 +245,14 @@ public UnaryCallSettings.Builder<InsertAddressHttpRequest, Operation> insertAddr
return getStubSettingsBuilder().insertAddressSettings();
}

/** Returns the builder for the settings used for calls to insertAddress. */
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public OperationCallSettings.Builder<InsertAddressHttpRequest, EmptyMessage, Operation>
insertAddressOperationSettings() {
return getStubSettingsBuilder().insertAddressOperationSettings();
}

/** Returns the builder for the settings used for calls to listAddresses. */
public PagedCallSettings.Builder<
ListAddressesHttpRequest, AddressList, ListAddressesPagedResponse>
Expand Down
Loading