@Generated(value="by gapic-generator-java") public class SnoozeServiceClient 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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Snooze snooze = Snooze.newBuilder().build();
Snooze response = snoozeServiceClient.createSnooze(parent, snooze);
}
Note: close() needs to be called on the SnoozeServiceClient 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:
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 SnoozeServiceSettings 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
SnoozeServiceSettings snoozeServiceSettings =
SnoozeServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create(snoozeServiceSettings);
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
SnoozeServiceSettings snoozeServiceSettings =
SnoozeServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create(snoozeServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
SnoozeServiceClient.ListSnoozesFixedSizeCollection |
static class |
SnoozeServiceClient.ListSnoozesPage |
static class |
SnoozeServiceClient.ListSnoozesPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
SnoozeServiceClient(SnoozeServiceSettings settings)
Constructs an instance of SnoozeServiceClient, using the given settings.
|
protected |
SnoozeServiceClient(SnoozeServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static SnoozeServiceClient |
create()
Constructs an instance of SnoozeServiceClient with default settings.
|
static SnoozeServiceClient |
create(SnoozeServiceSettings settings)
Constructs an instance of SnoozeServiceClient, using the given settings.
|
static SnoozeServiceClient |
create(SnoozeServiceStub stub)
Constructs an instance of SnoozeServiceClient, using the given stub for making calls.
|
Snooze |
createSnooze(CreateSnoozeRequest request)
Creates a `Snooze` that will prevent alerts, which match the provided criteria, from being
opened.
|
Snooze |
createSnooze(ProjectName parent,
Snooze snooze)
Creates a `Snooze` that will prevent alerts, which match the provided criteria, from being
opened.
|
Snooze |
createSnooze(String parent,
Snooze snooze)
Creates a `Snooze` that will prevent alerts, which match the provided criteria, from being
opened.
|
com.google.api.gax.rpc.UnaryCallable<CreateSnoozeRequest,Snooze> |
createSnoozeCallable()
Creates a `Snooze` that will prevent alerts, which match the provided criteria, from being
opened.
|
SnoozeServiceSettings |
getSettings() |
Snooze |
getSnooze(GetSnoozeRequest request)
Retrieves a `Snooze` by `name`.
|
Snooze |
getSnooze(SnoozeName name)
Retrieves a `Snooze` by `name`.
|
Snooze |
getSnooze(String name)
Retrieves a `Snooze` by `name`.
|
com.google.api.gax.rpc.UnaryCallable<GetSnoozeRequest,Snooze> |
getSnoozeCallable()
Retrieves a `Snooze` by `name`.
|
SnoozeServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
SnoozeServiceClient.ListSnoozesPagedResponse |
listSnoozes(ListSnoozesRequest request)
Lists the `Snooze`s associated with a project.
|
SnoozeServiceClient.ListSnoozesPagedResponse |
listSnoozes(ProjectName parent)
Lists the `Snooze`s associated with a project.
|
SnoozeServiceClient.ListSnoozesPagedResponse |
listSnoozes(String parent)
Lists the `Snooze`s associated with a project.
|
com.google.api.gax.rpc.UnaryCallable<ListSnoozesRequest,ListSnoozesResponse> |
listSnoozesCallable()
Lists the `Snooze`s associated with a project.
|
com.google.api.gax.rpc.UnaryCallable<ListSnoozesRequest,SnoozeServiceClient.ListSnoozesPagedResponse> |
listSnoozesPagedCallable()
Lists the `Snooze`s associated with a project.
|
void |
shutdown() |
void |
shutdownNow() |
Snooze |
updateSnooze(Snooze snooze,
com.google.protobuf.FieldMask updateMask)
Updates a `Snooze`, identified by its `name`, with the parameters in the given `Snooze` object.
|
Snooze |
updateSnooze(UpdateSnoozeRequest request)
Updates a `Snooze`, identified by its `name`, with the parameters in the given `Snooze` object.
|
com.google.api.gax.rpc.UnaryCallable<UpdateSnoozeRequest,Snooze> |
updateSnoozeCallable()
Updates a `Snooze`, identified by its `name`, with the parameters in the given `Snooze` object.
|
protected SnoozeServiceClient(SnoozeServiceSettings settings) throws IOException
IOExceptionprotected SnoozeServiceClient(SnoozeServiceStub stub)
public static final SnoozeServiceClient create() throws IOException
IOExceptionpublic static final SnoozeServiceClient create(SnoozeServiceSettings settings) throws IOException
IOExceptionpublic static final SnoozeServiceClient create(SnoozeServiceStub stub)
public final SnoozeServiceSettings getSettings()
public SnoozeServiceStub getStub()
public final Snooze createSnooze(ProjectName parent, Snooze snooze)
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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Snooze snooze = Snooze.newBuilder().build();
Snooze response = snoozeServiceClient.createSnooze(parent, snooze);
}
parent - Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name)
in which a `Snooze` should be created. The format is:
projects/[PROJECT_ID_OR_NUMBER]
snooze - Required. The `Snooze` to create. Omit the `name` field, as it will be filled in
by the API.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Snooze createSnooze(String parent, Snooze snooze)
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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
Snooze snooze = Snooze.newBuilder().build();
Snooze response = snoozeServiceClient.createSnooze(parent, snooze);
}
parent - Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name)
in which a `Snooze` should be created. The format is:
projects/[PROJECT_ID_OR_NUMBER]
snooze - Required. The `Snooze` to create. Omit the `name` field, as it will be filled in
by the API.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Snooze createSnooze(CreateSnoozeRequest 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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
CreateSnoozeRequest request =
CreateSnoozeRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setSnooze(Snooze.newBuilder().build())
.build();
Snooze response = snoozeServiceClient.createSnooze(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<CreateSnoozeRequest,Snooze> createSnoozeCallable()
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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
CreateSnoozeRequest request =
CreateSnoozeRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setSnooze(Snooze.newBuilder().build())
.build();
ApiFuture<Snooze> future = snoozeServiceClient.createSnoozeCallable().futureCall(request);
// Do something.
Snooze response = future.get();
}
public final SnoozeServiceClient.ListSnoozesPagedResponse listSnoozes(ProjectName 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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Snooze element : snoozeServiceClient.listSnoozes(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name)
whose `Snooze`s should be listed. The format is:
projects/[PROJECT_ID_OR_NUMBER]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final SnoozeServiceClient.ListSnoozesPagedResponse listSnoozes(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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
for (Snooze element : snoozeServiceClient.listSnoozes(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The [project](https://cloud.google.com/monitoring/api/v3#project_name)
whose `Snooze`s should be listed. The format is:
projects/[PROJECT_ID_OR_NUMBER]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final SnoozeServiceClient.ListSnoozesPagedResponse listSnoozes(ListSnoozesRequest 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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
ListSnoozesRequest request =
ListSnoozesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Snooze element : snoozeServiceClient.listSnoozes(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<ListSnoozesRequest,SnoozeServiceClient.ListSnoozesPagedResponse> listSnoozesPagedCallable()
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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
ListSnoozesRequest request =
ListSnoozesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Snooze> future = snoozeServiceClient.listSnoozesPagedCallable().futureCall(request);
// Do something.
for (Snooze element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListSnoozesRequest,ListSnoozesResponse> listSnoozesCallable()
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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
ListSnoozesRequest request =
ListSnoozesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListSnoozesResponse response = snoozeServiceClient.listSnoozesCallable().call(request);
for (Snooze element : response.getSnoozesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Snooze getSnooze(SnoozeName 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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
SnoozeName name = SnoozeName.of("[PROJECT]", "[SNOOZE]");
Snooze response = snoozeServiceClient.getSnooze(name);
}
name - Required. The ID of the `Snooze` to retrieve. The format is:
projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final Snooze getSnooze(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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
String name = SnoozeName.of("[PROJECT]", "[SNOOZE]").toString();
Snooze response = snoozeServiceClient.getSnooze(name);
}
name - Required. The ID of the `Snooze` to retrieve. The format is:
projects/[PROJECT_ID_OR_NUMBER]/snoozes/[SNOOZE_ID]
com.google.api.gax.rpc.ApiException - if the remote call failspublic final Snooze getSnooze(GetSnoozeRequest 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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
GetSnoozeRequest request =
GetSnoozeRequest.newBuilder()
.setName(SnoozeName.of("[PROJECT]", "[SNOOZE]").toString())
.build();
Snooze response = snoozeServiceClient.getSnooze(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<GetSnoozeRequest,Snooze> getSnoozeCallable()
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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
GetSnoozeRequest request =
GetSnoozeRequest.newBuilder()
.setName(SnoozeName.of("[PROJECT]", "[SNOOZE]").toString())
.build();
ApiFuture<Snooze> future = snoozeServiceClient.getSnoozeCallable().futureCall(request);
// Do something.
Snooze response = future.get();
}
public final Snooze updateSnooze(Snooze snooze, 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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
Snooze snooze = Snooze.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Snooze response = snoozeServiceClient.updateSnooze(snooze, updateMask);
}
snooze - Required. The `Snooze` to update. Must have the name field present.updateMask - Required. The fields to update.
For each field listed in `update_mask`:
* If the `Snooze` object supplied in the `UpdateSnoozeRequest` has a value for that field, the value of the field in the existing `Snooze` will be set to the value of the field in the supplied `Snooze`. * If the field does not have a value in the supplied `Snooze`, the field in the existing `Snooze` is set to its default value.
Fields not listed retain their existing value.
The following are the field names that are accepted in `update_mask`:
* `display_name` * `interval.start_time` * `interval.end_time`
That said, the start time and end time of the `Snooze` determines which fields can legally be updated. Before attempting an update, users should consult the documentation for `UpdateSnoozeRequest`, which talks about which fields can be updated.
com.google.api.gax.rpc.ApiException - if the remote call failspublic final Snooze updateSnooze(UpdateSnoozeRequest 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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
UpdateSnoozeRequest request =
UpdateSnoozeRequest.newBuilder()
.setSnooze(Snooze.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Snooze response = snoozeServiceClient.updateSnooze(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<UpdateSnoozeRequest,Snooze> updateSnoozeCallable()
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 (SnoozeServiceClient snoozeServiceClient = SnoozeServiceClient.create()) {
UpdateSnoozeRequest request =
UpdateSnoozeRequest.newBuilder()
.setSnooze(Snooze.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Snooze> future = snoozeServiceClient.updateSnoozeCallable().futureCall(request);
// Do something.
Snooze 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 © 2023 Google LLC. All rights reserved.