Class: Dto::InfraObjectsPayLoad

Inherits:
Object
  • Object
show all
Extended by:
Util::Logging
Includes:
Enum::InfrastructureResourceDiscovery
Defined in:
lib/dto/infra_objects_payload.rb

Constant Summary

Constants included from Util::Logging

Util::Logging::SEV_LABEL, Util::Logging::TRACE

Constants included from Enum::InfrastructureResourceDiscovery

Enum::InfrastructureResourceDiscovery::NODE_POOLS, Enum::InfrastructureResourceDiscovery::SUBNET

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::Logging

logger, logger=

Constructor Details

#initialize(cluster, vcn, subnet, load_balancer, node_pools) ⇒ InfraObjectsPayLoad

Returns a new instance of InfraObjectsPayLoad.



13
14
15
16
17
18
19
# File 'lib/dto/infra_objects_payload.rb', line 13

def initialize(cluster, vcn, subnet, load_balancer, node_pools)
  @cluster = cluster
  @vcn = vcn
  @subnet = subnet
  @load_balancer = load_balancer
  @node_pools = node_pools
end

Instance Attribute Details

#clusterObject

Returns the value of attribute cluster.



11
12
13
# File 'lib/dto/infra_objects_payload.rb', line 11

def cluster
  @cluster
end

#load_balancerObject

Returns the value of attribute load_balancer.



11
12
13
# File 'lib/dto/infra_objects_payload.rb', line 11

def load_balancer
  @load_balancer
end

#node_poolsObject

Returns the value of attribute node_pools.



11
12
13
# File 'lib/dto/infra_objects_payload.rb', line 11

def node_pools
  @node_pools
end

#subnetObject

Returns the value of attribute subnet.



11
12
13
# File 'lib/dto/infra_objects_payload.rb', line 11

def subnet
  @subnet
end

#vcnObject

Returns the value of attribute vcn.



11
12
13
# File 'lib/dto/infra_objects_payload.rb', line 11

def vcn
  @vcn
end

Instance Method Details

#get_hash(obj, obj_name) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/dto/infra_objects_payload.rb', line 21

def get_hash(obj, obj_name)
  if !obj.nil?
    obj.map(&:to_hash)
  else
    Util::Logging.logger.error("Cannot generate hash for #{obj_name}: as obj is nil")
    nil
  end
end

#to_hashObject



30
31
32
33
34
35
36
37
38
# File 'lib/dto/infra_objects_payload.rb', line 30

def to_hash
  {
    cluster: @cluster.to_hash,
    vcn: @vcn.to_hash,
    subnet: get_hash(@subnet, SUBNET.to_s),
    load_balancer: @load_balancer.to_hash,
    node_pools: get_hash(@node_pools, NODE_POOLS.to_s)
  }.compact
end