Class: OpsviewRest::Role

Inherits:
Object
  • Object
show all
Includes:
Mixin
Defined in:
lib/opsview_rest/role.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin

#resource_path, #save, #to_json

Constructor Details

#initialize(opsview, options = {}) ⇒ Role



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/opsview_rest/role.rb', line 10

def initialize(opsview, options = {})
  @options = {
    :name => "Unknown",
    :description => "",
    :all_hostgroups => true,
    :all_servicegroups => true,
    :all_keywords => false,
    :access_hostgroups => [],
    :access_servicegroups => [],
    :access_keywords => [],
    :hostgroups => [],
    :monitoringservers => [],
    :accesses => [ "NOTIFYSOME", "PASSWORDSAVE", "VIEWALL" ],
    :save    => true,
    :replace => false
  }.update options

  @opsview = opsview
  @resource_type = @options[:type]

  @options[:hostgroups] = @options[:hostgroups].map { |x| { "name" => x } }
  @options[:monitoringservers] = @options[:monitoringservers].map { |x| { "name" => x } }
  @options[:accesses] = @options[:accesses].map { |x| { "name" => x } }
  @options[:all_hostgroups] = if @options[:all_hostgroups] then 1 else 0 end
  @options[:all_servicegroups] = if @options[:all_servicegroups] then 1 else 0 end
  @options[:all_keywords] = if @options[:all_keywords] then 1 else 0 end

  save(@options[:replace]) if @options[:save]
end

Instance Attribute Details

#opsviewObject

Returns the value of attribute opsview.



8
9
10
# File 'lib/opsview_rest/role.rb', line 8

def opsview
  @opsview
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/opsview_rest/role.rb', line 8

def options
  @options
end

#resource_typeObject

Returns the value of attribute resource_type.



8
9
10
# File 'lib/opsview_rest/role.rb', line 8

def resource_type
  @resource_type
end