@BetaApi @Generated(value="by gapic-generator-java") public class WebhooksClient extends Object implements com.google.api.gax.core.BackgroundResource
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 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
WebhookName name = WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]");
Webhook response = webhooksClient.getWebhook(name);
}
Note: close() needs to be called on the WebhooksClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
ListWebhooks |
Returns the list of all webhooks in the specified agent. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetWebhook |
Retrieves the specified webhook. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateWebhook |
Creates a webhook in the specified agent. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateWebhook |
Updates the specified webhook. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteWebhook |
Deletes the specified webhook. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListLocations |
Lists information about the supported locations for this service. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetLocation |
Gets information about a location. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return 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 WebhooksSettings to create(). For example:
To customize credentials:
// 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
WebhooksSettings webhooksSettings =
WebhooksSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
WebhooksClient webhooksClient = WebhooksClient.create(webhooksSettings);
To customize the endpoint:
// 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
WebhooksSettings webhooksSettings =
WebhooksSettings.newBuilder().setEndpoint(myEndpoint).build();
WebhooksClient webhooksClient = WebhooksClient.create(webhooksSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// 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
WebhooksSettings webhooksSettings = WebhooksSettings.newHttpJsonBuilder().build();
WebhooksClient webhooksClient = WebhooksClient.create(webhooksSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
WebhooksClient.ListLocationsFixedSizeCollection |
static class |
WebhooksClient.ListLocationsPage |
static class |
WebhooksClient.ListLocationsPagedResponse |
static class |
WebhooksClient.ListWebhooksFixedSizeCollection |
static class |
WebhooksClient.ListWebhooksPage |
static class |
WebhooksClient.ListWebhooksPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
WebhooksClient(WebhooksSettings settings)
Constructs an instance of WebhooksClient, using the given settings.
|
protected |
WebhooksClient(WebhooksStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static WebhooksClient |
create()
Constructs an instance of WebhooksClient with default settings.
|
static WebhooksClient |
create(WebhooksSettings settings)
Constructs an instance of WebhooksClient, using the given settings.
|
static WebhooksClient |
create(WebhooksStub stub)
Constructs an instance of WebhooksClient, using the given stub for making calls.
|
Webhook |
createWebhook(AgentName parent,
Webhook webhook)
Creates a webhook in the specified agent.
|
Webhook |
createWebhook(CreateWebhookRequest request)
Creates a webhook in the specified agent.
|
Webhook |
createWebhook(String parent,
Webhook webhook)
Creates a webhook in the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<CreateWebhookRequest,Webhook> |
createWebhookCallable()
Creates a webhook in the specified agent.
|
void |
deleteWebhook(DeleteWebhookRequest request)
Deletes the specified webhook.
|
void |
deleteWebhook(String name)
Deletes the specified webhook.
|
void |
deleteWebhook(WebhookName name)
Deletes the specified webhook.
|
com.google.api.gax.rpc.UnaryCallable<DeleteWebhookRequest,com.google.protobuf.Empty> |
deleteWebhookCallable()
Deletes the specified webhook.
|
com.google.cloud.location.Location |
getLocation(com.google.cloud.location.GetLocationRequest request)
Gets information about a location.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> |
getLocationCallable()
Gets information about a location.
|
WebhooksSettings |
getSettings() |
WebhooksStub |
getStub() |
Webhook |
getWebhook(GetWebhookRequest request)
Retrieves the specified webhook.
|
Webhook |
getWebhook(String name)
Retrieves the specified webhook.
|
Webhook |
getWebhook(WebhookName name)
Retrieves the specified webhook.
|
com.google.api.gax.rpc.UnaryCallable<GetWebhookRequest,Webhook> |
getWebhookCallable()
Retrieves the specified webhook.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
WebhooksClient.ListLocationsPagedResponse |
listLocations(com.google.cloud.location.ListLocationsRequest request)
Lists information about the supported locations for this service.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> |
listLocationsCallable()
Lists information about the supported locations for this service.
|
com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,WebhooksClient.ListLocationsPagedResponse> |
listLocationsPagedCallable()
Lists information about the supported locations for this service.
|
WebhooksClient.ListWebhooksPagedResponse |
listWebhooks(AgentName parent)
Returns the list of all webhooks in the specified agent.
|
WebhooksClient.ListWebhooksPagedResponse |
listWebhooks(ListWebhooksRequest request)
Returns the list of all webhooks in the specified agent.
|
WebhooksClient.ListWebhooksPagedResponse |
listWebhooks(String parent)
Returns the list of all webhooks in the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<ListWebhooksRequest,ListWebhooksResponse> |
listWebhooksCallable()
Returns the list of all webhooks in the specified agent.
|
com.google.api.gax.rpc.UnaryCallable<ListWebhooksRequest,WebhooksClient.ListWebhooksPagedResponse> |
listWebhooksPagedCallable()
Returns the list of all webhooks in the specified agent.
|
void |
shutdown() |
void |
shutdownNow() |
Webhook |
updateWebhook(UpdateWebhookRequest request)
Updates the specified webhook.
|
Webhook |
updateWebhook(Webhook webhook,
com.google.protobuf.FieldMask updateMask)
Updates the specified webhook.
|
com.google.api.gax.rpc.UnaryCallable<UpdateWebhookRequest,Webhook> |
updateWebhookCallable()
Updates the specified webhook.
|
protected WebhooksClient(WebhooksSettings settings) throws IOException
IOExceptionprotected WebhooksClient(WebhooksStub stub)
public static final WebhooksClient create() throws IOException
IOExceptionpublic static final WebhooksClient create(WebhooksSettings settings) throws IOException
IOExceptionpublic static final WebhooksClient create(WebhooksStub stub)
public final WebhooksSettings getSettings()
public WebhooksStub getStub()
public final WebhooksClient.ListWebhooksPagedResponse listWebhooks(AgentName parent)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
for (Webhook element : webhooksClient.listWebhooks(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The agent to list all webhooks for. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final WebhooksClient.ListWebhooksPagedResponse listWebhooks(String parent)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
String parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
for (Webhook element : webhooksClient.listWebhooks(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The agent to list all webhooks for. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final WebhooksClient.ListWebhooksPagedResponse listWebhooks(ListWebhooksRequest request)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
ListWebhooksRequest request =
ListWebhooksRequest.newBuilder()
.setParent(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Webhook element : webhooksClient.listWebhooks(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListWebhooksRequest,WebhooksClient.ListWebhooksPagedResponse> listWebhooksPagedCallable()
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
ListWebhooksRequest request =
ListWebhooksRequest.newBuilder()
.setParent(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Webhook> future = webhooksClient.listWebhooksPagedCallable().futureCall(request);
// Do something.
for (Webhook element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListWebhooksRequest,ListWebhooksResponse> listWebhooksCallable()
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
ListWebhooksRequest request =
ListWebhooksRequest.newBuilder()
.setParent(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListWebhooksResponse response = webhooksClient.listWebhooksCallable().call(request);
for (Webhook element : response.getWebhooksList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Webhook getWebhook(WebhookName name)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
WebhookName name = WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]");
Webhook response = webhooksClient.getWebhook(name);
}
name - Required. The name of the webhook. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/webhooks/<WebhookID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Webhook getWebhook(String name)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
String name = WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]").toString();
Webhook response = webhooksClient.getWebhook(name);
}
name - Required. The name of the webhook. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/webhooks/<WebhookID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Webhook getWebhook(GetWebhookRequest request)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
GetWebhookRequest request =
GetWebhookRequest.newBuilder()
.setName(WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]").toString())
.build();
Webhook response = webhooksClient.getWebhook(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetWebhookRequest,Webhook> getWebhookCallable()
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
GetWebhookRequest request =
GetWebhookRequest.newBuilder()
.setName(WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]").toString())
.build();
ApiFuture<Webhook> future = webhooksClient.getWebhookCallable().futureCall(request);
// Do something.
Webhook response = future.get();
}
public final Webhook createWebhook(AgentName parent, Webhook webhook)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
Webhook webhook = Webhook.newBuilder().build();
Webhook response = webhooksClient.createWebhook(parent, webhook);
}
parent - Required. The agent to create a webhook for. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.webhook - Required. The webhook to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Webhook createWebhook(String parent, Webhook webhook)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
String parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
Webhook webhook = Webhook.newBuilder().build();
Webhook response = webhooksClient.createWebhook(parent, webhook);
}
parent - Required. The agent to create a webhook for. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`.webhook - Required. The webhook to create.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Webhook createWebhook(CreateWebhookRequest request)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
CreateWebhookRequest request =
CreateWebhookRequest.newBuilder()
.setParent(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setWebhook(Webhook.newBuilder().build())
.build();
Webhook response = webhooksClient.createWebhook(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreateWebhookRequest,Webhook> createWebhookCallable()
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
CreateWebhookRequest request =
CreateWebhookRequest.newBuilder()
.setParent(AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString())
.setWebhook(Webhook.newBuilder().build())
.build();
ApiFuture<Webhook> future = webhooksClient.createWebhookCallable().futureCall(request);
// Do something.
Webhook response = future.get();
}
public final Webhook updateWebhook(Webhook webhook, com.google.protobuf.FieldMask updateMask)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
Webhook webhook = Webhook.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Webhook response = webhooksClient.updateWebhook(webhook, updateMask);
}
webhook - Required. The webhook to update.updateMask - The mask to control which fields get updated. If the mask is not present, all
fields will be updated.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Webhook updateWebhook(UpdateWebhookRequest request)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
UpdateWebhookRequest request =
UpdateWebhookRequest.newBuilder()
.setWebhook(Webhook.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Webhook response = webhooksClient.updateWebhook(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<UpdateWebhookRequest,Webhook> updateWebhookCallable()
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
UpdateWebhookRequest request =
UpdateWebhookRequest.newBuilder()
.setWebhook(Webhook.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Webhook> future = webhooksClient.updateWebhookCallable().futureCall(request);
// Do something.
Webhook response = future.get();
}
public final void deleteWebhook(WebhookName name)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
WebhookName name = WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]");
webhooksClient.deleteWebhook(name);
}
name - Required. The name of the webhook to delete. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/webhooks/<WebhookID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteWebhook(String name)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
String name = WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]").toString();
webhooksClient.deleteWebhook(name);
}
name - Required. The name of the webhook to delete. Format:
`projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/webhooks/<WebhookID>`.com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deleteWebhook(DeleteWebhookRequest request)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
DeleteWebhookRequest request =
DeleteWebhookRequest.newBuilder()
.setName(WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]").toString())
.setForce(true)
.build();
webhooksClient.deleteWebhook(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeleteWebhookRequest,com.google.protobuf.Empty> deleteWebhookCallable()
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
DeleteWebhookRequest request =
DeleteWebhookRequest.newBuilder()
.setName(WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]").toString())
.setForce(true)
.build();
ApiFuture<Empty> future = webhooksClient.deleteWebhookCallable().futureCall(request);
// Do something.
future.get();
}
public final WebhooksClient.ListLocationsPagedResponse listLocations(com.google.cloud.location.ListLocationsRequest request)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Location element : webhooksClient.listLocations(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,WebhooksClient.ListLocationsPagedResponse> listLocationsPagedCallable()
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Location> future = webhooksClient.listLocationsPagedCallable().futureCall(request);
// Do something.
for (Location element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.ListLocationsRequest,com.google.cloud.location.ListLocationsResponse> listLocationsCallable()
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
ListLocationsRequest request =
ListLocationsRequest.newBuilder()
.setName("name3373707")
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListLocationsResponse response = webhooksClient.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 com.google.cloud.location.Location getLocation(com.google.cloud.location.GetLocationRequest request)
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
Location response = webhooksClient.getLocation(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<com.google.cloud.location.GetLocationRequest,com.google.cloud.location.Location> getLocationCallable()
Sample 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 (WebhooksClient webhooksClient = WebhooksClient.create()) {
GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
ApiFuture<Location> future = webhooksClient.getLocationCallable().futureCall(request);
// Do something.
Location response = future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2025 Google LLC. All rights reserved.