Class: DatadogBackup::Dashboards

Inherits:
Core
  • Object
show all
Defined in:
lib/datadog_backup/dashboards.rb

Overview

Dashboards specific overrides for backup and restore.

Instance Method Summary collapse

Methods inherited from Core

#api_service, #api_url, #body_with_2xx, #create, #diff, #except, #get, #get_all, #get_and_write_file, #get_by_id, #myclass, #restore, #update

Methods included from Options

#action, #backup_dir, #concurrency_limit, #diff_format, #force_restore, #output_format, #resources

Methods included from LocalFilesystem

#all_file_ids, #all_file_ids_for_selected_resources, #all_files, #class_from_id, #dump, #file_type, #filename, #find_file_by_id, #load_from_file, #load_from_file_by_id, #mydir, #purge, #write_file

Constructor Details

#initialize(options) ⇒ Dashboards

Returns a new instance of Dashboards.



37
38
39
40
# File 'lib/datadog_backup/dashboards.rb', line 37

def initialize(options)
  super(options)
  @banlist = %w[modified_at url].freeze
end

Instance Method Details

#allObject



6
7
8
# File 'lib/datadog_backup/dashboards.rb', line 6

def all
  get_all.fetch('dashboards')
end

#api_resource_nameObject



14
15
16
# File 'lib/datadog_backup/dashboards.rb', line 14

def api_resource_name
  'dashboard'
end

#api_versionObject



10
11
12
# File 'lib/datadog_backup/dashboards.rb', line 10

def api_version
  'v1'
end

#backupObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/datadog_backup/dashboards.rb', line 22

def backup
  LOGGER.info("Starting diffs on #{::DatadogBackup::ThreadPool::TPOOL.max_length} threads")
  futures = all.map do |dashboard|
    Concurrent::Promises.future_on(::DatadogBackup::ThreadPool::TPOOL, dashboard) do |board|
      id = board[id_keyname]
      get_and_write_file(id)
    end
  end

  watcher = ::DatadogBackup::ThreadPool.watcher
  watcher.join if watcher.status

  Concurrent::Promises.zip(*futures).value!
end

#id_keynameObject



18
19
20
# File 'lib/datadog_backup/dashboards.rb', line 18

def id_keyname
  'id'
end