Module: Gapic::Headers

Defined in:
lib/gapic/headers.rb

Overview

A collection of common header values.

Class Method Summary collapse

Class Method Details

.x_goog_api_client(ruby_version: nil, lib_name: nil, lib_version: nil, gax_version: nil, gapic_version: nil, grpc_version: nil, rest_version: nil, transports_version_send: [:grpc]) ⇒ Object

Parameters:

  • ruby_version (String) (defaults to: nil)

    The ruby version. Defaults to RUBY_VERSION.

  • lib_name (String) (defaults to: nil)

    The client library name.

  • lib_version (String) (defaults to: nil)

    The client library version.

  • gax_version (String) (defaults to: nil)

    The Gapic version. Defaults to Gapic::Common::VERSION.

  • gapic_version (String) (defaults to: nil)

    The Gapic version.

  • grpc_version (String) (defaults to: nil)

    The GRPC version. Defaults to GRPC::VERSION.

  • rest_version (String) (defaults to: nil)

    The Rest Library (Faraday) version. Defaults to Faraday::VERSION.

  • transports_version_send (Array) (defaults to: [:grpc])

    Which transports to send versions for. Allowed values to contain are: :grpc to send the GRPC library version (if defined) :rest to send the REST library version (if defined) Defaults to [:grpc]



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/gapic/headers.rb', line 35

def self.x_goog_api_client ruby_version: nil, lib_name: nil, lib_version: nil, gax_version: nil,
                           gapic_version: nil, grpc_version: nil, rest_version: nil,
                           transports_version_send: [:grpc]

  ruby_version ||= ::RUBY_VERSION
  gax_version  ||= ::Gapic::Common::VERSION
  grpc_version ||= ::GRPC::VERSION if defined? ::GRPC
  rest_version ||= ::Faraday::VERSION if defined? ::Faraday

  x_goog_api_client_header = ["gl-ruby/#{ruby_version}"]
  x_goog_api_client_header << "#{lib_name}/#{lib_version}" if lib_name
  x_goog_api_client_header << "gax/#{gax_version}"
  x_goog_api_client_header << "gapic/#{gapic_version}" if gapic_version
  x_goog_api_client_header << "grpc/#{grpc_version}" if grpc_version && transports_version_send.include?(:grpc)
  x_goog_api_client_header << "rest/#{rest_version}" if rest_version && transports_version_send.include?(:rest)
  x_goog_api_client_header.join " ".freeze
end