Skip to content

Commit

Permalink
add delete chart, dashboard, dataset and database
Browse files Browse the repository at this point in the history
  • Loading branch information
jonochang committed Dec 3, 2024
1 parent 78cd399 commit d0f9382
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/superset_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def create_chart(chart_params)
JSON.parse(resp.body)
end

def delete_chart(id)
resp = @http_conn.delete("chart/#{id}") do |req|
req.headers["X-CSRFToken"] = csrf_token
end
JSON.parse(resp.body)
end

def dataset(id)
resp = @http_conn.get("dataset/#{id}")
JSON.parse(resp.body)
Expand All @@ -63,6 +70,13 @@ def create_dataset(dataset_params)
JSON.parse(resp.body)
end

def delete_dataset(id)
resp = @http_conn.delete("dataset/#{id}") do |req|
req.headers["X-CSRFToken"] = csrf_token
end
JSON.parse(resp.body)
end

def databases(page: 0, page_size: 20)
query_param = format_query_param({ page: page, page_size: page_size })
resp = @http_conn.get("database/", q: query_param)
Expand All @@ -86,6 +100,13 @@ def create_database(database_params)
JSON.parse(resp.body)
end

def delete_database(id)
resp = @http_conn.delete("database/#{id}") do |req|
req.headers["X-CSRFToken"] = csrf_token
end
JSON.parse(resp.body)
end

def dashboard(id)
resp = @http_conn.get("dashboard/#{id}")
JSON.parse(resp.body)
Expand All @@ -98,6 +119,13 @@ def create_dashboard(dashboard_params)
JSON.parse(resp.body)
end

def delete_dashboard(id)
resp = @http_conn.delete("dashboard/#{id}") do |req|
req.headers["X-CSRFToken"] = csrf_token
end
JSON.parse(resp.body)
end

def format_query_param(query)
"(#{query.map { |k, v| "#{k}:#{v}" }.join(',')})"
end
Expand Down

0 comments on commit d0f9382

Please sign in to comment.