Class CloudFunctionsServiceClient (2.4.3)
Stay organized with collections
Save and categorize content based on your preferences.
- 2.83.0 (latest)
- 2.82.0
- 2.80.0
- 2.78.0
- 2.77.0
- 2.76.0
- 2.75.0
- 2.74.0
- 2.72.0
- 2.70.0
- 2.69.0
- 2.66.0
- 2.65.0
- 2.64.0
- 2.62.0
- 2.61.0
- 2.60.0
- 2.59.0
- 2.58.0
- 2.57.0
- 2.56.0
- 2.55.0
- 2.54.0
- 2.53.0
- 2.51.0
- 2.50.0
- 2.49.0
- 2.48.0
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.39.0
- 2.38.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.0
- 2.33.0
- 2.32.0
- 2.31.0
- 2.30.0
- 2.29.0
- 2.26.0
- 2.25.0
- 2.24.0
- 2.23.0
- 2.22.0
- 2.21.0
- 2.20.0
- 2.19.0
- 2.18.0
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.4
- 2.4.3
- 2.3.6
publicclass CloudFunctionsServiceClientimplementsBackgroundResourceService 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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
CloudFunctionNamename=CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]");
CloudFunctionresponse=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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
CloudFunctionsServiceSettingscloudFunctionsServiceSettings=
CloudFunctionsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
CloudFunctionsServiceSettingscloudFunctionsServiceSettings=
CloudFunctionsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
CloudFunctionsServiceSettingscloudFunctionsServiceSettings=
CloudFunctionsServiceSettings.newBuilder()
.setTransportChannelProvider(
CloudFunctionsServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
.build();
CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceInherited Members
Static Methods
create()
publicstaticfinalCloudFunctionsServiceClientcreate()Constructs an instance of CloudFunctionsServiceClient with default settings.
create(CloudFunctionsServiceSettings settings)
publicstaticfinalCloudFunctionsServiceClientcreate(CloudFunctionsServiceSettingssettings)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.
create(CloudFunctionsServiceStub stub)
publicstaticfinalCloudFunctionsServiceClientcreate(CloudFunctionsServiceStubstub)Constructs an instance of CloudFunctionsServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(CloudFunctionsServiceSettings).
Constructors
CloudFunctionsServiceClient(CloudFunctionsServiceSettings settings)
protectedCloudFunctionsServiceClient(CloudFunctionsServiceSettingssettings)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.
CloudFunctionsServiceClient(CloudFunctionsServiceStub stub)
protectedCloudFunctionsServiceClient(CloudFunctionsServiceStubstub)Methods
awaitTermination(long duration, TimeUnit unit)
publicbooleanawaitTermination(longduration,TimeUnitunit)callFunction(CallFunctionRequest request)
publicfinalCallFunctionResponsecallFunction(CallFunctionRequestrequest)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.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
CallFunctionRequestrequest=
CallFunctionRequest.newBuilder()
.setName(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.setData("data3076010")
.build();
CallFunctionResponseresponse=cloudFunctionsServiceClient.callFunction(request);
}
callFunction(CloudFunctionName name, String data)
publicfinalCallFunctionResponsecallFunction(CloudFunctionNamename,Stringdata)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.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
CloudFunctionNamename=CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]");
Stringdata="data3076010";
CallFunctionResponseresponse=cloudFunctionsServiceClient.callFunction(name,data);
}
callFunction(String name, String data)
publicfinalCallFunctionResponsecallFunction(Stringname,Stringdata)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.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
Stringname=CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString();
Stringdata="data3076010";
CallFunctionResponseresponse=cloudFunctionsServiceClient.callFunction(name,data);
}
callFunctionCallable()
publicfinalUnaryCallable<CallFunctionRequest,CallFunctionResponse>callFunctionCallable()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.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
CallFunctionRequestrequest=
CallFunctionRequest.newBuilder()
.setName(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.setData("data3076010")
.build();
ApiFuture<CallFunctionResponse>future=
cloudFunctionsServiceClient.callFunctionCallable().futureCall(request);
// Do something.
CallFunctionResponseresponse=future.get();
}
close()
publicfinalvoidclose()createFunctionAsync(CreateFunctionRequest request)
publicfinalOperationFuture<CloudFunction,OperationMetadataV1>createFunctionAsync(CreateFunctionRequestrequest)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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
CreateFunctionRequestrequest=
CreateFunctionRequest.newBuilder()
.setLocation(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setFunction(CloudFunction.newBuilder().build())
.build();
CloudFunctionresponse=cloudFunctionsServiceClient.createFunctionAsync(request).get();
}
createFunctionAsync(LocationName location, CloudFunction function)
publicfinalOperationFuture<CloudFunction,OperationMetadataV1>createFunctionAsync(LocationNamelocation,CloudFunctionfunction)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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
LocationNamelocation=LocationName.of("[PROJECT]","[LOCATION]");
CloudFunctionfunction=CloudFunction.newBuilder().build();
CloudFunctionresponse=
cloudFunctionsServiceClient.createFunctionAsync(location,function).get();
}
LocationName Required. The project and location in which the function should be created,
specified in the format projects/*/locations/*
createFunctionAsync(String location, CloudFunction function)
publicfinalOperationFuture<CloudFunction,OperationMetadataV1>createFunctionAsync(Stringlocation,CloudFunctionfunction)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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
Stringlocation=LocationName.of("[PROJECT]","[LOCATION]").toString();
CloudFunctionfunction=CloudFunction.newBuilder().build();
CloudFunctionresponse=
cloudFunctionsServiceClient.createFunctionAsync(location,function).get();
}
String Required. The project and location in which the function should be created,
specified in the format projects/*/locations/*
createFunctionCallable()
publicfinalUnaryCallable<CreateFunctionRequest,Operation>createFunctionCallable()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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
CreateFunctionRequestrequest=
CreateFunctionRequest.newBuilder()
.setLocation(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setFunction(CloudFunction.newBuilder().build())
.build();
ApiFuture<Operation>future=
cloudFunctionsServiceClient.createFunctionCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
createFunctionOperationCallable()
publicfinalOperationCallable<CreateFunctionRequest,CloudFunction,OperationMetadataV1>createFunctionOperationCallable()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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
CreateFunctionRequestrequest=
CreateFunctionRequest.newBuilder()
.setLocation(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setFunction(CloudFunction.newBuilder().build())
.build();
OperationFuture<CloudFunction,OperationMetadataV1>future=
cloudFunctionsServiceClient.createFunctionOperationCallable().futureCall(request);
// Do something.
CloudFunctionresponse=future.get();
}
deleteFunctionAsync(CloudFunctionName name)
publicfinalOperationFuture<Empty,OperationMetadataV1>deleteFunctionAsync(CloudFunctionNamename)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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
CloudFunctionNamename=CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]");
cloudFunctionsServiceClient.deleteFunctionAsync(name).get();
}
deleteFunctionAsync(DeleteFunctionRequest request)
publicfinalOperationFuture<Empty,OperationMetadataV1>deleteFunctionAsync(DeleteFunctionRequestrequest)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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
DeleteFunctionRequestrequest=
DeleteFunctionRequest.newBuilder()
.setName(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.build();
cloudFunctionsServiceClient.deleteFunctionAsync(request).get();
}
deleteFunctionAsync(String name)
publicfinalOperationFuture<Empty,OperationMetadataV1>deleteFunctionAsync(Stringname)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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
Stringname=CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString();
cloudFunctionsServiceClient.deleteFunctionAsync(name).get();
}
deleteFunctionCallable()
publicfinalUnaryCallable<DeleteFunctionRequest,Operation>deleteFunctionCallable()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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
DeleteFunctionRequestrequest=
DeleteFunctionRequest.newBuilder()
.setName(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.build();
ApiFuture<Operation>future=
cloudFunctionsServiceClient.deleteFunctionCallable().futureCall(request);
// Do something.
future.get();
}
deleteFunctionOperationCallable()
publicfinalOperationCallable<DeleteFunctionRequest,Empty,OperationMetadataV1>deleteFunctionOperationCallable()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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
DeleteFunctionRequestrequest=
DeleteFunctionRequest.newBuilder()
.setName(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.build();
OperationFuture<Empty,OperationMetadataV1>future=
cloudFunctionsServiceClient.deleteFunctionOperationCallable().futureCall(request);
// Do something.
future.get();
}
generateDownloadUrl(GenerateDownloadUrlRequest request)
publicfinalGenerateDownloadUrlResponsegenerateDownloadUrl(GenerateDownloadUrlRequestrequest)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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
GenerateDownloadUrlRequestrequest=
GenerateDownloadUrlRequest.newBuilder()
.setName("name3373707")
.setVersionId(-670497310)
.build();
GenerateDownloadUrlResponseresponse=
cloudFunctionsServiceClient.generateDownloadUrl(request);
}
GenerateDownloadUrlRequest The request object containing all of the parameters for the API call.
generateDownloadUrlCallable()
publicfinalUnaryCallable<GenerateDownloadUrlRequest,GenerateDownloadUrlResponse>generateDownloadUrlCallable()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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
GenerateDownloadUrlRequestrequest=
GenerateDownloadUrlRequest.newBuilder()
.setName("name3373707")
.setVersionId(-670497310)
.build();
ApiFuture<GenerateDownloadUrlResponse>future=
cloudFunctionsServiceClient.generateDownloadUrlCallable().futureCall(request);
// Do something.
GenerateDownloadUrlResponseresponse=future.get();
}
generateUploadUrl(GenerateUploadUrlRequest request)
publicfinalGenerateUploadUrlResponsegenerateUploadUrl(GenerateUploadUrlRequestrequest)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 a HTTP PUT request, these two headers need to be specified:
content-type: application/zipx-goog-content-length-range: 0,104857600
And this header SHOULD NOT be specified:
Authorization: Bearer YOUR_TOKEN
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
GenerateUploadUrlRequestrequest=
GenerateUploadUrlRequest.newBuilder()
.setParent("parent-995424086")
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]","[LOCATION]","[KEY_RING]","[CRYPTO_KEY]")
.toString())
.build();
GenerateUploadUrlResponseresponse=cloudFunctionsServiceClient.generateUploadUrl(request);
}
GenerateUploadUrlRequest The request object containing all of the parameters for the API call.
generateUploadUrlCallable()
publicfinalUnaryCallable<GenerateUploadUrlRequest,GenerateUploadUrlResponse>generateUploadUrlCallable()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 a HTTP PUT request, these two headers need to be specified:
content-type: application/zipx-goog-content-length-range: 0,104857600
And this header SHOULD NOT be specified:
Authorization: Bearer YOUR_TOKEN
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
GenerateUploadUrlRequestrequest=
GenerateUploadUrlRequest.newBuilder()
.setParent("parent-995424086")
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]","[LOCATION]","[KEY_RING]","[CRYPTO_KEY]")
.toString())
.build();
ApiFuture<GenerateUploadUrlResponse>future=
cloudFunctionsServiceClient.generateUploadUrlCallable().futureCall(request);
// Do something.
GenerateUploadUrlResponseresponse=future.get();
}
getFunction(CloudFunctionName name)
publicfinalCloudFunctiongetFunction(CloudFunctionNamename)Returns a function with the given name from the requested project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
CloudFunctionNamename=CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]");
CloudFunctionresponse=cloudFunctionsServiceClient.getFunction(name);
}
getFunction(GetFunctionRequest request)
publicfinalCloudFunctiongetFunction(GetFunctionRequestrequest)Returns a function with the given name from the requested project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
GetFunctionRequestrequest=
GetFunctionRequest.newBuilder()
.setName(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.build();
CloudFunctionresponse=cloudFunctionsServiceClient.getFunction(request);
}
getFunction(String name)
publicfinalCloudFunctiongetFunction(Stringname)Returns a function with the given name from the requested project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
Stringname=CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString();
CloudFunctionresponse=cloudFunctionsServiceClient.getFunction(name);
}
getFunctionCallable()
publicfinalUnaryCallable<GetFunctionRequest,CloudFunction>getFunctionCallable()Returns a function with the given name from the requested project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
GetFunctionRequestrequest=
GetFunctionRequest.newBuilder()
.setName(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.build();
ApiFuture<CloudFunction>future=
cloudFunctionsServiceClient.getFunctionCallable().futureCall(request);
// Do something.
CloudFunctionresponse=future.get();
}
getHttpJsonOperationsClient()
publicfinalOperationsClientgetHttpJsonOperationsClient()Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
getIamPolicy(GetIamPolicyRequest request)
publicfinalPolicygetIamPolicy(GetIamPolicyRequestrequest)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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
GetIamPolicyRequestrequest=
GetIamPolicyRequest.newBuilder()
.setResource(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policyresponse=cloudFunctionsServiceClient.getIamPolicy(request);
}
com.google.iam.v1.GetIamPolicyRequestThe request object containing all of the parameters for the API call.
getIamPolicyCallable()
publicfinalUnaryCallable<GetIamPolicyRequest,Policy>getIamPolicyCallable()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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
GetIamPolicyRequestrequest=
GetIamPolicyRequest.newBuilder()
.setResource(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy>future=
cloudFunctionsServiceClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policyresponse=future.get();
}
getOperationsClient()
publicfinalOperationsClientgetOperationsClient()Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
getSettings()
publicfinalCloudFunctionsServiceSettingsgetSettings()getStub()
publicCloudFunctionsServiceStubgetStub()isShutdown()
publicbooleanisShutdown()isTerminated()
publicbooleanisTerminated()listFunctions(ListFunctionsRequest request)
publicfinalCloudFunctionsServiceClient.ListFunctionsPagedResponselistFunctions(ListFunctionsRequestrequest)Returns a list of functions that belong to the requested project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
ListFunctionsRequestrequest=
ListFunctionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for(CloudFunctionelement:
cloudFunctionsServiceClient.listFunctions(request).iterateAll()){
// doThingsWith(element);
}
}
listFunctionsCallable()
publicfinalUnaryCallable<ListFunctionsRequest,ListFunctionsResponse>listFunctionsCallable()Returns a list of functions that belong to the requested project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
ListFunctionsRequestrequest=
ListFunctionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while(true){
ListFunctionsResponseresponse=
cloudFunctionsServiceClient.listFunctionsCallable().call(request);
for(CloudFunctionelement:response.getFunctionsList()){
// doThingsWith(element);
}
StringnextPageToken=response.getNextPageToken();
if(!Strings.isNullOrEmpty(nextPageToken)){
request=request.toBuilder().setPageToken(nextPageToken).build();
}else{
break;
}
}
}
listFunctionsPagedCallable()
publicfinalUnaryCallable<ListFunctionsRequest,CloudFunctionsServiceClient.ListFunctionsPagedResponse>listFunctionsPagedCallable()Returns a list of functions that belong to the requested project.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
ListFunctionsRequestrequest=
ListFunctionsRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]","[LOCATION]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<CloudFunction>future=
cloudFunctionsServiceClient.listFunctionsPagedCallable().futureCall(request);
// Do something.
for(CloudFunctionelement:future.get().iterateAll()){
// doThingsWith(element);
}
}
setIamPolicy(SetIamPolicyRequest request)
publicfinalPolicysetIamPolicy(SetIamPolicyRequestrequest)Sets the IAM access control policy on the specified function. Replaces any existing policy.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
SetIamPolicyRequestrequest=
SetIamPolicyRequest.newBuilder()
.setResource(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Policyresponse=cloudFunctionsServiceClient.setIamPolicy(request);
}
com.google.iam.v1.SetIamPolicyRequestThe request object containing all of the parameters for the API call.
setIamPolicyCallable()
publicfinalUnaryCallable<SetIamPolicyRequest,Policy>setIamPolicyCallable()Sets the IAM access control policy on the specified function. Replaces any existing policy.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
SetIamPolicyRequestrequest=
SetIamPolicyRequest.newBuilder()
.setResource(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Policy>future=
cloudFunctionsServiceClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policyresponse=future.get();
}
shutdown()
publicvoidshutdown()shutdownNow()
publicvoidshutdownNow()testIamPermissions(TestIamPermissionsRequest request)
publicfinalTestIamPermissionsResponsetestIamPermissions(TestIamPermissionsRequestrequest)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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
TestIamPermissionsRequestrequest=
TestIamPermissionsRequest.newBuilder()
.setResource(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.addAllPermissions(newArrayList<String>())
.build();
TestIamPermissionsResponseresponse=cloudFunctionsServiceClient.testIamPermissions(request);
}
com.google.iam.v1.TestIamPermissionsRequestThe request object containing all of the parameters for the API call.
testIamPermissionsCallable()
publicfinalUnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse>testIamPermissionsCallable()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:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
TestIamPermissionsRequestrequest=
TestIamPermissionsRequest.newBuilder()
.setResource(CloudFunctionName.of("[PROJECT]","[LOCATION]","[FUNCTION]").toString())
.addAllPermissions(newArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse>future=
cloudFunctionsServiceClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponseresponse=future.get();
}
updateFunctionAsync(CloudFunction function)
publicfinalOperationFuture<CloudFunction,OperationMetadataV1>updateFunctionAsync(CloudFunctionfunction)Updates existing function.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
CloudFunctionfunction=CloudFunction.newBuilder().build();
CloudFunctionresponse=cloudFunctionsServiceClient.updateFunctionAsync(function).get();
}
updateFunctionAsync(UpdateFunctionRequest request)
publicfinalOperationFuture<CloudFunction,OperationMetadataV1>updateFunctionAsync(UpdateFunctionRequestrequest)Updates existing function.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
UpdateFunctionRequestrequest=
UpdateFunctionRequest.newBuilder()
.setFunction(CloudFunction.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
CloudFunctionresponse=cloudFunctionsServiceClient.updateFunctionAsync(request).get();
}
updateFunctionCallable()
publicfinalUnaryCallable<UpdateFunctionRequest,Operation>updateFunctionCallable()Updates existing function.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
UpdateFunctionRequestrequest=
UpdateFunctionRequest.newBuilder()
.setFunction(CloudFunction.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Operation>future=
cloudFunctionsServiceClient.updateFunctionCallable().futureCall(request);
// Do something.
Operationresponse=future.get();
}
updateFunctionOperationCallable()
publicfinalOperationCallable<UpdateFunctionRequest,CloudFunction,OperationMetadataV1>updateFunctionOperationCallable()Updates existing function.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try(CloudFunctionsServiceClientcloudFunctionsServiceClient=
CloudFunctionsServiceClient.create()){
UpdateFunctionRequestrequest=
UpdateFunctionRequest.newBuilder()
.setFunction(CloudFunction.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
OperationFuture<CloudFunction,OperationMetadataV1>future=
cloudFunctionsServiceClient.updateFunctionOperationCallable().futureCall(request);
// Do something.
CloudFunctionresponse=future.get();
}