Class: Fog::Hetznercloud::Compute::FloatingIp
- Inherits:
-
Model
- Object
- Model
- Fog::Hetznercloud::Compute::FloatingIp
- Defined in:
- lib/fog/hetznercloud/models/compute/floating_ip.rb
Instance Method Summary collapse
- #assign(serverid) ⇒ Object
- #description=(value) ⇒ Object
- #destroy ⇒ Object
- #home_location=(value) ⇒ Object
- #save ⇒ Object
- #server=(value) ⇒ Object
- #type=(value) ⇒ Object
- #unassign ⇒ Object
- #update_dns_ptr(newname) ⇒ Object
Instance Method Details
#assign(serverid) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/fog/hetznercloud/models/compute/floating_ip.rb', line 72 def assign(serverid) requires :identity if serverid.nil? body = {} if (floating_ip = service.floating_ip_unassign(identity, body).body['floating_ip']) merge_attributes(floating_ip) true else false end else body = { server: serverid } if (floating_ip = service.floating_ip_assign_to_server(identity, body).body['floating_ip']) merge_attributes(floating_ip) true else false end end end |
#description=(value) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/fog/hetznercloud/models/compute/floating_ip.rb', line 25 def description=(value) @lastdescription = attributes[:description] attributes[:description] = value if @lastdescription && @lastdescription != attributes[:description] @needsupdate = true else @needsupdate = false end end |
#destroy ⇒ Object
57 58 59 60 61 62 |
# File 'lib/fog/hetznercloud/models/compute/floating_ip.rb', line 57 def destroy requires :identity service.delete_floating_ip(identity) true end |
#home_location=(value) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fog/hetznercloud/models/compute/floating_ip.rb', line 35 def home_location=(value) attributes[:home_location] = case value when Hash service.locations.new(value) when String service.locations.new(identity: value) else value end end |
#save ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/fog/hetznercloud/models/compute/floating_ip.rb', line 64 def save if persisted? reassign && unassign && update else create end end |
#server=(value) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fog/hetznercloud/models/compute/floating_ip.rb', line 46 def server=(value) attributes[:server] = case value when Hash service.servers.new(value) when Integer service.servers.get(value) else value end end |
#type=(value) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/fog/hetznercloud/models/compute/floating_ip.rb', line 16 def type=(value) valid = %w[ipv4 ipv6] if !valid.include? value raise Fog::Hetznercloud::Compute::InvalidInputError, "ERROR: floating_ip type must be one of #{valid}" else attributes[:type] = value end end |
#unassign ⇒ Object
113 114 115 |
# File 'lib/fog/hetznercloud/models/compute/floating_ip.rb', line 113 def unassign assign(nil) unless server.nil? end |
#update_dns_ptr(newname) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/fog/hetznercloud/models/compute/floating_ip.rb', line 97 def update_dns_ptr(newname) requires :identity body = { ip: ip, dns_ptr: newname } if (floating_ip = service.floating_ip_update_dns_ptr(identity, body).body['floating_ip']) merge_attributes(floating_ip) true else false end end |