Sha256: 34557f0898469658b1cfa99e58d30a5b7afa264f18c4e33c1ceb0f2886c8955e

Contents?: true

Size: 797 Bytes

Versions: 2

Compression:

Stored size: 797 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)
      except(all_monitors.select { |monitor| monitor['id'].to_s == id.to_s }.first)
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

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