Class LinkedDeviceServiceClient (0.52.0)

GitHub RepositoryProduct Reference

Service Description: Provides methods for handling LinkedDevice 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 (LinkedDeviceServiceClient linkedDeviceServiceClient = LinkedDeviceServiceClient.create()) {
   LinkedDeviceName name = LinkedDeviceName.of("[NETWORK_CODE]", "[LINKED_DEVICE]");
   LinkedDevice response = linkedDeviceServiceClient.getLinkedDevice(name);
 }
 

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

GetLinkedDevice

Gets a LinkedDevice.

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

  • getLinkedDevice(GetLinkedDeviceRequest request)

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

  • getLinkedDevice(LinkedDeviceName name)

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

  • getLinkedDeviceCallable()

ListLinkedDevices

Lists LinkedDevice objects.

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

  • listLinkedDevices(ListLinkedDevicesRequest request)

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

  • listLinkedDevices(NetworkName parent)

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

  • listLinkedDevicesPagedCallable()

  • listLinkedDevicesCallable()

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 LinkedDeviceServiceSettings 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
 LinkedDeviceServiceSettings linkedDeviceServiceSettings =
     LinkedDeviceServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 LinkedDeviceServiceClient linkedDeviceServiceClient =
     LinkedDeviceServiceClient.create(linkedDeviceServiceSettings);
 

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
 LinkedDeviceServiceSettings linkedDeviceServiceSettings =
     LinkedDeviceServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 LinkedDeviceServiceClient linkedDeviceServiceClient =
     LinkedDeviceServiceClient.create(linkedDeviceServiceSettings);
 

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

Inheritance

java.lang.Object > LinkedDeviceServiceClient

Static Methods

create()

public static final LinkedDeviceServiceClient create()

Constructs an instance of LinkedDeviceServiceClient with default settings.

Returns
Type Description
LinkedDeviceServiceClient
Exceptions
Type Description
IOException

create(LinkedDeviceServiceSettings settings)

public static final LinkedDeviceServiceClient create(LinkedDeviceServiceSettings settings)

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

create(LinkedDeviceServiceStub stub)

public static final LinkedDeviceServiceClient create(LinkedDeviceServiceStub stub)

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

Parameter
Name Description
stub LinkedDeviceServiceStub
Returns
Type Description
LinkedDeviceServiceClient

Constructors

LinkedDeviceServiceClient(LinkedDeviceServiceSettings settings)

protected LinkedDeviceServiceClient(LinkedDeviceServiceSettings settings)

Constructs an instance of LinkedDeviceServiceClient, 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 LinkedDeviceServiceSettings

LinkedDeviceServiceClient(LinkedDeviceServiceStub stub)

protected LinkedDeviceServiceClient(LinkedDeviceServiceStub stub)
Parameter
Name Description
stub LinkedDeviceServiceStub

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

getLinkedDevice(GetLinkedDeviceRequest request)

public final LinkedDevice getLinkedDevice(GetLinkedDeviceRequest request)

Gets a LinkedDevice.

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 (LinkedDeviceServiceClient linkedDeviceServiceClient = LinkedDeviceServiceClient.create()) {
   GetLinkedDeviceRequest request =
       GetLinkedDeviceRequest.newBuilder()
           .setName(LinkedDeviceName.of("[NETWORK_CODE]", "[LINKED_DEVICE]").toString())
           .build();
   LinkedDevice response = linkedDeviceServiceClient.getLinkedDevice(request);
 }
 
Parameter
Name Description
request GetLinkedDeviceRequest

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

Returns
Type Description
LinkedDevice

getLinkedDevice(LinkedDeviceName name)

public final LinkedDevice getLinkedDevice(LinkedDeviceName name)

Gets a LinkedDevice.

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 (LinkedDeviceServiceClient linkedDeviceServiceClient = LinkedDeviceServiceClient.create()) {
   LinkedDeviceName name = LinkedDeviceName.of("[NETWORK_CODE]", "[LINKED_DEVICE]");
   LinkedDevice response = linkedDeviceServiceClient.getLinkedDevice(name);
 }
 
Parameter
Name Description
name LinkedDeviceName

Required. The resource name of the LinkedDevice. Format: networks/{network_code}/linkedDevices/{linked_device_id}

Returns
Type Description
LinkedDevice

getLinkedDevice(String name)

public final LinkedDevice getLinkedDevice(String name)

Gets a LinkedDevice.

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 (LinkedDeviceServiceClient linkedDeviceServiceClient = LinkedDeviceServiceClient.create()) {
   String name = LinkedDeviceName.of("[NETWORK_CODE]", "[LINKED_DEVICE]").toString();
   LinkedDevice response = linkedDeviceServiceClient.getLinkedDevice(name);
 }
 
Parameter
Name Description
name String

Required. The resource name of the LinkedDevice. Format: networks/{network_code}/linkedDevices/{linked_device_id}

Returns
Type Description
LinkedDevice

getLinkedDeviceCallable()

public final UnaryCallable<GetLinkedDeviceRequest,LinkedDevice> getLinkedDeviceCallable()

Gets a LinkedDevice.

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 (LinkedDeviceServiceClient linkedDeviceServiceClient = LinkedDeviceServiceClient.create()) {
   GetLinkedDeviceRequest request =
       GetLinkedDeviceRequest.newBuilder()
           .setName(LinkedDeviceName.of("[NETWORK_CODE]", "[LINKED_DEVICE]").toString())
           .build();
   ApiFuture<LinkedDevice> future =
       linkedDeviceServiceClient.getLinkedDeviceCallable().futureCall(request);
   // Do something.
   LinkedDevice response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetLinkedDeviceRequest,LinkedDevice>

getSettings()

public final LinkedDeviceServiceSettings getSettings()
Returns
Type Description
LinkedDeviceServiceSettings

getStub()

public LinkedDeviceServiceStub getStub()
Returns
Type Description
LinkedDeviceServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listLinkedDevices(ListLinkedDevicesRequest request)

public final LinkedDeviceServiceClient.ListLinkedDevicesPagedResponse listLinkedDevices(ListLinkedDevicesRequest request)

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

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

Returns
Type Description
LinkedDeviceServiceClient.ListLinkedDevicesPagedResponse

listLinkedDevices(NetworkName parent)

public final LinkedDeviceServiceClient.ListLinkedDevicesPagedResponse listLinkedDevices(NetworkName parent)

Lists LinkedDevice 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 (LinkedDeviceServiceClient linkedDeviceServiceClient = LinkedDeviceServiceClient.create()) {
   NetworkName parent = NetworkName.of("[NETWORK_CODE]");
   for (LinkedDevice element :
       linkedDeviceServiceClient.listLinkedDevices(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent NetworkName

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

Returns
Type Description
LinkedDeviceServiceClient.ListLinkedDevicesPagedResponse

listLinkedDevices(String parent)

public final LinkedDeviceServiceClient.ListLinkedDevicesPagedResponse listLinkedDevices(String parent)

Lists LinkedDevice 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 (LinkedDeviceServiceClient linkedDeviceServiceClient = LinkedDeviceServiceClient.create()) {
   String parent = NetworkName.of("[NETWORK_CODE]").toString();
   for (LinkedDevice element :
       linkedDeviceServiceClient.listLinkedDevices(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

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

Returns
Type Description
LinkedDeviceServiceClient.ListLinkedDevicesPagedResponse

listLinkedDevicesCallable()

public final UnaryCallable<ListLinkedDevicesRequest,ListLinkedDevicesResponse> listLinkedDevicesCallable()

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

listLinkedDevicesPagedCallable()

public final UnaryCallable<ListLinkedDevicesRequest,LinkedDeviceServiceClient.ListLinkedDevicesPagedResponse> listLinkedDevicesPagedCallable()

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

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()