Class: Fog::Compute::Google::GlobalForwardingRule
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Google::GlobalForwardingRule
- Defined in:
- lib/fog/compute/google/models/global_forwarding_rule.rb
Instance Method Summary collapse
- #destroy(async = true) ⇒ Object
- #ready? ⇒ Boolean
- #reload ⇒ Object
- #save ⇒ Object
- #set_target(new_target) ⇒ Object
Instance Method Details
#destroy(async = true) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/fog/compute/google/models/global_forwarding_rule.rb', line 34 def destroy(async = true) requires :identity data = service.delete_global_forwarding_rule(identity) operation = Fog::Compute::Google::Operations.new(:service => service) .get(data.name, nil, data.region) operation.wait_for { ready? } unless async operation end |
#ready? ⇒ Boolean
54 55 56 57 58 59 60 |
# File 'lib/fog/compute/google/models/global_forwarding_rule.rb', line 54 def ready? service.get_global_forwarding_rule(name) true rescue ::Google::Apis::ClientError => e raise e unless e.status_code == 404 false end |
#reload ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fog/compute/google/models/global_forwarding_rule.rb', line 62 def reload requires :name return unless data = begin collection.get(name) rescue Excon::Errors::SocketError nil end new_attributes = data.attributes merge_attributes(new_attributes) self end |
#save ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/fog/compute/google/models/global_forwarding_rule.rb', line 24 def save requires :identity data = service.insert_global_forwarding_rule(identity, attributes) operation = Fog::Compute::Google::Operations.new(:service => service) .get(data.name, nil, data.region) operation.wait_for { ready? } reload end |
#set_target(new_target) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fog/compute/google/models/global_forwarding_rule.rb', line 43 def set_target(new_target) requires :identity new_target = new_target.self_link unless new_target.class == String self.target = new_target service.set_global_forwarding_rule_target( identity, :target => new_target ) reload end |