class Reliquary::API::Applications

Constants

METHOD_PARAMS

How to parameterize queries against API endpoint These are for parameters to be added to the query; some endpoints

require additional parameters to build the URI fragment.
URI_FRAGMENT

URI fragment for Applications API endpoint

URI_METHOD

URI method for Applications API endpoint

Public Instance Methods

delete(params = {}) click to toggle source

@!method delete Delete an application and all data @param [Hash] params parameters for delete

# File lib/reliquary/api/applications.rb, line 186
def delete(params = {})
  begin
    id = retrieve_id(params)

    # HTTP method is PUT
    # override the URI fragment
    api_params = {
      :uri_method => :delete,
      :uri_fragment => "applications/#{id}.json",
    }

    execute(api_params, {:params => process_request_params(__method__, params)})

  rescue StandardError => e
    raise e
  end
end
list(params = {}) click to toggle source

@!method list List applications, optionally filtering by name or ID @param [Hash] params parameters for listing @option [String] :name New Relic application name to select @option [Array<String>] :ids New Relic application IDs to select @option [String] :host New Relic application host to select @option [String] :lang New Relic application language to select

# File lib/reliquary/api/applications.rb, line 78
def list(params = {})
  begin
    # this is the "default" Applications method, no overrides
    api_params = {}

    execute(api_params, {:params => process_request_params(__method__, params)})

  rescue StandardError => e
    raise e
  end
end
metric_data(params = {}) click to toggle source

@!method metric_data List metric date for a single application @param [Hash] params parameters for listing @option params [Integer] :id New Relic application ID @option params [Array<String>] :names Names of metrics to retrieve @option params [Array<String>] :values Names of metric values to retrieve @option params [Time] :from Retrieve metrics after this time @option params [Time] :to Retrieve metrics before this time @option params [Time] :period Period of timeslices in seconds @option params [Boolean] :summarize Return summarized data or all the samples @option params [Boolean] :raw Return unformatted data

# File lib/reliquary/api/applications.rb, line 139
def metric_data(params = {})
  begin
    id = retrieve_id(params)

    names_param = params.fetch(:names).collect {|x| x.to_s}.join("\n")

    raise "you must supply one or more New Relic metric names" if names_param.nil?

    # HTTP method is the default GET
    # override the URI fragment
    api_params = { :uri_fragment => "applications/#{id}/metrics/data.json" }

    execute(api_params, {:params => process_request_params(__method__, params).merge({'names[]' => names_param})})

  rescue StandardError => e
    raise e
  end
end
metric_names(params = {}) click to toggle source

@!method metric_names List metric names for a single application @param [Hash] params parameters for listing @option params [Integer] :id New Relic application ID

# File lib/reliquary/api/applications.rb, line 113
def metric_names(params = {})
  begin
    id = retrieve_id(params)

    # HTTP method is the default GET
    # override the URI fragment
    api_params = { :uri_fragment => "applications/#{id}/metrics.json" }

    execute(api_params, {:params => process_request_params(__method__, params)})

  rescue StandardError => e
    raise e
  end
end
show(params = {}) click to toggle source

@!method show Show summary for a single application @param [Hash] params parameters for listing @option params [Integer] :id New Relic application ID

# File lib/reliquary/api/applications.rb, line 94
def show(params = {})
  begin
    id = retrieve_id(params)

    # HTTP method is the default GET
    # override the URI fragment
    api_params = { :uri_fragment => "applications/#{id}.json" }

    execute(api_params, {:params => process_request_params(__method__, params)})

  rescue StandardError => e
    raise e
  end
end
update(params = {}) click to toggle source

@!method update Update certain parameters of an application @param [Hash] params parameters for update

# File lib/reliquary/api/applications.rb, line 161
def update(params = {})
  begin
    id = retrieve_id(params)

    raise "not implemented yet"

    # FIXME build the JSON payload

    # HTTP method is PUT
    # override the URI fragment
    api_params = {
      :uri_method => :put,
      :uri_fragment => "applications/#{id}.json",
    }

    execute(api_params, {:params => process_request_params(__method__, params)})

  rescue StandardError => e
    raise e
  end
end