class Google::Cloud::Billing::V1::CloudBilling::Client
Client
for the CloudBilling
service.
Retrieves GCP Console billing accounts and associates them with projects.
Attributes
@private
Public Class Methods
Configure the CloudBilling
Client
class.
See {::Google::Cloud::Billing::V1::CloudBilling::Client::Configuration} for a description of the configuration fields.
@example
# Modify the configuration for all CloudBilling clients ::Google::Cloud::Billing::V1::CloudBilling::Client.configure do |config| config.timeout = 10.0 end
@yield [config] Configure the Client
client. @yieldparam config [Client::Configuration]
@return [Client::Configuration]
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 56 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "Billing", "V1"] parent_config = while namespace.any? parent_name = namespace.join "::" parent_const = const_get parent_name break parent_const.configure if parent_const.respond_to? :configure namespace.pop end default_config = Client::Configuration.new parent_config default_config.rpcs.get_billing_account.timeout = 60.0 default_config.rpcs.get_billing_account.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config.rpcs.list_billing_accounts.timeout = 60.0 default_config.rpcs.list_billing_accounts.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config.rpcs.update_billing_account.timeout = 60.0 default_config.rpcs.update_billing_account.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config.rpcs.create_billing_account.timeout = 60.0 default_config.rpcs.list_project_billing_info.timeout = 60.0 default_config.rpcs.list_project_billing_info.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config.rpcs.get_project_billing_info.timeout = 60.0 default_config.rpcs.get_project_billing_info.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config.rpcs.update_project_billing_info.timeout = 60.0 default_config.rpcs.update_project_billing_info.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config.rpcs.get_iam_policy.timeout = 60.0 default_config.rpcs.get_iam_policy.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config.rpcs.set_iam_policy.timeout = 60.0 default_config.rpcs.set_iam_policy.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config.rpcs.test_iam_permissions.timeout = 60.0 default_config.rpcs.test_iam_permissions.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config end yield @configure if block_given? @configure end
Create a new CloudBilling
client object.
@example
# Create a client using the default configuration client = ::Google::Cloud::Billing::V1::CloudBilling::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Billing::V1::CloudBilling::Client.new do |config| config.timeout = 10.0 end
@yield [config] Configure the CloudBilling
client. @yieldparam config [Client::Configuration]
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 156 def initialize # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "gapic/grpc" require "google/cloud/billing/v1/cloud_billing_services_pb" # Create the configuration object @config = Configuration.new Client.configure # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials # Use self-signed JWT if the endpoint is unchanged from default, # but only if the default endpoint does not have a region prefix. enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint && !@config.endpoint.split(".").first.include?("-") credentials ||= Credentials.default scope: @config.scope, enable_self_signed_jwt: enable_self_signed_jwt if credentials.is_a?(::String) || credentials.is_a?(::Hash) credentials = Credentials.new credentials, scope: @config.scope end @quota_project_id = @config.quota_project @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id @cloud_billing_stub = ::Gapic::ServiceStub.new( ::Google::Cloud::Billing::V1::CloudBilling::Stub, credentials: credentials, endpoint: @config.endpoint, channel_args: @config.channel_args, interceptors: @config.interceptors ) end
Public Instance Methods
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 {::Google::Cloud::Billing::V1::CloudBilling::Client::Configuration} for a description of the configuration fields.
@yield [config] Configure the Client
client. @yieldparam config [Client::Configuration]
@return [Client::Configuration]
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 135 def configure yield @config if block_given? @config end
Creates a billing account. This method can only be used to create [billing subaccounts](cloud.google.com/billing/docs/concepts) by GCP resellers. When creating a subaccount, the current authenticated user must have the `billing.accounts.update` IAM permission on the master account, which is typically given to billing account [administrators](cloud.google.com/billing/docs/how-to/billing-access). This method will return an error if the master account has not been provisioned as a reseller account.
@overload create_billing_account
(request, options = nil)
Pass arguments to `create_billing_account` via a request object, either of type {::Google::Cloud::Billing::V1::CreateBillingAccountRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload create_billing_account
(billing_account: nil)
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). @param 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 master billing account.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Billing::V1::BillingAccount] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Billing::V1::BillingAccount]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 461 def create_billing_account request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::V1::CreateBillingAccountRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.create_billing_account.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Billing::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.create_billing_account.timeout, metadata: metadata, retry_policy: @config.rpcs.create_billing_account.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_billing_stub.call_rpc :create_billing_account, request, options: options do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
Gets information about a billing account. The current authenticated user must be a [viewer of the billing account](cloud.google.com/billing/docs/how-to/billing-access).
@overload get_billing_account
(request, options = nil)
Pass arguments to `get_billing_account` via a request object, either of type {::Google::Cloud::Billing::V1::GetBillingAccountRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload get_billing_account
(name: nil)
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). @param name [::String] Required. The resource name of the billing account to retrieve. For example, `billingAccounts/012345-567890-ABCDEF`.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Billing::V1::BillingAccount] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Billing::V1::BillingAccount]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 226 def get_billing_account request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::V1::GetBillingAccountRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.get_billing_account.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Billing::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.get_billing_account.timeout, metadata: metadata, retry_policy: @config.rpcs.get_billing_account.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_billing_stub.call_rpc :get_billing_account, request, options: options do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
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](cloud.google.com/billing/docs/how-to/billing-access).
@overload get_iam_policy
(request, options = nil)
Pass arguments to `get_iam_policy` via a request object, either of type {::Google::Iam::V1::GetIamPolicyRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload get_iam_policy
(resource: nil, options: nil)
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). @param resource [::String] REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. @param options [::Google::Iam::V1::GetPolicyOptions, ::Hash] OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`. This field is only used by Cloud IAM.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Iam::V1::Policy] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Iam::V1::Policy]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 784 def get_iam_policy request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::GetIamPolicyRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.get_iam_policy.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Billing::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "resource" => request.resource } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.get_iam_policy.timeout, metadata: metadata, retry_policy: @config.rpcs.get_iam_policy.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_billing_stub.call_rpc :get_iam_policy, request, options: options do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
Gets the billing information for a project. The current authenticated user must have [permission to view the project](cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ).
@overload get_project_billing_info
(request, options = nil)
Pass arguments to `get_project_billing_info` via a request object, either of type {::Google::Cloud::Billing::V1::GetProjectBillingInfoRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload get_project_billing_info
(name: nil)
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). @param name [::String] Required. The resource name of the project for which billing information is retrieved. For example, `projects/tokyo-rain-123`.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Billing::V1::ProjectBillingInfo] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Billing::V1::ProjectBillingInfo]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 607 def get_project_billing_info request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::V1::GetProjectBillingInfoRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.get_project_billing_info.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Billing::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.get_project_billing_info.timeout, metadata: metadata, retry_policy: @config.rpcs.get_project_billing_info.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_billing_stub.call_rpc :get_project_billing_info, request, options: options do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
Lists the billing accounts that the current authenticated user has permission to [view](cloud.google.com/billing/docs/how-to/billing-access).
@overload list_billing_accounts
(request, options = nil)
Pass arguments to `list_billing_accounts` via a request object, either of type {::Google::Cloud::Billing::V1::ListBillingAccountsRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload list_billing_accounts
(page_size: nil, page_token: nil, filter: nil)
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). @param page_size [::Integer] Requested page size. The maximum page size is 100; this is also the default. @param 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. @param filter [::String] Options for how to filter the returned billing accounts. Currently this only supports filtering for [subaccounts](https://cloud.google.com/billing/docs/concepts) 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.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Billing::V1::BillingAccount>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Gapic::PagedEnumerable<::Google::Cloud::Billing::V1::BillingAccount>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 308 def list_billing_accounts request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::V1::ListBillingAccountsRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.list_billing_accounts.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Billing::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.list_billing_accounts.timeout, metadata: metadata, retry_policy: @config.rpcs.list_billing_accounts.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_billing_stub.call_rpc :list_billing_accounts, request, options: options do |response, operation| response = ::Gapic::PagedEnumerable.new @cloud_billing_stub, :list_billing_accounts, request, response, operation, options yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
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](cloud.google.com/billing/docs/how-to/billing-access).
@overload list_project_billing_info
(request, options = nil)
Pass arguments to `list_project_billing_info` via a request object, either of type {::Google::Cloud::Billing::V1::ListProjectBillingInfoRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload list_project_billing_info
(name: nil, page_size: nil, page_token: nil)
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). @param 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`. @param page_size [::Integer] Requested page size. The maximum page size is 100; this is also the default. @param 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.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Billing::V1::ProjectBillingInfo>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Gapic::PagedEnumerable<::Google::Cloud::Billing::V1::ProjectBillingInfo>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 534 def list_project_billing_info request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::V1::ListProjectBillingInfoRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.list_project_billing_info.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Billing::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.list_project_billing_info.timeout, metadata: metadata, retry_policy: @config.rpcs.list_project_billing_info.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_billing_stub.call_rpc :list_project_billing_info, request, options: options do |response, operation| response = ::Gapic::PagedEnumerable.new @cloud_billing_stub, :list_project_billing_info, request, response, operation, options yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
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](cloud.google.com/billing/docs/how-to/billing-access).
@overload set_iam_policy
(request, options = nil)
Pass arguments to `set_iam_policy` via a request object, either of type {::Google::Iam::V1::SetIamPolicyRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload set_iam_policy
(resource: nil, policy: nil)
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). @param resource [::String] REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. @param 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.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Iam::V1::Policy] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Iam::V1::Policy]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 862 def set_iam_policy request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::SetIamPolicyRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.set_iam_policy.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Billing::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "resource" => request.resource } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.set_iam_policy.timeout, metadata: metadata, retry_policy: @config.rpcs.set_iam_policy.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_billing_stub.call_rpc :set_iam_policy, request, options: options do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
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.
@overload test_iam_permissions
(request, options = nil)
Pass arguments to `test_iam_permissions` via a request object, either of type {::Google::Iam::V1::TestIamPermissionsRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload test_iam_permissions
(resource: nil, permissions: nil)
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). @param resource [::String] REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. @param 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](https://cloud.google.com/iam/docs/overview#permissions).
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Iam::V1::TestIamPermissionsResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Iam::V1::TestIamPermissionsResponse]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 938 def test_iam_permissions request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Iam::V1::TestIamPermissionsRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.test_iam_permissions.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Billing::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "resource" => request.resource } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.test_iam_permissions.timeout, metadata: metadata, retry_policy: @config.rpcs.test_iam_permissions.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_billing_stub.call_rpc :test_iam_permissions, request, options: options do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
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](cloud.google.com/billing/docs/how-to/billing-access) of the billing account.
@overload update_billing_account
(request, options = nil)
Pass arguments to `update_billing_account` via a request object, either of type {::Google::Cloud::Billing::V1::UpdateBillingAccountRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload update_billing_account
(name: nil, account: nil, update_mask: nil)
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). @param name [::String] Required. The name of the billing account resource to be updated. @param account [::Google::Cloud::Billing::V1::BillingAccount, ::Hash] Required. The billing account resource to replace the resource on the server. @param update_mask [::Google::Protobuf::FieldMask, ::Hash] The update mask applied to the resource. Only "display_name" is currently supported.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Billing::V1::BillingAccount] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Billing::V1::BillingAccount]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 381 def update_billing_account request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::V1::UpdateBillingAccountRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.update_billing_account.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Billing::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.update_billing_account.timeout, metadata: metadata, retry_policy: @config.rpcs.update_billing_account.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_billing_stub.call_rpc :update_billing_account, request, options: options do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end
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 GCP 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](cloud.google.com/docs/permissions-overview#h.bgs0oxofvnoo ) and the [billing account](cloud.google.com/billing/docs/how-to/billing-access).
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.
@overload update_project_billing_info
(request, options = nil)
Pass arguments to `update_project_billing_info` via a request object, either of type {::Google::Cloud::Billing::V1::UpdateProjectBillingInfoRequest} or an equivalent Hash. @param 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. @param options [::Gapic::CallOptions, ::Hash] Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@overload update_project_billing_info
(name: nil, project_billing_info: nil)
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). @param 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`. @param project_billing_info [::Google::Cloud::Billing::V1::ProjectBillingInfo, ::Hash] The new billing information for the project. Read-only fields are ignored; thus, you can leave empty all fields except `billing_account_name`.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Billing::V1::ProjectBillingInfo] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Billing::V1::ProjectBillingInfo]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/billing/v1/cloud_billing/client.rb, line 709 def update_project_billing_info request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::V1::UpdateProjectBillingInfoRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.update_project_billing_info.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Billing::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.update_project_billing_info.timeout, metadata: metadata, retry_policy: @config.rpcs.update_project_billing_info.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @cloud_billing_stub.call_rpc :update_project_billing_info, request, options: options do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end