Billing V1 API - Class Google::Cloud::Billing::V1::CloudBilling::Rest::Client (v0.13.2)

Reference documentation and code samples for the Billing V1 API class Google::Cloud::Billing::V1::CloudBilling::Rest::Client.

REST client for the CloudBilling service.

Retrieves the Google Cloud Console billing accounts and associates them with projects.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the CloudBilling Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all CloudBilling clients
::Google::Cloud::Billing::V1::CloudBilling::Rest::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the CloudBilling Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#create_billing_account

def create_billing_account(request, options = nil) -> ::Google::Cloud::Billing::V1::BillingAccount
def create_billing_account(billing_account: nil) -> ::Google::Cloud::Billing::V1::BillingAccount

This method creates billing subaccounts.

Google Cloud resellers should use the Channel Services APIs, accounts.customers.create and accounts.customers.entitlements.create.

When creating a subaccount, the current authenticated user must have the billing.accounts.update IAM permission on the parent account, which is typically given to billing account administrators. This method will return an error if the parent account has not been provisioned as a reseller account.

Overloads
def create_billing_account(request, options = nil) -> ::Google::Cloud::Billing::V1::BillingAccount
Pass arguments to create_billing_account via a request object, either of type Google::Cloud::Billing::V1::CreateBillingAccountRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Billing::V1::CreateBillingAccountRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def create_billing_account(billing_account: nil) -> ::Google::Cloud::Billing::V1::BillingAccount
Pass arguments to create_billing_account via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • billing_account (::Google::Cloud::Billing::V1::BillingAccount, ::Hash) — Required. The billing account resource to create. Currently CreateBillingAccount only supports subaccount creation, so any created billing accounts must be under a provided parent billing account.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.

#get_billing_account

def get_billing_account(request, options = nil) -> ::Google::Cloud::Billing::V1::BillingAccount
def get_billing_account(name: nil) -> ::Google::Cloud::Billing::V1::BillingAccount

Gets information about a billing account. The current authenticated user must be a viewer of the billing account.

Overloads
def get_billing_account(request, options = nil) -> ::Google::Cloud::Billing::V1::BillingAccount
Pass arguments to get_billing_account via a request object, either of type GetBillingAccountRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Billing::V1::GetBillingAccountRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_billing_account(name: nil) -> ::Google::Cloud::Billing::V1::BillingAccount
Pass arguments to get_billing_account via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. The resource name of the billing account to retrieve. For example, billingAccounts/012345-567890-ABCDEF.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.

#get_iam_policy

def get_iam_policy(request, options = nil) -> ::Google::Iam::V1::Policy
def get_iam_policy(resource: nil, options: nil) -> ::Google::Iam::V1::Policy

Gets the access control policy for a billing account. The caller must have the billing.accounts.getIamPolicy permission on the account, which is often given to billing account viewers.

Overloads
def get_iam_policy(request, options = nil) -> ::Google::Iam::V1::Policy
Pass arguments to get_iam_policy via a request object, either of type Iam::V1::GetIamPolicyRequest or an equivalent Hash.
Parameters
  • request (::Google::Iam::V1::GetIamPolicyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_iam_policy(resource: nil, options: nil) -> ::Google::Iam::V1::Policy
Pass arguments to get_iam_policy via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • resource (::String) — REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
  • options (::Google::Iam::V1::GetPolicyOptions, ::Hash) — OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.

#get_project_billing_info

def get_project_billing_info(request, options = nil) -> ::Google::Cloud::Billing::V1::ProjectBillingInfo
def get_project_billing_info(name: nil) -> ::Google::Cloud::Billing::V1::ProjectBillingInfo

Gets the billing information for a project. The current authenticated user must have the resourcemanager.projects.get permission for the project, which can be granted by assigning the Project Viewer role.

Overloads
def get_project_billing_info(request, options = nil) -> ::Google::Cloud::Billing::V1::ProjectBillingInfo
Pass arguments to get_project_billing_info via a request object, either of type GetProjectBillingInfoRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Billing::V1::GetProjectBillingInfoRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_project_billing_info(name: nil) -> ::Google::Cloud::Billing::V1::ProjectBillingInfo
Pass arguments to get_project_billing_info via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. The resource name of the project for which billing information is retrieved. For example, projects/tokyo-rain-123.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.

#initialize

def initialize() { |config| ... } -> Client

Create a new CloudBilling REST client object.

Yields
  • (config) — Configure the CloudBilling client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Billing::V1::CloudBilling::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Billing::V1::CloudBilling::Rest::Client.new do |config|
  config.timeout = 10.0
end

#list_billing_accounts

def list_billing_accounts(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Billing::V1::BillingAccount>
def list_billing_accounts(page_size: nil, page_token: nil, filter: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Billing::V1::BillingAccount>

Lists the billing accounts that the current authenticated user has permission to view.

Overloads
def list_billing_accounts(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Billing::V1::BillingAccount>
Pass arguments to list_billing_accounts via a request object, either of type ListBillingAccountsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Billing::V1::ListBillingAccountsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_billing_accounts(page_size: nil, page_token: nil, filter: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Billing::V1::BillingAccount>
Pass arguments to list_billing_accounts via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • page_size (::Integer) — Requested page size. The maximum page size is 100; this is also the default.
  • page_token (::String) — A token identifying a page of results to return. This should be a next_page_token value returned from a previous ListBillingAccounts call. If unspecified, the first page of results is returned.
  • filter (::String) — Options for how to filter the returned billing accounts. Currently this only supports filtering for subaccounts under a single provided reseller billing account. (e.g. "master_billing_account=billingAccounts/012345-678901-ABCDEF"). Boolean algebra and other fields are not currently supported.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.

#list_project_billing_info

def list_project_billing_info(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Billing::V1::ProjectBillingInfo>
def list_project_billing_info(name: nil, page_size: nil, page_token: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Billing::V1::ProjectBillingInfo>

Lists the projects associated with a billing account. The current authenticated user must have the billing.resourceAssociations.list IAM permission, which is often given to billing account viewers.

Overloads
def list_project_billing_info(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Billing::V1::ProjectBillingInfo>
Pass arguments to list_project_billing_info via a request object, either of type ListProjectBillingInfoRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Billing::V1::ListProjectBillingInfoRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_project_billing_info(name: nil, page_size: nil, page_token: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Billing::V1::ProjectBillingInfo>
Pass arguments to list_project_billing_info via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • name (::String) — Required. The resource name of the billing account associated with the projects that you want to list. For example, billingAccounts/012345-567890-ABCDEF.
  • page_size (::Integer) — Requested page size. The maximum page size is 100; this is also the default.
  • page_token (::String) — A token identifying a page of results to be returned. This should be a next_page_token value returned from a previous ListProjectBillingInfo call. If unspecified, the first page of results is returned.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.

#set_iam_policy

def set_iam_policy(request, options = nil) -> ::Google::Iam::V1::Policy
def set_iam_policy(resource: nil, policy: nil, update_mask: nil) -> ::Google::Iam::V1::Policy

Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the billing.accounts.setIamPolicy permission on the account, which is often given to billing account administrators.

Overloads
def set_iam_policy(request, options = nil) -> ::Google::Iam::V1::Policy
Pass arguments to set_iam_policy via a request object, either of type Iam::V1::SetIamPolicyRequest or an equivalent Hash.
Parameters
  • request (::Google::Iam::V1::SetIamPolicyRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def set_iam_policy(resource: nil, policy: nil, update_mask: nil) -> ::Google::Iam::V1::Policy
Pass arguments to set_iam_policy via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • resource (::String) — REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
  • policy (::Google::Iam::V1::Policy, ::Hash) — REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.
  • update_mask (::Google::Protobuf::FieldMask, ::Hash) — OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used:

    paths: "bindings, etag"

Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.

#test_iam_permissions

def test_iam_permissions(request, options = nil) -> ::Google::Iam::V1::TestIamPermissionsResponse
def test_iam_permissions(resource: nil, permissions: nil) -> ::Google::Iam::V1::TestIamPermissionsResponse

Tests the access control policy for a billing account. This method takes the resource and a set of permissions as input and returns the subset of the input permissions that the caller is allowed for that resource.

Overloads
def test_iam_permissions(request, options = nil) -> ::Google::Iam::V1::TestIamPermissionsResponse
Pass arguments to test_iam_permissions via a request object, either of type Iam::V1::TestIamPermissionsRequest or an equivalent Hash.
Parameters
  • request (::Google::Iam::V1::TestIamPermissionsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def test_iam_permissions(resource: nil, permissions: nil) -> ::Google::Iam::V1::TestIamPermissionsResponse
Pass arguments to test_iam_permissions via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • resource (::String) — REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
  • permissions (::Array<::String>) — The set of permissions to check for the resource. Permissions with wildcards (such as '' or 'storage.') are not allowed. For more information see IAM Overview.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.

#update_billing_account

def update_billing_account(request, options = nil) -> ::Google::Cloud::Billing::V1::BillingAccount
def update_billing_account(name: nil, account: nil, update_mask: nil) -> ::Google::Cloud::Billing::V1::BillingAccount

Updates a billing account's fields. Currently the only field that can be edited is display_name. The current authenticated user must have the billing.accounts.update IAM permission, which is typically given to the administrator of the billing account.

Overloads
def update_billing_account(request, options = nil) -> ::Google::Cloud::Billing::V1::BillingAccount
Pass arguments to update_billing_account via a request object, either of type UpdateBillingAccountRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Billing::V1::UpdateBillingAccountRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def update_billing_account(name: nil, account: nil, update_mask: nil) -> ::Google::Cloud::Billing::V1::BillingAccount
Pass arguments to update_billing_account via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • name (::String) — Required. The name of the billing account resource to be updated.
  • account (::Google::Cloud::Billing::V1::BillingAccount, ::Hash) — Required. The billing account resource to replace the resource on the server.
  • update_mask (::Google::Protobuf::FieldMask, ::Hash) — The update mask applied to the resource. Only "display_name" is currently supported.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.

#update_project_billing_info

def update_project_billing_info(request, options = nil) -> ::Google::Cloud::Billing::V1::ProjectBillingInfo
def update_project_billing_info(name: nil, project_billing_info: nil) -> ::Google::Cloud::Billing::V1::ProjectBillingInfo

Sets or updates the billing account associated with a project. You specify the new billing account by setting the billing_account_name in the ProjectBillingInfo resource to the resource name of a billing account. Associating a project with an open billing account enables billing on the project and allows charges for resource usage. If the project already had a billing account, this method changes the billing account used for resource usage charges.

Note: Incurred charges that have not yet been reported in the transaction history of the Google Cloud Console might be billed to the new billing account, even if the charge occurred before the new billing account was assigned to the project.

The current authenticated user must have ownership privileges for both the project and the billing account.

You can disable billing on the project by setting the billing_account_name field to empty. This action disassociates the current billing account from the project. Any billable activity of your in-use services will stop, and your application could stop functioning as expected. Any unbilled charges to date will be billed to the previously associated account. The current authenticated user must be either an owner of the project or an owner of the billing account for the project.

Note that associating a project with a closed billing account will have much the same effect as disabling billing on the project: any paid resources used by the project will be shut down. Thus, unless you wish to disable billing, you should always call this method with the name of an open billing account.

Overloads
def update_project_billing_info(request, options = nil) -> ::Google::Cloud::Billing::V1::ProjectBillingInfo
Pass arguments to update_project_billing_info via a request object, either of type UpdateProjectBillingInfoRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Billing::V1::UpdateProjectBillingInfoRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def update_project_billing_info(name: nil, project_billing_info: nil) -> ::Google::Cloud::Billing::V1::ProjectBillingInfo
Pass arguments to update_project_billing_info via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • name (::String) — Required. The resource name of the project associated with the billing information that you want to update. For example, projects/tokyo-rain-123.
  • project_billing_info (::Google::Cloud::Billing::V1::ProjectBillingInfo, ::Hash) — The new billing information for the project. Output-only fields are ignored; thus, you can leave empty all fields except billing_account_name.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.