Class: DatabricksGateway
- Inherits:
-
Object
- Object
- DatabricksGateway
- Includes:
- Databricks
- Defined in:
- lib/dbx/gateway.rb
Overview
This class is a gateway to the Databricks API. docs.databricks.com/api-explorer/workspace/introduction
Instance Method Summary collapse
-
#http ⇒ Net::HTTP
HTTP connection object.
-
#initialize(host: ENV.fetch("DBX_HOST", nil), token: ENV.fetch("DBX_TOKEN", nil), warehouse: ENV.fetch("DBX_WAREHOUSE_ID", nil), sleep_timer: 5) ⇒ DatabricksGateway
constructor
A new instance of DatabricksGateway.
-
#request_headers ⇒ Object
HTTP request headers.
Methods included from DatabricksJobs
#cancel_all_runs, #cancel_run, #create_job, #delete_job, #delete_run, #export_run, #get_run, #get_run_output, #job_info, #jobs_url, #list_jobs, #list_runs, #run_now, #submit_job
Methods included from DatabricksSQL
#get_sql_chunk, #get_sql_results, #load_additional_chunks, #post_sql_request, #run_sql, #sql_request, #sql_results_request, #sql_uri, #sql_url, #wait_for_sql_response
Constructor Details
#initialize(host: ENV.fetch("DBX_HOST", nil), token: ENV.fetch("DBX_TOKEN", nil), warehouse: ENV.fetch("DBX_WAREHOUSE_ID", nil), sleep_timer: 5) ⇒ DatabricksGateway
Returns a new instance of DatabricksGateway.
9 10 11 12 13 14 15 16 |
# File 'lib/dbx/gateway.rb', line 9 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 |
Instance Method Details
#http ⇒ Net::HTTP
HTTP connection object
29 30 31 32 33 |
# File 'lib/dbx/gateway.rb', line 29 def http http = Net::HTTP.new(@uri.host, @uri.port) http.use_ssl = true http end |
#request_headers ⇒ Object
HTTP request headers
19 20 21 22 23 24 25 |
# File 'lib/dbx/gateway.rb', line 19 def request_headers { "Authorization" => "Bearer #{@token}", "Content-Type" => "application/json", "Accept" => "application/json" } end |