# 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)) @base_url = host @uri = URI(@base_url) @token = token @warehouse = warehouse end # HTTP request headers def request_headers { "Authorization" => "Bearer #{@token}", "Content-Type" => "application/json", "Accept" => "application/json" } end # HTTP connection object def http http = Net::HTTP.new(@uri.host, @uri.port) http.use_ssl = true http end # include DatabricksSQL, DatabricksJobs include Databricks end