Class: OpsviewRest::Timeperiod

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixin

#resource_path, #save, #to_json

Constructor Details

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

Returns a new instance of Timeperiod.



9
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
# File 'lib/opsview_rest/timeperiod.rb', line 9

def initialize(opsview, options = {})
  @options = {
    name: 'nonworkhours',
    monday: '00:00-09:00,17:00-24:00',
    tuesday: '00:00-09:00,17:00-24:00',
    wednesday: '00:00-09:00,17:00-24:00',
    thursday: '00:00-09:00,17:00-24:00',
    friday: '00:00-09:00,17:00-24:00',
    saturday: '00:00-24:00',
    sunday: '00:00-24:00',
    servicecheck_notification_periods: [],
    servicecheck_check_periods: [],
    host_check_periods: [],
    alias: 'Non-work hours',
    host_notification_periods: [],
    save: true,
    replace: false
  }.update options

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

  @options[:servicecheck_notification_periods] = @options[:servicecheck_notification_periods].map { |x| { 'name' => x } } unless @options[:servicecheck_notification_periods].nil?
  @options[:servicecheck_check_periods] = @options[:servicecheck_check_periods].map { |x| { 'name' => x } } unless  @options[:servicecheck_check_periods].nil?
  @options[:host_check_periods] = @options[:host_check_periods].map { |x| { 'name' => x } } unless @options[:host_check_periods].nil?
  @options[:host_notification_periods] = @options[:host_notification_periods].map { |x| { 'name' => x } } unless @options[:host_notification_periods].nil?

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

Instance Attribute Details

#opsviewObject

Returns the value of attribute opsview.



7
8
9
# File 'lib/opsview_rest/timeperiod.rb', line 7

def opsview
  @opsview
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/opsview_rest/timeperiod.rb', line 7

def options
  @options
end

#resource_typeObject

Returns the value of attribute resource_type.



7
8
9
# File 'lib/opsview_rest/timeperiod.rb', line 7

def resource_type
  @resource_type
end