- 0.63.0 (latest)
- 0.62.0
- 0.60.0
- 0.59.0
- 0.58.0
- 0.57.0
- 0.56.0
- 0.55.0
- 0.54.0
- 0.53.0
- 0.52.0
- 0.51.0
- 0.50.0
- 0.48.0
- 0.47.0
- 0.46.0
- 0.45.0
- 0.44.0
- 0.43.0
- 0.42.0
- 0.41.0
- 0.40.0
- 0.39.0
- 0.38.0
- 0.35.0
- 0.34.0
- 0.33.0
- 0.32.0
- 0.31.0
- 0.30.0
- 0.29.0
- 0.28.0
- 0.27.0
- 0.26.0
- 0.25.0
- 0.24.0
- 0.23.0
- 0.22.0
- 0.20.0
- 0.19.0
- 0.18.0
- 0.17.0
- 0.16.0
- 0.15.0
- 0.14.7
- 0.13.1
- 0.12.1
- 0.11.5
public class WebhooksClient implements BackgroundResource
Service Description: Service for managing Webhooks.
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 (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().
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 WebhooksSettings 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.
WebhooksSettings webhooksSettings =
WebhooksSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
WebhooksClient webhooksClient = WebhooksClient.create(webhooksSettings);
To customize the endpoint:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
WebhooksSettings webhooksSettings =
WebhooksSettings.newBuilder().setEndpoint(myEndpoint).build();
WebhooksClient webhooksClient = WebhooksClient.create(webhooksSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final WebhooksClient create()
Constructs an instance of WebhooksClient with default settings.
Type | Description |
WebhooksClient |
Type | Description |
IOException |
create(WebhooksSettings settings)
public static final WebhooksClient create(WebhooksSettings settings)
Constructs an instance of WebhooksClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | WebhooksSettings |
Type | Description |
WebhooksClient |
Type | Description |
IOException |
create(WebhooksStub stub)
public static final WebhooksClient create(WebhooksStub stub)
Constructs an instance of WebhooksClient, using the given stub for making calls. This is for advanced usage - prefer using create(WebhooksSettings).
Name | Description |
stub | WebhooksStub |
Type | Description |
WebhooksClient |
Constructors
WebhooksClient(WebhooksSettings settings)
protected WebhooksClient(WebhooksSettings settings)
Constructs an instance of WebhooksClient, 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.
Name | Description |
settings | WebhooksSettings |
WebhooksClient(WebhooksStub stub)
protected WebhooksClient(WebhooksStub stub)
Name | Description |
stub | WebhooksStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
createWebhook(AgentName parent, Webhook webhook)
public final Webhook createWebhook(AgentName parent, Webhook webhook)
Creates a webhook in the specified agent.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
Webhook webhook = Webhook.newBuilder().build();
Webhook response = webhooksClient.createWebhook(parent, webhook);
}
Name | Description |
parent | AgentName Required. The agent to create a webhook for. Format: |
webhook | Webhook Required. The webhook to create. |
Type | Description |
Webhook |
createWebhook(CreateWebhookRequest request)
public final Webhook createWebhook(CreateWebhookRequest request)
Creates a webhook in the specified agent.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
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);
}
Name | Description |
request | CreateWebhookRequest The request object containing all of the parameters for the API call. |
Type | Description |
Webhook |
createWebhook(String parent, Webhook webhook)
public final Webhook createWebhook(String parent, Webhook webhook)
Creates a webhook in the specified agent.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
String parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
Webhook webhook = Webhook.newBuilder().build();
Webhook response = webhooksClient.createWebhook(parent, webhook);
}
Name | Description |
parent | String Required. The agent to create a webhook for. Format: |
webhook | Webhook Required. The webhook to create. |
Type | Description |
Webhook |
createWebhookCallable()
public final UnaryCallable<CreateWebhookRequest,Webhook> createWebhookCallable()
Creates a webhook in the specified agent.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
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();
}
Type | Description |
UnaryCallable<CreateWebhookRequest,Webhook> |
deleteWebhook(DeleteWebhookRequest request)
public final void deleteWebhook(DeleteWebhookRequest request)
Deletes the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
DeleteWebhookRequest request =
DeleteWebhookRequest.newBuilder()
.setName(WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]").toString())
.setForce(true)
.build();
webhooksClient.deleteWebhook(request);
}
Name | Description |
request | DeleteWebhookRequest The request object containing all of the parameters for the API call. |
deleteWebhook(WebhookName name)
public final void deleteWebhook(WebhookName name)
Deletes the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
WebhookName name = WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]");
webhooksClient.deleteWebhook(name);
}
Name | Description |
name | WebhookName Required. The name of the webhook to delete. Format: |
deleteWebhook(String name)
public final void deleteWebhook(String name)
Deletes the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
String name = WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]").toString();
webhooksClient.deleteWebhook(name);
}
Name | Description |
name | String Required. The name of the webhook to delete. Format: |
deleteWebhookCallable()
public final UnaryCallable<DeleteWebhookRequest,Empty> deleteWebhookCallable()
Deletes the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
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();
}
Type | Description |
UnaryCallable<DeleteWebhookRequest,Empty> |
getSettings()
public final WebhooksSettings getSettings()
Type | Description |
WebhooksSettings |
getStub()
public WebhooksStub getStub()
Type | Description |
WebhooksStub |
getWebhook(GetWebhookRequest request)
public final Webhook getWebhook(GetWebhookRequest request)
Retrieves the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
GetWebhookRequest request =
GetWebhookRequest.newBuilder()
.setName(WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]").toString())
.build();
Webhook response = webhooksClient.getWebhook(request);
}
Name | Description |
request | GetWebhookRequest The request object containing all of the parameters for the API call. |
Type | Description |
Webhook |
getWebhook(WebhookName name)
public final Webhook getWebhook(WebhookName name)
Retrieves the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
WebhookName name = WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]");
Webhook response = webhooksClient.getWebhook(name);
}
Name | Description |
name | WebhookName Required. The name of the webhook. Format: |
Type | Description |
Webhook |
getWebhook(String name)
public final Webhook getWebhook(String name)
Retrieves the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
String name = WebhookName.of("[PROJECT]", "[LOCATION]", "[AGENT]", "[WEBHOOK]").toString();
Webhook response = webhooksClient.getWebhook(name);
}
Name | Description |
name | String Required. The name of the webhook. Format: |
Type | Description |
Webhook |
getWebhookCallable()
public final UnaryCallable<GetWebhookRequest,Webhook> getWebhookCallable()
Retrieves the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
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();
}
Type | Description |
UnaryCallable<GetWebhookRequest,Webhook> |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listWebhooks(AgentName parent)
public final WebhooksClient.ListWebhooksPagedResponse listWebhooks(AgentName parent)
Returns the list of all webhooks in the specified agent.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
AgentName parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]");
for (Webhook element : webhooksClient.listWebhooks(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | AgentName Required. The agent to list all webhooks for. Format: |
Type | Description |
WebhooksClient.ListWebhooksPagedResponse |
listWebhooks(ListWebhooksRequest request)
public final WebhooksClient.ListWebhooksPagedResponse listWebhooks(ListWebhooksRequest request)
Returns the list of all webhooks in the specified agent.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
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);
}
}
Name | Description |
request | ListWebhooksRequest The request object containing all of the parameters for the API call. |
Type | Description |
WebhooksClient.ListWebhooksPagedResponse |
listWebhooks(String parent)
public final WebhooksClient.ListWebhooksPagedResponse listWebhooks(String parent)
Returns the list of all webhooks in the specified agent.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
String parent = AgentName.of("[PROJECT]", "[LOCATION]", "[AGENT]").toString();
for (Webhook element : webhooksClient.listWebhooks(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The agent to list all webhooks for. Format: |
Type | Description |
WebhooksClient.ListWebhooksPagedResponse |
listWebhooksCallable()
public final UnaryCallable<ListWebhooksRequest,ListWebhooksResponse> listWebhooksCallable()
Returns the list of all webhooks in the specified agent.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
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.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListWebhooksRequest,ListWebhooksResponse> |
listWebhooksPagedCallable()
public final UnaryCallable<ListWebhooksRequest,WebhooksClient.ListWebhooksPagedResponse> listWebhooksPagedCallable()
Returns the list of all webhooks in the specified agent.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
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);
}
}
Type | Description |
UnaryCallable<ListWebhooksRequest,ListWebhooksPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
updateWebhook(UpdateWebhookRequest request)
public final Webhook updateWebhook(UpdateWebhookRequest request)
Updates the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
UpdateWebhookRequest request =
UpdateWebhookRequest.newBuilder()
.setWebhook(Webhook.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Webhook response = webhooksClient.updateWebhook(request);
}
Name | Description |
request | UpdateWebhookRequest The request object containing all of the parameters for the API call. |
Type | Description |
Webhook |
updateWebhook(Webhook webhook, FieldMask updateMask)
public final Webhook updateWebhook(Webhook webhook, FieldMask updateMask)
Updates the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (WebhooksClient webhooksClient = WebhooksClient.create()) {
Webhook webhook = Webhook.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Webhook response = webhooksClient.updateWebhook(webhook, updateMask);
}
Name | Description |
webhook | Webhook Required. The webhook to update. |
updateMask | FieldMask The mask to control which fields get updated. If the mask is not present, all fields will be updated. |
Type | Description |
Webhook |
updateWebhookCallable()
public final UnaryCallable<UpdateWebhookRequest,Webhook> updateWebhookCallable()
Updates the specified webhook.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
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();
}
Type | Description |
UnaryCallable<UpdateWebhookRequest,Webhook> |