Module: Sensu::Settings::Validators::API

Included in:
Sensu::Settings::Validators
Defined in:
lib/sensu/settings/validators/api.rb

Instance Method Summary collapse

Instance Method Details

#validate_api(api) ⇒ Object

Validate a Sensu API definition. Validates: port, bind

Parameters:

  • api (Hash)

    sensu api definition.


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sensu/settings/validators/api.rb', line 22

def validate_api(api)
  if is_a_hash?(api)
    must_be_an_integer(api[:port]) ||
      invalid(api, "api port must be an integer")
    must_be_a_string_if_set(api[:bind]) ||
      invalid(api, "api bind must be a string")
    validate_api_authentication(api)
  else
    invalid(api, "api must be a hash")
  end
end

#validate_api_authentication(api) ⇒ Object

Validate API authentication. Validates: user, password

Parameters:

  • api (Hash)

    sensu api definition.


9
10
11
12
13
14
15
16
# File 'lib/sensu/settings/validators/api.rb', line 9

def validate_api_authentication(api)
  if either_are_set?(api[:user], api[:password])
    must_be_a_string(api[:user]) ||
      invalid(api, "api user must be a string")
    must_be_a_string(api[:password]) ||
      invalid(api, "api password must be a string")
  end
end