Class AdvisoryNotificationsServiceClient

java.lang.Object
com.google.cloud.advisorynotifications.v1.AdvisoryNotificationsServiceClient
All Implemented Interfaces:
BackgroundResource, AutoCloseable

@Generated("by gapic-generator-java") public class AdvisoryNotificationsServiceClient extends Object implements BackgroundResource
Service Description: Service to manage Security and Privacy Notifications.

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().

Methods
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.

  • listNotifications(ListNotificationsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listNotifications(LocationName parent)

  • listNotifications(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listNotificationsPagedCallable()

  • listNotificationsCallable()

GetNotification

Gets a notification.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getNotification(GetNotificationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getNotification(NotificationName name)

  • getNotification(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getNotificationCallable()

GetSettings

Get notification settings.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getSettings(GetSettingsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getSettings(SettingsName name)

  • getSettings(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getSettingsCallable()

UpdateSettings

Update notification settings.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateSettings(UpdateSettingsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateSettings(Settings settings)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateSettingsCallable()

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.

  • 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

      protected AdvisoryNotificationsServiceClient(AdvisoryNotificationsServiceStub stub)
  • Method Details

    • create

      public static final AdvisoryNotificationsServiceClient create() throws IOException
      Constructs an instance of AdvisoryNotificationsServiceClient with default settings.
      Throws:
      IOException
    • create

      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

      Constructs an instance of AdvisoryNotificationsServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(AdvisoryNotificationsServiceSettings).
    • getSettings

      public final AdvisoryNotificationsServiceSettings getSettings()
    • getStub

    • listNotifications

      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

      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

      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

      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

      public final Notification getNotification(NotificationName name)
      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

      public final Notification getNotification(String name)
      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

      public final Notification getNotification(GetNotificationRequest request)
      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

      public final UnaryCallable<GetNotificationRequest,Notification> 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

      public final Settings getSettings(SettingsName name)
      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

      public final Settings getSettings(String name)
      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

      public final Settings getSettings(GetSettingsRequest request)
      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

      public final UnaryCallable<GetSettingsRequest,Settings> 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

      public final Settings updateSettings(Settings settings)
      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

      public final Settings updateSettings(UpdateSettingsRequest request)
      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

      public final UnaryCallable<UpdateSettingsRequest,Settings> 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:
      close in interface AutoCloseable
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface BackgroundResource
    • isShutdown

      public boolean isShutdown()
      Specified by:
      isShutdown in interface BackgroundResource
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface BackgroundResource
    • shutdownNow

      public void shutdownNow()
      Specified by:
      shutdownNow in interface BackgroundResource
    • awaitTermination

      public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
      Specified by:
      awaitTermination in interface BackgroundResource
      Throws:
      InterruptedException