Sha256: e70bd51a1cde425fe463e8db2b26c5bf22c0f2447afd65ab42c0f4c9ad17b1fc

Contents?: true

Size: 1.67 KB

Versions: 3

Compression:

Stored size: 1.67 KB

Contents

require 'httparty'
require 'json'
require 'uri'

require 'flapjack-diner/version'
require 'flapjack-diner/argument_validator'

module Flapjack
  module Diner
    module Resources
      module Checks
        def create_checks(*args)
          data = unwrap_data(*args)
          validate_params(data) do
            validate :query => :id, :as => :uuid
            validate :query => :name, :as => [:required, :non_empty_string]
            validate :query => :enabled, :as => :boolean
            validate :query => :tags, :as => :multiple_link
          end
          perform_post(:checks, '/checks', data)
        end

        def checks(*args)
          ids, data = unwrap_uuids(*args), unwrap_data(*args)
          validate_params(data) do
            validate :query => [:fields, :sort, :include], :as => :string_or_array_of_strings
            validate :query => :filter, :as => :hash
            validate :query => [:page, :per_page], :as => :positive_integer
          end
          perform_get('/checks', ids, data)
        end

        def update_checks(*args)
          data = unwrap_data(*args)
          validate_params(data) do
            validate :query => :id, :as => [:required, :uuid]
            validate :query => :name, :as => :non_empty_string
            validate :query => :enabled, :as => :boolean
            validate :query => :tags, :as => :multiple_link
          end
          perform_patch(:checks, "/checks", data)
        end

        def delete_checks(*ids)
          raise "'delete_checks' requires at least one check id " \
                'parameter' if ids.nil? || ids.empty?
          perform_delete(:checks, '/checks', *ids)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flapjack-diner-2.0.0.pre.alpha.3 lib/flapjack-diner/resources/checks.rb
flapjack-diner-2.0.0.pre.alpha.2 lib/flapjack-diner/resources/checks.rb
flapjack-diner-2.0.0.pre.alpha.1 lib/flapjack-diner/resources/checks.rb