Sha256: a6dd4d69538566c4b54bbd63d6a1ca0f3506d7cd900a457234e127cf4b570e49

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

# frozen_string_literal: true

require "net/http"
require_relative "databricks/databricks"

# This class is a gateway to the Databricks API.
# https://docs.databricks.com/api-explorer/workspace/introduction
class DatabricksGateway
  def initialize(host: ENV.fetch("DBX_HOST", nil), token: ENV.fetch("DBX_TOKEN", nil),
                 warehouse: ENV.fetch("DBX_WAREHOUSE_ID", nil), sleep_timer: 5)
    @base_url = host
    @uri = URI(@base_url)
    @token = token
    @warehouse = warehouse
    @sleep_timer = sleep_timer
  end

  # HTTP request headers
  def request_headers
    {
      "Authorization" => "Bearer #{@token}",
      "Content-Type" => "application/json",
      "Accept" => "application/json"
    }
  end

  # HTTP connection object
  # @return [Net::HTTP]
  def http
    http = Net::HTTP.new(@uri.host, @uri.port)
    http.use_ssl = true
    http
  end

  # include DatabricksSQL, DatabricksJobs
  include Databricks
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dbx-api-0.2.1 lib/dbx/gateway.rb
dbx-api-0.2.0 lib/dbx/gateway.rb