Class SubscriptionsServiceClient (0.8.0)

GitHub RepositoryProduct ReferenceREST Documentation

Service Description: A service that manages subscriptions to Google Workspace events.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   SubscriptionName name = SubscriptionName.of("[SUBSCRIPTION]");
   Subscription response = subscriptionsServiceClient.getSubscription(name);
 }
 

Note: close() needs to be called on the SubscriptionsServiceClient 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

CreateSubscription

Creates a Google Workspace subscription. To learn how to use this method, see Create a Google Workspace subscription.

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

  • createSubscriptionAsync(CreateSubscriptionRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • createSubscriptionAsync(Subscription subscription)

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

  • createSubscriptionOperationCallable()

  • createSubscriptionCallable()

DeleteSubscription

Deletes a Google Workspace subscription. To learn how to use this method, see Delete a Google Workspace subscription.

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

  • deleteSubscriptionAsync(DeleteSubscriptionRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • deleteSubscriptionAsync(SubscriptionName name)

  • deleteSubscriptionAsync(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.

  • deleteSubscriptionOperationCallable()

  • deleteSubscriptionCallable()

GetSubscription

Gets details about a Google Workspace subscription. To learn how to use this method, see Get details about a Google Workspace subscription.

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

  • getSubscription(GetSubscriptionRequest request)

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

  • getSubscription(SubscriptionName name)

  • getSubscription(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.

  • getSubscriptionCallable()

ListSubscriptions

Lists Google Workspace subscriptions. To learn how to use this method, see List Google Workspace subscriptions.

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

  • listSubscriptions(ListSubscriptionsRequest request)

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

  • listSubscriptions(String filter)

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

  • listSubscriptionsPagedCallable()

  • listSubscriptionsCallable()

UpdateSubscription

Updates or renews a Google Workspace subscription. To learn how to use this method, see Update or renew a Google Workspace subscription.

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

  • updateSubscriptionAsync(UpdateSubscriptionRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • updateSubscriptionAsync(Subscription subscription, FieldMask updateMask)

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

  • updateSubscriptionOperationCallable()

  • updateSubscriptionCallable()

ReactivateSubscription

Reactivates a suspended Google Workspace subscription.

This method resets your subscription's State field to ACTIVE. Before you use this method, you must fix the error that suspended the subscription. To learn how to use this method, see Reactivate a Google Workspace subscription.

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

  • reactivateSubscriptionAsync(ReactivateSubscriptionRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • reactivateSubscriptionAsync(SubscriptionName name)

  • reactivateSubscriptionAsync(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.

  • reactivateSubscriptionOperationCallable()

  • reactivateSubscriptionCallable()

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 SubscriptionsServiceSettings 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
 SubscriptionsServiceSettings subscriptionsServiceSettings =
     SubscriptionsServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create(subscriptionsServiceSettings);
 

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
 SubscriptionsServiceSettings subscriptionsServiceSettings =
     SubscriptionsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create(subscriptionsServiceSettings);
 

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
 SubscriptionsServiceSettings subscriptionsServiceSettings =
     SubscriptionsServiceSettings.newHttpJsonBuilder().build();
 SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create(subscriptionsServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > SubscriptionsServiceClient

Static Methods

create()

public static final SubscriptionsServiceClient create()

Constructs an instance of SubscriptionsServiceClient with default settings.

Returns
Type Description
SubscriptionsServiceClient
Exceptions
Type Description
IOException

create(SubscriptionsServiceSettings settings)

public static final SubscriptionsServiceClient create(SubscriptionsServiceSettings settings)

Constructs an instance of SubscriptionsServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings SubscriptionsServiceSettings
Returns
Type Description
SubscriptionsServiceClient
Exceptions
Type Description
IOException

create(SubscriptionsServiceStub stub)

public static final SubscriptionsServiceClient create(SubscriptionsServiceStub stub)

Constructs an instance of SubscriptionsServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(SubscriptionsServiceSettings).

Parameter
Name Description
stub SubscriptionsServiceStub
Returns
Type Description
SubscriptionsServiceClient

Constructors

SubscriptionsServiceClient(SubscriptionsServiceSettings settings)

protected SubscriptionsServiceClient(SubscriptionsServiceSettings settings)

Constructs an instance of SubscriptionsServiceClient, 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.

Parameter
Name Description
settings SubscriptionsServiceSettings

SubscriptionsServiceClient(SubscriptionsServiceStub stub)

protected SubscriptionsServiceClient(SubscriptionsServiceStub stub)
Parameter
Name Description
stub SubscriptionsServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close()

public final void close()

createSubscriptionAsync(CreateSubscriptionRequest request)

public final OperationFuture<Subscription,CreateSubscriptionMetadata> createSubscriptionAsync(CreateSubscriptionRequest request)

Creates a Google Workspace subscription. To learn how to use this method, see Create a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   CreateSubscriptionRequest request =
       CreateSubscriptionRequest.newBuilder()
           .setSubscription(Subscription.newBuilder().build())
           .setValidateOnly(true)
           .build();
   Subscription response = subscriptionsServiceClient.createSubscriptionAsync(request).get();
 }
 
Parameter
Name Description
request CreateSubscriptionRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<Subscription,CreateSubscriptionMetadata>

createSubscriptionAsync(Subscription subscription)

public final OperationFuture<Subscription,CreateSubscriptionMetadata> createSubscriptionAsync(Subscription subscription)

Creates a Google Workspace subscription. To learn how to use this method, see Create a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   Subscription subscription = Subscription.newBuilder().build();
   Subscription response =
       subscriptionsServiceClient.createSubscriptionAsync(subscription).get();
 }
 
Parameter
Name Description
subscription Subscription

Required. The subscription resource to create.

Returns
Type Description
OperationFuture<Subscription,CreateSubscriptionMetadata>

createSubscriptionCallable()

public final UnaryCallable<CreateSubscriptionRequest,Operation> createSubscriptionCallable()

Creates a Google Workspace subscription. To learn how to use this method, see Create a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   CreateSubscriptionRequest request =
       CreateSubscriptionRequest.newBuilder()
           .setSubscription(Subscription.newBuilder().build())
           .setValidateOnly(true)
           .build();
   ApiFuture<Operation> future =
       subscriptionsServiceClient.createSubscriptionCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateSubscriptionRequest,Operation>

createSubscriptionOperationCallable()

public final OperationCallable<CreateSubscriptionRequest,Subscription,CreateSubscriptionMetadata> createSubscriptionOperationCallable()

Creates a Google Workspace subscription. To learn how to use this method, see Create a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   CreateSubscriptionRequest request =
       CreateSubscriptionRequest.newBuilder()
           .setSubscription(Subscription.newBuilder().build())
           .setValidateOnly(true)
           .build();
   OperationFuture<Subscription, CreateSubscriptionMetadata> future =
       subscriptionsServiceClient.createSubscriptionOperationCallable().futureCall(request);
   // Do something.
   Subscription response = future.get();
 }
 
Returns
Type Description
OperationCallable<CreateSubscriptionRequest,Subscription,CreateSubscriptionMetadata>

deleteSubscriptionAsync(DeleteSubscriptionRequest request)

public final OperationFuture<Empty,DeleteSubscriptionMetadata> deleteSubscriptionAsync(DeleteSubscriptionRequest request)

Deletes a Google Workspace subscription. To learn how to use this method, see Delete a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   DeleteSubscriptionRequest request =
       DeleteSubscriptionRequest.newBuilder()
           .setName(SubscriptionName.of("[SUBSCRIPTION]").toString())
           .setValidateOnly(true)
           .setAllowMissing(true)
           .setEtag("etag3123477")
           .build();
   subscriptionsServiceClient.deleteSubscriptionAsync(request).get();
 }
 
Parameter
Name Description
request DeleteSubscriptionRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<Empty,DeleteSubscriptionMetadata>

deleteSubscriptionAsync(SubscriptionName name)

public final OperationFuture<Empty,DeleteSubscriptionMetadata> deleteSubscriptionAsync(SubscriptionName name)

Deletes a Google Workspace subscription. To learn how to use this method, see Delete a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   SubscriptionName name = SubscriptionName.of("[SUBSCRIPTION]");
   subscriptionsServiceClient.deleteSubscriptionAsync(name).get();
 }
 
Parameter
Name Description
name SubscriptionName

Required. Resource name of the subscription to delete.

Format: subscriptions/{subscription}

Returns
Type Description
OperationFuture<Empty,DeleteSubscriptionMetadata>

deleteSubscriptionAsync(String name)

public final OperationFuture<Empty,DeleteSubscriptionMetadata> deleteSubscriptionAsync(String name)

Deletes a Google Workspace subscription. To learn how to use this method, see Delete a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   String name = SubscriptionName.of("[SUBSCRIPTION]").toString();
   subscriptionsServiceClient.deleteSubscriptionAsync(name).get();
 }
 
Parameter
Name Description
name String

Required. Resource name of the subscription to delete.

Format: subscriptions/{subscription}

Returns
Type Description
OperationFuture<Empty,DeleteSubscriptionMetadata>

deleteSubscriptionCallable()

public final UnaryCallable<DeleteSubscriptionRequest,Operation> deleteSubscriptionCallable()

Deletes a Google Workspace subscription. To learn how to use this method, see Delete a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   DeleteSubscriptionRequest request =
       DeleteSubscriptionRequest.newBuilder()
           .setName(SubscriptionName.of("[SUBSCRIPTION]").toString())
           .setValidateOnly(true)
           .setAllowMissing(true)
           .setEtag("etag3123477")
           .build();
   ApiFuture<Operation> future =
       subscriptionsServiceClient.deleteSubscriptionCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteSubscriptionRequest,Operation>

deleteSubscriptionOperationCallable()

public final OperationCallable<DeleteSubscriptionRequest,Empty,DeleteSubscriptionMetadata> deleteSubscriptionOperationCallable()

Deletes a Google Workspace subscription. To learn how to use this method, see Delete a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   DeleteSubscriptionRequest request =
       DeleteSubscriptionRequest.newBuilder()
           .setName(SubscriptionName.of("[SUBSCRIPTION]").toString())
           .setValidateOnly(true)
           .setAllowMissing(true)
           .setEtag("etag3123477")
           .build();
   OperationFuture<Empty, DeleteSubscriptionMetadata> future =
       subscriptionsServiceClient.deleteSubscriptionOperationCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
OperationCallable<DeleteSubscriptionRequest,Empty,DeleteSubscriptionMetadata>

getHttpJsonOperationsClient()

public final OperationsClient getHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description
OperationsClient

getOperationsClient()

public final OperationsClient getOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
Type Description
OperationsClient

getSettings()

public final SubscriptionsServiceSettings getSettings()
Returns
Type Description
SubscriptionsServiceSettings

getStub()

public SubscriptionsServiceStub getStub()
Returns
Type Description
SubscriptionsServiceStub

getSubscription(GetSubscriptionRequest request)

public final Subscription getSubscription(GetSubscriptionRequest request)

Gets details about a Google Workspace subscription. To learn how to use this method, see Get details about a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   GetSubscriptionRequest request =
       GetSubscriptionRequest.newBuilder()
           .setName(SubscriptionName.of("[SUBSCRIPTION]").toString())
           .build();
   Subscription response = subscriptionsServiceClient.getSubscription(request);
 }
 
Parameter
Name Description
request GetSubscriptionRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Subscription

getSubscription(SubscriptionName name)

public final Subscription getSubscription(SubscriptionName name)

Gets details about a Google Workspace subscription. To learn how to use this method, see Get details about a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   SubscriptionName name = SubscriptionName.of("[SUBSCRIPTION]");
   Subscription response = subscriptionsServiceClient.getSubscription(name);
 }
 
Parameter
Name Description
name SubscriptionName

Required. Resource name of the subscription.

Format: subscriptions/{subscription}

Returns
Type Description
Subscription

getSubscription(String name)

public final Subscription getSubscription(String name)

Gets details about a Google Workspace subscription. To learn how to use this method, see Get details about a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   String name = SubscriptionName.of("[SUBSCRIPTION]").toString();
   Subscription response = subscriptionsServiceClient.getSubscription(name);
 }
 
Parameter
Name Description
name String

Required. Resource name of the subscription.

Format: subscriptions/{subscription}

Returns
Type Description
Subscription

getSubscriptionCallable()

public final UnaryCallable<GetSubscriptionRequest,Subscription> getSubscriptionCallable()

Gets details about a Google Workspace subscription. To learn how to use this method, see Get details about a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   GetSubscriptionRequest request =
       GetSubscriptionRequest.newBuilder()
           .setName(SubscriptionName.of("[SUBSCRIPTION]").toString())
           .build();
   ApiFuture<Subscription> future =
       subscriptionsServiceClient.getSubscriptionCallable().futureCall(request);
   // Do something.
   Subscription response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetSubscriptionRequest,Subscription>

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listSubscriptions(ListSubscriptionsRequest request)

public final SubscriptionsServiceClient.ListSubscriptionsPagedResponse listSubscriptions(ListSubscriptionsRequest request)

Lists Google Workspace subscriptions. To learn how to use this method, see List Google Workspace subscriptions.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   ListSubscriptionsRequest request =
       ListSubscriptionsRequest.newBuilder()
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (Subscription element :
       subscriptionsServiceClient.listSubscriptions(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListSubscriptionsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
SubscriptionsServiceClient.ListSubscriptionsPagedResponse

listSubscriptions(String filter)

public final SubscriptionsServiceClient.ListSubscriptionsPagedResponse listSubscriptions(String filter)

Lists Google Workspace subscriptions. To learn how to use this method, see List Google Workspace subscriptions.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   String filter = "filter-1274492040";
   for (Subscription element :
       subscriptionsServiceClient.listSubscriptions(filter).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
filter String

Required. A query filter.

You can filter subscriptions by event type (event_types) and target resource (target_resource).

You must specify at least one event type in your query. To filter for multiple event types, use the OR operator.

To filter by both event type and target resource, use the AND operator and specify the full resource name, such as //chat.googleapis.com/spaces/{space}.

For example, the following queries are valid:

`<code> event_types:"google.workspace.chat.membership.v1.updated" OR event_types:"google.workspace.chat.message.v1.created" <p>event_types:"google.workspace.chat.message.v1.created" AND target_resource="//chat.googleapis.com/spaces/{space}" <p>( event_types:"google.workspace.chat.membership.v1.updated" OR event_types:"google.workspace.chat.message.v1.created" ) AND target_resource="//chat.googleapis.com/spaces/{space}" </code>

The server rejects invalid queries with an INVALID_ARGUMENT` error.

Returns
Type Description
SubscriptionsServiceClient.ListSubscriptionsPagedResponse

listSubscriptionsCallable()

public final UnaryCallable<ListSubscriptionsRequest,ListSubscriptionsResponse> listSubscriptionsCallable()

Lists Google Workspace subscriptions. To learn how to use this method, see List Google Workspace subscriptions.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   ListSubscriptionsRequest request =
       ListSubscriptionsRequest.newBuilder()
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListSubscriptionsResponse response =
         subscriptionsServiceClient.listSubscriptionsCallable().call(request);
     for (Subscription element : response.getSubscriptionsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListSubscriptionsRequest,ListSubscriptionsResponse>

listSubscriptionsPagedCallable()

public final UnaryCallable<ListSubscriptionsRequest,SubscriptionsServiceClient.ListSubscriptionsPagedResponse> listSubscriptionsPagedCallable()

Lists Google Workspace subscriptions. To learn how to use this method, see List Google Workspace subscriptions.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   ListSubscriptionsRequest request =
       ListSubscriptionsRequest.newBuilder()
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<Subscription> future =
       subscriptionsServiceClient.listSubscriptionsPagedCallable().futureCall(request);
   // Do something.
   for (Subscription element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListSubscriptionsRequest,ListSubscriptionsPagedResponse>

reactivateSubscriptionAsync(ReactivateSubscriptionRequest request)

public final OperationFuture<Subscription,ReactivateSubscriptionMetadata> reactivateSubscriptionAsync(ReactivateSubscriptionRequest request)

Reactivates a suspended Google Workspace subscription.

This method resets your subscription's State field to ACTIVE. Before you use this method, you must fix the error that suspended the subscription. To learn how to use this method, see Reactivate a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   ReactivateSubscriptionRequest request =
       ReactivateSubscriptionRequest.newBuilder()
           .setName(SubscriptionName.of("[SUBSCRIPTION]").toString())
           .build();
   Subscription response = subscriptionsServiceClient.reactivateSubscriptionAsync(request).get();
 }
 
Parameter
Name Description
request ReactivateSubscriptionRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<Subscription,ReactivateSubscriptionMetadata>

reactivateSubscriptionAsync(SubscriptionName name)

public final OperationFuture<Subscription,ReactivateSubscriptionMetadata> reactivateSubscriptionAsync(SubscriptionName name)

Reactivates a suspended Google Workspace subscription.

This method resets your subscription's State field to ACTIVE. Before you use this method, you must fix the error that suspended the subscription. To learn how to use this method, see Reactivate a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   SubscriptionName name = SubscriptionName.of("[SUBSCRIPTION]");
   Subscription response = subscriptionsServiceClient.reactivateSubscriptionAsync(name).get();
 }
 
Parameter
Name Description
name SubscriptionName

Required. Resource name of the subscription.

Format: subscriptions/{subscription}

Returns
Type Description
OperationFuture<Subscription,ReactivateSubscriptionMetadata>

reactivateSubscriptionAsync(String name)

public final OperationFuture<Subscription,ReactivateSubscriptionMetadata> reactivateSubscriptionAsync(String name)

Reactivates a suspended Google Workspace subscription.

This method resets your subscription's State field to ACTIVE. Before you use this method, you must fix the error that suspended the subscription. To learn how to use this method, see Reactivate a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   String name = SubscriptionName.of("[SUBSCRIPTION]").toString();
   Subscription response = subscriptionsServiceClient.reactivateSubscriptionAsync(name).get();
 }
 
Parameter
Name Description
name String

Required. Resource name of the subscription.

Format: subscriptions/{subscription}

Returns
Type Description
OperationFuture<Subscription,ReactivateSubscriptionMetadata>

reactivateSubscriptionCallable()

public final UnaryCallable<ReactivateSubscriptionRequest,Operation> reactivateSubscriptionCallable()

Reactivates a suspended Google Workspace subscription.

This method resets your subscription's State field to ACTIVE. Before you use this method, you must fix the error that suspended the subscription. To learn how to use this method, see Reactivate a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   ReactivateSubscriptionRequest request =
       ReactivateSubscriptionRequest.newBuilder()
           .setName(SubscriptionName.of("[SUBSCRIPTION]").toString())
           .build();
   ApiFuture<Operation> future =
       subscriptionsServiceClient.reactivateSubscriptionCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ReactivateSubscriptionRequest,Operation>

reactivateSubscriptionOperationCallable()

public final OperationCallable<ReactivateSubscriptionRequest,Subscription,ReactivateSubscriptionMetadata> reactivateSubscriptionOperationCallable()

Reactivates a suspended Google Workspace subscription.

This method resets your subscription's State field to ACTIVE. Before you use this method, you must fix the error that suspended the subscription. To learn how to use this method, see Reactivate a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   ReactivateSubscriptionRequest request =
       ReactivateSubscriptionRequest.newBuilder()
           .setName(SubscriptionName.of("[SUBSCRIPTION]").toString())
           .build();
   OperationFuture<Subscription, ReactivateSubscriptionMetadata> future =
       subscriptionsServiceClient.reactivateSubscriptionOperationCallable().futureCall(request);
   // Do something.
   Subscription response = future.get();
 }
 
Returns
Type Description
OperationCallable<ReactivateSubscriptionRequest,Subscription,ReactivateSubscriptionMetadata>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateSubscriptionAsync(Subscription subscription, FieldMask updateMask)

public final OperationFuture<Subscription,UpdateSubscriptionMetadata> updateSubscriptionAsync(Subscription subscription, FieldMask updateMask)

Updates or renews a Google Workspace subscription. To learn how to use this method, see Update or renew a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   Subscription subscription = Subscription.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Subscription response =
       subscriptionsServiceClient.updateSubscriptionAsync(subscription, updateMask).get();
 }
 
Parameters
Name Description
subscription Subscription

Required. The subscription to update.

The subscription's name field is used to identify the subscription to update.

updateMask FieldMask

Optional. Required. The field to update.

You can update one of the following fields in a subscription:

  • expire_time: The timestamp when the subscription expires.
  • ttl: The time-to-live (TTL) or duration of the subscription.

Returns
Type Description
OperationFuture<Subscription,UpdateSubscriptionMetadata>

updateSubscriptionAsync(UpdateSubscriptionRequest request)

public final OperationFuture<Subscription,UpdateSubscriptionMetadata> updateSubscriptionAsync(UpdateSubscriptionRequest request)

Updates or renews a Google Workspace subscription. To learn how to use this method, see Update or renew a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   UpdateSubscriptionRequest request =
       UpdateSubscriptionRequest.newBuilder()
           .setSubscription(Subscription.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .setValidateOnly(true)
           .build();
   Subscription response = subscriptionsServiceClient.updateSubscriptionAsync(request).get();
 }
 
Parameter
Name Description
request UpdateSubscriptionRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
OperationFuture<Subscription,UpdateSubscriptionMetadata>

updateSubscriptionCallable()

public final UnaryCallable<UpdateSubscriptionRequest,Operation> updateSubscriptionCallable()

Updates or renews a Google Workspace subscription. To learn how to use this method, see Update or renew a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   UpdateSubscriptionRequest request =
       UpdateSubscriptionRequest.newBuilder()
           .setSubscription(Subscription.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .setValidateOnly(true)
           .build();
   ApiFuture<Operation> future =
       subscriptionsServiceClient.updateSubscriptionCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateSubscriptionRequest,Operation>

updateSubscriptionOperationCallable()

public final OperationCallable<UpdateSubscriptionRequest,Subscription,UpdateSubscriptionMetadata> updateSubscriptionOperationCallable()

Updates or renews a Google Workspace subscription. To learn how to use this method, see Update or renew a Google Workspace subscription.

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 (SubscriptionsServiceClient subscriptionsServiceClient =
     SubscriptionsServiceClient.create()) {
   UpdateSubscriptionRequest request =
       UpdateSubscriptionRequest.newBuilder()
           .setSubscription(Subscription.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .setValidateOnly(true)
           .build();
   OperationFuture<Subscription, UpdateSubscriptionMetadata> future =
       subscriptionsServiceClient.updateSubscriptionOperationCallable().futureCall(request);
   // Do something.
   Subscription response = future.get();
 }
 
Returns
Type Description
OperationCallable<UpdateSubscriptionRequest,Subscription,UpdateSubscriptionMetadata>