Class: Fog::Compute::Google::ForwardingRule
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Google::ForwardingRule
- Defined in:
- lib/fog/compute/google/models/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
45 46 47 48 49 50 51 52 |
# File 'lib/fog/compute/google/models/forwarding_rule.rb', line 45 def destroy(async = true) requires :identity, :region data = service.delete_forwarding_rule(identity, region) 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 61 |
# File 'lib/fog/compute/google/models/forwarding_rule.rb', line 54 def ready? requires :identity service.get_forwarding_rule(identity, region) true rescue ::Google::Apis::ClientError => e raise e unless e.status_code == 404 false end |
#reload ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fog/compute/google/models/forwarding_rule.rb', line 63 def reload requires :name, :region return unless data = begin collection.get(name, region) 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/forwarding_rule.rb', line 24 def save requires :identity, :region data = service.insert_forwarding_rule(identity, region, 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
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fog/compute/google/models/forwarding_rule.rb', line 34 def set_target(new_target) requires :identity, :region new_target = new_target.self_link unless new_target.class == String self.target = new_target service.set_forwarding_rule_target( identity, region, :target => new_target ) reload end |