Module: HotDogPrincess::Client::Slas
- Included in:
- HotDogPrincess::Client
- Defined in:
- lib/hotdogprincess/client/slas.rb
Instance Method Summary collapse
- #fetch_slas(page_size = 100) ⇒ Object
- #parse_sla(sla) ⇒ Object
- #sla(sla_id, history = false) ⇒ Object
- #sla_count ⇒ Object
- #slas(page_size = 100, force_update = false) ⇒ Object
- #slas_raw(page_size = 100) ⇒ Object
Instance Method Details
#fetch_slas(page_size = 100) ⇒ Object
11 12 13 14 |
# File 'lib/hotdogprincess/client/slas.rb', line 11 def fetch_slas(page_size = 100) @slas_raw = get "Sla", _pageSize_: page_size @slas_raw end |
#parse_sla(sla) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/hotdogprincess/client/slas.rb', line 44 def parse_sla(sla) # Meta clean_sla = {} clean_sla[:id] = sla['@id'].to_i clean_sla[:uid] = sla['@uid'] clean_sla[:href] = sla['@href'] clean_sla[:name] = sla['Name']['#text'] clean_sla end |
#sla(sla_id, history = false) ⇒ Object
39 40 41 42 |
# File 'lib/hotdogprincess/client/slas.rb', line 39 def sla(sla_id, history = false) sla = get "Sla/#{sla_id}", _history_: history parse_sla sla['Sla'] end |
#sla_count ⇒ Object
33 34 35 36 37 |
# File 'lib/hotdogprincess/client/slas.rb', line 33 def sla_count return @slas.length if @slas return @slas["Entities"].length if @slas_raw 0 end |
#slas(page_size = 100, force_update = false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hotdogprincess/client/slas.rb', line 16 def slas(page_size = 100, force_update = false) return @slas if @slas and !force_update fetch_slas(page_size) return nil unless @slas_raw @slas ||= [] @slas_raw["Entities"]["Sla"].each do |sla| @slas.push parse_sla sla end @slas end |
#slas_raw(page_size = 100) ⇒ Object
27 28 29 30 31 |
# File 'lib/hotdogprincess/client/slas.rb', line 27 def slas_raw(page_size = 100) return @slas_raw if @slas_raw fetch_slas(page_size) @slas_raw end |