class Google::Cloud::Billing::V1::CloudCatalog::Client

Client for the CloudCatalog service.

A catalog of Google Cloud Platform services and SKUs. Provides pricing information and metadata on Google Cloud Platform services and SKUs.

Attributes

cloud_catalog_stub[R]

@private

Public Class Methods

configure() { |configure| ... } click to toggle source

Configure the CloudCatalog Client class.

See {::Google::Cloud::Billing::V1::CloudCatalog::Client::Configuration} for a description of the configuration fields.

@example

# Modify the configuration for all CloudCatalog clients
::Google::Cloud::Billing::V1::CloudCatalog::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_catalog/client.rb, line 58
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.list_services.timeout = 60.0

    default_config.rpcs.list_skus.timeout = 60.0

    default_config
  end
  yield @configure if block_given?
  @configure
end
new() { |config| ... } click to toggle source

Create a new CloudCatalog client object.

@example

# Create a client using the default configuration
client = ::Google::Cloud::Billing::V1::CloudCatalog::Client.new

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

@yield [config] Configure the CloudCatalog client. @yieldparam config [Client::Configuration]

# File lib/google/cloud/billing/v1/cloud_catalog/client.rb, line 115
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_catalog_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_catalog_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::Billing::V1::CloudCatalog::Stub,
    credentials:  credentials,
    endpoint:     @config.endpoint,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors
  )
end

Public Instance Methods

configure() { |config| ... } click to toggle source

Configure the CloudCatalog 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::CloudCatalog::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_catalog/client.rb, line 94
def configure
  yield @config if block_given?
  @config
end
list_services(request, options = nil) { |response, operation| ... } click to toggle source

Lists all public cloud services.

@overload list_services(request, options = nil)

Pass arguments to `list_services` via a request object, either of type
{::Google::Cloud::Billing::V1::ListServicesRequest} or an equivalent Hash.

@param request [::Google::Cloud::Billing::V1::ListServicesRequest, ::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_services(page_size: nil, page_token: nil)

Pass arguments to `list_services` 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. Defaults to 5000.
@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 `ListServices`
  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::Service>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Google::Cloud::Billing::V1::Service>]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/billing/v1/cloud_catalog/client.rb, line 186
def list_services request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::V1::ListServicesRequest

  # 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_services.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_services.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_services.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @cloud_catalog_stub.call_rpc :list_services, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @cloud_catalog_stub, :list_services, 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
list_skus(request, options = nil) { |response, operation| ... } click to toggle source

Lists all publicly available SKUs for a given cloud service.

@overload list_skus(request, options = nil)

Pass arguments to `list_skus` via a request object, either of type
{::Google::Cloud::Billing::V1::ListSkusRequest} or an equivalent Hash.

@param request [::Google::Cloud::Billing::V1::ListSkusRequest, ::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_skus(parent: nil, start_time: nil, end_time: nil, currency_code: nil, page_size: nil, page_token: nil)

Pass arguments to `list_skus` 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 parent [::String]
  Required. The name of the service.
  Example: "services/DA34-426B-A397"
@param start_time [::Google::Protobuf::Timestamp, ::Hash]
  Optional inclusive start time of the time range for which the pricing
  versions will be returned. Timestamps in the future are not allowed.
  The time range has to be within a single calendar month in
  America/Los_Angeles timezone. Time range as a whole is optional. If not
  specified, the latest pricing will be returned (up to 12 hours old at
  most).
@param end_time [::Google::Protobuf::Timestamp, ::Hash]
  Optional exclusive end time of the time range for which the pricing
  versions will be returned. Timestamps in the future are not allowed.
  The time range has to be within a single calendar month in
  America/Los_Angeles timezone. Time range as a whole is optional. If not
  specified, the latest pricing will be returned (up to 12 hours old at
  most).
@param currency_code [::String]
  The ISO 4217 currency code for the pricing info in the response proto.
  Will use the conversion rate as of start_time.
  Optional. If not specified USD will be used.
@param page_size [::Integer]
  Requested page size. Defaults to 5000.
@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 `ListSkus`
  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::Sku>] @yieldparam operation [::GRPC::ActiveCall::Operation]

@return [::Gapic::PagedEnumerable<::Google::Cloud::Billing::V1::Sku>]

@raise [::Google::Cloud::Error] if the RPC is aborted.

# File lib/google/cloud/billing/v1/cloud_catalog/client.rb, line 274
def list_skus request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Billing::V1::ListSkusRequest

  # 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_skus.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 = {
    "parent" => request.parent
  }
  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_skus.timeout,
                         metadata:     metadata,
                         retry_policy: @config.rpcs.list_skus.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.metadata,
                         retry_policy: @config.retry_policy

  @cloud_catalog_stub.call_rpc :list_skus, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @cloud_catalog_stub, :list_skus, 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