Class: Fog::Compute::Google::Firewall
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Google::Firewall
- Defined in:
- lib/fog/compute/google/models/firewall.rb
Overview
Represents a Firewall resource
Instance Method Summary collapse
-
#allowed ⇒ Array<Hash>
Allowed ports in API format.
- #create ⇒ Object
-
#denied ⇒ Array<Hash>
Denied ports in API format.
- #destroy(async = true) ⇒ Object
- #patch(diff = {}) ⇒ Object
- #save ⇒ Object
- #update ⇒ Object
Instance Method Details
#allowed ⇒ Array<Hash>
Allowed ports in API format
[
{ :ip_protocol => "TCP",
:ports => ["201"] }
]
19 |
# File 'lib/fog/compute/google/models/firewall.rb', line 19 attribute :allowed |
#create ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/fog/compute/google/models/firewall.rb', line 54 def create data = service.insert_firewall(identity, attributes) operation = Fog::Compute::Google::Operations.new(service: service) .get(data.name) operation.wait_for { ready? } reload end |
#denied ⇒ Array<Hash>
Denied ports in API format
[
{ :ip_protocol => "TCP",
:ports => ["201"] }
]
29 |
# File 'lib/fog/compute/google/models/firewall.rb', line 29 attribute :denied |
#destroy(async = true) ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/fog/compute/google/models/firewall.rb', line 82 def destroy(async = true) requires :identity data = service.delete_firewall(identity) operation = Fog::Compute::Google::Operations.new(:service => service) .get(data.name) operation.wait_for { ready? } unless async operation end |
#patch(diff = {}) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/fog/compute/google/models/firewall.rb', line 72 def patch(diff = {}) requires :identity data = service.patch_firewall(identity, diff) operation = Fog::Compute::Google::Operations.new(:service => service) .get(data.name) operation.wait_for { ready? } reload end |
#save ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/fog/compute/google/models/firewall.rb', line 44 def save requires :identity unless self.allowed || self.denied raise Fog::Errors::Error.new("Firewall needs denied or allowed ports specified") end id.nil? ? create : update end |
#update ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/fog/compute/google/models/firewall.rb', line 62 def update requires :identity, :allowed, :network data = service.update_firewall(identity, attributes) operation = Fog::Compute::Google::Operations.new(service: service) .get(data.name) operation.wait_for { ready? } reload end |