Class: IbmPowerHmc::AbstractRest Abstract

Inherits:
AbstractNonRest show all
Defined in:
lib/ibm_power_hmc/schema/parser.rb

Overview

This class is abstract.

HMC generic K2 REST object. Encapsulate data for a single REST object. The XML looks like this: <entry>

<id>uuid</id>
<published>timestamp</published>
<link rel="SELF" href="https://..."/>
<etag:etag>ETag</etag:etag>
<content type="type">
  <!-- actual content here -->
</content>

</entry>

Constant Summary

Constants inherited from AbstractNonRest

IbmPowerHmc::AbstractNonRest::ATTRS

Instance Attribute Summary collapse

Attributes inherited from AbstractNonRest

#xml

Instance Method Summary collapse

Methods inherited from AbstractNonRest

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

Constructor Details

#initialize(entry) ⇒ AbstractRest

Returns a new instance of AbstractRest.



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/ibm_power_hmc/schema/parser.rb', line 215

def initialize(entry)
  if entry.name != "entry"
    # We are inlined.
    super(entry)
    return
  end

  @uuid = entry.elements["id"]&.text
  @published = Time.xmlschema(entry.elements["published"]&.text)
  link = entry.elements["link[@rel='SELF']"]
  @href = URI(link.attributes["href"]) unless link.nil?
  @etag = entry.elements["etag:etag"]&.text&.strip
  content = entry.elements["content"]
  @content_type = content.attributes["type"]
  super(content.elements.first)
end

Instance Attribute Details

#content_typeString (readonly)

The content type of the object contained in the entry.

Returns:

  • (String)

    the current value of content_type



212
213
214
# File 'lib/ibm_power_hmc/schema/parser.rb', line 212

def content_type
  @content_type
end

#etagString (readonly)

The entity tag of the entry.

Returns:

  • (String)

    the current value of etag



212
213
214
# File 'lib/ibm_power_hmc/schema/parser.rb', line 212

def etag
  @etag
end

#hrefURI::HTTPS (readonly)

The URL of the object itself.

Returns:

  • (URI::HTTPS)

    the current value of href



212
213
214
# File 'lib/ibm_power_hmc/schema/parser.rb', line 212

def href
  @href
end

#publishedTime (readonly)

The time at which the entry was published.

Returns:

  • (Time)

    the current value of published



212
213
214
# File 'lib/ibm_power_hmc/schema/parser.rb', line 212

def published
  @published
end

#uuidString (readonly)

The UUID of the object contained in the entry.

Returns:

  • (String)

    the current value of uuid



212
213
214
# File 'lib/ibm_power_hmc/schema/parser.rb', line 212

def uuid
  @uuid
end

Instance Method Details

#to_sObject



232
233
234
235
236
237
# File 'lib/ibm_power_hmc/schema/parser.rb', line 232

def to_s
  str = super
  str << "  uuid: '#{uuid}'\n" if defined?(@uuid)
  str << "  published: '#{published}'\n" if defined?(@published)
  str
end