Cloud Commerce Consumer Procurement v1 API - Class ConsumerProcurementServiceClient (1.2.0)

public abstract class ConsumerProcurementServiceClient

Reference documentation and code samples for the Cloud Commerce Consumer Procurement v1 API class ConsumerProcurementServiceClient.

ConsumerProcurementService client wrapper, for convenient use.

Inheritance

object > ConsumerProcurementServiceClient

Namespace

Google.Cloud.Commerce.Consumer.Procurement.V1

Assembly

Google.Cloud.Commerce.Consumer.Procurement.V1.dll

Remarks

ConsumerProcurementService allows customers to make purchases of products served by the Cloud Commerce platform.

When purchases are made, the [ConsumerProcurementService][google.cloud.commerce.consumer.procurement.v1.ConsumerProcurementService] programs the appropriate backends, including both Google's own infrastructure, as well as third-party systems, and to enable billing setup for charging for the procured item.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the ConsumerProcurementService service, which is a host of "cloudcommerceconsumerprocurement.googleapis.com" and a port of 443.

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default ConsumerProcurementService scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

The default ConsumerProcurementService scopes are:

GrpcClient

public virtual ConsumerProcurementService.ConsumerProcurementServiceClient GrpcClient { get; }

The underlying gRPC ConsumerProcurementService client

Property Value
Type Description
ConsumerProcurementServiceConsumerProcurementServiceClient

PlaceOrderOperationsClient

public virtual OperationsClient PlaceOrderOperationsClient { get; }

The long-running operations client for PlaceOrder.

Property Value
Type Description
OperationsClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

Methods

Create()

public static ConsumerProcurementServiceClient Create()

Synchronously creates a ConsumerProcurementServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use ConsumerProcurementServiceClientBuilder.

Returns
Type Description
ConsumerProcurementServiceClient

The created ConsumerProcurementServiceClient.

CreateAsync(CancellationToken)

public static Task<ConsumerProcurementServiceClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a ConsumerProcurementServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use ConsumerProcurementServiceClientBuilder.

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskConsumerProcurementServiceClient

The task representing the created ConsumerProcurementServiceClient.

GetOrder(GetOrderRequest, CallSettings)

public virtual Order GetOrder(GetOrderRequest request, CallSettings callSettings = null)

Returns the requested [Order][google.cloud.commerce.consumer.procurement.v1.Order] resource.

Parameters
Name Description
request GetOrderRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Order

The RPC response.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = ConsumerProcurementServiceClient.Create();
// Initialize request argument(s)
GetOrderRequest request = new GetOrderRequest { Name = "", };
// Make the request
Order response = consumerProcurementServiceClient.GetOrder(request);

GetOrder(string, CallSettings)

public virtual Order GetOrder(string name, CallSettings callSettings = null)

Returns the requested [Order][google.cloud.commerce.consumer.procurement.v1.Order] resource.

Parameters
Name Description
name string

Required. The name of the order to retrieve.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
Order

The RPC response.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = ConsumerProcurementServiceClient.Create();
// Initialize request argument(s)
string name = "";
// Make the request
Order response = consumerProcurementServiceClient.GetOrder(name);

GetOrderAsync(GetOrderRequest, CallSettings)

public virtual Task<Order> GetOrderAsync(GetOrderRequest request, CallSettings callSettings = null)

Returns the requested [Order][google.cloud.commerce.consumer.procurement.v1.Order] resource.

Parameters
Name Description
request GetOrderRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOrder

A Task containing the RPC response.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = await ConsumerProcurementServiceClient.CreateAsync();
// Initialize request argument(s)
GetOrderRequest request = new GetOrderRequest { Name = "", };
// Make the request
Order response = await consumerProcurementServiceClient.GetOrderAsync(request);

GetOrderAsync(GetOrderRequest, CancellationToken)

public virtual Task<Order> GetOrderAsync(GetOrderRequest request, CancellationToken cancellationToken)

Returns the requested [Order][google.cloud.commerce.consumer.procurement.v1.Order] resource.

Parameters
Name Description
request GetOrderRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskOrder

A Task containing the RPC response.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = await ConsumerProcurementServiceClient.CreateAsync();
// Initialize request argument(s)
GetOrderRequest request = new GetOrderRequest { Name = "", };
// Make the request
Order response = await consumerProcurementServiceClient.GetOrderAsync(request);

GetOrderAsync(string, CallSettings)

public virtual Task<Order> GetOrderAsync(string name, CallSettings callSettings = null)

Returns the requested [Order][google.cloud.commerce.consumer.procurement.v1.Order] resource.

Parameters
Name Description
name string

Required. The name of the order to retrieve.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOrder

A Task containing the RPC response.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = await ConsumerProcurementServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
Order response = await consumerProcurementServiceClient.GetOrderAsync(name);

GetOrderAsync(string, CancellationToken)

public virtual Task<Order> GetOrderAsync(string name, CancellationToken cancellationToken)

Returns the requested [Order][google.cloud.commerce.consumer.procurement.v1.Order] resource.

Parameters
Name Description
name string

Required. The name of the order to retrieve.

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskOrder

A Task containing the RPC response.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = await ConsumerProcurementServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "";
// Make the request
Order response = await consumerProcurementServiceClient.GetOrderAsync(name);

ListOrders(ListOrdersRequest, CallSettings)

public virtual PagedEnumerable<ListOrdersResponse, Order> ListOrders(ListOrdersRequest request, CallSettings callSettings = null)

Lists [Order][google.cloud.commerce.consumer.procurement.v1.Order] resources that the user has access to, within the scope of the parent resource.

Parameters
Name Description
request ListOrdersRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListOrdersResponseOrder

A pageable sequence of Order resources.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = ConsumerProcurementServiceClient.Create();
// Initialize request argument(s)
ListOrdersRequest request = new ListOrdersRequest
{
    Parent = "",
    Filter = "",
};
// Make the request
PagedEnumerable<ListOrdersResponse, Order> response = consumerProcurementServiceClient.ListOrders(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Order item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListOrdersResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Order item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Order> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Order item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListOrders(string, string, int?, CallSettings)

public virtual PagedEnumerable<ListOrdersResponse, Order> ListOrders(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists [Order][google.cloud.commerce.consumer.procurement.v1.Order] resources that the user has access to, within the scope of the parent resource.

Parameters
Name Description
parent string

Required. The parent resource to query for orders. This field has the form billingAccounts/{billing-account-id}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedEnumerableListOrdersResponseOrder

A pageable sequence of Order resources.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = ConsumerProcurementServiceClient.Create();
// Initialize request argument(s)
string parent = "";
// Make the request
PagedEnumerable<ListOrdersResponse, Order> response = consumerProcurementServiceClient.ListOrders(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (Order item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListOrdersResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Order item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Order> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Order item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListOrdersAsync(ListOrdersRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListOrdersResponse, Order> ListOrdersAsync(ListOrdersRequest request, CallSettings callSettings = null)

Lists [Order][google.cloud.commerce.consumer.procurement.v1.Order] resources that the user has access to, within the scope of the parent resource.

Parameters
Name Description
request ListOrdersRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListOrdersResponseOrder

A pageable asynchronous sequence of Order resources.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = await ConsumerProcurementServiceClient.CreateAsync();
// Initialize request argument(s)
ListOrdersRequest request = new ListOrdersRequest
{
    Parent = "",
    Filter = "",
};
// Make the request
PagedAsyncEnumerable<ListOrdersResponse, Order> response = consumerProcurementServiceClient.ListOrdersAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Order item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListOrdersResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Order item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Order> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Order item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ListOrdersAsync(string, string, int?, CallSettings)

public virtual PagedAsyncEnumerable<ListOrdersResponse, Order> ListOrdersAsync(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)

Lists [Order][google.cloud.commerce.consumer.procurement.v1.Order] resources that the user has access to, within the scope of the parent resource.

Parameters
Name Description
parent string

Required. The parent resource to query for orders. This field has the form billingAccounts/{billing-account-id}.

pageToken string

The token returned from the previous request. A value of null or an empty string retrieves the first page.

pageSize int

The size of page to request. The response will not be larger than this, but may be smaller. A value of null or 0 uses a server-defined page size.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
PagedAsyncEnumerableListOrdersResponseOrder

A pageable asynchronous sequence of Order resources.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = await ConsumerProcurementServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "";
// Make the request
PagedAsyncEnumerable<ListOrdersResponse, Order> response = consumerProcurementServiceClient.ListOrdersAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Order item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListOrdersResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Order item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Order> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Order item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

PlaceOrder(PlaceOrderRequest, CallSettings)

public virtual Operation<Order, PlaceOrderMetadata> PlaceOrder(PlaceOrderRequest request, CallSettings callSettings = null)

Creates a new [Order][google.cloud.commerce.consumer.procurement.v1.Order].

This API only supports GCP spend-based committed use discounts specified by GCP documentation.

The returned long-running operation is in-progress until the backend completes the creation of the resource. Once completed, the order is in [OrderState.ORDER_STATE_ACTIVE][google.cloud.commerce.consumer.procurement.v1.OrderState.ORDER_STATE_ACTIVE]. In case of failure, the order resource will be removed.

Parameters
Name Description
request PlaceOrderRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationOrderPlaceOrderMetadata

The RPC response.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = ConsumerProcurementServiceClient.Create();
// Initialize request argument(s)
PlaceOrderRequest request = new PlaceOrderRequest
{
    ParentAsBillingAccountName = BillingAccountName.FromBillingAccount("[BILLING_ACCOUNT]"),
    DisplayName = "",
    RequestId = "",
    LineItemInfo = { new LineItemInfo(), },
};
// Make the request
Operation<Order, PlaceOrderMetadata> response = consumerProcurementServiceClient.PlaceOrder(request);

// Poll until the returned long-running operation is complete
Operation<Order, PlaceOrderMetadata> completedResponse = response.PollUntilCompleted();
// Retrieve the operation result
Order result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Order, PlaceOrderMetadata> retrievedResponse = consumerProcurementServiceClient.PollOncePlaceOrder(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Order retrievedResult = retrievedResponse.Result;
}

PlaceOrderAsync(PlaceOrderRequest, CallSettings)

public virtual Task<Operation<Order, PlaceOrderMetadata>> PlaceOrderAsync(PlaceOrderRequest request, CallSettings callSettings = null)

Creates a new [Order][google.cloud.commerce.consumer.procurement.v1.Order].

This API only supports GCP spend-based committed use discounts specified by GCP documentation.

The returned long-running operation is in-progress until the backend completes the creation of the resource. Once completed, the order is in [OrderState.ORDER_STATE_ACTIVE][google.cloud.commerce.consumer.procurement.v1.OrderState.ORDER_STATE_ACTIVE]. In case of failure, the order resource will be removed.

Parameters
Name Description
request PlaceOrderRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationOrderPlaceOrderMetadata

A Task containing the RPC response.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = await ConsumerProcurementServiceClient.CreateAsync();
// Initialize request argument(s)
PlaceOrderRequest request = new PlaceOrderRequest
{
    ParentAsBillingAccountName = BillingAccountName.FromBillingAccount("[BILLING_ACCOUNT]"),
    DisplayName = "",
    RequestId = "",
    LineItemInfo = { new LineItemInfo(), },
};
// Make the request
Operation<Order, PlaceOrderMetadata> response = await consumerProcurementServiceClient.PlaceOrderAsync(request);

// Poll until the returned long-running operation is complete
Operation<Order, PlaceOrderMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Order result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Order, PlaceOrderMetadata> retrievedResponse = await consumerProcurementServiceClient.PollOncePlaceOrderAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Order retrievedResult = retrievedResponse.Result;
}

PlaceOrderAsync(PlaceOrderRequest, CancellationToken)

public virtual Task<Operation<Order, PlaceOrderMetadata>> PlaceOrderAsync(PlaceOrderRequest request, CancellationToken cancellationToken)

Creates a new [Order][google.cloud.commerce.consumer.procurement.v1.Order].

This API only supports GCP spend-based committed use discounts specified by GCP documentation.

The returned long-running operation is in-progress until the backend completes the creation of the resource. Once completed, the order is in [OrderState.ORDER_STATE_ACTIVE][google.cloud.commerce.consumer.procurement.v1.OrderState.ORDER_STATE_ACTIVE]. In case of failure, the order resource will be removed.

Parameters
Name Description
request PlaceOrderRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskOperationOrderPlaceOrderMetadata

A Task containing the RPC response.

Example
// Create client
ConsumerProcurementServiceClient consumerProcurementServiceClient = await ConsumerProcurementServiceClient.CreateAsync();
// Initialize request argument(s)
PlaceOrderRequest request = new PlaceOrderRequest
{
    ParentAsBillingAccountName = BillingAccountName.FromBillingAccount("[BILLING_ACCOUNT]"),
    DisplayName = "",
    RequestId = "",
    LineItemInfo = { new LineItemInfo(), },
};
// Make the request
Operation<Order, PlaceOrderMetadata> response = await consumerProcurementServiceClient.PlaceOrderAsync(request);

// Poll until the returned long-running operation is complete
Operation<Order, PlaceOrderMetadata> completedResponse = await response.PollUntilCompletedAsync();
// Retrieve the operation result
Order result = completedResponse.Result;

// Or get the name of the operation
string operationName = response.Name;
// This name can be stored, then the long-running operation retrieved later by name
Operation<Order, PlaceOrderMetadata> retrievedResponse = await consumerProcurementServiceClient.PollOncePlaceOrderAsync(operationName);
// Check if the retrieved long-running operation has completed
if (retrievedResponse.IsCompleted)
{
    // If it has completed, then access the result
    Order retrievedResult = retrievedResponse.Result;
}

PollOncePlaceOrder(string, CallSettings)

public virtual Operation<Order, PlaceOrderMetadata> PollOncePlaceOrder(string operationName, CallSettings callSettings = null)

Poll an operation once, using an operationName from a previous invocation of PlaceOrder.

Parameters
Name Description
operationName string

The name of a previously invoked operation. Must not be null or empty.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
OperationOrderPlaceOrderMetadata

The result of polling the operation.

PollOncePlaceOrderAsync(string, CallSettings)

public virtual Task<Operation<Order, PlaceOrderMetadata>> PollOncePlaceOrderAsync(string operationName, CallSettings callSettings = null)

Asynchronously poll an operation once, using an operationName from a previous invocation of PlaceOrder.

Parameters
Name Description
operationName string

The name of a previously invoked operation. Must not be null or empty.

callSettings CallSettings

If not null, applies overrides to this RPC call.

Returns
Type Description
TaskOperationOrderPlaceOrderMetadata

A task representing the result of polling the operation.

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
Type Description
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.