Sha256: a091ff70863022320e411cf9f3c892223a5f41d163168095633257128f2796d0

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

module Fog
  module Compute
    class ProfitBricks
      class Real
        # Deletes the specified firewall rule
        #
        # ==== Parameters
        # * datacenter_id<~String>   - UUID of the data center
        # * server_id<~String>        - UUID of the server
        # * nic_id<~String>           - UUID of the NIC
        # * firewall_rule_id<~String> - UUID of the NIC
        #
        # ==== Returns
        # * response<~Excon::Response> - No response parameters
        #   (HTTP/1.1 202 Accepted)
        #
        # {ProfitBricks API Documentation}[https://devops.profitbricks.com/api/cloud/v2/#delete-firewall-rule]
        def delete_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id)
          request(
              :expects => [202],
              :method  => 'DELETE',
              :path    => "/datacenters/#{datacenter_id}/servers/#{server_id}/nics/#{nic_id}/firewallrules/#{firewall_rule_id}"
          )
        rescue => error
          Fog::Errors::NotFound.new(error)
        end
      end

      class Mock
        def delete_firewall_rule(datacenter_id, server_id, nic_id, firewall_rule_id)
          response = Excon::Response.new
          response.status = 202

          if firewall_rule = self.data[:firewall_rules]["items"].find {
              |attribute| attribute["datacenter_id"] == datacenter_id && attribute["server_id"] == server_id && attribute["nic_id"] == nic_id && attribute["id"] == firewall_rule_id

          }
          else
            raise Fog::Errors::NotFound.new("The requested firewall rule resource could not be found")
          end

          response
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-profitbricks-2.0.1 lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb