Class BrowserServiceClient (0.39.0)

GitHub RepositoryProduct Reference

Service Description: Provides methods for handling Browser objects.

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 (BrowserServiceClient browserServiceClient = BrowserServiceClient.create()) {
   BrowserName name = BrowserName.of("[NETWORK_CODE]", "[BROWSER]");
   Browser response = browserServiceClient.getBrowser(name);
 }
 

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

GetBrowser

API to retrieve a Browser object.

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

  • getBrowser(GetBrowserRequest request)

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

  • getBrowser(BrowserName name)

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

  • getBrowserCallable()

ListBrowsers

API to retrieve a list of Browser objects.

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

  • listBrowsers(ListBrowsersRequest request)

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

  • listBrowsers(NetworkName parent)

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

  • listBrowsersPagedCallable()

  • listBrowsersCallable()

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 BrowserServiceSettings 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
 BrowserServiceSettings browserServiceSettings =
     BrowserServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 BrowserServiceClient browserServiceClient = BrowserServiceClient.create(browserServiceSettings);
 

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
 BrowserServiceSettings browserServiceSettings =
     BrowserServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 BrowserServiceClient browserServiceClient = BrowserServiceClient.create(browserServiceSettings);
 

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

Inheritance

java.lang.Object > BrowserServiceClient

Static Methods

create()

public static final BrowserServiceClient create()

Constructs an instance of BrowserServiceClient with default settings.

Returns
Type Description
BrowserServiceClient
Exceptions
Type Description
IOException

create(BrowserServiceSettings settings)

public static final BrowserServiceClient create(BrowserServiceSettings settings)

Constructs an instance of BrowserServiceClient, 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 BrowserServiceSettings
Returns
Type Description
BrowserServiceClient
Exceptions
Type Description
IOException

create(BrowserServiceStub stub)

public static final BrowserServiceClient create(BrowserServiceStub stub)

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

Parameter
Name Description
stub BrowserServiceStub
Returns
Type Description
BrowserServiceClient

Constructors

BrowserServiceClient(BrowserServiceSettings settings)

protected BrowserServiceClient(BrowserServiceSettings settings)

Constructs an instance of BrowserServiceClient, 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 BrowserServiceSettings

BrowserServiceClient(BrowserServiceStub stub)

protected BrowserServiceClient(BrowserServiceStub stub)
Parameter
Name Description
stub BrowserServiceStub

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

getBrowser(BrowserName name)

public final Browser getBrowser(BrowserName name)

API to retrieve a Browser object.

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 (BrowserServiceClient browserServiceClient = BrowserServiceClient.create()) {
   BrowserName name = BrowserName.of("[NETWORK_CODE]", "[BROWSER]");
   Browser response = browserServiceClient.getBrowser(name);
 }
 
Parameter
Name Description
name BrowserName

Required. The resource name of the Browser. Format: networks/{network_code}/browsers/{browser_id}

Returns
Type Description
Browser

getBrowser(GetBrowserRequest request)

public final Browser getBrowser(GetBrowserRequest request)

API to retrieve a Browser object.

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 (BrowserServiceClient browserServiceClient = BrowserServiceClient.create()) {
   GetBrowserRequest request =
       GetBrowserRequest.newBuilder()
           .setName(BrowserName.of("[NETWORK_CODE]", "[BROWSER]").toString())
           .build();
   Browser response = browserServiceClient.getBrowser(request);
 }
 
Parameter
Name Description
request GetBrowserRequest

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

Returns
Type Description
Browser

getBrowser(String name)

public final Browser getBrowser(String name)

API to retrieve a Browser object.

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 (BrowserServiceClient browserServiceClient = BrowserServiceClient.create()) {
   String name = BrowserName.of("[NETWORK_CODE]", "[BROWSER]").toString();
   Browser response = browserServiceClient.getBrowser(name);
 }
 
Parameter
Name Description
name String

Required. The resource name of the Browser. Format: networks/{network_code}/browsers/{browser_id}

Returns
Type Description
Browser

getBrowserCallable()

public final UnaryCallable<GetBrowserRequest,Browser> getBrowserCallable()

API to retrieve a Browser object.

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 (BrowserServiceClient browserServiceClient = BrowserServiceClient.create()) {
   GetBrowserRequest request =
       GetBrowserRequest.newBuilder()
           .setName(BrowserName.of("[NETWORK_CODE]", "[BROWSER]").toString())
           .build();
   ApiFuture<Browser> future = browserServiceClient.getBrowserCallable().futureCall(request);
   // Do something.
   Browser response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetBrowserRequest,Browser>

getSettings()

public final BrowserServiceSettings getSettings()
Returns
Type Description
BrowserServiceSettings

getStub()

public BrowserServiceStub getStub()
Returns
Type Description
BrowserServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listBrowsers(ListBrowsersRequest request)

public final BrowserServiceClient.ListBrowsersPagedResponse listBrowsers(ListBrowsersRequest request)

API to retrieve a list of Browser objects.

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 (BrowserServiceClient browserServiceClient = BrowserServiceClient.create()) {
   ListBrowsersRequest request =
       ListBrowsersRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   for (Browser element : browserServiceClient.listBrowsers(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListBrowsersRequest

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

Returns
Type Description
BrowserServiceClient.ListBrowsersPagedResponse

listBrowsers(NetworkName parent)

public final BrowserServiceClient.ListBrowsersPagedResponse listBrowsers(NetworkName parent)

API to retrieve a list of Browser objects.

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 (BrowserServiceClient browserServiceClient = BrowserServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   for (Browser element : browserServiceClient.listBrowsers(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent NetworkName

Required. The parent, which owns this collection of Browsers. Format: networks/{network_code}

Returns
Type Description
BrowserServiceClient.ListBrowsersPagedResponse

listBrowsers(String parent)

public final BrowserServiceClient.ListBrowsersPagedResponse listBrowsers(String parent)

API to retrieve a list of Browser objects.

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 (BrowserServiceClient browserServiceClient = BrowserServiceClient.create()) {
   String parent = NetworkName.of("[NETWORK_CODE]").toString();
   for (Browser element : browserServiceClient.listBrowsers(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The parent, which owns this collection of Browsers. Format: networks/{network_code}

Returns
Type Description
BrowserServiceClient.ListBrowsersPagedResponse

listBrowsersCallable()

public final UnaryCallable<ListBrowsersRequest,ListBrowsersResponse> listBrowsersCallable()

API to retrieve a list of Browser objects.

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 (BrowserServiceClient browserServiceClient = BrowserServiceClient.create()) {
   ListBrowsersRequest request =
       ListBrowsersRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   while (true) {
     ListBrowsersResponse response = browserServiceClient.listBrowsersCallable().call(request);
     for (Browser element : response.getBrowsersList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListBrowsersRequest,ListBrowsersResponse>

listBrowsersPagedCallable()

public final UnaryCallable<ListBrowsersRequest,BrowserServiceClient.ListBrowsersPagedResponse> listBrowsersPagedCallable()

API to retrieve a list of Browser objects.

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 (BrowserServiceClient browserServiceClient = BrowserServiceClient.create()) {
   ListBrowsersRequest request =
       ListBrowsersRequest.newBuilder()
           .setParent(NetworkName.of("[NETWORK_CODE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setSkip(3532159)
           .build();
   ApiFuture<Browser> future =
       browserServiceClient.listBrowsersPagedCallable().futureCall(request);
   // Do something.
   for (Browser element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListBrowsersRequest,ListBrowsersPagedResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()