lib/fluent/plugin/out_google_cloud.rb
def init_api_client
      if @use_grpc
        uri = URI.parse(@logging_api_url)
        host = uri.host
        unless host
          raise Fluent::ConfigError,
                'The logging_api_url option specifies an invalid URL:' \
                " #{@logging_api_url}."
        end
        if uri.scheme == 'https'
          ssl_creds = GRPC::Core::ChannelCredentials.new
          authentication = Google::Auth.get_application_default
          creds = GRPC::Core::CallCredentials.new(authentication.updater_proc)
          creds = ssl_creds.compose(creds)
        else
          creds = :this_channel_is_insecure
        end
        port = ":#{uri.port}" if uri.port
        user_agent = \
          "#{PLUGIN_NAME}/#{PLUGIN_VERSION} grpc-ruby/#{GRPC::VERSION} " \
          "#{Google::Apis::OS_VERSION}"
        @client = Google::Cloud::Logging::V2::LoggingServiceV2Client.new(
          credentials: GRPC::Core::Channel.new(
            "#{host}#{port}", { 'grpc.primary_user_agent' => user_agent },
            creds))
      else
        # TODO: Use a non-default ClientOptions object.
        Google::Apis::ClientOptions.default.application_name = PLUGIN_NAME
        Google::Apis::ClientOptions.default.application_version = PLUGIN_VERSION
        @client = Google::Apis::LoggingV2::LoggingService.new
        @client.authorization = Google::Auth.get_application_default(
          LOGGING_SCOPE)
      end
    end
# Constants for service names, resource types and etc.
Constants for service names, resource types and etc.
Constants for service names resource types and etc .
def init_api_client
      if @use_grpc
        uri = URI.parse(@logging_api_url)
        host = uri.host
        unless host
          raise Fluent::ConfigError,
                'The logging_api_url option specifies an invalid URL:' \
                " #{@logging_api_url}."
        end
        if uri.scheme == 'https'
          ssl_creds = GRPC::Core::ChannelCredentials.new
          authentication = Google::Auth.get_application_default
          creds = GRPC::Core::CallCredentials.new(authentication.updater_proc)
          creds = ssl_creds.compose(creds)
        else
          creds = :this_channel_is_insecure
        end
        port = ":#{uri.port}" if uri.port
        user_agent = \
          "#{PLUGIN_NAME}/#{PLUGIN_VERSION} grpc-ruby/#{GRPC::VERSION} " \
          "#{Google::Apis::OS_VERSION}"
        @client = Google::Cloud::Logging::V2::LoggingServiceV2Client.new(
          credentials: GRPC::Core::Channel.new(
            "#{host}#{port}", { 'grpc.primary_user_agent' => user_agent },
            creds))
      else
        Google::Apis::ClientOptions.default.application_name = PLUGIN_NAME
        Google::Apis::ClientOptions.default.application_version = PLUGIN_VERSION
        @client = Google::Apis::LoggingV2::LoggingService.new
        @client.authorization = Google::Auth.get_application_default(
          LOGGING_SCOPE)
      end
    end
def init_api_client if @use_grpc uri = URI . parse ( @logging_api_url ) host = uri . host unless host raise Fluent :: ConfigError , 'The logging_api_url option specifies an invalid URL:' " #{@logging_api_url}." end if uri . scheme == 'https' ssl_creds = GRPC :: Core :: ChannelCredentials . new authentication = Google :: Auth . get_application_default creds = GRPC :: Core :: CallCredentials . new ( authentication . updater_proc ) creds = ssl_creds . compose ( creds ) else creds = :this_channel_is_insecure end port = ":#{uri.port}" if uri . port user_agent = "#{PLUGIN_NAME}/#{PLUGIN_VERSION} grpc-ruby/#{GRPC::VERSION} " "#{Google::Apis::OS_VERSION}" @client = Google :: Cloud :: Logging :: V2 :: LoggingServiceV2Client . new ( credentials : GRPC :: Core :: Channel . new ( "#{host}#{port}" , { 'grpc.primary_user_agent' => user_agent } , creds ) ) else Google :: Apis :: ClientOptions . default . application_name = PLUGIN_NAME Google :: Apis :: ClientOptions . default . application_version = PLUGIN_VERSION @client = Google :: Apis :: LoggingV2 :: LoggingService . new @client . authorization = Google :: Auth . get_application_default ( LOGGING_SCOPE ) end end
Constants for service names, resource types and etc.
Constants for service names resource types and etc .
# TODO: Use a non-default ClientOptions object.