Class: Fog::Compute::Aliyun::EipAddress
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Aliyun::EipAddress
- Defined in:
- lib/fog/aliyun/models/compute/eip_address.rb
Instance Method Summary collapse
- #associate(new_server, options = {}) ⇒ Object
- #destroy ⇒ Object
- #disassociate(new_server, options = {}) ⇒ Object
- #ready? ⇒ Boolean
- #save(options = {}) ⇒ Object
Instance Method Details
#associate(new_server, options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/fog/aliyun/models/compute/eip_address.rb', line 41 def associate(new_server, = {}) if persisted? @server = nil self.server_id = new_server.id service.associate_eip_address(server_id, id, ) else @server = new_server end end |
#destroy ⇒ Object
19 20 21 22 23 |
# File 'lib/fog/aliyun/models/compute/eip_address.rb', line 19 def destroy requires :id service.release_eip_address(id) true end |
#disassociate(new_server, options = {}) ⇒ Object
51 52 53 54 55 |
# File 'lib/fog/aliyun/models/compute/eip_address.rb', line 51 def disassociate(new_server, = {}) @server = nil self.server_id = new_server.id service.unassociate_eip_address(server_id, id, ) if persisted? end |
#ready? ⇒ Boolean
25 26 27 28 |
# File 'lib/fog/aliyun/models/compute/eip_address.rb', line 25 def ready? requires :state state == 'Available' end |
#save(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/aliyun/models/compute/eip_address.rb', line 30 def save( = {}) # raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? # requires :availability_zone [:bandwidth] = bandwidth if bandwidth [:internet_charge_type] = charge_type if charge_type data = Fog::JSON.decode(service.allocate_eip_address().body) merge_attributes(data) true end |