diff --git a/.github/readme/synth.metadata/synth.metadata b/.github/readme/synth.metadata/synth.metadata index cf1a9f06..16f1f7e4 100644 --- a/.github/readme/synth.metadata/synth.metadata +++ b/.github/readme/synth.metadata/synth.metadata @@ -4,14 +4,14 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-functions.git", - "sha": "c7a188a5a6c1c897120156219542a7618e559e6c" + "sha": "80170a344a82b50fa7c256b54b8273d49705d73d" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "7fcc405a579d5d53a726ff3da1b7c8c08f0f2d58" + "sha": "996775eca5fd934edac3c2ae34b80ff0395b1717" } } ] diff --git a/.kokoro/release/publish_javadoc.sh b/.kokoro/release/publish_javadoc.sh index e4749a64..3789eac4 100755 --- a/.kokoro/release/publish_javadoc.sh +++ b/.kokoro/release/publish_javadoc.sh @@ -38,8 +38,8 @@ python3 -m pip install gcp-docuploader # compile all packages mvn clean install -B -q -DskipTests=true -NAME=google-cloud-functions -VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3) +export NAME=google-cloud-functions +export VERSION=$(grep ${NAME}: versions.txt | cut -d: -f3) # build the docs mvn site -B -q @@ -59,7 +59,8 @@ python3 -m docuploader upload . \ popd -# V2 +# V2 due to problems w/ the released javadoc plugin doclava, Java 8 is required. Beware of accidental updates. + mvn clean site -B -q -Ddevsite.template="${KOKORO_GFILE_DIR}/java/" pushd target/devsite/reference diff --git a/CHANGELOG.md b/CHANGELOG.md index a9cd9802..4934e70c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### [1.0.4](https://www.github.com/googleapis/java-functions/compare/v1.0.3...v1.0.4) (2020-12-14) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.16.1 ([#104](https://www.github.com/googleapis/java-functions/issues/104)) ([b2aeafe](https://www.github.com/googleapis/java-functions/commit/b2aeafe9c9fb6fa6ad688fd2fe6b43b0f52c54aa)) + ### [1.0.3](https://www.github.com/googleapis/java-functions/compare/v1.0.2...v1.0.3) (2020-12-02) diff --git a/README.md b/README.md index ee9b85e0..cc5d21c0 100644 --- a/README.md +++ b/README.md @@ -17,18 +17,18 @@ If you are using Maven, add this to your pom.xml file: com.google.cloud google-cloud-functions - 1.0.2 + 1.0.3 ``` If you are using Gradle, add this to your dependencies ```Groovy -compile 'com.google.cloud:google-cloud-functions:1.0.2' +compile 'com.google.cloud:google-cloud-functions:1.0.3' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-functions" % "1.0.2" +libraryDependencies += "com.google.cloud" % "google-cloud-functions" % "1.0.3" ``` ## Authentication @@ -106,6 +106,8 @@ Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3] Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4] Java 11 | [![Kokoro CI][kokoro-badge-image-5]][kokoro-badge-link-5] +Java is a registered trademark of Oracle and/or its affiliates. + [product-docs]: https://cloud.google.com/functions [javadocs]: https://googleapis.dev/java/google-cloud-functions/latest/index.html [kokoro-badge-image-1]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-functions/java7.svg diff --git a/google-cloud-functions-bom/pom.xml b/google-cloud-functions-bom/pom.xml index 12c30763..35892d66 100644 --- a/google-cloud-functions-bom/pom.xml +++ b/google-cloud-functions-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-functions-bom - 1.0.3 + 1.0.4 pom com.google.cloud @@ -68,17 +68,17 @@ com.google.cloud google-cloud-functions - 1.0.3 + 1.0.4 com.google.api.grpc proto-google-cloud-functions-v1 - 1.0.3 + 1.0.4 com.google.api.grpc grpc-google-cloud-functions-v1 - 1.0.3 + 1.0.4 diff --git a/google-cloud-functions/pom.xml b/google-cloud-functions/pom.xml index 7b348501..5e8505d7 100644 --- a/google-cloud-functions/pom.xml +++ b/google-cloud-functions/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-functions - 1.0.3 + 1.0.4 jar Google Cloud Functions https://github.com/googleapis/java-functions @@ -11,7 +11,7 @@ com.google.cloud google-cloud-functions-parent - 1.0.3 + 1.0.4 google-cloud-functions diff --git a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceClient.java b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceClient.java index a719edc4..67716b05 100644 --- a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceClient.java +++ b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceClient.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.functions.v1; import com.google.api.core.ApiFunction; @@ -43,23 +44,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: A service that application uses to manipulate triggers and functions. * *

This class provides the ability to make remote calls to the backing service through method * calls that map to API methods. Sample code to get started: * - *

- * 
- * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
- *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
- *   CloudFunction response = cloudFunctionsServiceClient.getFunction(name);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the cloudFunctionsServiceClient object to clean up + *

Note: close() needs to be called on the CloudFunctionsServiceClient object to clean up * resources such as threads. In the example above, try-with-resources is used, which automatically * calls close(). * @@ -88,30 +80,28 @@ * *

To customize credentials: * - *

- * 
+ * 
{@code
  * CloudFunctionsServiceSettings cloudFunctionsServiceSettings =
  *     CloudFunctionsServiceSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * CloudFunctionsServiceClient cloudFunctionsServiceClient =
  *     CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
- * 
- * 
+ * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * CloudFunctionsServiceSettings cloudFunctionsServiceSettings =
  *     CloudFunctionsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
  * CloudFunctionsServiceClient cloudFunctionsServiceClient =
  *     CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
- * 
- * 
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator") public class CloudFunctionsServiceClient implements BackgroundResource { private final CloudFunctionsServiceSettings settings; private final CloudFunctionsServiceStub stub; @@ -133,7 +123,7 @@ public static final CloudFunctionsServiceClient create(CloudFunctionsServiceSett /** * Constructs an instance of CloudFunctionsServiceClient, using the given stub for making calls. - * This is for advanced usage - prefer to use CloudFunctionsServiceSettings}. + * This is for advanced usage - prefer using create(CloudFunctionsServiceSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final CloudFunctionsServiceClient create(CloudFunctionsServiceStub stub) { @@ -171,27 +161,14 @@ public CloudFunctionsServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationsClient getOperationsClient() { return operationsClient; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a list of functions that belong to the requested project. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   ListFunctionsRequest request = ListFunctionsRequest.newBuilder().build();
-   *   for (CloudFunction element : cloudFunctionsServiceClient.listFunctions(request).iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -199,69 +176,31 @@ public final ListFunctionsPagedResponse listFunctions(ListFunctionsRequest reque return listFunctionsPagedCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a list of functions that belong to the requested project. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   ListFunctionsRequest request = ListFunctionsRequest.newBuilder().build();
-   *   ApiFuture<ListFunctionsPagedResponse> future = cloudFunctionsServiceClient.listFunctionsPagedCallable().futureCall(request);
-   *   // Do something
-   *   for (CloudFunction element : future.get().iterateAll()) {
-   *     // doThingsWith(element);
-   *   }
-   * }
-   * 
*/ public final UnaryCallable listFunctionsPagedCallable() { return stub.listFunctionsPagedCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a list of functions that belong to the requested project. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   ListFunctionsRequest request = ListFunctionsRequest.newBuilder().build();
-   *   while (true) {
-   *     ListFunctionsResponse response = cloudFunctionsServiceClient.listFunctionsCallable().call(request);
-   *     for (CloudFunction element : response.getFunctionsList()) {
-   *       // doThingsWith(element);
-   *     }
-   *     String nextPageToken = response.getNextPageToken();
-   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
-   *       request = request.toBuilder().setPageToken(nextPageToken).build();
-   *     } else {
-   *       break;
-   *     }
-   *   }
-   * }
-   * 
*/ public final UnaryCallable listFunctionsCallable() { return stub.listFunctionsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a function with the given name from the requested project. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   CloudFunction response = cloudFunctionsServiceClient.getFunction(name);
-   * }
-   * 
- * * @param name Required. The name of the function which details should be obtained. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -271,19 +210,10 @@ public final CloudFunction getFunction(CloudFunctionName name) { return getFunction(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a function with the given name from the requested project. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   CloudFunction response = cloudFunctionsServiceClient.getFunction(name.toString());
-   * }
-   * 
- * * @param name Required. The name of the function which details should be obtained. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -292,22 +222,10 @@ public final CloudFunction getFunction(String name) { return getFunction(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a function with the given name from the requested project. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   GetFunctionRequest request = GetFunctionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   CloudFunction response = cloudFunctionsServiceClient.getFunction(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -315,50 +233,26 @@ public final CloudFunction getFunction(GetFunctionRequest request) { return getFunctionCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a function with the given name from the requested project. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   GetFunctionRequest request = GetFunctionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<CloudFunction> future = cloudFunctionsServiceClient.getFunctionCallable().futureCall(request);
-   *   // Do something
-   *   CloudFunction response = future.get();
-   * }
-   * 
*/ public final UnaryCallable getFunctionCallable() { return stub.getFunctionCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new function. If a function with the given name already exists in the specified * project, the long running operation will return `ALREADY_EXISTS` error. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   LocationName location = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   CloudFunction function = CloudFunction.newBuilder().build();
-   *   CloudFunction response = cloudFunctionsServiceClient.createFunctionAsync(location, function).get();
-   * }
-   * 
- * * @param location Required. The project and location in which the function should be created, * specified in the format `projects/*/locations/*` * @param function Required. Function to be created. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture createFunctionAsync( LocationName location, CloudFunction function) { CreateFunctionRequest request = @@ -369,28 +263,16 @@ public final OperationFuture createFunctionA return createFunctionAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new function. If a function with the given name already exists in the specified * project, the long running operation will return `ALREADY_EXISTS` error. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   LocationName location = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   CloudFunction function = CloudFunction.newBuilder().build();
-   *   CloudFunction response = cloudFunctionsServiceClient.createFunctionAsync(location.toString(), function).get();
-   * }
-   * 
- * * @param location Required. The project and location in which the function should be created, * specified in the format `projects/*/locations/*` * @param function Required. Function to be created. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture createFunctionAsync( String location, CloudFunction function) { CreateFunctionRequest request = @@ -398,105 +280,49 @@ public final OperationFuture createFunctionA return createFunctionAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new function. If a function with the given name already exists in the specified * project, the long running operation will return `ALREADY_EXISTS` error. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   LocationName location = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   CloudFunction function = CloudFunction.newBuilder().build();
-   *   CreateFunctionRequest request = CreateFunctionRequest.newBuilder()
-   *     .setLocation(location.toString())
-   *     .setFunction(function)
-   *     .build();
-   *   CloudFunction response = cloudFunctionsServiceClient.createFunctionAsync(request).get();
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture createFunctionAsync( CreateFunctionRequest request) { return createFunctionOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new function. If a function with the given name already exists in the specified * project, the long running operation will return `ALREADY_EXISTS` error. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   LocationName location = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   CloudFunction function = CloudFunction.newBuilder().build();
-   *   CreateFunctionRequest request = CreateFunctionRequest.newBuilder()
-   *     .setLocation(location.toString())
-   *     .setFunction(function)
-   *     .build();
-   *   OperationFuture<CloudFunction, OperationMetadataV1> future = cloudFunctionsServiceClient.createFunctionOperationCallable().futureCall(request);
-   *   // Do something
-   *   CloudFunction response = future.get();
-   * }
-   * 
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable createFunctionOperationCallable() { return stub.createFunctionOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new function. If a function with the given name already exists in the specified * project, the long running operation will return `ALREADY_EXISTS` error. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   LocationName location = LocationName.of("[PROJECT]", "[LOCATION]");
-   *   CloudFunction function = CloudFunction.newBuilder().build();
-   *   CreateFunctionRequest request = CreateFunctionRequest.newBuilder()
-   *     .setLocation(location.toString())
-   *     .setFunction(function)
-   *     .build();
-   *   ApiFuture<Operation> future = cloudFunctionsServiceClient.createFunctionCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
*/ public final UnaryCallable createFunctionCallable() { return stub.createFunctionCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates existing function. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunction function = CloudFunction.newBuilder().build();
-   *   CloudFunction response = cloudFunctionsServiceClient.updateFunctionAsync(function).get();
-   * }
-   * 
- * * @param function Required. New version of the function. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture updateFunctionAsync( CloudFunction function) { UpdateFunctionRequest request = @@ -504,97 +330,47 @@ public final OperationFuture updateFunctionA return updateFunctionAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates existing function. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunction function = CloudFunction.newBuilder().build();
-   *   UpdateFunctionRequest request = UpdateFunctionRequest.newBuilder()
-   *     .setFunction(function)
-   *     .build();
-   *   CloudFunction response = cloudFunctionsServiceClient.updateFunctionAsync(request).get();
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture updateFunctionAsync( UpdateFunctionRequest request) { return updateFunctionOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates existing function. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunction function = CloudFunction.newBuilder().build();
-   *   UpdateFunctionRequest request = UpdateFunctionRequest.newBuilder()
-   *     .setFunction(function)
-   *     .build();
-   *   OperationFuture<CloudFunction, OperationMetadataV1> future = cloudFunctionsServiceClient.updateFunctionOperationCallable().futureCall(request);
-   *   // Do something
-   *   CloudFunction response = future.get();
-   * }
-   * 
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable updateFunctionOperationCallable() { return stub.updateFunctionOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Updates existing function. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunction function = CloudFunction.newBuilder().build();
-   *   UpdateFunctionRequest request = UpdateFunctionRequest.newBuilder()
-   *     .setFunction(function)
-   *     .build();
-   *   ApiFuture<Operation> future = cloudFunctionsServiceClient.updateFunctionCallable().futureCall(request);
-   *   // Do something
-   *   Operation response = future.get();
-   * }
-   * 
*/ public final UnaryCallable updateFunctionCallable() { return stub.updateFunctionCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a function with the given name from the specified project. If the given function is * used by some trigger, the trigger will be updated to remove this function. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   cloudFunctionsServiceClient.deleteFunctionAsync(name).get();
-   * }
-   * 
- * * @param name Required. The name of the function which should be deleted. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture deleteFunctionAsync( CloudFunctionName name) { DeleteFunctionRequest request = @@ -602,121 +378,61 @@ public final OperationFuture deleteFunctionAsync( return deleteFunctionAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a function with the given name from the specified project. If the given function is * used by some trigger, the trigger will be updated to remove this function. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   cloudFunctionsServiceClient.deleteFunctionAsync(name.toString()).get();
-   * }
-   * 
- * * @param name Required. The name of the function which should be deleted. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture deleteFunctionAsync(String name) { DeleteFunctionRequest request = DeleteFunctionRequest.newBuilder().setName(name).build(); return deleteFunctionAsync(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a function with the given name from the specified project. If the given function is * used by some trigger, the trigger will be updated to remove this function. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   DeleteFunctionRequest request = DeleteFunctionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   cloudFunctionsServiceClient.deleteFunctionAsync(request).get();
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture deleteFunctionAsync( DeleteFunctionRequest request) { return deleteFunctionOperationCallable().futureCall(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a function with the given name from the specified project. If the given function is * used by some trigger, the trigger will be updated to remove this function. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   DeleteFunctionRequest request = DeleteFunctionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   OperationFuture<Empty, OperationMetadataV1> future = cloudFunctionsServiceClient.deleteFunctionOperationCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
*/ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable deleteFunctionOperationCallable() { return stub.deleteFunctionOperationCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Deletes a function with the given name from the specified project. If the given function is * used by some trigger, the trigger will be updated to remove this function. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   DeleteFunctionRequest request = DeleteFunctionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .build();
-   *   ApiFuture<Operation> future = cloudFunctionsServiceClient.deleteFunctionCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
*/ public final UnaryCallable deleteFunctionCallable() { return stub.deleteFunctionCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very * limited traffic is allowed. For more information on the actual limits, refer to [Rate * Limits](https://cloud.google.com/functions/quotas#rate_limits). * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   String data = "";
-   *   CallFunctionResponse response = cloudFunctionsServiceClient.callFunction(name, data);
-   * }
-   * 
- * * @param name Required. The name of the function to be called. * @param data Required. Input to be passed to the function. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -730,22 +446,12 @@ public final CallFunctionResponse callFunction(CloudFunctionName name, String da return callFunction(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very * limited traffic is allowed. For more information on the actual limits, refer to [Rate * Limits](https://cloud.google.com/functions/quotas#rate_limits). * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   String data = "";
-   *   CallFunctionResponse response = cloudFunctionsServiceClient.callFunction(name.toString(), data);
-   * }
-   * 
- * * @param name Required. The name of the function to be called. * @param data Required. Input to be passed to the function. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -756,26 +462,12 @@ public final CallFunctionResponse callFunction(String name, String data) { return callFunction(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very * limited traffic is allowed. For more information on the actual limits, refer to [Rate * Limits](https://cloud.google.com/functions/quotas#rate_limits). * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   String data = "";
-   *   CallFunctionRequest request = CallFunctionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setData(data)
-   *     .build();
-   *   CallFunctionResponse response = cloudFunctionsServiceClient.callFunction(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -783,33 +475,19 @@ public final CallFunctionResponse callFunction(CallFunctionRequest request) { return callFunctionCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very * limited traffic is allowed. For more information on the actual limits, refer to [Rate * Limits](https://cloud.google.com/functions/quotas#rate_limits). * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   String data = "";
-   *   CallFunctionRequest request = CallFunctionRequest.newBuilder()
-   *     .setName(name.toString())
-   *     .setData(data)
-   *     .build();
-   *   ApiFuture<CallFunctionResponse> future = cloudFunctionsServiceClient.callFunctionCallable().futureCall(request);
-   *   // Do something
-   *   CallFunctionResponse response = future.get();
-   * }
-   * 
*/ public final UnaryCallable callFunctionCallable() { return stub.callFunctionCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a signed URL for uploading a function source code. For more information about the * signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls. Once @@ -818,28 +496,27 @@ public final UnaryCallable callFuncti * *

When uploading source code to the generated signed URL, please follow these restrictions: * - *

* Source file type should be a zip file. * Source file size should not exceed 100MB - * limit. * No credentials should be attached - the signed URLs provide access to the target - * bucket using internal service identity; if credentials were attached, the identity from the - * credentials would be used, but that identity does not have permissions to upload files to the - * URL. + *

    + *
  • Source file type should be a zip file. + *
  • Source file size should not exceed 100MB limit. + *
  • No credentials should be attached - the signed URLs provide access to the target bucket + * using internal service identity; if credentials were attached, the identity from the + * credentials would be used, but that identity does not have permissions to upload files to + * the URL. + *
* *

When making a HTTP PUT request, these two headers need to be specified: * - *

* `content-type: application/zip` * `x-goog-content-length-range: 0,104857600` + *

    + *
  • `content-type: application/zip` + *
  • `x-goog-content-length-range: 0,104857600` + *
* *

And this header SHOULD NOT be specified: * - *

* `Authorization: Bearer YOUR_TOKEN` - * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   GenerateUploadUrlRequest request = GenerateUploadUrlRequest.newBuilder().build();
-   *   GenerateUploadUrlResponse response = cloudFunctionsServiceClient.generateUploadUrl(request);
-   * }
-   * 
+ *
    + *
  • `Authorization: Bearer YOUR_TOKEN` + *
* * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -848,7 +525,7 @@ public final GenerateUploadUrlResponse generateUploadUrl(GenerateUploadUrlReques return generateUploadUrlCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a signed URL for uploading a function source code. For more information about the * signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls. Once @@ -857,51 +534,41 @@ public final GenerateUploadUrlResponse generateUploadUrl(GenerateUploadUrlReques * *

When uploading source code to the generated signed URL, please follow these restrictions: * - *

* Source file type should be a zip file. * Source file size should not exceed 100MB - * limit. * No credentials should be attached - the signed URLs provide access to the target - * bucket using internal service identity; if credentials were attached, the identity from the - * credentials would be used, but that identity does not have permissions to upload files to the - * URL. + *

    + *
  • Source file type should be a zip file. + *
  • Source file size should not exceed 100MB limit. + *
  • No credentials should be attached - the signed URLs provide access to the target bucket + * using internal service identity; if credentials were attached, the identity from the + * credentials would be used, but that identity does not have permissions to upload files to + * the URL. + *
* *

When making a HTTP PUT request, these two headers need to be specified: * - *

* `content-type: application/zip` * `x-goog-content-length-range: 0,104857600` + *

    + *
  • `content-type: application/zip` + *
  • `x-goog-content-length-range: 0,104857600` + *
* *

And this header SHOULD NOT be specified: * - *

* `Authorization: Bearer YOUR_TOKEN` + *

    + *
  • `Authorization: Bearer YOUR_TOKEN` + *
* *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   GenerateUploadUrlRequest request = GenerateUploadUrlRequest.newBuilder().build();
-   *   ApiFuture<GenerateUploadUrlResponse> future = cloudFunctionsServiceClient.generateUploadUrlCallable().futureCall(request);
-   *   // Do something
-   *   GenerateUploadUrlResponse response = future.get();
-   * }
-   * 
*/ public final UnaryCallable generateUploadUrlCallable() { return stub.generateUploadUrlCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a signed URL for downloading deployed function source code. The URL is only valid for a * limited period and should be used within minutes after generation. For more information about * the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   GenerateDownloadUrlRequest request = GenerateDownloadUrlRequest.newBuilder().build();
-   *   GenerateDownloadUrlResponse response = cloudFunctionsServiceClient.generateDownloadUrl(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -909,46 +576,23 @@ public final GenerateDownloadUrlResponse generateDownloadUrl(GenerateDownloadUrl return generateDownloadUrlCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns a signed URL for downloading deployed function source code. The URL is only valid for a * limited period and should be used within minutes after generation. For more information about * the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   GenerateDownloadUrlRequest request = GenerateDownloadUrlRequest.newBuilder().build();
-   *   ApiFuture<GenerateDownloadUrlResponse> future = cloudFunctionsServiceClient.generateDownloadUrlCallable().futureCall(request);
-   *   // Do something
-   *   GenerateDownloadUrlResponse response = future.get();
-   * }
-   * 
*/ public final UnaryCallable generateDownloadUrlCallable() { return stub.generateDownloadUrlCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Sets the IAM access control policy on the specified function. Replaces any existing policy. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .setPolicy(policy)
-   *     .build();
-   *   Policy response = cloudFunctionsServiceClient.setIamPolicy(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -956,47 +600,21 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { return setIamPolicyCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Sets the IAM access control policy on the specified function. Replaces any existing policy. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .setPolicy(policy)
-   *     .build();
-   *   ApiFuture<Policy> future = cloudFunctionsServiceClient.setIamPolicyCallable().futureCall(request);
-   *   // Do something
-   *   Policy response = future.get();
-   * }
-   * 
*/ public final UnaryCallable setIamPolicyCallable() { return stub.setIamPolicyCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets the IAM access control policy for a function. Returns an empty policy if the function * exists and does not have a policy set. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .build();
-   *   Policy response = cloudFunctionsServiceClient.getIamPolicy(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1004,48 +622,22 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { return getIamPolicyCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets the IAM access control policy for a function. Returns an empty policy if the function * exists and does not have a policy set. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .build();
-   *   ApiFuture<Policy> future = cloudFunctionsServiceClient.getIamPolicyCallable().futureCall(request);
-   *   // Do something
-   *   Policy response = future.get();
-   * }
-   * 
*/ public final UnaryCallable getIamPolicyCallable() { return stub.getIamPolicyCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Tests the specified permissions against the IAM access control policy for a function. If the * function does not exist, this will return an empty set of permissions, not a NOT_FOUND error. * - *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .addAllPermissions(permissions)
-   *     .build();
-   *   TestIamPermissionsResponse response = cloudFunctionsServiceClient.testIamPermissions(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -1053,26 +645,12 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq return testIamPermissionsCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Tests the specified permissions against the IAM access control policy for a function. If the * function does not exist, this will return an empty set of permissions, not a NOT_FOUND error. * *

Sample code: - * - *


-   * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
-   *   ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .addAllPermissions(permissions)
-   *     .build();
-   *   ApiFuture<TestIamPermissionsResponse> future = cloudFunctionsServiceClient.testIamPermissionsCallable().futureCall(request);
-   *   // Do something
-   *   TestIamPermissionsResponse response = future.get();
-   * }
-   * 
*/ public final UnaryCallable testIamPermissionsCallable() { diff --git a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceSettings.java b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceSettings.java index 39892158..cccf008c 100644 --- a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceSettings.java +++ b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/CloudFunctionsServiceSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.functions.v1; import static com.google.cloud.functions.v1.CloudFunctionsServiceClient.ListFunctionsPagedResponse; @@ -41,7 +42,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link CloudFunctionsServiceClient}. * @@ -59,23 +60,25 @@ * *

For example, to set the total timeout of getFunction to 30 seconds: * - *

- * 
+ * 
{@code
  * CloudFunctionsServiceSettings.Builder cloudFunctionsServiceSettingsBuilder =
  *     CloudFunctionsServiceSettings.newBuilder();
  * cloudFunctionsServiceSettingsBuilder
  *     .getFunctionSettings()
  *     .setRetrySettings(
- *         cloudFunctionsServiceSettingsBuilder.getFunctionSettings().getRetrySettings().toBuilder()
+ *         cloudFunctionsServiceSettingsBuilder
+ *             .getFunctionSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * CloudFunctionsServiceSettings cloudFunctionsServiceSettings = cloudFunctionsServiceSettingsBuilder.build();
- * 
- * 
+ * CloudFunctionsServiceSettings cloudFunctionsServiceSettings = + * cloudFunctionsServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") -@BetaApi +@Generated("by gapic-generator-java") public class CloudFunctionsServiceSettings extends ClientSettings { + /** Returns the object with the settings used for calls to listFunctions. */ public PagedCallSettings listFunctionsSettings() { @@ -93,8 +96,6 @@ public UnaryCallSettings createFunctionSetting } /** Returns the object with the settings used for calls to createFunction. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings createFunctionOperationSettings() { return ((CloudFunctionsServiceStubSettings) getStubSettings()) @@ -107,8 +108,6 @@ public UnaryCallSettings updateFunctionSetting } /** Returns the object with the settings used for calls to updateFunction. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings updateFunctionOperationSettings() { return ((CloudFunctionsServiceStubSettings) getStubSettings()) @@ -121,8 +120,6 @@ public UnaryCallSettings deleteFunctionSetting } /** Returns the object with the settings used for calls to deleteFunction. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings deleteFunctionOperationSettings() { return ((CloudFunctionsServiceStubSettings) getStubSettings()) @@ -223,18 +220,15 @@ protected CloudFunctionsServiceSettings(Builder settingsBuilder) throws IOExcept /** Builder for CloudFunctionsServiceSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(CloudFunctionsServiceStubSettings.newBuilder(clientContext)); } - private static Builder createDefault() { - return new Builder(CloudFunctionsServiceStubSettings.newBuilder()); - } - protected Builder(CloudFunctionsServiceSettings settings) { super(settings.getStubSettings().toBuilder()); } @@ -243,11 +237,15 @@ protected Builder(CloudFunctionsServiceStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(CloudFunctionsServiceStubSettings.newBuilder()); + } + public CloudFunctionsServiceStubSettings.Builder getStubSettingsBuilder() { return ((CloudFunctionsServiceStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * @@ -278,8 +276,6 @@ public UnaryCallSettings.Builder createFunctio } /** Returns the builder for the settings used for calls to createFunction. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder createFunctionOperationSettings() { return getStubSettingsBuilder().createFunctionOperationSettings(); @@ -291,8 +287,6 @@ public UnaryCallSettings.Builder updateFunctio } /** Returns the builder for the settings used for calls to updateFunction. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder updateFunctionOperationSettings() { return getStubSettingsBuilder().updateFunctionOperationSettings(); @@ -304,8 +298,6 @@ public UnaryCallSettings.Builder deleteFunctio } /** Returns the builder for the settings used for calls to deleteFunction. */ - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder deleteFunctionOperationSettings() { return getStubSettingsBuilder().deleteFunctionOperationSettings(); diff --git a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/package-info.java b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/package-info.java index a99e00a5..5e9e48c0 100644 --- a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/package-info.java +++ b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/package-info.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -15,26 +15,15 @@ */ /** - * A client to Cloud Functions API. + * The interfaces provided are listed below, along with usage samples. * - *

The interfaces provided are listed below, along with usage samples. - * - *

=========================== CloudFunctionsServiceClient =========================== + *

======================= CloudFunctionsServiceClient ======================= * *

Service Description: A service that application uses to manipulate triggers and functions. * *

Sample for CloudFunctionsServiceClient: - * - *

- * 
- * try (CloudFunctionsServiceClient cloudFunctionsServiceClient = CloudFunctionsServiceClient.create()) {
- *   CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
- *   CloudFunction response = cloudFunctionsServiceClient.getFunction(name);
- * }
- * 
- * 
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") package com.google.cloud.functions.v1; import javax.annotation.Generated; diff --git a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/CloudFunctionsServiceStub.java b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/CloudFunctionsServiceStub.java index 68272c3c..ad064508 100644 --- a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/CloudFunctionsServiceStub.java +++ b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/CloudFunctionsServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.functions.v1.stub; import static com.google.cloud.functions.v1.CloudFunctionsServiceClient.ListFunctionsPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; @@ -45,17 +45,15 @@ import com.google.protobuf.Empty; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Cloud Functions API. + * Base stub class for the CloudFunctionsService service API. * *

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") public abstract class CloudFunctionsServiceStub implements BackgroundResource { - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationsStub getOperationsStub() { throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); } @@ -73,7 +71,6 @@ public UnaryCallable getFunctionCallable() { throw new UnsupportedOperationException("Not implemented: getFunctionCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable createFunctionOperationCallable() { throw new UnsupportedOperationException("Not implemented: createFunctionOperationCallable()"); @@ -83,7 +80,6 @@ public UnaryCallable createFunctionCallable() throw new UnsupportedOperationException("Not implemented: createFunctionCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable updateFunctionOperationCallable() { throw new UnsupportedOperationException("Not implemented: updateFunctionOperationCallable()"); @@ -93,7 +89,6 @@ public UnaryCallable updateFunctionCallable() throw new UnsupportedOperationException("Not implemented: updateFunctionCallable()"); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable deleteFunctionOperationCallable() { throw new UnsupportedOperationException("Not implemented: deleteFunctionOperationCallable()"); diff --git a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/CloudFunctionsServiceStubSettings.java b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/CloudFunctionsServiceStubSettings.java index 59ac3e98..80de0147 100644 --- a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/CloudFunctionsServiceStubSettings.java +++ b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/CloudFunctionsServiceStubSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.functions.v1.stub; import static com.google.cloud.functions.v1.CloudFunctionsServiceClient.ListFunctionsPagedResponse; @@ -73,7 +74,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link CloudFunctionsServiceStub}. * @@ -91,22 +92,24 @@ * *

For example, to set the total timeout of getFunction to 30 seconds: * - *

- * 
+ * 
{@code
  * CloudFunctionsServiceStubSettings.Builder cloudFunctionsServiceSettingsBuilder =
  *     CloudFunctionsServiceStubSettings.newBuilder();
  * cloudFunctionsServiceSettingsBuilder
  *     .getFunctionSettings()
  *     .setRetrySettings(
- *         cloudFunctionsServiceSettingsBuilder.getFunctionSettings().getRetrySettings().toBuilder()
+ *         cloudFunctionsServiceSettingsBuilder
+ *             .getFunctionSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * CloudFunctionsServiceStubSettings cloudFunctionsServiceSettings = cloudFunctionsServiceSettingsBuilder.build();
- * 
- * 
+ * CloudFunctionsServiceStubSettings cloudFunctionsServiceSettings = + * cloudFunctionsServiceSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator-java") public class CloudFunctionsServiceStubSettings extends StubSettings { /** The default scopes of the service. */ @@ -136,6 +139,60 @@ public class CloudFunctionsServiceStubSettings private final UnaryCallSettings testIamPermissionsSettings; + private static final PagedListDescriptor< + ListFunctionsRequest, ListFunctionsResponse, CloudFunction> + LIST_FUNCTIONS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListFunctionsRequest injectToken(ListFunctionsRequest payload, String token) { + return ListFunctionsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListFunctionsRequest injectPageSize(ListFunctionsRequest payload, int pageSize) { + return ListFunctionsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListFunctionsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListFunctionsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListFunctionsResponse payload) { + return payload.getFunctionsList() == null + ? ImmutableList.of() + : payload.getFunctionsList(); + } + }; + + private static final PagedListResponseFactory< + ListFunctionsRequest, ListFunctionsResponse, ListFunctionsPagedResponse> + LIST_FUNCTIONS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListFunctionsRequest, ListFunctionsResponse, ListFunctionsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListFunctionsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_FUNCTIONS_PAGE_STR_DESC, request, context); + return ListFunctionsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + /** Returns the object with the settings used for calls to listFunctions. */ public PagedCallSettings listFunctionsSettings() { @@ -153,7 +210,6 @@ public UnaryCallSettings createFunctionSetting } /** Returns the object with the settings used for calls to createFunction. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings createFunctionOperationSettings() { return createFunctionOperationSettings; @@ -165,7 +221,6 @@ public UnaryCallSettings updateFunctionSetting } /** Returns the object with the settings used for calls to updateFunction. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings updateFunctionOperationSettings() { return updateFunctionOperationSettings; @@ -177,7 +232,6 @@ public UnaryCallSettings deleteFunctionSetting } /** Returns the object with the settings used for calls to deleteFunction. */ - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallSettings deleteFunctionOperationSettings() { return deleteFunctionOperationSettings; @@ -222,10 +276,10 @@ public CloudFunctionsServiceStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCloudFunctionsServiceStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -301,65 +355,10 @@ protected CloudFunctionsServiceStubSettings(Builder settingsBuilder) throws IOEx testIamPermissionsSettings = settingsBuilder.testIamPermissionsSettings().build(); } - private static final PagedListDescriptor< - ListFunctionsRequest, ListFunctionsResponse, CloudFunction> - LIST_FUNCTIONS_PAGE_STR_DESC = - new PagedListDescriptor() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public ListFunctionsRequest injectToken(ListFunctionsRequest payload, String token) { - return ListFunctionsRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public ListFunctionsRequest injectPageSize(ListFunctionsRequest payload, int pageSize) { - return ListFunctionsRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(ListFunctionsRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(ListFunctionsResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources(ListFunctionsResponse payload) { - return payload.getFunctionsList() != null - ? payload.getFunctionsList() - : ImmutableList.of(); - } - }; - - private static final PagedListResponseFactory< - ListFunctionsRequest, ListFunctionsResponse, ListFunctionsPagedResponse> - LIST_FUNCTIONS_PAGE_STR_FACT = - new PagedListResponseFactory< - ListFunctionsRequest, ListFunctionsResponse, ListFunctionsPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - ListFunctionsRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext pageContext = - PageContext.create(callable, LIST_FUNCTIONS_PAGE_STR_DESC, request, context); - return ListFunctionsPagedResponse.createAsync(pageContext, futureResponse); - } - }; - /** Builder for CloudFunctionsServiceStubSettings. */ public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final PagedCallSettings.Builder< ListFunctionsRequest, ListFunctionsResponse, ListFunctionsPagedResponse> listFunctionsSettings; @@ -388,21 +387,13 @@ public static class Builder private final UnaryCallSettings.Builder getIamPolicySettings; private final UnaryCallSettings.Builder testIamPermissionsSettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; static { ImmutableMap.Builder> definitions = ImmutableMap.builder(); - definitions.put( - "retry_policy_1_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); - definitions.put( - "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -411,63 +402,31 @@ public static class Builder static { ImmutableMap.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; - settings = - RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(100L)) - .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(60000L)) - .setInitialRpcTimeout(Duration.ofMillis(600000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(600000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) - .build(); - definitions.put("retry_policy_1_params", settings); settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); definitions.put("no_retry_params", settings); - settings = - RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(600000L)) - .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(600000L)) - .setTotalTimeout(Duration.ofMillis(600000L)) - .build(); - definitions.put("no_retry_1_params", settings); RETRY_PARAM_DEFINITIONS = definitions.build(); } protected Builder() { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(clientContext); listFunctionsSettings = PagedCallSettings.newBuilder(LIST_FUNCTIONS_PAGE_STR_FACT); - getFunctionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - createFunctionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - createFunctionOperationSettings = OperationCallSettings.newBuilder(); - updateFunctionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - updateFunctionOperationSettings = OperationCallSettings.newBuilder(); - deleteFunctionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - deleteFunctionOperationSettings = OperationCallSettings.newBuilder(); - callFunctionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - generateUploadUrlSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - generateDownloadUrlSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - setIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - getIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - testIamPermissionsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); unaryMethodSettingsBuilders = @@ -483,49 +442,82 @@ protected Builder(ClientContext clientContext) { setIamPolicySettings, getIamPolicySettings, testIamPermissionsSettings); - initDefaults(this); } + protected Builder(CloudFunctionsServiceStubSettings settings) { + super(settings); + + listFunctionsSettings = settings.listFunctionsSettings.toBuilder(); + getFunctionSettings = settings.getFunctionSettings.toBuilder(); + createFunctionSettings = settings.createFunctionSettings.toBuilder(); + createFunctionOperationSettings = settings.createFunctionOperationSettings.toBuilder(); + updateFunctionSettings = settings.updateFunctionSettings.toBuilder(); + updateFunctionOperationSettings = settings.updateFunctionOperationSettings.toBuilder(); + deleteFunctionSettings = settings.deleteFunctionSettings.toBuilder(); + deleteFunctionOperationSettings = settings.deleteFunctionOperationSettings.toBuilder(); + callFunctionSettings = settings.callFunctionSettings.toBuilder(); + generateUploadUrlSettings = settings.generateUploadUrlSettings.toBuilder(); + generateDownloadUrlSettings = settings.generateDownloadUrlSettings.toBuilder(); + setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); + getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); + testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listFunctionsSettings, + getFunctionSettings, + createFunctionSettings, + updateFunctionSettings, + deleteFunctionSettings, + callFunctionSettings, + generateUploadUrlSettings, + generateDownloadUrlSettings, + setIamPolicySettings, + getIamPolicySettings, + testIamPermissionsSettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + Builder builder = new Builder(((ClientContext) null)); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); } private static Builder initDefaults(Builder builder) { - builder .listFunctionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); builder .getFunctionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); builder .createFunctionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); builder .updateFunctionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); builder .deleteFunctionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); builder .callFunctionSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); builder @@ -552,12 +544,13 @@ private static Builder initDefaults(Builder builder) { .testIamPermissionsSettings() .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + builder .createFunctionOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")) .build()) .setResponseTransformer( @@ -567,20 +560,21 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); + builder .updateFunctionOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")) .build()) .setResponseTransformer( @@ -590,20 +584,21 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); + builder .deleteFunctionOperationSettings() .setInitialCallSettings( UnaryCallSettings .newUnaryCallSettingsBuilder() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")) .build()) .setResponseTransformer( @@ -613,52 +608,19 @@ private static Builder initDefaults(Builder builder) { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setInitialRetryDelay(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.5) - .setMaxRetryDelay(Duration.ofMillis(5000L)) - .setInitialRpcTimeout(Duration.ZERO) // ignored - .setRpcTimeoutMultiplier(1.0) // ignored - .setMaxRpcTimeout(Duration.ZERO) // ignored + .setMaxRetryDelay(Duration.ofMillis(45000L)) + .setInitialRpcTimeout(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ZERO) .setTotalTimeout(Duration.ofMillis(300000L)) .build())); return builder; } - protected Builder(CloudFunctionsServiceStubSettings settings) { - super(settings); - - listFunctionsSettings = settings.listFunctionsSettings.toBuilder(); - getFunctionSettings = settings.getFunctionSettings.toBuilder(); - createFunctionSettings = settings.createFunctionSettings.toBuilder(); - createFunctionOperationSettings = settings.createFunctionOperationSettings.toBuilder(); - updateFunctionSettings = settings.updateFunctionSettings.toBuilder(); - updateFunctionOperationSettings = settings.updateFunctionOperationSettings.toBuilder(); - deleteFunctionSettings = settings.deleteFunctionSettings.toBuilder(); - deleteFunctionOperationSettings = settings.deleteFunctionOperationSettings.toBuilder(); - callFunctionSettings = settings.callFunctionSettings.toBuilder(); - generateUploadUrlSettings = settings.generateUploadUrlSettings.toBuilder(); - generateDownloadUrlSettings = settings.generateDownloadUrlSettings.toBuilder(); - setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); - getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); - testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - listFunctionsSettings, - getFunctionSettings, - createFunctionSettings, - updateFunctionSettings, - deleteFunctionSettings, - callFunctionSettings, - generateUploadUrlSettings, - generateDownloadUrlSettings, - setIamPolicySettings, - getIamPolicySettings, - testIamPermissionsSettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/GrpcCloudFunctionsServiceCallableFactory.java b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/GrpcCloudFunctionsServiceCallableFactory.java index 3fa668d3..47aa56a4 100644 --- a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/GrpcCloudFunctionsServiceCallableFactory.java +++ b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/GrpcCloudFunctionsServiceCallableFactory.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.functions.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -31,18 +31,19 @@ import com.google.api.gax.rpc.StreamingCallSettings; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Cloud Functions API. + * gRPC callable factory implementation for the CloudFunctionsService service API. * *

This class is for advanced usage. */ @Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public class GrpcCloudFunctionsServiceCallableFactory implements GrpcStubCallableFactory { + @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") @Override public OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/GrpcCloudFunctionsServiceStub.java b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/GrpcCloudFunctionsServiceStub.java index fa80c329..90d93531 100644 --- a/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/GrpcCloudFunctionsServiceStub.java +++ b/google-cloud-functions/src/main/java/com/google/cloud/functions/v1/stub/GrpcCloudFunctionsServiceStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.functions.v1.stub; import static com.google.cloud.functions.v1.CloudFunctionsServiceClient.ListFunctionsPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -56,16 +56,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Cloud Functions API. + * gRPC stub implementation for the CloudFunctionsService service API. * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@Generated("by gapic-generator-java") public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { - private static final MethodDescriptor listFunctionsMethodDescriptor = MethodDescriptor.newBuilder() @@ -76,6 +74,7 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { .setResponseMarshaller( ProtoUtils.marshaller(ListFunctionsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor getFunctionMethodDescriptor = MethodDescriptor.newBuilder() @@ -84,6 +83,7 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(GetFunctionRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(CloudFunction.getDefaultInstance())) .build(); + private static final MethodDescriptor createFunctionMethodDescriptor = MethodDescriptor.newBuilder() @@ -93,6 +93,7 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { ProtoUtils.marshaller(CreateFunctionRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor updateFunctionMethodDescriptor = MethodDescriptor.newBuilder() @@ -102,6 +103,7 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { ProtoUtils.marshaller(UpdateFunctionRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor deleteFunctionMethodDescriptor = MethodDescriptor.newBuilder() @@ -111,6 +113,7 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { ProtoUtils.marshaller(DeleteFunctionRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor callFunctionMethodDescriptor = MethodDescriptor.newBuilder() @@ -120,6 +123,7 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { .setResponseMarshaller( ProtoUtils.marshaller(CallFunctionResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor generateUploadUrlMethodDescriptor = MethodDescriptor.newBuilder() @@ -131,6 +135,7 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { .setResponseMarshaller( ProtoUtils.marshaller(GenerateUploadUrlResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor generateDownloadUrlMethodDescriptor = MethodDescriptor.newBuilder() @@ -142,6 +147,7 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { .setResponseMarshaller( ProtoUtils.marshaller(GenerateDownloadUrlResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor setIamPolicyMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -149,6 +155,7 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(SetIamPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) .build(); + private static final MethodDescriptor getIamPolicyMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -156,6 +163,7 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { .setRequestMarshaller(ProtoUtils.marshaller(GetIamPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) .build(); + private static final MethodDescriptor testIamPermissionsMethodDescriptor = MethodDescriptor.newBuilder() @@ -168,9 +176,6 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final GrpcOperationsStub operationsStub; - private final UnaryCallable listFunctionsCallable; private final UnaryCallable listFunctionsPagedCallable; @@ -194,6 +199,8 @@ public class GrpcCloudFunctionsServiceStub extends CloudFunctionsServiceStub { private final UnaryCallable testIamPermissionsCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcCloudFunctionsServiceStub create( @@ -400,7 +407,7 @@ public Map extract(TestIamPermissionsRequest request) { createFunctionTransportSettings, settings.createFunctionOperationSettings(), clientContext, - this.operationsStub); + operationsStub); this.updateFunctionCallable = callableFactory.createUnaryCallable( updateFunctionTransportSettings, settings.updateFunctionSettings(), clientContext); @@ -409,7 +416,7 @@ public Map extract(TestIamPermissionsRequest request) { updateFunctionTransportSettings, settings.updateFunctionOperationSettings(), clientContext, - this.operationsStub); + operationsStub); this.deleteFunctionCallable = callableFactory.createUnaryCallable( deleteFunctionTransportSettings, settings.deleteFunctionSettings(), clientContext); @@ -418,7 +425,7 @@ public Map extract(TestIamPermissionsRequest request) { deleteFunctionTransportSettings, settings.deleteFunctionOperationSettings(), clientContext, - this.operationsStub); + operationsStub); this.callFunctionCallable = callableFactory.createUnaryCallable( callFunctionTransportSettings, settings.callFunctionSettings(), clientContext); @@ -444,57 +451,54 @@ public Map extract(TestIamPermissionsRequest request) { settings.testIamPermissionsSettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public GrpcOperationsStub getOperationsStub() { return operationsStub; } + public UnaryCallable listFunctionsCallable() { + return listFunctionsCallable; + } + public UnaryCallable listFunctionsPagedCallable() { return listFunctionsPagedCallable; } - public UnaryCallable listFunctionsCallable() { - return listFunctionsCallable; - } - public UnaryCallable getFunctionCallable() { return getFunctionCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public UnaryCallable createFunctionCallable() { + return createFunctionCallable; + } + public OperationCallable createFunctionOperationCallable() { return createFunctionOperationCallable; } - public UnaryCallable createFunctionCallable() { - return createFunctionCallable; + public UnaryCallable updateFunctionCallable() { + return updateFunctionCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable updateFunctionOperationCallable() { return updateFunctionOperationCallable; } - public UnaryCallable updateFunctionCallable() { - return updateFunctionCallable; + public UnaryCallable deleteFunctionCallable() { + return deleteFunctionCallable; } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable deleteFunctionOperationCallable() { return deleteFunctionOperationCallable; } - public UnaryCallable deleteFunctionCallable() { - return deleteFunctionCallable; - } - public UnaryCallable callFunctionCallable() { return callFunctionCallable; } diff --git a/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/CloudFunctionsServiceClientTest.java b/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/CloudFunctionsServiceClientTest.java index 85c2d414..03118c8f 100644 --- a/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/CloudFunctionsServiceClientTest.java +++ b/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/CloudFunctionsServiceClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.functions.v1; import static com.google.cloud.functions.v1.CloudFunctionsServiceClient.ListFunctionsPagedResponse; @@ -25,9 +26,10 @@ import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.InvalidArgumentException; import com.google.api.gax.rpc.StatusCode; -import com.google.api.resourcenames.ResourceName; import com.google.common.collect.Lists; +import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; +import com.google.iam.v1.GetPolicyOptions; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; @@ -36,16 +38,18 @@ import com.google.protobuf.AbstractMessage; import com.google.protobuf.Any; import com.google.protobuf.ByteString; +import com.google.protobuf.Duration; import com.google.protobuf.Empty; -import io.grpc.Status; +import com.google.protobuf.Timestamp; import io.grpc.StatusRuntimeException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; -import java.util.Objects; import java.util.UUID; import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -53,32 +57,32 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class CloudFunctionsServiceClientTest { - private static MockCloudFunctionsService mockCloudFunctionsService; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private CloudFunctionsServiceClient client; + private static MockCloudFunctionsService mockCloudFunctionsService; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { mockCloudFunctionsService = new MockCloudFunctionsService(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), Arrays.asList(mockCloudFunctionsService)); - serviceHelper.start(); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); CloudFunctionsServiceSettings settings = CloudFunctionsServiceSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -93,30 +97,36 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void listFunctionsTest() { - String nextPageToken = ""; - CloudFunction functionsElement = CloudFunction.newBuilder().build(); - List functions = Arrays.asList(functionsElement); + public void listFunctionsTest() throws Exception { + CloudFunction responsesElement = CloudFunction.newBuilder().build(); ListFunctionsResponse expectedResponse = ListFunctionsResponse.newBuilder() - .setNextPageToken(nextPageToken) - .addAllFunctions(functions) + .setNextPageToken("") + .addAllFunctions(Arrays.asList(responsesElement)) .build(); mockCloudFunctionsService.addResponse(expectedResponse); - ListFunctionsRequest request = ListFunctionsRequest.newBuilder().build(); + ListFunctionsRequest request = + ListFunctionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); ListFunctionsPagedResponse pagedListResponse = client.listFunctions(request); List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getFunctionsList().get(0), resources.get(0)); List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - ListFunctionsRequest actualRequest = (ListFunctionsRequest) actualRequests.get(0); + ListFunctionsRequest actualRequest = ((ListFunctionsRequest) actualRequests.get(0)); + Assert.assertEquals(request.getParent(), actualRequest.getParent()); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -124,50 +134,43 @@ public void listFunctionsTest() { } @Test - @SuppressWarnings("all") public void listFunctionsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { - ListFunctionsRequest request = ListFunctionsRequest.newBuilder().build(); - + ListFunctionsRequest request = + ListFunctionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); client.listFunctions(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getFunctionTest() { - CloudFunctionName name2 = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); - String description = "description-1724546052"; - String sourceArchiveUrl = "sourceArchiveUrl-289007026"; - String entryPoint = "entryPoint-799136893"; - String runtime = "runtime1550962648"; - int availableMemoryMb = 1964533661; - String serviceAccountEmail = "serviceAccountEmail-1300473088"; - long versionId = 670497310L; - String network = "network1843485230"; - int maxInstances = 330682013; - String vpcConnector = "vpcConnector1732864119"; - String buildId = "buildId-1430655860"; + public void getFunctionTest() throws Exception { CloudFunction expectedResponse = CloudFunction.newBuilder() - .setName(name2.toString()) - .setDescription(description) - .setSourceArchiveUrl(sourceArchiveUrl) - .setEntryPoint(entryPoint) - .setRuntime(runtime) - .setAvailableMemoryMb(availableMemoryMb) - .setServiceAccountEmail(serviceAccountEmail) - .setVersionId(versionId) - .setNetwork(network) - .setMaxInstances(maxInstances) - .setVpcConnector(vpcConnector) - .setBuildId(buildId) + .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .setDescription("description-1724546052") + .setEntryPoint("entryPoint-1979329474") + .setRuntime("runtime1550962648") + .setTimeout(Duration.newBuilder().build()) + .setAvailableMemoryMb(1964533661) + .setServiceAccountEmail("serviceAccountEmail1825953988") + .setUpdateTime(Timestamp.newBuilder().build()) + .setVersionId(-670497310) + .putAllLabels(new HashMap()) + .putAllEnvironmentVariables(new HashMap()) + .setNetwork("network1843485230") + .setMaxInstances(-330682013) + .setVpcConnector("vpcConnector2101559652") + .setBuildId("buildId230943785") .build(); mockCloudFunctionsService.addResponse(expectedResponse); @@ -178,9 +181,9 @@ public void getFunctionTest() { List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetFunctionRequest actualRequest = (GetFunctionRequest) actualRequests.get(0); + GetFunctionRequest actualRequest = ((GetFunctionRequest) actualRequests.get(0)); - Assert.assertEquals(name, CloudFunctionName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -188,50 +191,90 @@ public void getFunctionTest() { } @Test - @SuppressWarnings("all") public void getFunctionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); + client.getFunction(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFunctionTest2() throws Exception { + CloudFunction expectedResponse = + CloudFunction.newBuilder() + .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .setDescription("description-1724546052") + .setEntryPoint("entryPoint-1979329474") + .setRuntime("runtime1550962648") + .setTimeout(Duration.newBuilder().build()) + .setAvailableMemoryMb(1964533661) + .setServiceAccountEmail("serviceAccountEmail1825953988") + .setUpdateTime(Timestamp.newBuilder().build()) + .setVersionId(-670497310) + .putAllLabels(new HashMap()) + .putAllEnvironmentVariables(new HashMap()) + .setNetwork("network1843485230") + .setMaxInstances(-330682013) + .setVpcConnector("vpcConnector2101559652") + .setBuildId("buildId230943785") + .build(); + mockCloudFunctionsService.addResponse(expectedResponse); + String name = "name3373707"; + + CloudFunction actualResponse = client.getFunction(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockCloudFunctionsService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetFunctionRequest actualRequest = ((GetFunctionRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getFunctionExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockCloudFunctionsService.addException(exception); + + try { + String name = "name3373707"; client.getFunction(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") public void createFunctionTest() throws Exception { - CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); - String description = "description-1724546052"; - String sourceArchiveUrl = "sourceArchiveUrl-289007026"; - String entryPoint = "entryPoint-799136893"; - String runtime = "runtime1550962648"; - int availableMemoryMb = 1964533661; - String serviceAccountEmail = "serviceAccountEmail-1300473088"; - long versionId = 670497310L; - String network = "network1843485230"; - int maxInstances = 330682013; - String vpcConnector = "vpcConnector1732864119"; - String buildId = "buildId-1430655860"; CloudFunction expectedResponse = CloudFunction.newBuilder() - .setName(name.toString()) - .setDescription(description) - .setSourceArchiveUrl(sourceArchiveUrl) - .setEntryPoint(entryPoint) - .setRuntime(runtime) - .setAvailableMemoryMb(availableMemoryMb) - .setServiceAccountEmail(serviceAccountEmail) - .setVersionId(versionId) - .setNetwork(network) - .setMaxInstances(maxInstances) - .setVpcConnector(vpcConnector) - .setBuildId(buildId) + .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .setDescription("description-1724546052") + .setEntryPoint("entryPoint-1979329474") + .setRuntime("runtime1550962648") + .setTimeout(Duration.newBuilder().build()) + .setAvailableMemoryMb(1964533661) + .setServiceAccountEmail("serviceAccountEmail1825953988") + .setUpdateTime(Timestamp.newBuilder().build()) + .setVersionId(-670497310) + .putAllLabels(new HashMap()) + .putAllEnvironmentVariables(new HashMap()) + .setNetwork("network1843485230") + .setMaxInstances(-330682013) + .setVpcConnector("vpcConnector2101559652") + .setBuildId("buildId230943785") .build(); Operation resultOperation = Operation.newBuilder() @@ -249,9 +292,9 @@ public void createFunctionTest() throws Exception { List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CreateFunctionRequest actualRequest = (CreateFunctionRequest) actualRequests.get(0); + CreateFunctionRequest actualRequest = ((CreateFunctionRequest) actualRequests.get(0)); - Assert.assertEquals(location, LocationName.parse(actualRequest.getLocation())); + Assert.assertEquals(location.toString(), actualRequest.getLocation()); Assert.assertEquals(function, actualRequest.getFunction()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -260,53 +303,104 @@ public void createFunctionTest() throws Exception { } @Test - @SuppressWarnings("all") public void createFunctionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { LocationName location = LocationName.of("[PROJECT]", "[LOCATION]"); CloudFunction function = CloudFunction.newBuilder().build(); + client.createFunctionAsync(location, function).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void createFunctionTest2() throws Exception { + CloudFunction expectedResponse = + CloudFunction.newBuilder() + .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .setDescription("description-1724546052") + .setEntryPoint("entryPoint-1979329474") + .setRuntime("runtime1550962648") + .setTimeout(Duration.newBuilder().build()) + .setAvailableMemoryMb(1964533661) + .setServiceAccountEmail("serviceAccountEmail1825953988") + .setUpdateTime(Timestamp.newBuilder().build()) + .setVersionId(-670497310) + .putAllLabels(new HashMap()) + .putAllEnvironmentVariables(new HashMap()) + .setNetwork("network1843485230") + .setMaxInstances(-330682013) + .setVpcConnector("vpcConnector2101559652") + .setBuildId("buildId230943785") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createFunctionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockCloudFunctionsService.addResponse(resultOperation); + + String location = "location1901043637"; + CloudFunction function = CloudFunction.newBuilder().build(); + + CloudFunction actualResponse = client.createFunctionAsync(location, function).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockCloudFunctionsService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateFunctionRequest actualRequest = ((CreateFunctionRequest) actualRequests.get(0)); + Assert.assertEquals(location, actualRequest.getLocation()); + Assert.assertEquals(function, actualRequest.getFunction()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createFunctionExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockCloudFunctionsService.addException(exception); + + try { + String location = "location1901043637"; + CloudFunction function = CloudFunction.newBuilder().build(); client.createFunctionAsync(location, function).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") public void updateFunctionTest() throws Exception { - CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); - String description = "description-1724546052"; - String sourceArchiveUrl = "sourceArchiveUrl-289007026"; - String entryPoint = "entryPoint-799136893"; - String runtime = "runtime1550962648"; - int availableMemoryMb = 1964533661; - String serviceAccountEmail = "serviceAccountEmail-1300473088"; - long versionId = 670497310L; - String network = "network1843485230"; - int maxInstances = 330682013; - String vpcConnector = "vpcConnector1732864119"; - String buildId = "buildId-1430655860"; CloudFunction expectedResponse = CloudFunction.newBuilder() - .setName(name.toString()) - .setDescription(description) - .setSourceArchiveUrl(sourceArchiveUrl) - .setEntryPoint(entryPoint) - .setRuntime(runtime) - .setAvailableMemoryMb(availableMemoryMb) - .setServiceAccountEmail(serviceAccountEmail) - .setVersionId(versionId) - .setNetwork(network) - .setMaxInstances(maxInstances) - .setVpcConnector(vpcConnector) - .setBuildId(buildId) + .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .setDescription("description-1724546052") + .setEntryPoint("entryPoint-1979329474") + .setRuntime("runtime1550962648") + .setTimeout(Duration.newBuilder().build()) + .setAvailableMemoryMb(1964533661) + .setServiceAccountEmail("serviceAccountEmail1825953988") + .setUpdateTime(Timestamp.newBuilder().build()) + .setVersionId(-670497310) + .putAllLabels(new HashMap()) + .putAllEnvironmentVariables(new HashMap()) + .setNetwork("network1843485230") + .setMaxInstances(-330682013) + .setVpcConnector("vpcConnector2101559652") + .setBuildId("buildId230943785") .build(); Operation resultOperation = Operation.newBuilder() @@ -323,7 +417,7 @@ public void updateFunctionTest() throws Exception { List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - UpdateFunctionRequest actualRequest = (UpdateFunctionRequest) actualRequests.get(0); + UpdateFunctionRequest actualRequest = ((UpdateFunctionRequest) actualRequests.get(0)); Assert.assertEquals(function, actualRequest.getFunction()); Assert.assertTrue( @@ -333,25 +427,22 @@ public void updateFunctionTest() throws Exception { } @Test - @SuppressWarnings("all") public void updateFunctionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { CloudFunction function = CloudFunction.newBuilder().build(); - client.updateFunctionAsync(function).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") public void deleteFunctionTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); Operation resultOperation = @@ -364,14 +455,13 @@ public void deleteFunctionTest() throws Exception { CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); - Empty actualResponse = client.deleteFunctionAsync(name).get(); - Assert.assertEquals(expectedResponse, actualResponse); + client.deleteFunctionAsync(name).get(); List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - DeleteFunctionRequest actualRequest = (DeleteFunctionRequest) actualRequests.get(0); + DeleteFunctionRequest actualRequest = ((DeleteFunctionRequest) actualRequests.get(0)); - Assert.assertEquals(name, CloudFunctionName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -379,34 +469,70 @@ public void deleteFunctionTest() throws Exception { } @Test - @SuppressWarnings("all") public void deleteFunctionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); + client.deleteFunctionAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void deleteFunctionTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteFunctionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockCloudFunctionsService.addResponse(resultOperation); + + String name = "name3373707"; + client.deleteFunctionAsync(name).get(); + + List actualRequests = mockCloudFunctionsService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteFunctionRequest actualRequest = ((DeleteFunctionRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteFunctionExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockCloudFunctionsService.addException(exception); + + try { + String name = "name3373707"; client.deleteFunctionAsync(name).get(); Assert.fail("No exception raised"); } catch (ExecutionException e) { Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } @Test - @SuppressWarnings("all") - public void callFunctionTest() { - String executionId = "executionId-1217171550"; - String result = "result-934426595"; - String error = "error96784904"; + public void callFunctionTest() throws Exception { CallFunctionResponse expectedResponse = CallFunctionResponse.newBuilder() - .setExecutionId(executionId) - .setResult(result) - .setError(error) + .setExecutionId("executionId-454906285") + .setResult("result-934426595") + .setError("error96784904") .build(); mockCloudFunctionsService.addResponse(expectedResponse); @@ -418,9 +544,9 @@ public void callFunctionTest() { List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - CallFunctionRequest actualRequest = (CallFunctionRequest) actualRequests.get(0); + CallFunctionRequest actualRequest = ((CallFunctionRequest) actualRequests.get(0)); - Assert.assertEquals(name, CloudFunctionName.parse(actualRequest.getName())); + Assert.assertEquals(name.toString(), actualRequest.getName()); Assert.assertEquals(data, actualRequest.getData()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -429,39 +555,80 @@ public void callFunctionTest() { } @Test - @SuppressWarnings("all") public void callFunctionExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); String data = "data3076010"; + client.callFunction(name, data); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + @Test + public void callFunctionTest2() throws Exception { + CallFunctionResponse expectedResponse = + CallFunctionResponse.newBuilder() + .setExecutionId("executionId-454906285") + .setResult("result-934426595") + .setError("error96784904") + .build(); + mockCloudFunctionsService.addResponse(expectedResponse); + + String name = "name3373707"; + String data = "data3076010"; + + CallFunctionResponse actualResponse = client.callFunction(name, data); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockCloudFunctionsService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CallFunctionRequest actualRequest = ((CallFunctionRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertEquals(data, actualRequest.getData()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void callFunctionExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockCloudFunctionsService.addException(exception); + + try { + String name = "name3373707"; + String data = "data3076010"; client.callFunction(name, data); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void generateUploadUrlTest() { - String uploadUrl = "uploadUrl-242738639"; + public void generateUploadUrlTest() throws Exception { GenerateUploadUrlResponse expectedResponse = - GenerateUploadUrlResponse.newBuilder().setUploadUrl(uploadUrl).build(); + GenerateUploadUrlResponse.newBuilder().setUploadUrl("uploadUrl1239085998").build(); mockCloudFunctionsService.addResponse(expectedResponse); - GenerateUploadUrlRequest request = GenerateUploadUrlRequest.newBuilder().build(); + GenerateUploadUrlRequest request = + GenerateUploadUrlRequest.newBuilder().setParent("parent-995424086").build(); GenerateUploadUrlResponse actualResponse = client.generateUploadUrl(request); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GenerateUploadUrlRequest actualRequest = (GenerateUploadUrlRequest) actualRequests.get(0); + GenerateUploadUrlRequest actualRequest = ((GenerateUploadUrlRequest) actualRequests.get(0)); + Assert.assertEquals(request.getParent(), actualRequest.getParent()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -469,38 +636,41 @@ public void generateUploadUrlTest() { } @Test - @SuppressWarnings("all") public void generateUploadUrlExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { - GenerateUploadUrlRequest request = GenerateUploadUrlRequest.newBuilder().build(); - + GenerateUploadUrlRequest request = + GenerateUploadUrlRequest.newBuilder().setParent("parent-995424086").build(); client.generateUploadUrl(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void generateDownloadUrlTest() { - String downloadUrl = "downloadUrl1109408056"; + public void generateDownloadUrlTest() throws Exception { GenerateDownloadUrlResponse expectedResponse = - GenerateDownloadUrlResponse.newBuilder().setDownloadUrl(downloadUrl).build(); + GenerateDownloadUrlResponse.newBuilder().setDownloadUrl("downloadUrl-1211148345").build(); mockCloudFunctionsService.addResponse(expectedResponse); - GenerateDownloadUrlRequest request = GenerateDownloadUrlRequest.newBuilder().build(); + GenerateDownloadUrlRequest request = + GenerateDownloadUrlRequest.newBuilder() + .setName("name3373707") + .setVersionId(-670497310) + .build(); GenerateDownloadUrlResponse actualResponse = client.generateDownloadUrl(request); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GenerateDownloadUrlRequest actualRequest = (GenerateDownloadUrlRequest) actualRequests.get(0); + GenerateDownloadUrlRequest actualRequest = ((GenerateDownloadUrlRequest) actualRequests.get(0)); + Assert.assertEquals(request.getName(), actualRequest.getName()); + Assert.assertEquals(request.getVersionId(), actualRequest.getVersionId()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -508,43 +678,48 @@ public void generateDownloadUrlTest() { } @Test - @SuppressWarnings("all") public void generateDownloadUrlExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { - GenerateDownloadUrlRequest request = GenerateDownloadUrlRequest.newBuilder().build(); - + GenerateDownloadUrlRequest request = + GenerateDownloadUrlRequest.newBuilder() + .setName("name3373707") + .setVersionId(-670497310) + .build(); client.generateDownloadUrl(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void setIamPolicyTest() { - int version = 351608024; - ByteString etag = ByteString.copyFromUtf8("21"); - Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build(); + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); mockCloudFunctionsService.addResponse(expectedResponse); - ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); - Policy policy = Policy.newBuilder().build(); SetIamPolicyRequest request = - SetIamPolicyRequest.newBuilder().setResource(resource.toString()).setPolicy(policy).build(); + SetIamPolicyRequest.newBuilder() + .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .setPolicy(Policy.newBuilder().build()) + .build(); Policy actualResponse = client.setIamPolicy(request); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - SetIamPolicyRequest actualRequest = (SetIamPolicyRequest) actualRequests.get(0); + SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); - Assert.assertEquals(policy, actualRequest.getPolicy()); + Assert.assertEquals(request.getResource(), actualRequest.getResource()); + Assert.assertEquals(request.getPolicy(), actualRequest.getPolicy()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -552,47 +727,48 @@ public void setIamPolicyTest() { } @Test - @SuppressWarnings("all") public void setIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { - ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); - Policy policy = Policy.newBuilder().build(); SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() - .setResource(resource.toString()) - .setPolicy(policy) + .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .setPolicy(Policy.newBuilder().build()) .build(); - client.setIamPolicy(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getIamPolicyTest() { - int version = 351608024; - ByteString etag = ByteString.copyFromUtf8("21"); - Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build(); + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); mockCloudFunctionsService.addResponse(expectedResponse); - ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); GetIamPolicyRequest request = - GetIamPolicyRequest.newBuilder().setResource(resource.toString()).build(); + GetIamPolicyRequest.newBuilder() + .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); Policy actualResponse = client.getIamPolicy(request); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetIamPolicyRequest actualRequest = (GetIamPolicyRequest) actualRequests.get(0); + GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); + Assert.assertEquals(request.getResource(), actualRequest.getResource()); + Assert.assertEquals(request.getOptions(), actualRequest.getOptions()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -600,35 +776,33 @@ public void getIamPolicyTest() { } @Test - @SuppressWarnings("all") public void getIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { - ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); GetIamPolicyRequest request = - GetIamPolicyRequest.newBuilder().setResource(resource.toString()).build(); - + GetIamPolicyRequest.newBuilder() + .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .setOptions(GetPolicyOptions.newBuilder().build()) + .build(); client.getIamPolicy(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void testIamPermissionsTest() { - TestIamPermissionsResponse expectedResponse = TestIamPermissionsResponse.newBuilder().build(); + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); mockCloudFunctionsService.addResponse(expectedResponse); - ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); - List permissions = new ArrayList<>(); TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() - .setResource(resource.toString()) - .addAllPermissions(permissions) + .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .addAllPermissions(new ArrayList()) .build(); TestIamPermissionsResponse actualResponse = client.testIamPermissions(request); @@ -636,10 +810,10 @@ public void testIamPermissionsTest() { List actualRequests = mockCloudFunctionsService.getRequests(); Assert.assertEquals(1, actualRequests.size()); - TestIamPermissionsRequest actualRequest = (TestIamPermissionsRequest) actualRequests.get(0); + TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); - Assert.assertEquals(permissions, actualRequest.getPermissionsList()); + Assert.assertEquals(request.getResource(), actualRequest.getResource()); + Assert.assertEquals(request.getPermissionsList(), actualRequest.getPermissionsList()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -647,24 +821,20 @@ public void testIamPermissionsTest() { } @Test - @SuppressWarnings("all") public void testIamPermissionsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockCloudFunctionsService.addException(exception); try { - ResourceName resource = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]"); - List permissions = new ArrayList<>(); TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() - .setResource(resource.toString()) - .addAllPermissions(permissions) + .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString()) + .addAllPermissions(new ArrayList()) .build(); - client.testIamPermissions(request); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } } diff --git a/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/MockCloudFunctionsService.java b/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/MockCloudFunctionsService.java index d6a08c36..89616024 100644 --- a/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/MockCloudFunctionsService.java +++ b/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/MockCloudFunctionsService.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.functions.v1; import com.google.api.core.BetaApi; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockCloudFunctionsService implements MockGrpcService { private final MockCloudFunctionsServiceImpl serviceImpl; diff --git a/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/MockCloudFunctionsServiceImpl.java b/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/MockCloudFunctionsServiceImpl.java index 8644c3e6..c6115e71 100644 --- a/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/MockCloudFunctionsServiceImpl.java +++ b/google-cloud-functions/src/test/java/com/google/cloud/functions/v1/MockCloudFunctionsServiceImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.functions.v1; import com.google.api.core.BetaApi; @@ -29,9 +30,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockCloudFunctionsServiceImpl extends CloudFunctionsServiceImplBase { private List requests; private Queue responses; @@ -68,10 +70,10 @@ public void listFunctions( Object response = responses.remove(); if (response instanceof ListFunctionsResponse) { requests.add(request); - responseObserver.onNext((ListFunctionsResponse) response); + responseObserver.onNext(((ListFunctionsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -83,10 +85,10 @@ public void getFunction( Object response = responses.remove(); if (response instanceof CloudFunction) { requests.add(request); - responseObserver.onNext((CloudFunction) response); + responseObserver.onNext(((CloudFunction) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -98,10 +100,10 @@ public void createFunction( Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -113,10 +115,10 @@ public void updateFunction( Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -128,10 +130,10 @@ public void deleteFunction( Object response = responses.remove(); if (response instanceof Operation) { requests.add(request); - responseObserver.onNext((Operation) response); + responseObserver.onNext(((Operation) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -143,10 +145,10 @@ public void callFunction( Object response = responses.remove(); if (response instanceof CallFunctionResponse) { requests.add(request); - responseObserver.onNext((CallFunctionResponse) response); + responseObserver.onNext(((CallFunctionResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -159,10 +161,10 @@ public void generateUploadUrl( Object response = responses.remove(); if (response instanceof GenerateUploadUrlResponse) { requests.add(request); - responseObserver.onNext((GenerateUploadUrlResponse) response); + responseObserver.onNext(((GenerateUploadUrlResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -175,10 +177,10 @@ public void generateDownloadUrl( Object response = responses.remove(); if (response instanceof GenerateDownloadUrlResponse) { requests.add(request); - responseObserver.onNext((GenerateDownloadUrlResponse) response); + responseObserver.onNext(((GenerateDownloadUrlResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -189,10 +191,10 @@ public void setIamPolicy(SetIamPolicyRequest request, StreamObserver res Object response = responses.remove(); if (response instanceof Policy) { requests.add(request); - responseObserver.onNext((Policy) response); + responseObserver.onNext(((Policy) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -203,10 +205,10 @@ public void getIamPolicy(GetIamPolicyRequest request, StreamObserver res Object response = responses.remove(); if (response instanceof Policy) { requests.add(request); - responseObserver.onNext((Policy) response); + responseObserver.onNext(((Policy) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -219,10 +221,10 @@ public void testIamPermissions( Object response = responses.remove(); if (response instanceof TestIamPermissionsResponse) { requests.add(request); - responseObserver.onNext((TestIamPermissionsResponse) response); + responseObserver.onNext(((TestIamPermissionsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/grpc-google-cloud-functions-v1/pom.xml b/grpc-google-cloud-functions-v1/pom.xml index d894e383..fb6ae1b5 100644 --- a/grpc-google-cloud-functions-v1/pom.xml +++ b/grpc-google-cloud-functions-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-functions-v1 - 1.0.3 + 1.0.4 grpc-google-cloud-functions-v1 GRPC library for grpc-google-cloud-functions-v1 com.google.cloud google-cloud-functions-parent - 1.0.3 + 1.0.4 diff --git a/pom.xml b/pom.xml index 9eb50ffb..332a883d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-functions-parent pom - 1.0.3 + 1.0.4 Google Cloud Functions Parent https://github.com/googleapis/java-functions @@ -70,23 +70,23 @@ com.google.cloud google-cloud-functions - 1.0.3 + 1.0.4 com.google.api.grpc proto-google-cloud-functions-v1 - 1.0.3 + 1.0.4 com.google.api.grpc grpc-google-cloud-functions-v1 - 1.0.3 + 1.0.4 com.google.cloud google-cloud-shared-dependencies - 0.16.0 + 0.16.1 pom import diff --git a/proto-google-cloud-functions-v1/pom.xml b/proto-google-cloud-functions-v1/pom.xml index fdbce3a8..ad442ca3 100644 --- a/proto-google-cloud-functions-v1/pom.xml +++ b/proto-google-cloud-functions-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-functions-v1 - 1.0.3 + 1.0.4 proto-google-cloud-functions-v1 PROTO library for proto-google-cloud-functions-v1 com.google.cloud google-cloud-functions-parent - 1.0.3 + 1.0.4 diff --git a/proto-google-cloud-functions-v1/src/main/java/com/google/cloud/functions/v1/CloudFunctionName.java b/proto-google-cloud-functions-v1/src/main/java/com/google/cloud/functions/v1/CloudFunctionName.java index c4334f08..ea765514 100644 --- a/proto-google-cloud-functions-v1/src/main/java/com/google/cloud/functions/v1/CloudFunctionName.java +++ b/proto-google-cloud-functions-v1/src/main/java/com/google/cloud/functions/v1/CloudFunctionName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -23,21 +23,33 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class CloudFunctionName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_LOCATION_FUNCTION = PathTemplate.createWithoutUrlEncoding( "projects/{project}/locations/{location}/functions/{function}"); - private volatile Map fieldValuesMap; - private final String project; private final String location; private final String function; + @Deprecated + protected CloudFunctionName() { + project = null; + location = null; + function = null; + } + + private CloudFunctionName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + function = Preconditions.checkNotNull(builder.getFunction()); + } + public String getProject() { return project; } @@ -58,12 +70,6 @@ public Builder toBuilder() { return new Builder(this); } - private CloudFunctionName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - function = Preconditions.checkNotNull(builder.getFunction()); - } - public static CloudFunctionName of(String project, String location, String function) { return newBuilder().setProject(project).setLocation(location).setFunction(function).build(); } @@ -82,7 +88,7 @@ public static CloudFunctionName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_LOCATION_FUNCTION.validatedMatch( formattedString, "CloudFunctionName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("function")); } @@ -96,7 +102,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (CloudFunctionName value : values) { if (value == null) { list.add(""); @@ -108,17 +114,24 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_LOCATION_FUNCTION.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("location", location); - fieldMapBuilder.put("function", function); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + if (function != null) { + fieldMapBuilder.put("function", function); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -132,17 +145,44 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate( + return PROJECT_LOCATION_FUNCTION.instantiate( "project", project, "location", location, "function", function); } - /** Builder for CloudFunctionName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + CloudFunctionName that = ((CloudFunctionName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.function, that.function); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(function); + return h; + } + + /** Builder for projects/{project}/locations/{location}/functions/{function}. */ + public static class Builder { private String project; private String location; private String function; + protected Builder() {} + public String getProject() { return project; } @@ -170,8 +210,6 @@ public Builder setFunction(String function) { return this; } - private Builder() {} - private Builder(CloudFunctionName cloudFunctionName) { project = cloudFunctionName.project; location = cloudFunctionName.location; @@ -182,30 +220,4 @@ public CloudFunctionName build() { return new CloudFunctionName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof CloudFunctionName) { - CloudFunctionName that = (CloudFunctionName) o; - return (this.project.equals(that.project)) - && (this.location.equals(that.location)) - && (this.function.equals(that.function)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= location.hashCode(); - h *= 1000003; - h ^= function.hashCode(); - return h; - } } diff --git a/proto-google-cloud-functions-v1/src/main/java/com/google/cloud/functions/v1/LocationName.java b/proto-google-cloud-functions-v1/src/main/java/com/google/cloud/functions/v1/LocationName.java index 17858662..e919b901 100644 --- a/proto-google-cloud-functions-v1/src/main/java/com/google/cloud/functions/v1/LocationName.java +++ b/proto-google-cloud-functions-v1/src/main/java/com/google/cloud/functions/v1/LocationName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -23,19 +23,29 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; -/** AUTO-GENERATED DOCUMENTATION AND CLASS */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class LocationName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT_LOCATION = PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); - private volatile Map fieldValuesMap; - private final String project; private final String location; + @Deprecated + protected LocationName() { + project = null; + location = null; + } + + private LocationName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + public String getProject() { return project; } @@ -52,11 +62,6 @@ public Builder toBuilder() { return new Builder(this); } - private LocationName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - location = Preconditions.checkNotNull(builder.getLocation()); - } - public static LocationName of(String project, String location) { return newBuilder().setProject(project).setLocation(location).build(); } @@ -70,7 +75,7 @@ public static LocationName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT_LOCATION.validatedMatch( formattedString, "LocationName.parse: formattedString not in valid format"); return of(matchMap.get("project"), matchMap.get("location")); } @@ -84,7 +89,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (LocationName value : values) { if (value == null) { list.add(""); @@ -96,16 +101,21 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_LOCATION.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("location", location); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -119,15 +129,39 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate("project", project, "location", location); + return PROJECT_LOCATION.instantiate("project", project, "location", location); } - /** Builder for LocationName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + LocationName that = ((LocationName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for projects/{project}/locations/{location}. */ + public static class Builder { private String project; private String location; + protected Builder() {} + public String getProject() { return project; } @@ -146,8 +180,6 @@ public Builder setLocation(String location) { return this; } - private Builder() {} - private Builder(LocationName locationName) { project = locationName.project; location = locationName.location; @@ -157,26 +189,4 @@ public LocationName build() { return new LocationName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof LocationName) { - LocationName that = (LocationName) o; - return (this.project.equals(that.project)) && (this.location.equals(that.location)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - h *= 1000003; - h ^= location.hashCode(); - return h; - } } diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index d11fa70e..e3bb7775 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.cloud google-cloud-functions - 1.0.2 + 1.0.3 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index a8008e5c..e12b4f19 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-functions - 1.0.2 + 1.0.3 diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 53ea2fa2..74d49e85 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-functions - 1.0.2 + 1.0.3 diff --git a/synth.metadata b/synth.metadata index 87aeb2d9..cd33cda5 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,22 +4,22 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-functions.git", - "sha": "f3b46631b3aee07c0f75991971b731036be1587b" + "sha": "2e385dd9e300eda6764ebc6a344c8ff2bac48dc0" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "4d52dfb72078000b13de923c1dadec19f3a64ad1", - "internalRef": "324098852" + "sha": "857f70daef9f4c38f042fb3dfb7b8423ae18fd19", + "internalRef": "346372957" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "943bb78606d035001123030067dffcc34f4645f2" + "sha": "5d11bd2888c38ce1fb6fa6bf25494a4219a73928" } } ], diff --git a/versions.txt b/versions.txt index cd6998cd..5aa4ba01 100644 --- a/versions.txt +++ b/versions.txt @@ -1,6 +1,6 @@ # Format: # module:released-version:current-version -google-cloud-functions:1.0.3:1.0.3 -proto-google-cloud-functions-v1:1.0.3:1.0.3 -grpc-google-cloud-functions-v1:1.0.3:1.0.3 +google-cloud-functions:1.0.4:1.0.4 +proto-google-cloud-functions-v1:1.0.4:1.0.4 +grpc-google-cloud-functions-v1:1.0.4:1.0.4