Method: Auth0::Api::V2::Users#user_logs

Defined in:
lib/auth0/api/v2/users.rb

#user_logs(user_id, options = {}) ⇒ json Also known as: get_user_log_events

Retrieve every log event for a specific user id rubocop:disable Metrics/MethodLength, Metrics/AbcSize

Parameters:

  • user_id (string)

    The user_id of the logs to retrieve.

  • options (hash) (defaults to: {})
    • :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.

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

    • :include_totals [boolean] True if a query summary must be included in the result.

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

Returns:

  • (json)

    Returns the list of existing log entries for the given user_id.

Raises:

See Also:



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/auth0/api/v2/users.rb', line 181

def user_logs(user_id, options = {})
  raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
  path = "#{users_path}/#{user_id}/logs"
  request_params = {
    per_page:       options.fetch(:per_page, nil),
    page:           options.fetch(:page, nil),
    include_totals: options.fetch(:include_totals, nil),
    sort:           options.fetch(:sort, nil)
  }
  if request_params[:per_page].to_i > 100
    raise Auth0::InvalidParameter, 'The total amount of entries per page should be less than 100'
  end
  sort_pattern = /^(([a-zA-Z0-9_\.]+))\:(1|-1)$/
  if !request_params[:sort].nil? && !sort_pattern.match(request_params[:sort])
    raise Auth0::InvalidParameter, 'Sort does not match pattern ^(([a-zA-Z0-9_\\.]+))\\:(1|-1)$'
  end
  get(path, request_params)
end