GitHub Repository | Product Reference |
Service Description: Provides methods for handling Order
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 (OrderServiceClient orderServiceClient = OrderServiceClient.create()) {
OrderName name = OrderName.of("[NETWORK_CODE]", "[ORDER]");
Order response = orderServiceClient.getOrder(name);
}
Note: close() needs to be called on the OrderServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
Method | Description | Method Variants |
---|---|---|
GetOrder |
API to retrieve an Order object. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListOrders |
API to retrieve a list of Fields used for literal matching in filter string:
|
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of OrderServiceSettings 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
OrderServiceSettings orderServiceSettings =
OrderServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
OrderServiceClient orderServiceClient = OrderServiceClient.create(orderServiceSettings);
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
OrderServiceSettings orderServiceSettings =
OrderServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
OrderServiceClient orderServiceClient = OrderServiceClient.create(orderServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final OrderServiceClient create()
Constructs an instance of OrderServiceClient with default settings.
Returns | |
---|---|
Type | Description |
OrderServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(OrderServiceSettings settings)
public static final OrderServiceClient create(OrderServiceSettings settings)
Constructs an instance of OrderServiceClient, 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 |
OrderServiceSettings |
Returns | |
---|---|
Type | Description |
OrderServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(OrderServiceStub stub)
public static final OrderServiceClient create(OrderServiceStub stub)
Constructs an instance of OrderServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(OrderServiceSettings).
Parameter | |
---|---|
Name | Description |
stub |
OrderServiceStub |
Returns | |
---|---|
Type | Description |
OrderServiceClient |
Constructors
OrderServiceClient(OrderServiceSettings settings)
protected OrderServiceClient(OrderServiceSettings settings)
Constructs an instance of OrderServiceClient, 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 |
OrderServiceSettings |
OrderServiceClient(OrderServiceStub stub)
protected OrderServiceClient(OrderServiceStub stub)
Parameter | |
---|---|
Name | Description |
stub |
OrderServiceStub |
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()
getOrder(GetOrderRequest request)
public final Order getOrder(GetOrderRequest request)
API to retrieve an Order 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 (OrderServiceClient orderServiceClient = OrderServiceClient.create()) {
GetOrderRequest request =
GetOrderRequest.newBuilder()
.setName(OrderName.of("[NETWORK_CODE]", "[ORDER]").toString())
.build();
Order response = orderServiceClient.getOrder(request);
}
Parameter | |
---|---|
Name | Description |
request |
GetOrderRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Order |
getOrder(OrderName name)
public final Order getOrder(OrderName name)
API to retrieve an Order 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 (OrderServiceClient orderServiceClient = OrderServiceClient.create()) {
OrderName name = OrderName.of("[NETWORK_CODE]", "[ORDER]");
Order response = orderServiceClient.getOrder(name);
}
Parameter | |
---|---|
Name | Description |
name |
OrderName Required. The resource name of the Order. Format:
|
Returns | |
---|---|
Type | Description |
Order |
getOrder(String name)
public final Order getOrder(String name)
API to retrieve an Order 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 (OrderServiceClient orderServiceClient = OrderServiceClient.create()) {
String name = OrderName.of("[NETWORK_CODE]", "[ORDER]").toString();
Order response = orderServiceClient.getOrder(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. The resource name of the Order. Format:
|
Returns | |
---|---|
Type | Description |
Order |
getOrderCallable()
public final UnaryCallable<GetOrderRequest,Order> getOrderCallable()
API to retrieve an Order 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 (OrderServiceClient orderServiceClient = OrderServiceClient.create()) {
GetOrderRequest request =
GetOrderRequest.newBuilder()
.setName(OrderName.of("[NETWORK_CODE]", "[ORDER]").toString())
.build();
ApiFuture<Order> future = orderServiceClient.getOrderCallable().futureCall(request);
// Do something.
Order response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<GetOrderRequest,Order> |
getSettings()
public final OrderServiceSettings getSettings()
Returns | |
---|---|
Type | Description |
OrderServiceSettings |
getStub()
public OrderServiceStub getStub()
Returns | |
---|---|
Type | Description |
OrderServiceStub |
isShutdown()
public boolean isShutdown()
Returns | |
---|---|
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Returns | |
---|---|
Type | Description |
boolean |
listOrders(ListOrdersRequest request)
public final OrderServiceClient.ListOrdersPagedResponse listOrders(ListOrdersRequest request)
API to retrieve a list of Order
objects.
Fields used for literal matching in filter string:
order_id
display_name
external_order_id
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 (OrderServiceClient orderServiceClient = OrderServiceClient.create()) {
ListOrdersRequest request =
ListOrdersRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
for (Order element : orderServiceClient.listOrders(request).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
request |
ListOrdersRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
OrderServiceClient.ListOrdersPagedResponse |
listOrders(NetworkName parent)
public final OrderServiceClient.ListOrdersPagedResponse listOrders(NetworkName parent)
API to retrieve a list of Order
objects.
Fields used for literal matching in filter string:
order_id
display_name
external_order_id
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 (OrderServiceClient orderServiceClient = OrderServiceClient.create()) {
NetworkName parent = NetworkName.of("[NETWORK_CODE]");
for (Order element : orderServiceClient.listOrders(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
NetworkName Required. The parent, which owns this collection of Orders. Format:
|
Returns | |
---|---|
Type | Description |
OrderServiceClient.ListOrdersPagedResponse |
listOrders(String parent)
public final OrderServiceClient.ListOrdersPagedResponse listOrders(String parent)
API to retrieve a list of Order
objects.
Fields used for literal matching in filter string:
order_id
display_name
external_order_id
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 (OrderServiceClient orderServiceClient = OrderServiceClient.create()) {
String parent = NetworkName.of("[NETWORK_CODE]").toString();
for (Order element : orderServiceClient.listOrders(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
String Required. The parent, which owns this collection of Orders. Format:
|
Returns | |
---|---|
Type | Description |
OrderServiceClient.ListOrdersPagedResponse |
listOrdersCallable()
public final UnaryCallable<ListOrdersRequest,ListOrdersResponse> listOrdersCallable()
API to retrieve a list of Order
objects.
Fields used for literal matching in filter string:
order_id
display_name
external_order_id
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 (OrderServiceClient orderServiceClient = OrderServiceClient.create()) {
ListOrdersRequest request =
ListOrdersRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
while (true) {
ListOrdersResponse response = orderServiceClient.listOrdersCallable().call(request);
for (Order element : response.getOrdersList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ListOrdersRequest,ListOrdersResponse> |
listOrdersPagedCallable()
public final UnaryCallable<ListOrdersRequest,OrderServiceClient.ListOrdersPagedResponse> listOrdersPagedCallable()
API to retrieve a list of Order
objects.
Fields used for literal matching in filter string:
order_id
display_name
external_order_id
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 (OrderServiceClient orderServiceClient = OrderServiceClient.create()) {
ListOrdersRequest request =
ListOrdersRequest.newBuilder()
.setParent(NetworkName.of("[NETWORK_CODE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setSkip(3532159)
.build();
ApiFuture<Order> future = orderServiceClient.listOrdersPagedCallable().futureCall(request);
// Do something.
for (Order element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ListOrdersRequest,ListOrdersPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()