Sha256: 5020f053d4a8ebba3328ee1abd35c351979ef74251d7bf62657d91beec2d4402

Contents?: true

Size: 1.6 KB

Versions: 53

Compression:

Stored size: 1.6 KB

Contents

class Ey::Core::Client
  class Real
    def get_firewalls(params={})
      query = Ey::Core.paging_parameters(params)
      url = params.delete("url")

      request(
        :params => params,
        :query  => query,
        :path   => "/firewalls",
        :url    => url,
      )
    end
  end

  class Mock
    def get_firewalls(params={})
      extract_url_params!(params)

      if server_url = params.delete("server")
        params.merge!("cluster" => resource_identity(self.find(:servers, server_url)["cluster"]))
      end

      resources = if database_server_url = params.delete("database_server")
                    database_server_id = resource_identity(database_server_url)
                    firewall_ids = self.data[:database_server_firewalls].inject([]) { |r, (ds, f)| (ds == database_server_id) ? r << f : r }
                    firewall_ids.inject({}) { |r, id| r.merge(id => self.data[:firewalls][id]) }
                  elsif cluster_url = params.delete("cluster")
                    cluster_id = resource_identity(cluster_url)
                    firewall_ids = self.data[:cluster_firewalls].inject([]) { |r, (c, f)| (c == cluster_id) ? r << f : r }
                    firewall_ids.inject({}) { |r, id| r.merge(id => self.data[:firewalls][id]) }
                  else
                    self.data[:firewalls]
                  end

      headers, firewalls_page = search_and_page(params, :firewalls, search_keys: %w[provisioned_id name], resources: resources)

      response(
        :body    => {"firewalls" => firewalls_page},
        :status  => 200,
        :headers => headers
      )
    end
  end
end

Version data entries

53 entries across 53 versions & 3 rubygems

Version Path
ey-core-3.1.11 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.10 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.9 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.8 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.7 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.6 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.5 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.4 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.3 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.2 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.1 lib/ey-core/requests/get_firewalls.rb
ey-core-3.1.0 lib/ey-core/requests/get_firewalls.rb
ey-core-3.0.5 lib/ey-core/requests/get_firewalls.rb
ey-core-3.0.4 lib/ey-core/requests/get_firewalls.rb
ey-core-3.0.3 lib/ey-core/requests/get_firewalls.rb
ey-core-3.0.2 lib/ey-core/requests/get_firewalls.rb
ey-core-3.0.1 lib/ey-core/requests/get_firewalls.rb
ey-core-3.0.0 lib/ey-core/requests/get_firewalls.rb
ey-pro-cli-0.0.17 lib/vendor/core/ey-core/requests/get_firewalls.rb
ey-pro-cli-0.0.16 lib/vendor/core/ey-core/requests/get_firewalls.rb