Sha256: df87fca950d47fac0ffbc6110228d5c5adb7adce7eb136da3d413588bef6e5af

Contents?: true

Size: 1.67 KB

Versions: 53

Compression:

Stored size: 1.67 KB

Contents

class Ey::Core::Client
  class Real
    def create_firewall_rule(params={})
      firewall = params.delete("firewall")
      url      = params.delete("url")

      request(
        :method => :post,
        :path   => "/firewalls/#{firewall}/rules",
        :url    => url,
        :body   => params,
      )
    end
  end

  class Mock
    def create_firewall_rule(params={})
      request_id = self.uuid
      resource_id = self.serial_id

      firewall_id = resource_identity(params["firewall"])

      find(:firewalls, firewall_id)

      source = params["firewall_rule"]["source"] or return response(status: 422, body: { "errors" => ["missing firewall rule source"] })
      range  = params["firewall_rule"]["port_range"] or return response(status: 422, body: { "errors" => ["missing firewall rule port_range"] })

      resource = {
        "id"           => resource_id,
        "source"       => source.to_s,
        "port_range"   => range.to_s,
        "firewall"     => url_for("/firewalls/#{firewall_id}"),
        "resource_url" => "/firewall-rules/#{resource_id}",
      }

      request = {
        "id"          => request_id,
        "type"        => "provision_firewall_rule",
        "successful"  => "true",
        "started_at"  => Time.now,
        "finished_at" => nil,
        "resource"    => [:firewall_rules, resource_id, resource],
      }

      self.data[:requests][request_id] = request

      response_hash = request.dup

      response_hash.delete("resource")

      response(
        :body    => {"request" => response_hash},
        :status  => 201,
        :headers => {
          "Content-Type" => "application/json; charset=utf8"
        }
      )
    end
  end
end

Version data entries

53 entries across 53 versions & 3 rubygems

Version Path
ey-core-3.6.4 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.6.3 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.6.1 lib/ey-core/requests/create_firewall_rule.rb
groove-ey-core-3.6.3 lib/ey-core/requests/create_firewall_rule.rb
groove-ey-core-3.6.2 lib/ey-core/requests/create_firewall_rule.rb
groove-ey-core-3.6.1 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.5.0 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.4.4 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.4.2 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.4.1 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.4.0 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.3.1 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.3.0 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.2.6 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.2.5 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.2.4 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.2.3 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.2.2 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.2.1 lib/ey-core/requests/create_firewall_rule.rb
ey-core-3.2.0 lib/ey-core/requests/create_firewall_rule.rb