Class: Superset::Database::Export

Inherits:
Request
  • Object
show all
Includes:
FileUtilities
Defined in:
lib/superset/database/export.rb

Constant Summary collapse

TMP_SUPERSET_DATABASE_PATH =
'/tmp/superset_database_exports'.freeze

Constants inherited from Request

Request::PAGE_SIZE

Instance Attribute Summary collapse

Attributes inherited from Request

#page_num

Instance Method Summary collapse

Methods included from FileUtilities

#unzip_file

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(database_id:, destination_path:, remove_dataset_yamls: true) ⇒ Export

Returns a new instance of Export.



24
25
26
27
28
# File 'lib/superset/database/export.rb', line 24

def initialize(database_id: , destination_path: , remove_dataset_yamls: true)
  @database_id = database_id
  @destination_path = destination_path.chomp('/')
  @remove_dataset_yamls = remove_dataset_yamls
end

Instance Attribute Details

#database_idObject (readonly)

Returns the value of attribute database_id.



22
23
24
# File 'lib/superset/database/export.rb', line 22

def database_id
  @database_id
end

#destination_pathObject (readonly)

Returns the value of attribute destination_path.



22
23
24
# File 'lib/superset/database/export.rb', line 22

def destination_path
  @destination_path
end

#remove_dataset_yamlsObject (readonly)

Returns the value of attribute remove_dataset_yamls.



22
23
24
# File 'lib/superset/database/export.rb', line 22

def remove_dataset_yamls
  @remove_dataset_yamls
end

Instance Method Details

#exported_zip_pathObject



47
48
49
# File 'lib/superset/database/export.rb', line 47

def exported_zip_path
  @exported_zip_path ||= "#{tmp_uniq_database_path}/database_#{database_id}_export_#{datestamp}.zip"
end

#performObject



30
31
32
33
34
35
36
37
# File 'lib/superset/database/export.rb', line 30

def perform
  create_tmp_dir
  save_exported_zip_file
  unzip_files
  copy_export_files_to_destination_path

  Dir.glob("#{destination_path_with_db_id}/databases/*")
end

#responseObject



39
40
41
42
43
44
45
# File 'lib/superset/database/export.rb', line 39

def response
  @response ||= client.call(
    :get,
    client.url(route),
    client.param_check(params)
  )
end