Class AdvisoryNotificationsServiceClient
- All Implemented Interfaces:
BackgroundResource,AutoCloseable
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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient =
AdvisoryNotificationsServiceClient.create()) {
NotificationName name =
NotificationName.ofOrganizationLocationNotificationName(
"[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
Notification response = advisoryNotificationsServiceClient.getNotification(name);
}
Note: close() needs to be called on the AdvisoryNotificationsServiceClient 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 |
|---|---|---|
ListNotifications |
Lists notifications under a given parent. |
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.
|
GetNotification |
Gets a notification. |
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.
|
GetSettings |
Get notification settings. |
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.
|
UpdateSettings |
Update notification settings. |
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.
|
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 AdvisoryNotificationsServiceSettings 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
AdvisoryNotificationsServiceSettings advisoryNotificationsServiceSettings =
AdvisoryNotificationsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient =
AdvisoryNotificationsServiceClient.create(advisoryNotificationsServiceSettings);
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
AdvisoryNotificationsServiceSettings advisoryNotificationsServiceSettings =
AdvisoryNotificationsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient =
AdvisoryNotificationsServiceClient.create(advisoryNotificationsServiceSettings);
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
AdvisoryNotificationsServiceSettings advisoryNotificationsServiceSettings =
AdvisoryNotificationsServiceSettings.newHttpJsonBuilder().build();
AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient =
AdvisoryNotificationsServiceClient.create(advisoryNotificationsServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an instance of AdvisoryNotificationsServiceClient, using the given settings.protected -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long duration, TimeUnit unit) final voidclose()static final AdvisoryNotificationsServiceClientcreate()Constructs an instance of AdvisoryNotificationsServiceClient with default settings.static final AdvisoryNotificationsServiceClientcreate(AdvisoryNotificationsServiceSettings settings) Constructs an instance of AdvisoryNotificationsServiceClient, using the given settings.static final AdvisoryNotificationsServiceClientConstructs an instance of AdvisoryNotificationsServiceClient, using the given stub for making calls.final NotificationgetNotification(GetNotificationRequest request) Gets a notification.final NotificationGets a notification.final NotificationgetNotification(String name) Gets a notification.Gets a notification.final SettingsgetSettings(GetSettingsRequest request) Get notification settings.final SettingsgetSettings(SettingsName name) Get notification settings.final SettingsgetSettings(String name) Get notification settings.Get notification settings.getStub()booleanbooleanLists notifications under a given parent.listNotifications(LocationName parent) Lists notifications under a given parent.listNotifications(String parent) Lists notifications under a given parent.Lists notifications under a given parent.final UnaryCallable<ListNotificationsRequest,AdvisoryNotificationsServiceClient.ListNotificationsPagedResponse> Lists notifications under a given parent.voidshutdown()voidfinal SettingsupdateSettings(Settings settings) Update notification settings.final SettingsupdateSettings(UpdateSettingsRequest request) Update notification settings.Update notification settings.
-
Constructor Details
-
AdvisoryNotificationsServiceClient
protected AdvisoryNotificationsServiceClient(AdvisoryNotificationsServiceSettings settings) throws IOException Constructs an instance of AdvisoryNotificationsServiceClient, 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.- Throws:
IOException
-
AdvisoryNotificationsServiceClient
-
-
Method Details
-
create
Constructs an instance of AdvisoryNotificationsServiceClient with default settings.- Throws:
IOException
-
create
public static final AdvisoryNotificationsServiceClient create(AdvisoryNotificationsServiceSettings settings) throws IOException Constructs an instance of AdvisoryNotificationsServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.- Throws:
IOException
-
create
public static final AdvisoryNotificationsServiceClient create(AdvisoryNotificationsServiceStub stub) Constructs an instance of AdvisoryNotificationsServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(AdvisoryNotificationsServiceSettings). -
getSettings
-
getStub
-
listNotifications
public final AdvisoryNotificationsServiceClient.ListNotificationsPagedResponse listNotifications(LocationName parent) Lists notifications under a given 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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { LocationName parent = LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]"); for (Notification element : advisoryNotificationsServiceClient.listNotifications(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The parent, which owns this collection of notifications. Must be of the form "organizations/{organization}/locations/{location}" or "projects/{project}/locations/{location}".- Throws:
ApiException- if the remote call fails
-
listNotifications
public final AdvisoryNotificationsServiceClient.ListNotificationsPagedResponse listNotifications(String parent) Lists notifications under a given 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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { String parent = LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]").toString(); for (Notification element : advisoryNotificationsServiceClient.listNotifications(parent).iterateAll()) { // doThingsWith(element); } }- Parameters:
parent- Required. The parent, which owns this collection of notifications. Must be of the form "organizations/{organization}/locations/{location}" or "projects/{project}/locations/{location}".- Throws:
ApiException- if the remote call fails
-
listNotifications
public final AdvisoryNotificationsServiceClient.ListNotificationsPagedResponse listNotifications(ListNotificationsRequest request) Lists notifications under a given 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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { ListNotificationsRequest request = ListNotificationsRequest.newBuilder() .setParent( LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]") .toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setView(NotificationView.forNumber(0)) .setLanguageCode("languageCode-2092349083") .build(); for (Notification element : advisoryNotificationsServiceClient.listNotifications(request).iterateAll()) { // doThingsWith(element); } }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
listNotificationsPagedCallable
public final UnaryCallable<ListNotificationsRequest,AdvisoryNotificationsServiceClient.ListNotificationsPagedResponse> listNotificationsPagedCallable()Lists notifications under a given 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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { ListNotificationsRequest request = ListNotificationsRequest.newBuilder() .setParent( LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]") .toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setView(NotificationView.forNumber(0)) .setLanguageCode("languageCode-2092349083") .build(); ApiFuture<Notification> future = advisoryNotificationsServiceClient.listNotificationsPagedCallable().futureCall(request); // Do something. for (Notification element : future.get().iterateAll()) { // doThingsWith(element); } } -
listNotificationsCallable
public final UnaryCallable<ListNotificationsRequest,ListNotificationsResponse> listNotificationsCallable()Lists notifications under a given 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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { ListNotificationsRequest request = ListNotificationsRequest.newBuilder() .setParent( LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]") .toString()) .setPageSize(883849137) .setPageToken("pageToken873572522") .setView(NotificationView.forNumber(0)) .setLanguageCode("languageCode-2092349083") .build(); while (true) { ListNotificationsResponse response = advisoryNotificationsServiceClient.listNotificationsCallable().call(request); for (Notification element : response.getNotificationsList()) { // doThingsWith(element); } String nextPageToken = response.getNextPageToken(); if (!Strings.isNullOrEmpty(nextPageToken)) { request = request.toBuilder().setPageToken(nextPageToken).build(); } else { break; } } } -
getNotification
Gets a notification.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { NotificationName name = NotificationName.ofOrganizationLocationNotificationName( "[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]"); Notification response = advisoryNotificationsServiceClient.getNotification(name); }- Parameters:
name- Required. A name of the notification to retrieve. Format: organizations/{organization}/locations/{location}/notifications/{notification} or projects/{projects}/locations/{location}/notifications/{notification}.- Throws:
ApiException- if the remote call fails
-
getNotification
Gets a notification.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { String name = NotificationName.ofOrganizationLocationNotificationName( "[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]") .toString(); Notification response = advisoryNotificationsServiceClient.getNotification(name); }- Parameters:
name- Required. A name of the notification to retrieve. Format: organizations/{organization}/locations/{location}/notifications/{notification} or projects/{projects}/locations/{location}/notifications/{notification}.- Throws:
ApiException- if the remote call fails
-
getNotification
Gets a notification.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { GetNotificationRequest request = GetNotificationRequest.newBuilder() .setName( NotificationName.ofOrganizationLocationNotificationName( "[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]") .toString()) .setLanguageCode("languageCode-2092349083") .build(); Notification response = advisoryNotificationsServiceClient.getNotification(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getNotificationCallable
Gets a notification.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { GetNotificationRequest request = GetNotificationRequest.newBuilder() .setName( NotificationName.ofOrganizationLocationNotificationName( "[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]") .toString()) .setLanguageCode("languageCode-2092349083") .build(); ApiFuture<Notification> future = advisoryNotificationsServiceClient.getNotificationCallable().futureCall(request); // Do something. Notification response = future.get(); } -
getSettings
Get notification settings.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { SettingsName name = SettingsName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]"); Settings response = advisoryNotificationsServiceClient.getSettings(name); }- Parameters:
name- Required. The resource name of the settings to retrieve. Format: organizations/{organization}/locations/{location}/settings or projects/{projects}/locations/{location}/settings.- Throws:
ApiException- if the remote call fails
-
getSettings
Get notification settings.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { String name = SettingsName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]").toString(); Settings response = advisoryNotificationsServiceClient.getSettings(name); }- Parameters:
name- Required. The resource name of the settings to retrieve. Format: organizations/{organization}/locations/{location}/settings or projects/{projects}/locations/{location}/settings.- Throws:
ApiException- if the remote call fails
-
getSettings
Get notification settings.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { GetSettingsRequest request = GetSettingsRequest.newBuilder() .setName( SettingsName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]") .toString()) .build(); Settings response = advisoryNotificationsServiceClient.getSettings(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
getSettingsCallable
Get notification settings.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { GetSettingsRequest request = GetSettingsRequest.newBuilder() .setName( SettingsName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]") .toString()) .build(); ApiFuture<Settings> future = advisoryNotificationsServiceClient.getSettingsCallable().futureCall(request); // Do something. Settings response = future.get(); } -
updateSettings
Update notification settings.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { Settings settings = Settings.newBuilder().build(); Settings response = advisoryNotificationsServiceClient.updateSettings(settings); }- Parameters:
settings- Required. New settings.- Throws:
ApiException- if the remote call fails
-
updateSettings
Update notification settings.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { UpdateSettingsRequest request = UpdateSettingsRequest.newBuilder().setSettings(Settings.newBuilder().build()).build(); Settings response = advisoryNotificationsServiceClient.updateSettings(request); }- Parameters:
request- The request object containing all of the parameters for the API call.- Throws:
ApiException- if the remote call fails
-
updateSettingsCallable
Update notification settings.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 (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient = AdvisoryNotificationsServiceClient.create()) { UpdateSettingsRequest request = UpdateSettingsRequest.newBuilder().setSettings(Settings.newBuilder().build()).build(); ApiFuture<Settings> future = advisoryNotificationsServiceClient.updateSettingsCallable().futureCall(request); // Do something. Settings response = future.get(); } -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceBackgroundResource
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceBackgroundResource
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceBackgroundResource
-
shutdownNow
public void shutdownNow()- Specified by:
shutdownNowin interfaceBackgroundResource
-
awaitTermination
- Specified by:
awaitTerminationin interfaceBackgroundResource- Throws:
InterruptedException
-