Class: Zona::Zone

Inherits:
OZonesElement show all
Defined in:
zona/ZoneElement.rb

Overview

This class describes a single OZones Zone element. It can be used to allocate, delete and retrieve full information for a Zone.

Constant Summary

ZONE_KIND =

String describing the kind of this resource

"zone"

Instance Attribute Summary

Attributes inherited from OZonesElement

name, pe_id

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from OZonesElement

new_with_id

Methods inherited from JSONElement

#[], #initialize_json

Constructor Details

- (String) initialize(hash, client)

Initializes a Zone object instance

Parameters:

  • hash (Hash)

    zone description

  • client (Zona::Client)

    OZones Client



43
44
45
# File 'zona/ZoneElement.rb', line 43

def initialize(hash, client)
    super(hash, client)
end

Class Method Details

+ (Hash, Zona::Error) build_json(pe_id = nil)

Builds minimal JSON description for a Zone

Parameters:

  • pe_id (#to_i) (defaults to: nil)

    zone’s ID

Returns:

  • (Hash, Zona::Error)

    Hash description of the object, or Error



30
31
32
33
34
35
36
37
# File 'zona/ZoneElement.rb', line 30

def self.build_json(pe_id=nil)
    if pe_id
        json = "{\"ZONE\":{\"ID\":#{pe_id}}}"
    else
        json = '{"ZONE":{}}'
    end
    OZonesJSON.build_json(json,:ZONE)
end

Instance Method Details

- (Zona::Error) allocate(template)

Allocates a new element from a JSON description

Parameters:

  • template (String)

    element description

Returns:



64
65
66
# File 'zona/ZoneElement.rb', line 64

def allocate(template)
    super(ZONE_KIND,template)
end

- (Zona::Error) allocate_hash(template)

Allocates a new element from a hash description

Parameters:

  • template (Hash)

    element description

Returns:



57
58
59
# File 'zona/ZoneElement.rb', line 57

def allocate_hash(template)
    super(ZONE_KIND,template)
end

- (Zona::Error) delete

Deletes current element

Returns:



70
71
72
# File 'zona/ZoneElement.rb', line 70

def delete
    super(ZONE_KIND)
end

- (Zona::Error) info

Retrieves details about this object and fills in the information hash

Returns:



50
51
52
# File 'zona/ZoneElement.rb', line 50

def info
    super(ZONE_KIND,:ZONE)
end