From ab4a6f5eeda57bd8a0a49c79a63cbf93d1215522 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 19:34:13 +0000 Subject: [PATCH 1/6] chore(main): release 2.2.2-SNAPSHOT (#319) :robot: I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- google-cloud-workflow-executions-bom/pom.xml | 12 ++++++------ google-cloud-workflow-executions/pom.xml | 4 ++-- grpc-google-cloud-workflow-executions-v1/pom.xml | 4 ++-- grpc-google-cloud-workflow-executions-v1beta/pom.xml | 4 ++-- pom.xml | 12 ++++++------ proto-google-cloud-workflow-executions-v1/pom.xml | 4 ++-- .../pom.xml | 4 ++-- samples/snapshot/pom.xml | 2 +- versions.txt | 10 +++++----- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/google-cloud-workflow-executions-bom/pom.xml b/google-cloud-workflow-executions-bom/pom.xml index be4cec08..5329ce28 100644 --- a/google-cloud-workflow-executions-bom/pom.xml +++ b/google-cloud-workflow-executions-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-workflow-executions-bom - 2.2.1 + 2.2.2-SNAPSHOT pom com.google.cloud @@ -56,27 +56,27 @@ com.google.cloud google-cloud-workflow-executions - 2.2.1 + 2.2.2-SNAPSHOT com.google.api.grpc grpc-google-cloud-workflow-executions-v1beta - 0.6.1 + 0.6.2-SNAPSHOT com.google.api.grpc grpc-google-cloud-workflow-executions-v1 - 2.2.1 + 2.2.2-SNAPSHOT com.google.api.grpc proto-google-cloud-workflow-executions-v1beta - 0.6.1 + 0.6.2-SNAPSHOT com.google.api.grpc proto-google-cloud-workflow-executions-v1 - 2.2.1 + 2.2.2-SNAPSHOT diff --git a/google-cloud-workflow-executions/pom.xml b/google-cloud-workflow-executions/pom.xml index 047bfc6b..1890b788 100644 --- a/google-cloud-workflow-executions/pom.xml +++ b/google-cloud-workflow-executions/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-workflow-executions - 2.2.1 + 2.2.2-SNAPSHOT jar Google Cloud Workflow Executions https://github.com/googleapis/java-workflow-executions @@ -11,7 +11,7 @@ com.google.cloud google-cloud-workflow-executions-parent - 2.2.1 + 2.2.2-SNAPSHOT google-cloud-workflow-executions diff --git a/grpc-google-cloud-workflow-executions-v1/pom.xml b/grpc-google-cloud-workflow-executions-v1/pom.xml index 66508fdd..86bc0767 100644 --- a/grpc-google-cloud-workflow-executions-v1/pom.xml +++ b/grpc-google-cloud-workflow-executions-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-workflow-executions-v1 - 2.2.1 + 2.2.2-SNAPSHOT grpc-google-cloud-workflow-executions-v1 GRPC library for google-cloud-workflow-executions com.google.cloud google-cloud-workflow-executions-parent - 2.2.1 + 2.2.2-SNAPSHOT diff --git a/grpc-google-cloud-workflow-executions-v1beta/pom.xml b/grpc-google-cloud-workflow-executions-v1beta/pom.xml index ac69fa4b..0d0f49f9 100644 --- a/grpc-google-cloud-workflow-executions-v1beta/pom.xml +++ b/grpc-google-cloud-workflow-executions-v1beta/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-workflow-executions-v1beta - 0.6.1 + 0.6.2-SNAPSHOT grpc-google-cloud-workflow-executions-v1beta GRPC library for google-cloud-workflow-executions com.google.cloud google-cloud-workflow-executions-parent - 2.2.1 + 2.2.2-SNAPSHOT diff --git a/pom.xml b/pom.xml index 2924488e..5c7276e8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-workflow-executions-parent pom - 2.2.1 + 2.2.2-SNAPSHOT Google Cloud Workflow Executions Parent https://github.com/googleapis/java- @@ -61,27 +61,27 @@ com.google.cloud google-cloud-workflow-executions - 2.2.1 + 2.2.2-SNAPSHOT com.google.api.grpc proto-google-cloud-workflow-executions-v1 - 2.2.1 + 2.2.2-SNAPSHOT com.google.api.grpc grpc-google-cloud-workflow-executions-v1 - 2.2.1 + 2.2.2-SNAPSHOT com.google.api.grpc proto-google-cloud-workflow-executions-v1beta - 0.6.1 + 0.6.2-SNAPSHOT com.google.api.grpc grpc-google-cloud-workflow-executions-v1beta - 0.6.1 + 0.6.2-SNAPSHOT diff --git a/proto-google-cloud-workflow-executions-v1/pom.xml b/proto-google-cloud-workflow-executions-v1/pom.xml index 388ca7c9..e7cc31fe 100644 --- a/proto-google-cloud-workflow-executions-v1/pom.xml +++ b/proto-google-cloud-workflow-executions-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-workflow-executions-v1 - 2.2.1 + 2.2.2-SNAPSHOT proto-google-cloud-workflow-executions-v1 Proto library for google-cloud-workflow-executions com.google.cloud google-cloud-workflow-executions-parent - 2.2.1 + 2.2.2-SNAPSHOT diff --git a/proto-google-cloud-workflow-executions-v1beta/pom.xml b/proto-google-cloud-workflow-executions-v1beta/pom.xml index bb48adbf..983c1e9e 100644 --- a/proto-google-cloud-workflow-executions-v1beta/pom.xml +++ b/proto-google-cloud-workflow-executions-v1beta/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-workflow-executions-v1beta - 0.6.1 + 0.6.2-SNAPSHOT proto-google-cloud-workflow-executions-v1beta Proto library for google-cloud-workflow-executions com.google.cloud google-cloud-workflow-executions-parent - 2.2.1 + 2.2.2-SNAPSHOT diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 865c011d..97829196 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-workflow-executions - 2.2.1 + 2.2.2-SNAPSHOT diff --git a/versions.txt b/versions.txt index f5ca4c66..13378f39 100644 --- a/versions.txt +++ b/versions.txt @@ -1,8 +1,8 @@ # Format: # module:released-version:current-version -google-cloud-workflow-executions:2.2.1:2.2.1 -grpc-google-cloud-workflow-executions-v1beta:0.6.1:0.6.1 -grpc-google-cloud-workflow-executions-v1:2.2.1:2.2.1 -proto-google-cloud-workflow-executions-v1beta:0.6.1:0.6.1 -proto-google-cloud-workflow-executions-v1:2.2.1:2.2.1 +google-cloud-workflow-executions:2.2.1:2.2.2-SNAPSHOT +grpc-google-cloud-workflow-executions-v1beta:0.6.1:0.6.2-SNAPSHOT +grpc-google-cloud-workflow-executions-v1:2.2.1:2.2.2-SNAPSHOT +proto-google-cloud-workflow-executions-v1beta:0.6.1:0.6.2-SNAPSHOT +proto-google-cloud-workflow-executions-v1:2.2.1:2.2.2-SNAPSHOT From f42b2d0ef1f55cc72e355199a85d981147f829e0 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 28 Jun 2022 16:43:39 -0700 Subject: [PATCH 2/6] feat: Enable REST transport for most of Java and Go clients (#311) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): upgrade gapic-generator-java to 2.8.0 and update gax-java to 2.18.1 PiperOrigin-RevId: 450543911 Source-Link: https://github.com/googleapis/googleapis/commit/55283447ab72f10b6c2571d770af0498b593e84f Source-Link: https://github.com/googleapis/googleapis-gen/commit/9f6775cab1958982b88967a43e5e806af0f135db Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWY2Nzc1Y2FiMTk1ODk4MmI4ODk2N2E0M2U1ZTgwNmFmMGYxMzVkYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Integrate new gapic-generator-java and rules_gapic PiperOrigin-RevId: 454027580 Source-Link: https://github.com/googleapis/googleapis/commit/1b222777baa702e7135610355706570ed2b56318 Source-Link: https://github.com/googleapis/googleapis-gen/commit/e04cea20d0d12eb5c3bdb360a9e72b654edcb638 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTA0Y2VhMjBkMGQxMmViNWMzYmRiMzYwYTllNzJiNjU0ZWRjYjYzOCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Enable REST transport for most of Java and Go clients PiperOrigin-RevId: 456641589 Source-Link: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Update pom.xml Co-authored-by: Owl Bot Co-authored-by: Neenu Shaji --- google-cloud-workflow-executions/pom.xml | 16 + .../executions/v1/ExecutionsClient.java | 20 +- .../executions/v1/ExecutionsSettings.java | 23 +- .../v1/stub/ExecutionsStubSettings.java | 54 +- .../HttpJsonExecutionsCallableFactory.java | 105 ++++ .../v1/stub/HttpJsonExecutionsStub.java | 363 +++++++++++++ .../executions/v1beta/ExecutionsClient.java | 19 +- .../executions/v1beta/ExecutionsSettings.java | 23 +- .../v1beta/stub/ExecutionsStubSettings.java | 54 +- .../HttpJsonExecutionsCallableFactory.java | 105 ++++ .../v1beta/stub/HttpJsonExecutionsStub.java | 366 +++++++++++++ .../v1/ExecutionsClientHttpJsonTest.java | 491 ++++++++++++++++++ .../v1beta/ExecutionsClientHttpJsonTest.java | 491 ++++++++++++++++++ 13 files changed, 2109 insertions(+), 21 deletions(-) create mode 100644 google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/HttpJsonExecutionsCallableFactory.java create mode 100644 google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/HttpJsonExecutionsStub.java create mode 100644 google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/HttpJsonExecutionsCallableFactory.java create mode 100644 google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/HttpJsonExecutionsStub.java create mode 100644 google-cloud-workflow-executions/src/test/java/com/google/cloud/workflows/executions/v1/ExecutionsClientHttpJsonTest.java create mode 100644 google-cloud-workflow-executions/src/test/java/com/google/cloud/workflows/executions/v1beta/ExecutionsClientHttpJsonTest.java diff --git a/google-cloud-workflow-executions/pom.xml b/google-cloud-workflow-executions/pom.xml index 1890b788..787ba06f 100644 --- a/google-cloud-workflow-executions/pom.xml +++ b/google-cloud-workflow-executions/pom.xml @@ -62,6 +62,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + @@ -82,12 +86,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/ExecutionsClient.java b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/ExecutionsClient.java index af1133bc..e4dc3948 100644 --- a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/ExecutionsClient.java +++ b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/ExecutionsClient.java @@ -18,7 +18,6 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -99,6 +98,20 @@ * ExecutionsClient executionsClient = ExecutionsClient.create(executionsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ExecutionsSettings executionsSettings =
+ *     ExecutionsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ExecutionsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ExecutionsClient executionsClient = ExecutionsClient.create(executionsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -123,7 +136,6 @@ public static final ExecutionsClient create(ExecutionsSettings settings) throws * Constructs an instance of ExecutionsClient, using the given stub for making calls. This is for * advanced usage - prefer using create(ExecutionsSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ExecutionsClient create(ExecutionsStub stub) { return new ExecutionsClient(stub); } @@ -137,7 +149,6 @@ protected ExecutionsClient(ExecutionsSettings settings) throws IOException { this.stub = ((ExecutionsStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ExecutionsClient(ExecutionsStub stub) { this.settings = null; this.stub = stub; @@ -147,7 +158,6 @@ public final ExecutionsSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ExecutionsStub getStub() { return stub; } @@ -297,7 +307,7 @@ public final ListExecutionsPagedResponse listExecutions(ListExecutionsRequest re * .build(); * while (true) { * ListExecutionsResponse response = executionsClient.listExecutionsCallable().call(request); - * for (Execution element : response.getResponsesList()) { + * for (Execution element : response.getExecutionsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/ExecutionsSettings.java b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/ExecutionsSettings.java index 4bef877f..986e5a64 100644 --- a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/ExecutionsSettings.java +++ b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/ExecutionsSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +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; @@ -117,11 +118,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ExecutionsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ExecutionsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ExecutionsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ExecutionsStubSettings.defaultTransportChannelProvider(); } @@ -131,11 +139,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ExecutionsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -173,6 +187,11 @@ private static Builder createDefault() { return new Builder(ExecutionsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ExecutionsStubSettings.newHttpJsonBuilder()); + } + public ExecutionsStubSettings.Builder getStubSettingsBuilder() { return ((ExecutionsStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/ExecutionsStubSettings.java b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/ExecutionsStubSettings.java index 3614293f..a5f9248a 100644 --- a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/ExecutionsStubSettings.java +++ b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/ExecutionsStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -177,13 +180,17 @@ public UnaryCallSettings cancelExecutionSetti return cancelExecutionSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ExecutionsStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcExecutionsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonExecutionsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -216,18 +223,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ExecutionsStubSettings.class)) @@ -235,11 +249,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ExecutionsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ExecutionsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -340,6 +373,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listExecutionsSettings() diff --git a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/HttpJsonExecutionsCallableFactory.java b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/HttpJsonExecutionsCallableFactory.java new file mode 100644 index 00000000..d8ae6e8f --- /dev/null +++ b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/HttpJsonExecutionsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.workflows.executions.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Executions service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonExecutionsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/HttpJsonExecutionsStub.java b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/HttpJsonExecutionsStub.java new file mode 100644 index 00000000..c1f006f8 --- /dev/null +++ b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1/stub/HttpJsonExecutionsStub.java @@ -0,0 +1,363 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.workflows.executions.v1.stub; + +import static com.google.cloud.workflows.executions.v1.ExecutionsClient.ListExecutionsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.workflows.executions.v1.CancelExecutionRequest; +import com.google.cloud.workflows.executions.v1.CreateExecutionRequest; +import com.google.cloud.workflows.executions.v1.Execution; +import com.google.cloud.workflows.executions.v1.GetExecutionRequest; +import com.google.cloud.workflows.executions.v1.ListExecutionsRequest; +import com.google.cloud.workflows.executions.v1.ListExecutionsResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Executions service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonExecutionsStub extends ExecutionsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listExecutionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.workflows.executions.v1.Executions/ListExecutions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/workflows/*}/executions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListExecutionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createExecutionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.workflows.executions.v1.Executions/CreateExecution") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/workflows/*}/executions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("execution", request.getExecution())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Execution.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getExecutionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.workflows.executions.v1.Executions/GetExecution") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/workflows/*/executions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Execution.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + cancelExecutionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.workflows.executions.v1.Executions/CancelExecution") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/workflows/*/executions/*}:cancel", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Execution.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listExecutionsCallable; + private final UnaryCallable + listExecutionsPagedCallable; + private final UnaryCallable createExecutionCallable; + private final UnaryCallable getExecutionCallable; + private final UnaryCallable cancelExecutionCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonExecutionsStub create(ExecutionsStubSettings settings) + throws IOException { + return new HttpJsonExecutionsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonExecutionsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonExecutionsStub( + ExecutionsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonExecutionsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonExecutionsStub( + ExecutionsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonExecutionsStub, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected HttpJsonExecutionsStub(ExecutionsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonExecutionsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonExecutionsStub, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected HttpJsonExecutionsStub( + ExecutionsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listExecutionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listExecutionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createExecutionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createExecutionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getExecutionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getExecutionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings cancelExecutionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(cancelExecutionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listExecutionsCallable = + callableFactory.createUnaryCallable( + listExecutionsTransportSettings, settings.listExecutionsSettings(), clientContext); + this.listExecutionsPagedCallable = + callableFactory.createPagedCallable( + listExecutionsTransportSettings, settings.listExecutionsSettings(), clientContext); + this.createExecutionCallable = + callableFactory.createUnaryCallable( + createExecutionTransportSettings, settings.createExecutionSettings(), clientContext); + this.getExecutionCallable = + callableFactory.createUnaryCallable( + getExecutionTransportSettings, settings.getExecutionSettings(), clientContext); + this.cancelExecutionCallable = + callableFactory.createUnaryCallable( + cancelExecutionTransportSettings, settings.cancelExecutionSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listExecutionsMethodDescriptor); + methodDescriptors.add(createExecutionMethodDescriptor); + methodDescriptors.add(getExecutionMethodDescriptor); + methodDescriptors.add(cancelExecutionMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listExecutionsCallable() { + return listExecutionsCallable; + } + + @Override + public UnaryCallable + listExecutionsPagedCallable() { + return listExecutionsPagedCallable; + } + + @Override + public UnaryCallable createExecutionCallable() { + return createExecutionCallable; + } + + @Override + public UnaryCallable getExecutionCallable() { + return getExecutionCallable; + } + + @Override + public UnaryCallable cancelExecutionCallable() { + return cancelExecutionCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/ExecutionsClient.java b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/ExecutionsClient.java index 2be349f7..cd1d50e5 100644 --- a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/ExecutionsClient.java +++ b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/ExecutionsClient.java @@ -99,6 +99,20 @@ * ExecutionsClient executionsClient = ExecutionsClient.create(executionsSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ExecutionsSettings executionsSettings =
+ *     ExecutionsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ExecutionsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ExecutionsClient executionsClient = ExecutionsClient.create(executionsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -124,7 +138,6 @@ public static final ExecutionsClient create(ExecutionsSettings settings) throws * Constructs an instance of ExecutionsClient, using the given stub for making calls. This is for * advanced usage - prefer using create(ExecutionsSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ExecutionsClient create(ExecutionsStub stub) { return new ExecutionsClient(stub); } @@ -138,7 +151,6 @@ protected ExecutionsClient(ExecutionsSettings settings) throws IOException { this.stub = ((ExecutionsStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ExecutionsClient(ExecutionsStub stub) { this.settings = null; this.stub = stub; @@ -148,7 +160,6 @@ public final ExecutionsSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ExecutionsStub getStub() { return stub; } @@ -298,7 +309,7 @@ public final ListExecutionsPagedResponse listExecutions(ListExecutionsRequest re * .build(); * while (true) { * ListExecutionsResponse response = executionsClient.listExecutionsCallable().call(request); - * for (Execution element : response.getResponsesList()) { + * for (Execution element : response.getExecutionsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/ExecutionsSettings.java b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/ExecutionsSettings.java index 0db5f1a1..195c1d9a 100644 --- a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/ExecutionsSettings.java +++ b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/ExecutionsSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +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; @@ -118,11 +119,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ExecutionsStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ExecutionsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ExecutionsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ExecutionsStubSettings.defaultTransportChannelProvider(); } @@ -132,11 +140,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ExecutionsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -174,6 +188,11 @@ private static Builder createDefault() { return new Builder(ExecutionsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ExecutionsStubSettings.newHttpJsonBuilder()); + } + public ExecutionsStubSettings.Builder getStubSettingsBuilder() { return ((ExecutionsStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/ExecutionsStubSettings.java b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/ExecutionsStubSettings.java index 1aac28d2..60f17195 100644 --- a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/ExecutionsStubSettings.java +++ b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/ExecutionsStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -178,13 +181,17 @@ public UnaryCallSettings cancelExecutionSetti return cancelExecutionSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ExecutionsStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcExecutionsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonExecutionsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -217,18 +224,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ExecutionsStubSettings.class)) @@ -236,11 +250,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ExecutionsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ExecutionsStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -341,6 +374,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listExecutionsSettings() diff --git a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/HttpJsonExecutionsCallableFactory.java b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/HttpJsonExecutionsCallableFactory.java new file mode 100644 index 00000000..4d0f9b53 --- /dev/null +++ b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/HttpJsonExecutionsCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.workflows.executions.v1beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Executions service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonExecutionsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/HttpJsonExecutionsStub.java b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/HttpJsonExecutionsStub.java new file mode 100644 index 00000000..238c2e6b --- /dev/null +++ b/google-cloud-workflow-executions/src/main/java/com/google/cloud/workflows/executions/v1beta/stub/HttpJsonExecutionsStub.java @@ -0,0 +1,366 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.workflows.executions.v1beta.stub; + +import static com.google.cloud.workflows.executions.v1beta.ExecutionsClient.ListExecutionsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.workflows.executions.v1beta.CancelExecutionRequest; +import com.google.cloud.workflows.executions.v1beta.CreateExecutionRequest; +import com.google.cloud.workflows.executions.v1beta.Execution; +import com.google.cloud.workflows.executions.v1beta.GetExecutionRequest; +import com.google.cloud.workflows.executions.v1beta.ListExecutionsRequest; +import com.google.cloud.workflows.executions.v1beta.ListExecutionsResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Executions service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonExecutionsStub extends ExecutionsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listExecutionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.workflows.executions.v1beta.Executions/ListExecutions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*/locations/*/workflows/*}/executions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListExecutionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createExecutionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.workflows.executions.v1beta.Executions/CreateExecution") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*/locations/*/workflows/*}/executions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("execution", request.getExecution())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Execution.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getExecutionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.workflows.executions.v1beta.Executions/GetExecution") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/locations/*/workflows/*/executions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Execution.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + cancelExecutionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.workflows.executions.v1beta.Executions/CancelExecution") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/locations/*/workflows/*/executions/*}:cancel", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Execution.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listExecutionsCallable; + private final UnaryCallable + listExecutionsPagedCallable; + private final UnaryCallable createExecutionCallable; + private final UnaryCallable getExecutionCallable; + private final UnaryCallable cancelExecutionCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonExecutionsStub create(ExecutionsStubSettings settings) + throws IOException { + return new HttpJsonExecutionsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonExecutionsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonExecutionsStub( + ExecutionsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonExecutionsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonExecutionsStub( + ExecutionsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonExecutionsStub, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected HttpJsonExecutionsStub(ExecutionsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonExecutionsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonExecutionsStub, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected HttpJsonExecutionsStub( + ExecutionsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listExecutionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listExecutionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createExecutionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createExecutionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getExecutionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getExecutionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings cancelExecutionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(cancelExecutionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listExecutionsCallable = + callableFactory.createUnaryCallable( + listExecutionsTransportSettings, settings.listExecutionsSettings(), clientContext); + this.listExecutionsPagedCallable = + callableFactory.createPagedCallable( + listExecutionsTransportSettings, settings.listExecutionsSettings(), clientContext); + this.createExecutionCallable = + callableFactory.createUnaryCallable( + createExecutionTransportSettings, settings.createExecutionSettings(), clientContext); + this.getExecutionCallable = + callableFactory.createUnaryCallable( + getExecutionTransportSettings, settings.getExecutionSettings(), clientContext); + this.cancelExecutionCallable = + callableFactory.createUnaryCallable( + cancelExecutionTransportSettings, settings.cancelExecutionSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listExecutionsMethodDescriptor); + methodDescriptors.add(createExecutionMethodDescriptor); + methodDescriptors.add(getExecutionMethodDescriptor); + methodDescriptors.add(cancelExecutionMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listExecutionsCallable() { + return listExecutionsCallable; + } + + @Override + public UnaryCallable + listExecutionsPagedCallable() { + return listExecutionsPagedCallable; + } + + @Override + public UnaryCallable createExecutionCallable() { + return createExecutionCallable; + } + + @Override + public UnaryCallable getExecutionCallable() { + return getExecutionCallable; + } + + @Override + public UnaryCallable cancelExecutionCallable() { + return cancelExecutionCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-workflow-executions/src/test/java/com/google/cloud/workflows/executions/v1/ExecutionsClientHttpJsonTest.java b/google-cloud-workflow-executions/src/test/java/com/google/cloud/workflows/executions/v1/ExecutionsClientHttpJsonTest.java new file mode 100644 index 00000000..79a04544 --- /dev/null +++ b/google-cloud-workflow-executions/src/test/java/com/google/cloud/workflows/executions/v1/ExecutionsClientHttpJsonTest.java @@ -0,0 +1,491 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.workflows.executions.v1; + +import static com.google.cloud.workflows.executions.v1.ExecutionsClient.ListExecutionsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.workflows.executions.v1.stub.HttpJsonExecutionsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ExecutionsClientHttpJsonTest { + private static MockHttpService mockService; + private static ExecutionsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonExecutionsStub.getMethodDescriptors(), ExecutionsSettings.getDefaultEndpoint()); + ExecutionsSettings settings = + ExecutionsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ExecutionsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ExecutionsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listExecutionsTest() throws Exception { + Execution responsesElement = Execution.newBuilder().build(); + ListExecutionsResponse expectedResponse = + ListExecutionsResponse.newBuilder() + .setNextPageToken("") + .addAllExecutions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); + + ListExecutionsPagedResponse pagedListResponse = client.listExecutions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getExecutionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listExecutionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); + client.listExecutions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listExecutionsTest2() throws Exception { + Execution responsesElement = Execution.newBuilder().build(); + ListExecutionsResponse expectedResponse = + ListExecutionsResponse.newBuilder() + .setNextPageToken("") + .addAllExecutions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9319/locations/location-9319/workflows/workflow-9319"; + + ListExecutionsPagedResponse pagedListResponse = client.listExecutions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getExecutionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listExecutionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9319/locations/location-9319/workflows/workflow-9319"; + client.listExecutions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createExecutionTest() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); + Execution execution = Execution.newBuilder().build(); + + Execution actualResponse = client.createExecution(parent, execution); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createExecutionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); + Execution execution = Execution.newBuilder().build(); + client.createExecution(parent, execution); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createExecutionTest2() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9319/locations/location-9319/workflows/workflow-9319"; + Execution execution = Execution.newBuilder().build(); + + Execution actualResponse = client.createExecution(parent, execution); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createExecutionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9319/locations/location-9319/workflows/workflow-9319"; + Execution execution = Execution.newBuilder().build(); + client.createExecution(parent, execution); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getExecutionTest() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + ExecutionName name = ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]"); + + Execution actualResponse = client.getExecution(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getExecutionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ExecutionName name = ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]"); + client.getExecution(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getExecutionTest2() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7317/locations/location-7317/workflows/workflow-7317/executions/execution-7317"; + + Execution actualResponse = client.getExecution(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getExecutionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7317/locations/location-7317/workflows/workflow-7317/executions/execution-7317"; + client.getExecution(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cancelExecutionTest() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + ExecutionName name = ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]"); + + Execution actualResponse = client.cancelExecution(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void cancelExecutionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ExecutionName name = ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]"); + client.cancelExecution(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cancelExecutionTest2() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7317/locations/location-7317/workflows/workflow-7317/executions/execution-7317"; + + Execution actualResponse = client.cancelExecution(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void cancelExecutionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7317/locations/location-7317/workflows/workflow-7317/executions/execution-7317"; + client.cancelExecution(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-workflow-executions/src/test/java/com/google/cloud/workflows/executions/v1beta/ExecutionsClientHttpJsonTest.java b/google-cloud-workflow-executions/src/test/java/com/google/cloud/workflows/executions/v1beta/ExecutionsClientHttpJsonTest.java new file mode 100644 index 00000000..b9795412 --- /dev/null +++ b/google-cloud-workflow-executions/src/test/java/com/google/cloud/workflows/executions/v1beta/ExecutionsClientHttpJsonTest.java @@ -0,0 +1,491 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +package com.google.cloud.workflows.executions.v1beta; + +import static com.google.cloud.workflows.executions.v1beta.ExecutionsClient.ListExecutionsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.workflows.executions.v1beta.stub.HttpJsonExecutionsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ExecutionsClientHttpJsonTest { + private static MockHttpService mockService; + private static ExecutionsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonExecutionsStub.getMethodDescriptors(), ExecutionsSettings.getDefaultEndpoint()); + ExecutionsSettings settings = + ExecutionsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ExecutionsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ExecutionsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listExecutionsTest() throws Exception { + Execution responsesElement = Execution.newBuilder().build(); + ListExecutionsResponse expectedResponse = + ListExecutionsResponse.newBuilder() + .setNextPageToken("") + .addAllExecutions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); + + ListExecutionsPagedResponse pagedListResponse = client.listExecutions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getExecutionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listExecutionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); + client.listExecutions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listExecutionsTest2() throws Exception { + Execution responsesElement = Execution.newBuilder().build(); + ListExecutionsResponse expectedResponse = + ListExecutionsResponse.newBuilder() + .setNextPageToken("") + .addAllExecutions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9319/locations/location-9319/workflows/workflow-9319"; + + ListExecutionsPagedResponse pagedListResponse = client.listExecutions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getExecutionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listExecutionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9319/locations/location-9319/workflows/workflow-9319"; + client.listExecutions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createExecutionTest() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); + Execution execution = Execution.newBuilder().build(); + + Execution actualResponse = client.createExecution(parent, execution); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createExecutionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + WorkflowName parent = WorkflowName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]"); + Execution execution = Execution.newBuilder().build(); + client.createExecution(parent, execution); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createExecutionTest2() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9319/locations/location-9319/workflows/workflow-9319"; + Execution execution = Execution.newBuilder().build(); + + Execution actualResponse = client.createExecution(parent, execution); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createExecutionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9319/locations/location-9319/workflows/workflow-9319"; + Execution execution = Execution.newBuilder().build(); + client.createExecution(parent, execution); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getExecutionTest() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + ExecutionName name = ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]"); + + Execution actualResponse = client.getExecution(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getExecutionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ExecutionName name = ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]"); + client.getExecution(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getExecutionTest2() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7317/locations/location-7317/workflows/workflow-7317/executions/execution-7317"; + + Execution actualResponse = client.getExecution(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getExecutionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7317/locations/location-7317/workflows/workflow-7317/executions/execution-7317"; + client.getExecution(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cancelExecutionTest() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + ExecutionName name = ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]"); + + Execution actualResponse = client.cancelExecution(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void cancelExecutionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ExecutionName name = ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]"); + client.cancelExecution(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cancelExecutionTest2() throws Exception { + Execution expectedResponse = + Execution.newBuilder() + .setName( + ExecutionName.of("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]").toString()) + .setStartTime(Timestamp.newBuilder().build()) + .setEndTime(Timestamp.newBuilder().build()) + .setArgument("argument-1589682499") + .setResult("result-934426595") + .setError(Execution.Error.newBuilder().build()) + .setWorkflowRevisionId("workflowRevisionId-1575712907") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-7317/locations/location-7317/workflows/workflow-7317/executions/execution-7317"; + + Execution actualResponse = client.cancelExecution(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void cancelExecutionExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7317/locations/location-7317/workflows/workflow-7317/executions/execution-7317"; + client.cancelExecution(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} From d4785f7c4c7df6971b9e72695f95f8aa3c2e8330 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 29 Jun 2022 14:40:11 +0000 Subject: [PATCH 3/6] feat: java template no longer require clirr (#1469) (#322) Source-Link: https://github.com/googleapis/synthtool/commit/0238f3dca6202855d36c3cb9fe9bf4c4e3fc886e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7410586c94c608ea884879fa4083754cc28601909484c5987f4ea784da54b881 --- .github/.OwlBot.lock.yaml | 4 ++-- README.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index f0625e4d..aa4f776f 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:1ec28a46062b19135b11178ceee60231e5f5a92dab454e23ae0aab72cd875906 -# created: 2022-06-27T15:01:06.405564326Z + digest: sha256:7410586c94c608ea884879fa4083754cc28601909484c5987f4ea784da54b881 +# created: 2022-06-28T19:40:16.719636226Z diff --git a/README.md b/README.md index 717b775f..022a23d1 100644 --- a/README.md +++ b/README.md @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file: com.google.cloud google-cloud-workflow-executions - 2.2.0 + 2.2.1 ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-workflow-executions:2.2.0' +implementation 'com.google.cloud:google-cloud-workflow-executions:2.2.1' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-workflow-executions" % "2.2.0" +libraryDependencies += "com.google.cloud" % "google-cloud-workflow-executions" % "2.2.1" ``` ## Authentication From 264971eddc3c6983110774c27844110b254b5c49 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 02:20:19 +0000 Subject: [PATCH 4/6] chore: Disable CLIRR checks on releas (#1474) (#325) Source-Link: https://github.com/googleapis/synthtool/commit/7a220e27993a25ab3cda26510d5619d97b6952a9 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 --- .github/.OwlBot.lock.yaml | 4 ++-- .kokoro/release/stage.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index aa4f776f..a454a61e 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:7410586c94c608ea884879fa4083754cc28601909484c5987f4ea784da54b881 -# created: 2022-06-28T19:40:16.719636226Z + digest: sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 +# created: 2022-06-29T23:17:33.110417661Z diff --git a/.kokoro/release/stage.sh b/.kokoro/release/stage.sh index 77dc4e8f..1dba8de1 100755 --- a/.kokoro/release/stage.sh +++ b/.kokoro/release/stage.sh @@ -32,6 +32,7 @@ retry_with_backoff 3 10 \ mvn clean deploy -B \ --settings ${MAVEN_SETTINGS_FILE} \ -DskipTests=true \ + -Dclirr.skip=true \ -DperformRelease=true \ -Dgpg.executable=gpg \ -Dgpg.passphrase=${GPG_PASSPHRASE} \ @@ -42,4 +43,4 @@ then mvn nexus-staging:release -B \ -DperformRelease=true \ --settings=settings.xml -fi \ No newline at end of file +fi From 51877171666cadb170691c55a5f56553d3756e0a Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Fri, 1 Jul 2022 10:34:15 -0400 Subject: [PATCH 5/6] ci: removing clirr from required checks (#321) Making CLIRR not required. The version bumps are now controlled by the Release Please and OwlBot. The CL authors create appropriate change description to control major version bumps. --- .github/sync-repo-settings.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 6f09d695..dd5626f3 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -11,7 +11,6 @@ branchProtectionRules: - dependencies (8) - dependencies (11) - lint - - clirr - units (8) - units (11) - 'Kokoro - Test: Integration' @@ -26,7 +25,6 @@ branchProtectionRules: - dependencies (8) - dependencies (11) - lint - - clirr - units (7) - units (8) - units (11) From 76e567ed812f2eb62972d88b0b173a985fb88f11 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Fri, 1 Jul 2022 17:30:33 +0000 Subject: [PATCH 6/6] chore(main): release 2.3.0 (#323) :robot: I have created a release *beep* *boop* --- ## [2.3.0](https://github.com/googleapis/java-workflow-executions/compare/v2.2.1...v2.3.0) (2022-07-01) ### Features * Enable REST transport for most of Java and Go clients ([#311](https://github.com/googleapis/java-workflow-executions/issues/311)) ([f42b2d0](https://github.com/googleapis/java-workflow-executions/commit/f42b2d0ef1f55cc72e355199a85d981147f829e0)) * java template no longer require clirr ([#1469](https://github.com/googleapis/java-workflow-executions/issues/1469)) ([#322](https://github.com/googleapis/java-workflow-executions/issues/322)) ([d4785f7](https://github.com/googleapis/java-workflow-executions/commit/d4785f7c4c7df6971b9e72695f95f8aa3c2e8330)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 8 ++++++++ google-cloud-workflow-executions-bom/pom.xml | 12 ++++++------ google-cloud-workflow-executions/pom.xml | 4 ++-- grpc-google-cloud-workflow-executions-v1/pom.xml | 4 ++-- grpc-google-cloud-workflow-executions-v1beta/pom.xml | 4 ++-- pom.xml | 12 ++++++------ proto-google-cloud-workflow-executions-v1/pom.xml | 4 ++-- .../pom.xml | 4 ++-- samples/snapshot/pom.xml | 2 +- versions.txt | 10 +++++----- 10 files changed, 36 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e6a995c..97d391c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [2.3.0](https://github.com/googleapis/java-workflow-executions/compare/v2.2.1...v2.3.0) (2022-07-01) + + +### Features + +* Enable REST transport for most of Java and Go clients ([#311](https://github.com/googleapis/java-workflow-executions/issues/311)) ([f42b2d0](https://github.com/googleapis/java-workflow-executions/commit/f42b2d0ef1f55cc72e355199a85d981147f829e0)) +* java template no longer require clirr ([#1469](https://github.com/googleapis/java-workflow-executions/issues/1469)) ([#322](https://github.com/googleapis/java-workflow-executions/issues/322)) ([d4785f7](https://github.com/googleapis/java-workflow-executions/commit/d4785f7c4c7df6971b9e72695f95f8aa3c2e8330)) + ## [2.2.1](https://github.com/googleapis/java-workflow-executions/compare/v2.2.0...v2.2.1) (2022-06-27) diff --git a/google-cloud-workflow-executions-bom/pom.xml b/google-cloud-workflow-executions-bom/pom.xml index 5329ce28..4f03bd86 100644 --- a/google-cloud-workflow-executions-bom/pom.xml +++ b/google-cloud-workflow-executions-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-workflow-executions-bom - 2.2.2-SNAPSHOT + 2.3.0 pom com.google.cloud @@ -56,27 +56,27 @@ com.google.cloud google-cloud-workflow-executions - 2.2.2-SNAPSHOT + 2.3.0 com.google.api.grpc grpc-google-cloud-workflow-executions-v1beta - 0.6.2-SNAPSHOT + 0.7.0 com.google.api.grpc grpc-google-cloud-workflow-executions-v1 - 2.2.2-SNAPSHOT + 2.3.0 com.google.api.grpc proto-google-cloud-workflow-executions-v1beta - 0.6.2-SNAPSHOT + 0.7.0 com.google.api.grpc proto-google-cloud-workflow-executions-v1 - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/google-cloud-workflow-executions/pom.xml b/google-cloud-workflow-executions/pom.xml index 787ba06f..b80943b2 100644 --- a/google-cloud-workflow-executions/pom.xml +++ b/google-cloud-workflow-executions/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-workflow-executions - 2.2.2-SNAPSHOT + 2.3.0 jar Google Cloud Workflow Executions https://github.com/googleapis/java-workflow-executions @@ -11,7 +11,7 @@ com.google.cloud google-cloud-workflow-executions-parent - 2.2.2-SNAPSHOT + 2.3.0 google-cloud-workflow-executions diff --git a/grpc-google-cloud-workflow-executions-v1/pom.xml b/grpc-google-cloud-workflow-executions-v1/pom.xml index 86bc0767..72a3c00b 100644 --- a/grpc-google-cloud-workflow-executions-v1/pom.xml +++ b/grpc-google-cloud-workflow-executions-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-workflow-executions-v1 - 2.2.2-SNAPSHOT + 2.3.0 grpc-google-cloud-workflow-executions-v1 GRPC library for google-cloud-workflow-executions com.google.cloud google-cloud-workflow-executions-parent - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/grpc-google-cloud-workflow-executions-v1beta/pom.xml b/grpc-google-cloud-workflow-executions-v1beta/pom.xml index 0d0f49f9..41e98621 100644 --- a/grpc-google-cloud-workflow-executions-v1beta/pom.xml +++ b/grpc-google-cloud-workflow-executions-v1beta/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-workflow-executions-v1beta - 0.6.2-SNAPSHOT + 0.7.0 grpc-google-cloud-workflow-executions-v1beta GRPC library for google-cloud-workflow-executions com.google.cloud google-cloud-workflow-executions-parent - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/pom.xml b/pom.xml index 5c7276e8..5bdda2c2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-workflow-executions-parent pom - 2.2.2-SNAPSHOT + 2.3.0 Google Cloud Workflow Executions Parent https://github.com/googleapis/java- @@ -61,27 +61,27 @@ com.google.cloud google-cloud-workflow-executions - 2.2.2-SNAPSHOT + 2.3.0 com.google.api.grpc proto-google-cloud-workflow-executions-v1 - 2.2.2-SNAPSHOT + 2.3.0 com.google.api.grpc grpc-google-cloud-workflow-executions-v1 - 2.2.2-SNAPSHOT + 2.3.0 com.google.api.grpc proto-google-cloud-workflow-executions-v1beta - 0.6.2-SNAPSHOT + 0.7.0 com.google.api.grpc grpc-google-cloud-workflow-executions-v1beta - 0.6.2-SNAPSHOT + 0.7.0 diff --git a/proto-google-cloud-workflow-executions-v1/pom.xml b/proto-google-cloud-workflow-executions-v1/pom.xml index e7cc31fe..80359ab2 100644 --- a/proto-google-cloud-workflow-executions-v1/pom.xml +++ b/proto-google-cloud-workflow-executions-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-workflow-executions-v1 - 2.2.2-SNAPSHOT + 2.3.0 proto-google-cloud-workflow-executions-v1 Proto library for google-cloud-workflow-executions com.google.cloud google-cloud-workflow-executions-parent - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/proto-google-cloud-workflow-executions-v1beta/pom.xml b/proto-google-cloud-workflow-executions-v1beta/pom.xml index 983c1e9e..c508f8f9 100644 --- a/proto-google-cloud-workflow-executions-v1beta/pom.xml +++ b/proto-google-cloud-workflow-executions-v1beta/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-workflow-executions-v1beta - 0.6.2-SNAPSHOT + 0.7.0 proto-google-cloud-workflow-executions-v1beta Proto library for google-cloud-workflow-executions com.google.cloud google-cloud-workflow-executions-parent - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 97829196..33b125b0 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-workflow-executions - 2.2.2-SNAPSHOT + 2.3.0 diff --git a/versions.txt b/versions.txt index 13378f39..e23978ab 100644 --- a/versions.txt +++ b/versions.txt @@ -1,8 +1,8 @@ # Format: # module:released-version:current-version -google-cloud-workflow-executions:2.2.1:2.2.2-SNAPSHOT -grpc-google-cloud-workflow-executions-v1beta:0.6.1:0.6.2-SNAPSHOT -grpc-google-cloud-workflow-executions-v1:2.2.1:2.2.2-SNAPSHOT -proto-google-cloud-workflow-executions-v1beta:0.6.1:0.6.2-SNAPSHOT -proto-google-cloud-workflow-executions-v1:2.2.1:2.2.2-SNAPSHOT +google-cloud-workflow-executions:2.3.0:2.3.0 +grpc-google-cloud-workflow-executions-v1beta:0.7.0:0.7.0 +grpc-google-cloud-workflow-executions-v1:2.3.0:2.3.0 +proto-google-cloud-workflow-executions-v1beta:0.7.0:0.7.0 +proto-google-cloud-workflow-executions-v1:2.3.0:2.3.0