com.google.cloud.functions.v1.CloudFunctionsServiceClient Maven / Gradle / Ivy
Show all versions of google-cloud-functions Show documentation
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.functions.v1;
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.functions.v1.stub.CloudFunctionsServiceStub;
import com.google.cloud.functions.v1.stub.CloudFunctionsServiceStubSettings;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.cloud.location.Location;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* 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
* resources such as threads. In the example above, try-with-resources is used, which automatically
* calls close().
*
*
The surface of this class includes several types of Java methods for each of the API's
* methods:
*
*
* - A "flattened" method. With this type of method, the fields of the request type have been
* converted into function parameters. It may be the case that not all fields are available as
* parameters, and not every API method will have a flattened method entry point.
*
- A "request object" method. This type of method only takes one parameter, a request object,
* which must be constructed before the call. Not every API method will have a request object
* method.
*
- A "callable" method. This type of method takes no parameters and returns an immutable API
* callable object, which can be used to initiate calls to the service.
*
*
* See the individual methods for example code.
*
*
Many parameters require resource names to be formatted in a particular way. To assist with
* these names, this class includes a format method for each type of name, and additionally a parse
* method to extract the individual identifiers contained within names that are returned.
*
*
This class can be customized by passing in a custom instance of CloudFunctionsServiceSettings
* to create(). For example:
*
*
To customize credentials:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* CloudFunctionsServiceSettings cloudFunctionsServiceSettings =
* CloudFunctionsServiceSettings.newBuilder()
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
* .build();
* CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
* }
*
* To customize the endpoint:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* CloudFunctionsServiceSettings cloudFunctionsServiceSettings =
* CloudFunctionsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
* CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
* }
*
* To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
* the wire:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* CloudFunctionsServiceSettings cloudFunctionsServiceSettings =
* CloudFunctionsServiceSettings.newHttpJsonBuilder().build();
* CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
* }
*
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class CloudFunctionsServiceClient implements BackgroundResource {
private final CloudFunctionsServiceSettings settings;
private final CloudFunctionsServiceStub stub;
private final OperationsClient httpJsonOperationsClient;
private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of CloudFunctionsServiceClient with default settings. */
public static final CloudFunctionsServiceClient create() throws IOException {
return create(CloudFunctionsServiceSettings.newBuilder().build());
}
/**
* Constructs an instance of CloudFunctionsServiceClient, using the given settings. The channels
* are created based on the settings passed in, or defaults for any settings that are not set.
*/
public static final CloudFunctionsServiceClient create(CloudFunctionsServiceSettings settings)
throws IOException {
return new CloudFunctionsServiceClient(settings);
}
/**
* Constructs an instance of CloudFunctionsServiceClient, using the given stub for making calls.
* This is for advanced usage - prefer using create(CloudFunctionsServiceSettings).
*/
public static final CloudFunctionsServiceClient create(CloudFunctionsServiceStub stub) {
return new CloudFunctionsServiceClient(stub);
}
/**
* Constructs an instance of CloudFunctionsServiceClient, using the given settings. This is
* protected so that it is easy to make a subclass, but otherwise, the static factory methods
* should be preferred.
*/
protected CloudFunctionsServiceClient(CloudFunctionsServiceSettings settings) throws IOException {
this.settings = settings;
this.stub = ((CloudFunctionsServiceStubSettings) settings.getStubSettings()).createStub();
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
protected CloudFunctionsServiceClient(CloudFunctionsServiceStub stub) {
this.settings = null;
this.stub = stub;
this.operationsClient =
com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
public final CloudFunctionsServiceSettings getSettings() {
return settings;
}
public CloudFunctionsServiceStub getStub() {
return stub;
}
/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}
/**
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
@BetaApi
public final OperationsClient getHttpJsonOperationsClient() {
return httpJsonOperationsClient;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a list of functions that belong to the requested project.
*
*
Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* ListFunctionsRequest request =
* ListFunctionsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .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
*/
public final ListFunctionsPagedResponse listFunctions(ListFunctionsRequest request) {
return listFunctionsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a list of functions that belong to the requested project.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* ListFunctionsRequest request =
* ListFunctionsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* ApiFuture 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.
/**
* Returns a list of functions that belong to the requested project.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* ListFunctionsRequest request =
* ListFunctionsRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .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.
/**
* Returns a function with the given name from the requested project.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* 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
*/
public final CloudFunction getFunction(CloudFunctionName name) {
GetFunctionRequest request =
GetFunctionRequest.newBuilder().setName(name == null ? null : name.toString()).build();
return getFunction(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a function with the given name from the requested project.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* String name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString();
* 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
*/
public final CloudFunction getFunction(String name) {
GetFunctionRequest request = GetFunctionRequest.newBuilder().setName(name).build();
return getFunction(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a function with the given name from the requested project.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* GetFunctionRequest request =
* GetFunctionRequest.newBuilder()
* .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").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
*/
public final CloudFunction getFunction(GetFunctionRequest request) {
return getFunctionCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Returns a function with the given name from the requested project.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* GetFunctionRequest request =
* GetFunctionRequest.newBuilder()
* .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.getFunctionCallable().futureCall(request);
* // Do something.
* CloudFunction response = future.get();
* }
* }
*/
public final UnaryCallable getFunctionCallable() {
return stub.getFunctionCallable();
}
// 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 returns an `ALREADY_EXISTS` error.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* 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
*/
public final OperationFuture createFunctionAsync(
LocationName location, CloudFunction function) {
CreateFunctionRequest request =
CreateFunctionRequest.newBuilder()
.setLocation(location == null ? null : location.toString())
.setFunction(function)
.build();
return createFunctionAsync(request);
}
// 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 returns an `ALREADY_EXISTS` error.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* String location = LocationName.of("[PROJECT]", "[LOCATION]").toString();
* 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
*/
public final OperationFuture createFunctionAsync(
String location, CloudFunction function) {
CreateFunctionRequest request =
CreateFunctionRequest.newBuilder().setLocation(location).setFunction(function).build();
return createFunctionAsync(request);
}
// 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 returns an `ALREADY_EXISTS` error.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* CreateFunctionRequest request =
* CreateFunctionRequest.newBuilder()
* .setLocation(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setFunction(CloudFunction.newBuilder().build())
* .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
*/
public final OperationFuture createFunctionAsync(
CreateFunctionRequest request) {
return createFunctionOperationCallable().futureCall(request);
}
// 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 returns an `ALREADY_EXISTS` error.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* CreateFunctionRequest request =
* CreateFunctionRequest.newBuilder()
* .setLocation(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setFunction(CloudFunction.newBuilder().build())
* .build();
* OperationFuture future =
* cloudFunctionsServiceClient.createFunctionOperationCallable().futureCall(request);
* // Do something.
* CloudFunction response = future.get();
* }
* }
*/
public final OperationCallable
createFunctionOperationCallable() {
return stub.createFunctionOperationCallable();
}
// 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 returns an `ALREADY_EXISTS` error.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* CreateFunctionRequest request =
* CreateFunctionRequest.newBuilder()
* .setLocation(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setFunction(CloudFunction.newBuilder().build())
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.createFunctionCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable createFunctionCallable() {
return stub.createFunctionCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates existing function.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* 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
*/
public final OperationFuture updateFunctionAsync(
CloudFunction function) {
UpdateFunctionRequest request =
UpdateFunctionRequest.newBuilder().setFunction(function).build();
return updateFunctionAsync(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates existing function.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* UpdateFunctionRequest request =
* UpdateFunctionRequest.newBuilder()
* .setFunction(CloudFunction.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .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
*/
public final OperationFuture updateFunctionAsync(
UpdateFunctionRequest request) {
return updateFunctionOperationCallable().futureCall(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates existing function.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* UpdateFunctionRequest request =
* UpdateFunctionRequest.newBuilder()
* .setFunction(CloudFunction.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* OperationFuture future =
* cloudFunctionsServiceClient.updateFunctionOperationCallable().futureCall(request);
* // Do something.
* CloudFunction response = future.get();
* }
* }
*/
public final OperationCallable
updateFunctionOperationCallable() {
return stub.updateFunctionOperationCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Updates existing function.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* UpdateFunctionRequest request =
* UpdateFunctionRequest.newBuilder()
* .setFunction(CloudFunction.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.updateFunctionCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }
*/
public final UnaryCallable updateFunctionCallable() {
return stub.updateFunctionCallable();
}
// 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 is updated to remove this function.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* 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
*/
public final OperationFuture deleteFunctionAsync(
CloudFunctionName name) {
DeleteFunctionRequest request =
DeleteFunctionRequest.newBuilder().setName(name == null ? null : name.toString()).build();
return deleteFunctionAsync(request);
}
// 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 is updated to remove this function.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* String name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString();
* 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
*/
public final OperationFuture deleteFunctionAsync(String name) {
DeleteFunctionRequest request = DeleteFunctionRequest.newBuilder().setName(name).build();
return deleteFunctionAsync(request);
}
// 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 is updated to remove this function.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* DeleteFunctionRequest request =
* DeleteFunctionRequest.newBuilder()
* .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").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
*/
public final OperationFuture deleteFunctionAsync(
DeleteFunctionRequest request) {
return deleteFunctionOperationCallable().futureCall(request);
}
// 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 is updated to remove this function.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* DeleteFunctionRequest request =
* DeleteFunctionRequest.newBuilder()
* .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .build();
* OperationFuture future =
* cloudFunctionsServiceClient.deleteFunctionOperationCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }
*/
public final OperationCallable
deleteFunctionOperationCallable() {
return stub.deleteFunctionOperationCallable();
}
// 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 is updated to remove this function.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* DeleteFunctionRequest request =
* DeleteFunctionRequest.newBuilder()
* .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.deleteFunctionCallable().futureCall(request);
* // Do something.
* future.get();
* }
* }
*/
public final UnaryCallable deleteFunctionCallable() {
return stub.deleteFunctionCallable();
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* CloudFunctionName name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]");
* String data = "data3076010";
* 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
*/
public final CallFunctionResponse callFunction(CloudFunctionName name, String data) {
CallFunctionRequest request =
CallFunctionRequest.newBuilder()
.setName(name == null ? null : name.toString())
.setData(data)
.build();
return callFunction(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* String name = CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString();
* String data = "data3076010";
* 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
*/
public final CallFunctionResponse callFunction(String name, String data) {
CallFunctionRequest request =
CallFunctionRequest.newBuilder().setName(name).setData(data).build();
return callFunction(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* CallFunctionRequest request =
* CallFunctionRequest.newBuilder()
* .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .setData("data3076010")
* .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
*/
public final CallFunctionResponse callFunction(CallFunctionRequest request) {
return callFunctionCallable().call(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* CallFunctionRequest request =
* CallFunctionRequest.newBuilder()
* .setName(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .setData("data3076010")
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.callFunctionCallable().futureCall(request);
* // Do something.
* CallFunctionResponse response = future.get();
* }
* }
*/
public final UnaryCallable callFunctionCallable() {
return stub.callFunctionCallable();
}
// 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
* the function source code upload is complete, the used signed URL should be provided in
* CreateFunction or UpdateFunction request as a reference to the function source code.
*
* 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.
*
*
* When making an HTTP PUT request, these two headers must be specified:
*
*
* - `content-type: application/zip`
*
- `x-goog-content-length-range: 0,104857600`
*
*
* And this header must NOT be specified:
*
*
* - `Authorization: Bearer YOUR_TOKEN`
*
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* GenerateUploadUrlRequest request =
* GenerateUploadUrlRequest.newBuilder()
* .setParent("parent-995424086")
* .setKmsKeyName(
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
* .toString())
* .build();
* GenerateUploadUrlResponse response = cloudFunctionsServiceClient.generateUploadUrl(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
*/
public final GenerateUploadUrlResponse generateUploadUrl(GenerateUploadUrlRequest request) {
return generateUploadUrlCallable().call(request);
}
// 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
* the function source code upload is complete, the used signed URL should be provided in
* CreateFunction or UpdateFunction request as a reference to the function source code.
*
* 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.
*
*
* When making an HTTP PUT request, these two headers must be specified:
*
*
* - `content-type: application/zip`
*
- `x-goog-content-length-range: 0,104857600`
*
*
* And this header must NOT be specified:
*
*
* - `Authorization: Bearer YOUR_TOKEN`
*
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* GenerateUploadUrlRequest request =
* GenerateUploadUrlRequest.newBuilder()
* .setParent("parent-995424086")
* .setKmsKeyName(
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
* .toString())
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.generateUploadUrlCallable().futureCall(request);
* // Do something.
* GenerateUploadUrlResponse response = future.get();
* }
* }
*/
public final UnaryCallable
generateUploadUrlCallable() {
return stub.generateUploadUrlCallable();
}
// 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 must 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* GenerateDownloadUrlRequest request =
* GenerateDownloadUrlRequest.newBuilder()
* .setName("name3373707")
* .setVersionId(-670497310)
* .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
*/
public final GenerateDownloadUrlResponse generateDownloadUrl(GenerateDownloadUrlRequest request) {
return generateDownloadUrlCallable().call(request);
}
// 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 must 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* GenerateDownloadUrlRequest request =
* GenerateDownloadUrlRequest.newBuilder()
* .setName("name3373707")
* .setVersionId(-670497310)
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.generateDownloadUrlCallable().futureCall(request);
* // Do something.
* GenerateDownloadUrlResponse response = future.get();
* }
* }
*/
public final UnaryCallable
generateDownloadUrlCallable() {
return stub.generateDownloadUrlCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the IAM access control policy on the specified function. Replaces any existing policy.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* SetIamPolicyRequest request =
* SetIamPolicyRequest.newBuilder()
* .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .setPolicy(Policy.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .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
*/
public final Policy setIamPolicy(SetIamPolicyRequest request) {
return setIamPolicyCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Sets the IAM access control policy on the specified function. Replaces any existing policy.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* SetIamPolicyRequest request =
* SetIamPolicyRequest.newBuilder()
* .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .setPolicy(Policy.newBuilder().build())
* .setUpdateMask(FieldMask.newBuilder().build())
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.setIamPolicyCallable().futureCall(request);
* // Do something.
* Policy response = future.get();
* }
* }
*/
public final UnaryCallable setIamPolicyCallable() {
return stub.setIamPolicyCallable();
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* GetIamPolicyRequest request =
* GetIamPolicyRequest.newBuilder()
* .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .setOptions(GetPolicyOptions.newBuilder().build())
* .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
*/
public final Policy getIamPolicy(GetIamPolicyRequest request) {
return getIamPolicyCallable().call(request);
}
// 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:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* GetIamPolicyRequest request =
* GetIamPolicyRequest.newBuilder()
* .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .setOptions(GetPolicyOptions.newBuilder().build())
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.getIamPolicyCallable().futureCall(request);
* // Do something.
* Policy response = future.get();
* }
* }
*/
public final UnaryCallable getIamPolicyCallable() {
return stub.getIamPolicyCallable();
}
// 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 returns an empty set of permissions, not a NOT_FOUND error.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* TestIamPermissionsRequest request =
* TestIamPermissionsRequest.newBuilder()
* .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .addAllPermissions(new ArrayList())
* .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
*/
public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) {
return testIamPermissionsCallable().call(request);
}
// 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 returns an empty set of permissions, not a NOT_FOUND error.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* TestIamPermissionsRequest request =
* TestIamPermissionsRequest.newBuilder()
* .setResource(CloudFunctionName.of("[PROJECT]", "[LOCATION]", "[FUNCTION]").toString())
* .addAllPermissions(new ArrayList())
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.testIamPermissionsCallable().futureCall(request);
* // Do something.
* TestIamPermissionsResponse response = future.get();
* }
* }
*/
public final UnaryCallable
testIamPermissionsCallable() {
return stub.testIamPermissionsCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* ListLocationsRequest request =
* ListLocationsRequest.newBuilder()
* .setName("name3373707")
* .setFilter("filter-1274492040")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* for (Location element : cloudFunctionsServiceClient.listLocations(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
*/
public final ListLocationsPagedResponse listLocations(ListLocationsRequest request) {
return listLocationsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* ListLocationsRequest request =
* ListLocationsRequest.newBuilder()
* .setName("name3373707")
* .setFilter("filter-1274492040")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* ApiFuture future =
* cloudFunctionsServiceClient.listLocationsPagedCallable().futureCall(request);
* // Do something.
* for (Location element : future.get().iterateAll()) {
* // doThingsWith(element);
* }
* }
* }
*/
public final UnaryCallable
listLocationsPagedCallable() {
return stub.listLocationsPagedCallable();
}
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists information about the supported locations for this service.
*
* Sample code:
*
*
{@code
* // This snippet has been automatically generated and should be regarded as a code template only.
* // It will require modifications to work:
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* ListLocationsRequest request =
* ListLocationsRequest.newBuilder()
* .setName("name3373707")
* .setFilter("filter-1274492040")
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .build();
* while (true) {
* ListLocationsResponse response =
* cloudFunctionsServiceClient.listLocationsCallable().call(request);
* for (Location element : response.getLocationsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
* if (!Strings.isNullOrEmpty(nextPageToken)) {
* request = request.toBuilder().setPageToken(nextPageToken).build();
* } else {
* break;
* }
* }
* }
* }
*/
public final UnaryCallable listLocationsCallable() {
return stub.listLocationsCallable();
}
@Override
public final void close() {
stub.close();
}
@Override
public void shutdown() {
stub.shutdown();
}
@Override
public boolean isShutdown() {
return stub.isShutdown();
}
@Override
public boolean isTerminated() {
return stub.isTerminated();
}
@Override
public void shutdownNow() {
stub.shutdownNow();
}
@Override
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
return stub.awaitTermination(duration, unit);
}
public static class ListFunctionsPagedResponse
extends AbstractPagedListResponse<
ListFunctionsRequest,
ListFunctionsResponse,
CloudFunction,
ListFunctionsPage,
ListFunctionsFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListFunctionsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListFunctionsPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListFunctionsPagedResponse(ListFunctionsPage page) {
super(page, ListFunctionsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListFunctionsPage
extends AbstractPage<
ListFunctionsRequest, ListFunctionsResponse, CloudFunction, ListFunctionsPage> {
private ListFunctionsPage(
PageContext context,
ListFunctionsResponse response) {
super(context, response);
}
private static ListFunctionsPage createEmptyPage() {
return new ListFunctionsPage(null, null);
}
@Override
protected ListFunctionsPage createPage(
PageContext context,
ListFunctionsResponse response) {
return new ListFunctionsPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListFunctionsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListFunctionsRequest,
ListFunctionsResponse,
CloudFunction,
ListFunctionsPage,
ListFunctionsFixedSizeCollection> {
private ListFunctionsFixedSizeCollection(List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListFunctionsFixedSizeCollection createEmptyCollection() {
return new ListFunctionsFixedSizeCollection(null, 0);
}
@Override
protected ListFunctionsFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListFunctionsFixedSizeCollection(pages, collectionSize);
}
}
public static class ListLocationsPagedResponse
extends AbstractPagedListResponse<
ListLocationsRequest,
ListLocationsResponse,
Location,
ListLocationsPage,
ListLocationsFixedSizeCollection> {
public static ApiFuture createAsync(
PageContext context,
ApiFuture futureResponse) {
ApiFuture futurePage =
ListLocationsPage.createEmptyPage().createPageAsync(context, futureResponse);
return ApiFutures.transform(
futurePage,
input -> new ListLocationsPagedResponse(input),
MoreExecutors.directExecutor());
}
private ListLocationsPagedResponse(ListLocationsPage page) {
super(page, ListLocationsFixedSizeCollection.createEmptyCollection());
}
}
public static class ListLocationsPage
extends AbstractPage<
ListLocationsRequest, ListLocationsResponse, Location, ListLocationsPage> {
private ListLocationsPage(
PageContext context,
ListLocationsResponse response) {
super(context, response);
}
private static ListLocationsPage createEmptyPage() {
return new ListLocationsPage(null, null);
}
@Override
protected ListLocationsPage createPage(
PageContext context,
ListLocationsResponse response) {
return new ListLocationsPage(context, response);
}
@Override
public ApiFuture createPageAsync(
PageContext context,
ApiFuture futureResponse) {
return super.createPageAsync(context, futureResponse);
}
}
public static class ListLocationsFixedSizeCollection
extends AbstractFixedSizeCollection<
ListLocationsRequest,
ListLocationsResponse,
Location,
ListLocationsPage,
ListLocationsFixedSizeCollection> {
private ListLocationsFixedSizeCollection(List pages, int collectionSize) {
super(pages, collectionSize);
}
private static ListLocationsFixedSizeCollection createEmptyCollection() {
return new ListLocationsFixedSizeCollection(null, 0);
}
@Override
protected ListLocationsFixedSizeCollection createCollection(
List pages, int collectionSize) {
return new ListLocationsFixedSizeCollection(pages, collectionSize);
}
}
}