Class: Fog::Compute::Google::Address
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Google::Address
- Defined in:
- lib/fog/compute/google/models/address.rb
Overview
Represents an Address resource
Constant Summary collapse
- IN_USE_STATE =
"IN_USE".freeze
- RESERVED_STATE =
"RESERVED".freeze
- RESERVING_STATE =
"RESERVING".freeze
Instance Method Summary collapse
- #destroy(async = true) ⇒ Object
- #in_use? ⇒ Boolean
- #ready? ⇒ Boolean
- #reload ⇒ Object
- #save ⇒ Object
- #server ⇒ Object
- #server=(server) ⇒ Object
Instance Method Details
#destroy(async = true) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fog/compute/google/models/address.rb', line 47 def destroy(async = true) requires :identity, :region data = service.delete_address(identity, region.split("/")[-1]) operation = Fog::Compute::Google::Operations .new(:service => service) .get(data.name, nil, data.region) operation.wait_for { ready? } unless async operation end |
#in_use? ⇒ Boolean
67 68 69 |
# File 'lib/fog/compute/google/models/address.rb', line 67 def in_use? status == IN_USE_STATE end |
#ready? ⇒ Boolean
71 72 73 |
# File 'lib/fog/compute/google/models/address.rb', line 71 def ready? status != RESERVING_STATE end |
#reload ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/fog/compute/google/models/address.rb', line 59 def reload requires :identity, :region data = collection.get(identity, region.split("/")[-1]) merge_attributes(data.attributes) self end |
#save ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fog/compute/google/models/address.rb', line 36 def save requires :identity, :region data = service.insert_address(identity, region, attributes) operation = Fog::Compute::Google::Operations .new(service: service) .get(data.name, nil, data.region) operation.wait_for { ready? } reload end |
#server ⇒ Object
25 26 27 28 29 |
# File 'lib/fog/compute/google/models/address.rb', line 25 def server return nil if !in_use? || users.nil? || users.empty? service.servers.get(users.first.split("/")[-1]) end |
#server=(server) ⇒ Object
31 32 33 34 |
# File 'lib/fog/compute/google/models/address.rb', line 31 def server=(server) requires :identity, :region server ? associate(server) : disassociate end |