Class: Superset::Dataset::Duplicate
- Defined in:
- lib/superset/dataset/duplicate.rb
Constant Summary
Constants inherited from Request
Instance Attribute Summary collapse
-
#new_dataset_name ⇒ Object
readonly
Returns the value of attribute new_dataset_name.
-
#source_dataset_id ⇒ Object
readonly
Returns the value of attribute source_dataset_id.
Attributes inherited from Request
Instance Method Summary collapse
-
#initialize(source_dataset_id:, new_dataset_name:) ⇒ Duplicate
constructor
A new instance of Duplicate.
- #params ⇒ Object
- #perform ⇒ Object
- #response ⇒ Object
Methods inherited from Request
call, #query_params, #result, #superset_host
Methods included from Superset::Display
#display_headers, #headings, #list, #list_attributes, #result, #rows, #table, #title
Constructor Details
#initialize(source_dataset_id:, new_dataset_name:) ⇒ Duplicate
Returns a new instance of Duplicate.
10 11 12 13 |
# File 'lib/superset/dataset/duplicate.rb', line 10 def initialize(source_dataset_id: , new_dataset_name: ) @source_dataset_id = source_dataset_id @new_dataset_name = new_dataset_name end |
Instance Attribute Details
#new_dataset_name ⇒ Object (readonly)
Returns the value of attribute new_dataset_name.
8 9 10 |
# File 'lib/superset/dataset/duplicate.rb', line 8 def new_dataset_name @new_dataset_name end |
#source_dataset_id ⇒ Object (readonly)
Returns the value of attribute source_dataset_id.
8 9 10 |
# File 'lib/superset/dataset/duplicate.rb', line 8 def source_dataset_id @source_dataset_id end |
Instance Method Details
#params ⇒ Object
29 30 31 32 33 34 |
# File 'lib/superset/dataset/duplicate.rb', line 29 def params { "base_model_id" => source_dataset_id, "table_name" => new_dataset_name } end |
#perform ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/superset/dataset/duplicate.rb', line 15 def perform raise "Error: source_dataset_id integer is required" unless source_dataset_id.present? && source_dataset_id.is_a?(Integer) raise "Error: new_dataset_name string is required" unless new_dataset_name.present? && new_dataset_name.is_a?(String) raise "Error: new_dataset_name already in use in this schema: #{new_dataset_name}. Suggest you add (COPY) as a suffix to the name" if new_dataset_name_already_in_use? logger.info("Duplicating Source Dataset #{source_dataset.title} with id #{source_dataset_id}") new_dataset_id end |
#response ⇒ Object
25 26 27 |
# File 'lib/superset/dataset/duplicate.rb', line 25 def response @response ||= client.post(route, params) end |