Module: Google::Area120::Tables

Defined in:
lib/google/area120/tables.rb,
lib/google/area120/tables/version.rb

Constant Summary collapse

VERSION =
"0.7.2"

Class Method Summary collapse

Class Method Details

.tables_service(version: :v1alpha1, transport: :grpc, &block) ⇒ ::Object

Create a new client object for TablesService.

By default, this returns an instance of Google::Area120::Tables::V1alpha1::TablesService::Client for a gRPC client for version V1alpha1 of the API. However, you can specify a different API version by passing it in the version parameter. If the TablesService service is supported by that API version, and the corresponding gem is available, the appropriate versioned client will be returned. You can also specify a different transport by passing :rest or :grpc in the transport parameter.

Raises an exception if the currently installed versioned client gem for the given API version does not support the given transport of the TablesService service. You can determine whether the method will succeed by calling tables_service_available?.

About TablesService

The Tables Service provides an API for reading and updating tables. It defines the following resource model:

  • The API has a collection of Table resources, named tables/*

  • Each Table has a collection of Row resources, named tables/*/rows/*

  • The API has a collection of Workspace resources, named workspaces/*.

Parameters:

  • version (::String, ::Symbol) (defaults to: :v1alpha1)

    The API version to connect to. Optional. Defaults to :v1alpha1.

  • transport (:grpc, :rest) (defaults to: :grpc)

    The transport to use. Defaults to :grpc.

Returns:

  • (::Object)

    A client object for the specified version.



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/google/area120/tables.rb', line 68

def self.tables_service version: :v1alpha1, transport: :grpc, &block
  require "google/area120/tables/#{version.to_s.downcase}"

  package_name = Google::Area120::Tables
                 .constants
                 .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
                 .first
  service_module = Google::Area120::Tables.const_get(package_name).const_get(:TablesService)
  service_module = service_module.const_get(:Rest) if transport == :rest
  service_module.const_get(:Client).new(&block)
end

.tables_service_available?(version: :v1alpha1, transport: :grpc) ⇒ boolean

Determines whether the TablesService service is supported by the current client. If true, you can retrieve a client object by calling tables_service. If false, that method will raise an exception. This could happen if the given API version does not exist or does not support the TablesService service, or if the versioned client gem needs an update to support the TablesService service.

Parameters:

  • version (::String, ::Symbol) (defaults to: :v1alpha1)

    The API version to connect to. Optional. Defaults to :v1alpha1.

  • transport (:grpc, :rest) (defaults to: :grpc)

    The transport to use. Defaults to :grpc.

Returns:

  • (boolean)

    Whether the service is available.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/google/area120/tables.rb', line 92

def self.tables_service_available? version: :v1alpha1, transport: :grpc
  require "google/area120/tables/#{version.to_s.downcase}"
  package_name = Google::Area120::Tables
                 .constants
                 .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
                 .first
  return false unless package_name
  service_module = Google::Area120::Tables.const_get package_name
  return false unless service_module.const_defined? :TablesService
  service_module = service_module.const_get :TablesService
  if transport == :rest
    return false unless service_module.const_defined? :Rest
    service_module = service_module.const_get :Rest
  end
  service_module.const_defined? :Client
rescue ::LoadError
  false
end