Sha256: c9ebb5bf3aa419082343325534455a3f2d1166675cd02e4dd9a8df8333c649c3

Contents?: true

Size: 699 Bytes

Versions: 3

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

module DatadogBackup
  class Monitors < Core
    def all_monitors
      @all_monitors ||= get_all
    end

    def api_version
      'v1'
    end

    def api_resource_name
      'monitor'
    end

    def backup
      all_monitors.map do |monitor|
        id = monitor['id']
        write_file(dump(get_by_id(id)), filename(id))
      end
    end

    def get_by_id(id)
      monitor = all_monitors.select { |monitor| monitor['id'].to_s == id.to_s }.first
      monitor.nil? ? {} : except(monitor)
    end

    def initialize(options)
      super(options)
      @banlist = %w[overall_state overall_state_modified matching_downtimes modified].freeze
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datadog_backup-3.0.0 lib/datadog_backup/monitors.rb
datadog_backup-3.0.0.alpha.2 lib/datadog_backup/monitors.rb
datadog_backup-3.0.0.alpha.1 lib/datadog_backup/monitors.rb