Sha256: ff22bbd729a78983d11bbefb1ea071733a2b3f2c4f4ae87f75f7c873acfc1bfb

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

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

      request(
        :params => params,
        :query  => query,
        :path   => "/alerts",
        :url    => url,
      )
    end
  end # Real

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

      if params["server"] && params["database_server"]
        return response(status: 422, body: "Cannot search for both server & database_server")
      end

      if database_server_id = resource_identity(params.delete("database_server"))
        params["resource"] = url_for("/database-servers/#{database_server_id}")
      end

      if server_id = resource_identity(params.delete("server"))
        params["resource"] = url_for("/servers/#{server_id}")
      end

      if agent_id = resource_identity(params.delete("agent"))
        params["resource"] = url_for("/agents/#{agent_id}")
      end

      headers, alerts_page = search_and_page(params, :alerts, search_keys: %w[resource external_id name severity agent finished_at started_at], deleted_key: "finished_at")

      response(
        :body    => {"alerts" => alerts_page},
        :headers => headers
      )
    end
  end # Mock
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ey-core-3.6.6 lib/ey-core/requests/get_alerts.rb
ey-core-3.4.5 lib/ey-core/requests/get_alerts.rb
ey-core-3.6.5 lib/ey-core/requests/get_alerts.rb