Class: Fog::AWS::Compute::Address
- Inherits:
-
Model
- Object
- Model
- Fog::AWS::Compute::Address
- Defined in:
- lib/fog/aws/models/compute/address.rb
Instance Method Summary collapse
- #change_scope ⇒ Object
- #destroy ⇒ Object
-
#initialize(attributes = {}) ⇒ Address
constructor
A new instance of Address.
- #save ⇒ Object
- #server ⇒ Object
- #server=(new_server) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Address
Returns a new instance of Address.
16 17 18 19 20 |
# File 'lib/fog/aws/models/compute/address.rb', line 16 def initialize(attributes = {}) # assign server first to prevent race condition with persisted? self.server = attributes.delete(:server) super end |
Instance Method Details
#change_scope ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/aws/models/compute/address.rb', line 29 def change_scope if self.domain == 'standard' service.move_address_to_vpc(self.identity) wait_for { self.domain == 'vpc' } else service.restore_address_to_classic(self.identity) wait_for { self.domain == 'standard' } end end |
#destroy ⇒ Object
22 23 24 25 26 27 |
# File 'lib/fog/aws/models/compute/address.rb', line 22 def destroy requires :public_ip service.release_address(allocation_id || public_ip) true end |
#save ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fog/aws/models/compute/address.rb', line 51 def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? data = service.allocate_address(domain).body new_attributes = data.reject {|key,value| key == 'requestId'} merge_attributes(new_attributes) if @server self.server = @server end true end |
#server ⇒ Object
47 48 49 |
# File 'lib/fog/aws/models/compute/address.rb', line 47 def server service.servers.get(server_id) end |
#server=(new_server) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/fog/aws/models/compute/address.rb', line 39 def server=(new_server) if new_server associate(new_server) else disassociate end end |