class Fog::Compute::Google::Firewall

Represents a Firewall resource

@see developers.google.com/compute/docs/reference/latest/firewalls

Public Instance Methods

create() click to toggle source
# 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
destroy(async = true) click to toggle source
# 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 = {}) click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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