Class: IbmPowerHmc::JobRequest

Inherits:
AbstractRest show all
Defined in:
lib/ibm_power_hmc/schema/job.rb

Overview

Job Request

Constant Summary

Constants inherited from AbstractNonRest

AbstractNonRest::ATTRS

Instance Attribute Summary

Attributes inherited from AbstractRest

#content_type, #etag, #href, #published, #uuid

Attributes inherited from AbstractNonRest

#xml

Instance Method Summary collapse

Methods inherited from AbstractRest

#initialize, #to_s

Methods inherited from AbstractNonRest

#collection_of, #create_element, #initialize, marshal, #marshal, #singleton, #timestamp, #to_s, #uuid_from_href, #uuids_from_links

Constructor Details

This class inherits a constructor from IbmPowerHmc::AbstractRest

Instance Method Details

#groupObject



16
17
18
# File 'lib/ibm_power_hmc/schema/job.rb', line 16

def group
  singleton("RequestedOperation/GroupName")
end

#group=(group) ⇒ Object



20
21
22
23
24
# File 'lib/ibm_power_hmc/schema/job.rb', line 20

def group=(group)
  elem = xml.elements["RequestedOperation"]
  elem = xml.add_element("RequestedOperation", "schemaVersion" => "V1_1_0") if elem.nil?
  elem.add_element("GroupName").text = group
end

#operationObject



6
7
8
# File 'lib/ibm_power_hmc/schema/job.rb', line 6

def operation
  singleton("RequestedOperation/OperationName")
end

#operation=(operation) ⇒ Object



10
11
12
13
14
# File 'lib/ibm_power_hmc/schema/job.rb', line 10

def operation=(operation)
  elem = xml.elements["RequestedOperation"]
  elem = xml.add_element("RequestedOperation", "schemaVersion" => "V1_1_0") if elem.nil?
  elem.add_element("OperationName").text = operation
end

#paramsObject



26
27
28
29
30
31
32
33
34
# File 'lib/ibm_power_hmc/schema/job.rb', line 26

def params
  params = {}
  xml.each_element("JobParameters/JobParameter") do |jobparam|
    name = jobparam.elements["ParameterName"]&.text&.strip
    value = jobparam.elements["ParameterValue"]&.text&.strip
    params[name] = value unless name.nil?
  end
  params
end

#params=(params) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/ibm_power_hmc/schema/job.rb', line 36

def params=(params)
  jobparams = xml.add_element("JobParameters", "schemaVersion" => "V1_1_0")
  params.each do |key, value|
    jobparam = jobparams.add_element("JobParameter", "schemaVersion" => "V1_1_0")
    jobparam.add_element("ParameterName").text = key
    jobparam.add_element("ParameterValue").text = value
  end
end