Class: Fog::Compute::Google::GlobalForwardingRule
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Google::GlobalForwardingRule
- Defined in:
- lib/fog/compute/google/models/global_forwarding_rule.rb
Constant Summary collapse
- RUNNING_STATE =
"READY"
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
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/compute/google/models/global_forwarding_rule.rb', line 36 def destroy(async = true) requires :name operation = service.delete_global_forwarding_rule(name, "global") unless async # wait until "RUNNING" or "DONE" to ensure the operation doesn't # fail, raises exception on error Fog.wait_for do operation.body["status"] == "DONE" end end operation end |
#ready? ⇒ Boolean
57 58 59 60 61 62 |
# File 'lib/fog/compute/google/models/global_forwarding_rule.rb', line 57 def ready? service.get_global_forwarding_rule(name, "global") true rescue Fog::Errors::NotFound false end |
#reload ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fog/compute/google/models/global_forwarding_rule.rb', line 64 def reload requires :name return unless data = begin collection.get(name, "global") rescue Excon::Errors::SocketError nil end new_attributes = data.attributes merge_attributes(new_attributes) self end |
#save ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fog/compute/google/models/global_forwarding_rule.rb', line 18 def save requires :name = { "description" => description, "region" => "global", "IPAddress" => ip_address, "IPProtocol" => ip_protocol || "TCP", "portRange" => port_range || 80, "target" => target } data = service.insert_global_forwarding_rule(name, ).body operation = Fog::Compute::Google::Operations.new(:service => service).get(data["name"], nil, data["region"]) operation.wait_for { !pending? } reload end |
#set_target(new_target) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/fog/compute/google/models/global_forwarding_rule.rb', line 50 def set_target(new_target) new_target = new_target.self_link unless new_target.class == String self.target = new_target service.set_global_forwarding_rule_target(self, new_target) reload end |