Module: Auth0::Api::V2::Logs

Included in:
Auth0::Api::V2
Defined in:
lib/auth0/api/v2/logs.rb

Overview

Methods to use the logs endpoints

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#logs_pathObject (readonly)

Logs API path



59
60
61
# File 'lib/auth0/api/v2/logs.rb', line 59

def logs_path
  @logs_path
end

Instance Method Details

#log(log_id) ⇒ json Also known as: get_logs_by_id

Retrieves log entries that match the specified search criteria.

Parameters:

  • log_id (string)

    The log_id of the log to retrieve.

Returns:

  • (json)

    Returns the log with the given id if exists.

Raises:

See Also:



51
52
53
54
55
# File 'lib/auth0/api/v2/logs.rb', line 51

def log(log_id)
  raise Auth0::MissingParameter, 'Must supply a valid log_id' if log_id.to_s.empty?
  path = "#{logs_path}/#{log_id}"
  get(path)
end

#logs(options = {}) ⇒ json Also known as: get_logs

Retrieves log entries that match the specified search criteria. Default: 50. Max value: 100.

Parameters:

  • options (hash) (defaults to: {})
    • :q [string] Query in Lucene query string syntax.

    • :page [integer] The page number. Zero based.

    • :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.

    • :sort [string] The field to use for sorting. 1 == ascending and -1 == descending.

    • :fields [string] A comma separated list of fields to include or exclude from the result.

    • :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.

    • :include_totals [string] True if a query summary must be included in the result, false otherwise.

    • :from [string] For checkpoint pagination, the ID from which to start selection from.

    • :take [integer] For checkpoint pagination, the number of entries to retrieve. Default is 50.

Returns:

  • (json)

    Returns the list of existing log entries.

See Also:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/auth0/api/v2/logs.rb', line 24

def logs(options = {})
  request_params = {
    q: options.fetch(:q, nil),
    page: options.fetch(:page, nil),
    per_page: options.fetch(:per_page, nil),
    sort: options.fetch(:sort, nil),
    fields: options.fetch(:fields, nil),
    include_fields: options.fetch(:include_fields, nil),
    include_totals: options.fetch(:include_totals, nil),
    from: options.fetch(:from, nil),
    take: options.fetch(:take, nil)
  }
  if request_params[:take].to_i > 100
    raise Auth0::InvalidParameter, 'The total amount of entries to retrieve should be less than 100'
  end
  if request_params[:per_page].to_i > 100
    raise Auth0::InvalidParameter, 'The total amount of entries per page should be less than 100'
  end
  get(logs_path, request_params)
end