Class: OVH::Provisioner::APIObject::IP

Inherits:
OVH::Provisioner::APIObject show all
Defined in:
lib/ovh/provisioner/api_object/ip.rb

Overview

Represent an OVH IP

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#can_be_terminatedObject (readonly)

Returns the value of attribute can_be_terminated.



25
26
27
# File 'lib/ovh/provisioner/api_object/ip.rb', line 25

def can_be_terminated
  @can_be_terminated
end

#countryObject (readonly)

Returns the value of attribute country.



24
25
26
# File 'lib/ovh/provisioner/api_object/ip.rb', line 24

def country
  @country
end

#descriptionObject (readonly)

Returns the value of attribute description.



26
27
28
# File 'lib/ovh/provisioner/api_object/ip.rb', line 26

def description
  @description
end

#kindObject (readonly)

Returns the value of attribute kind.



28
29
30
# File 'lib/ovh/provisioner/api_object/ip.rb', line 28

def kind
  @kind
end

#organisation_idObject (readonly)

Returns the value of attribute organisation_id.



24
25
26
# File 'lib/ovh/provisioner/api_object/ip.rb', line 24

def organisation_id
  @organisation_id
end

#reverseObject (readonly)

Returns the value of attribute reverse.



27
28
29
# File 'lib/ovh/provisioner/api_object/ip.rb', line 27

def reverse
  @reverse
end

#routed_toObject (readonly)

Returns the value of attribute routed_to.



25
26
27
# File 'lib/ovh/provisioner/api_object/ip.rb', line 25

def routed_to
  @routed_to
end

#typeObject (readonly)

Returns the value of attribute type.



25
26
27
# File 'lib/ovh/provisioner/api_object/ip.rb', line 25

def type
  @type
end

Instance Method Details

#add_reverse(reverse) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ovh/provisioner/api_object/ip.rb', line 30

def add_reverse(reverse)
  body = {
    'ipReverse' => id.split('/').first,
    'reverse' => reverse
  }
  response = post('reverse', body)
  unless response['reverse'].nil?
    response = "#{id} - reverse #{reverse} has been added"
    @reverse = reverse['reverse']
  end
  response
end

#rm_reverseObject



43
44
45
46
47
# File 'lib/ovh/provisioner/api_object/ip.rb', line 43

def rm_reverse
  response = delete("reverse/#{id.split('/').first}")
  response ||= "#{id} - reverse #{reverse} has been removed"
  response
end

#to_sObject



49
50
51
52
53
54
55
56
# File 'lib/ovh/provisioner/api_object/ip.rb', line 49

def to_s
  base = "#{id} - #{routed_to}(#{type}) - #{endable}"
  %i[organisation_id country reverse description].each do |key|
    value = send(key)
    base += "\n  #{key}: #{value}" unless value.nil?
  end
  base
end