Sha256: d8041084d14100b25bdcb7bb34335320c4156d5bb6dca266d3ff71f957398027

Contents?: true

Size: 841 Bytes

Versions: 15

Compression:

Stored size: 841 Bytes

Contents

# frozen_string_literal: true

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

    def api_service
      # The underlying class from Dogapi that talks to datadog
      client.instance_variable_get(:@monitor_svc)
    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

15 entries across 15 versions & 1 rubygems

Version Path
datadog_backup-2.0.2 lib/datadog_backup/monitors.rb
datadog_backup-2.0.1 lib/datadog_backup/monitors.rb
datadog_backup-2.0.0 lib/datadog_backup/monitors.rb
datadog_backup-1.1.4 lib/datadog_backup/monitors.rb
datadog_backup-1.1.3 lib/datadog_backup/monitors.rb
datadog_backup-1.1.2 lib/datadog_backup/monitors.rb
datadog_backup-1.1.1 lib/datadog_backup/monitors.rb
datadog_backup-1.1.0 lib/datadog_backup/monitors.rb
datadog_backup-1.0.5 lib/datadog_backup/monitors.rb
datadog_backup-1.0.4 lib/datadog_backup/monitors.rb
datadog_backup-1.0.3 lib/datadog_backup/monitors.rb
datadog_backup-1.0.2 lib/datadog_backup/monitors.rb
datadog_backup-1.0.1 lib/datadog_backup/monitors.rb
datadog_backup-1.0.1.alpha.1 lib/datadog_backup/monitors.rb
datadog_backup-1.0.0 lib/datadog_backup/monitors.rb