Cloud Billing Budget v1beta1 API - Class BudgetServiceClient (2.0.0-beta05)

public abstract class BudgetServiceClient

Reference documentation and code samples for the Cloud Billing Budget v1beta1 API class BudgetServiceClient.

BudgetService client wrapper, for convenient use.

Inheritance

object > BudgetServiceClient

Derived Types

Namespace

Google.Cloud.Billing.Budgets.V1Beta1

Assembly

Google.Cloud.Billing.Budgets.V1Beta1.dll

Remarks

BudgetService stores Cloud Billing budgets, which define a budget plan and rules to execute as we track spend against that plan.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

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

Property Value
Type Description
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default BudgetService scopes.

Property Value
Type Description
IReadOnlyListstring
Remarks

GrpcClient

public virtual BudgetService.BudgetServiceClient GrpcClient { get; }

The underlying gRPC BudgetService client

Property Value
Type Description
BudgetServiceBudgetServiceClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
Type Description
ServiceMetadata

Methods

Create()

public static BudgetServiceClient Create()

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

Returns
Type Description
BudgetServiceClient

The created BudgetServiceClient.

CreateAsync(CancellationToken)

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

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

Parameter
Name Description
cancellationToken CancellationToken

The CancellationToken to use while creating the client.

Returns
Type Description
TaskBudgetServiceClient

The task representing the created BudgetServiceClient.

CreateBudget(CreateBudgetRequest, CallSettings)

public virtual Budget CreateBudget(CreateBudgetRequest request, CallSettings callSettings = null)

Creates a new budget. See Quotas and limits for more information on the limits of the number of budgets you can create.

Parameters
Name Description
request CreateBudgetRequest

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
Budget

The RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = BudgetServiceClient.Create();
// Initialize request argument(s)
CreateBudgetRequest request = new CreateBudgetRequest
{
    ParentAsBillingAccountName = BillingAccountName.FromBillingAccount("[BILLING_ACCOUNT]"),
    Budget = new Budget(),
};
// Make the request
Budget response = budgetServiceClient.CreateBudget(request);

CreateBudgetAsync(CreateBudgetRequest, CallSettings)

public virtual Task<Budget> CreateBudgetAsync(CreateBudgetRequest request, CallSettings callSettings = null)

Creates a new budget. See Quotas and limits for more information on the limits of the number of budgets you can create.

Parameters
Name Description
request CreateBudgetRequest

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
TaskBudget

A Task containing the RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = await BudgetServiceClient.CreateAsync();
// Initialize request argument(s)
CreateBudgetRequest request = new CreateBudgetRequest
{
    ParentAsBillingAccountName = BillingAccountName.FromBillingAccount("[BILLING_ACCOUNT]"),
    Budget = new Budget(),
};
// Make the request
Budget response = await budgetServiceClient.CreateBudgetAsync(request);

CreateBudgetAsync(CreateBudgetRequest, CancellationToken)

public virtual Task<Budget> CreateBudgetAsync(CreateBudgetRequest request, CancellationToken cancellationToken)

Creates a new budget. See Quotas and limits for more information on the limits of the number of budgets you can create.

Parameters
Name Description
request CreateBudgetRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskBudget

A Task containing the RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = await BudgetServiceClient.CreateAsync();
// Initialize request argument(s)
CreateBudgetRequest request = new CreateBudgetRequest
{
    ParentAsBillingAccountName = BillingAccountName.FromBillingAccount("[BILLING_ACCOUNT]"),
    Budget = new Budget(),
};
// Make the request
Budget response = await budgetServiceClient.CreateBudgetAsync(request);

DeleteBudget(DeleteBudgetRequest, CallSettings)

public virtual void DeleteBudget(DeleteBudgetRequest request, CallSettings callSettings = null)

Deletes a budget. Returns successfully if already deleted.

Parameters
Name Description
request DeleteBudgetRequest

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

callSettings CallSettings

If not null, applies overrides to this RPC call.

Example
// Create client
BudgetServiceClient budgetServiceClient = BudgetServiceClient.Create();
// Initialize request argument(s)
DeleteBudgetRequest request = new DeleteBudgetRequest
{
    BudgetName = BudgetName.FromBillingAccountBudget("[BILLING_ACCOUNT]", "[BUDGET]"),
};
// Make the request
budgetServiceClient.DeleteBudget(request);

DeleteBudgetAsync(DeleteBudgetRequest, CallSettings)

public virtual Task DeleteBudgetAsync(DeleteBudgetRequest request, CallSettings callSettings = null)

Deletes a budget. Returns successfully if already deleted.

Parameters
Name Description
request DeleteBudgetRequest

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
Task

A Task containing the RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = await BudgetServiceClient.CreateAsync();
// Initialize request argument(s)
DeleteBudgetRequest request = new DeleteBudgetRequest
{
    BudgetName = BudgetName.FromBillingAccountBudget("[BILLING_ACCOUNT]", "[BUDGET]"),
};
// Make the request
await budgetServiceClient.DeleteBudgetAsync(request);

DeleteBudgetAsync(DeleteBudgetRequest, CancellationToken)

public virtual Task DeleteBudgetAsync(DeleteBudgetRequest request, CancellationToken cancellationToken)

Deletes a budget. Returns successfully if already deleted.

Parameters
Name Description
request DeleteBudgetRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
Task

A Task containing the RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = await BudgetServiceClient.CreateAsync();
// Initialize request argument(s)
DeleteBudgetRequest request = new DeleteBudgetRequest
{
    BudgetName = BudgetName.FromBillingAccountBudget("[BILLING_ACCOUNT]", "[BUDGET]"),
};
// Make the request
await budgetServiceClient.DeleteBudgetAsync(request);

GetBudget(GetBudgetRequest, CallSettings)

public virtual Budget GetBudget(GetBudgetRequest request, CallSettings callSettings = null)

Returns a budget.

WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. When reading from the API, you will not see these fields in the return value, though they may have been set in the Cloud Console.

Parameters
Name Description
request GetBudgetRequest

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
Budget

The RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = BudgetServiceClient.Create();
// Initialize request argument(s)
GetBudgetRequest request = new GetBudgetRequest
{
    BudgetName = BudgetName.FromBillingAccountBudget("[BILLING_ACCOUNT]", "[BUDGET]"),
};
// Make the request
Budget response = budgetServiceClient.GetBudget(request);

GetBudgetAsync(GetBudgetRequest, CallSettings)

public virtual Task<Budget> GetBudgetAsync(GetBudgetRequest request, CallSettings callSettings = null)

Returns a budget.

WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. When reading from the API, you will not see these fields in the return value, though they may have been set in the Cloud Console.

Parameters
Name Description
request GetBudgetRequest

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
TaskBudget

A Task containing the RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = await BudgetServiceClient.CreateAsync();
// Initialize request argument(s)
GetBudgetRequest request = new GetBudgetRequest
{
    BudgetName = BudgetName.FromBillingAccountBudget("[BILLING_ACCOUNT]", "[BUDGET]"),
};
// Make the request
Budget response = await budgetServiceClient.GetBudgetAsync(request);

GetBudgetAsync(GetBudgetRequest, CancellationToken)

public virtual Task<Budget> GetBudgetAsync(GetBudgetRequest request, CancellationToken cancellationToken)

Returns a budget.

WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. When reading from the API, you will not see these fields in the return value, though they may have been set in the Cloud Console.

Parameters
Name Description
request GetBudgetRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskBudget

A Task containing the RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = await BudgetServiceClient.CreateAsync();
// Initialize request argument(s)
GetBudgetRequest request = new GetBudgetRequest
{
    BudgetName = BudgetName.FromBillingAccountBudget("[BILLING_ACCOUNT]", "[BUDGET]"),
};
// Make the request
Budget response = await budgetServiceClient.GetBudgetAsync(request);

ListBudgets(ListBudgetsRequest, CallSettings)

public virtual PagedEnumerable<ListBudgetsResponse, Budget> ListBudgets(ListBudgetsRequest request, CallSettings callSettings = null)

Returns a list of budgets for a billing account.

WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. When reading from the API, you will not see these fields in the return value, though they may have been set in the Cloud Console.

Parameters
Name Description
request ListBudgetsRequest

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
PagedEnumerableListBudgetsResponseBudget

A pageable sequence of Budget resources.

Example
// Create client
BudgetServiceClient budgetServiceClient = BudgetServiceClient.Create();
// Initialize request argument(s)
ListBudgetsRequest request = new ListBudgetsRequest
{
    ParentAsBillingAccountName = BillingAccountName.FromBillingAccount("[BILLING_ACCOUNT]"),
    Scope = "",
};
// Make the request
PagedEnumerable<ListBudgetsResponse, Budget> response = budgetServiceClient.ListBudgets(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (Budget 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 (ListBudgetsResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Budget 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<Budget> 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 (Budget 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;

ListBudgetsAsync(ListBudgetsRequest, CallSettings)

public virtual PagedAsyncEnumerable<ListBudgetsResponse, Budget> ListBudgetsAsync(ListBudgetsRequest request, CallSettings callSettings = null)

Returns a list of budgets for a billing account.

WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. When reading from the API, you will not see these fields in the return value, though they may have been set in the Cloud Console.

Parameters
Name Description
request ListBudgetsRequest

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
PagedAsyncEnumerableListBudgetsResponseBudget

A pageable asynchronous sequence of Budget resources.

Example
// Create client
BudgetServiceClient budgetServiceClient = await BudgetServiceClient.CreateAsync();
// Initialize request argument(s)
ListBudgetsRequest request = new ListBudgetsRequest
{
    ParentAsBillingAccountName = BillingAccountName.FromBillingAccount("[BILLING_ACCOUNT]"),
    Scope = "",
};
// Make the request
PagedAsyncEnumerable<ListBudgetsResponse, Budget> response = budgetServiceClient.ListBudgetsAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Budget 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((ListBudgetsResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (Budget 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<Budget> 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 (Budget 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;

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.

UpdateBudget(UpdateBudgetRequest, CallSettings)

public virtual Budget UpdateBudget(UpdateBudgetRequest request, CallSettings callSettings = null)

Updates a budget and returns the updated budget.

WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. Budget fields that are not exposed in this API will not be changed by this method.

Parameters
Name Description
request UpdateBudgetRequest

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
Budget

The RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = BudgetServiceClient.Create();
// Initialize request argument(s)
UpdateBudgetRequest request = new UpdateBudgetRequest
{
    Budget = new Budget(),
    UpdateMask = new FieldMask(),
};
// Make the request
Budget response = budgetServiceClient.UpdateBudget(request);

UpdateBudgetAsync(UpdateBudgetRequest, CallSettings)

public virtual Task<Budget> UpdateBudgetAsync(UpdateBudgetRequest request, CallSettings callSettings = null)

Updates a budget and returns the updated budget.

WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. Budget fields that are not exposed in this API will not be changed by this method.

Parameters
Name Description
request UpdateBudgetRequest

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
TaskBudget

A Task containing the RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = await BudgetServiceClient.CreateAsync();
// Initialize request argument(s)
UpdateBudgetRequest request = new UpdateBudgetRequest
{
    Budget = new Budget(),
    UpdateMask = new FieldMask(),
};
// Make the request
Budget response = await budgetServiceClient.UpdateBudgetAsync(request);

UpdateBudgetAsync(UpdateBudgetRequest, CancellationToken)

public virtual Task<Budget> UpdateBudgetAsync(UpdateBudgetRequest request, CancellationToken cancellationToken)

Updates a budget and returns the updated budget.

WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. Budget fields that are not exposed in this API will not be changed by this method.

Parameters
Name Description
request UpdateBudgetRequest

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

cancellationToken CancellationToken

A CancellationToken to use for this RPC.

Returns
Type Description
TaskBudget

A Task containing the RPC response.

Example
// Create client
BudgetServiceClient budgetServiceClient = await BudgetServiceClient.CreateAsync();
// Initialize request argument(s)
UpdateBudgetRequest request = new UpdateBudgetRequest
{
    Budget = new Budget(),
    UpdateMask = new FieldMask(),
};
// Make the request
Budget response = await budgetServiceClient.UpdateBudgetAsync(request);