Class: Auth0::Logs::Client
- Inherits:
-
Object
- Object
- Auth0::Logs::Client
- Defined in:
- lib/auth0/logs/client.rb
Instance Method Summary collapse
-
#get(request_options: {}, **params) ⇒ Auth0::Types::GetLogResponseContent
Retrieve an individual log event.
- #initialize(client:) ⇒ void constructor
-
#list(request_options: {}, **params) ⇒ Auth0::Types::ListLogOffsetPaginatedResponseContent
Retrieve log entries that match the specified search criteria (or all log entries if no criteria specified).
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/auth0/logs/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#get(request_options: {}, **params) ⇒ Auth0::Types::GetLogResponseContent
Retrieve an individual log event.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/auth0/logs/client.rb', line 121 def get(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "logs/#{URI.encode_uri_component(params[:id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Auth0::Types::GetLogResponseContent.load(response.body) else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list(request_options: {}, **params) ⇒ Auth0::Types::ListLogOffsetPaginatedResponseContent
Retrieve log entries that match the specified search criteria (or all log entries if no criteria specified).
Set custom search criteria using the ‘q` parameter, or search from a specific log ID (_“search from checkpoint”_).
For more information on all possible event types, their respective acronyms, and descriptions, see [Log Event Type Codes](auth0.com/docs/logs/log-event-type-codes).
**To set custom search criteria, use the following parameters:**
-
q: Search Criteria using [Query String Syntax](auth0.com/docs/logs/log-search-query-syntax)
-
page: Page index of the results to return. First page is 0.
-
per_page: Number of results per page.
-
sort: Field to use for sorting appended with ‘:1` for ascending and `:-1` for descending. e.g. `date:-1`
-
fields: Comma-separated list of fields to include or exclude (depending on include_fields) from the
result, empty to retrieve all fields.
-
include_fields: Whether specified fields are to be included (true) or excluded (false).
-
include_totals: Return results inside an object that contains the total result count (true) or as a direct
array of results (false, default). Deprecated: this field is deprecated and should be removed from use. See [Search Engine V3 Breaking Changes](auth0.com/docs/product-lifecycle/deprecations-and-migrations/migrate-to-tenant-log-search-v3#pagination)
For more information on the list of fields that can be used in ‘fields` and `sort`, see [Searchable Fields](auth0.com/docs/logs/log-search-query-syntax#searchable-fields).
Auth0 [limits the number of logs](auth0.com/docs/logs/retrieve-log-events-using-mgmt-api#limitations) you can return by search criteria to 100 logs per request. Furthermore, you may paginate only through 1,000 search results. If you exceed this threshold, please redefine your search or use the [get logs by checkpoint method](auth0.com/docs/logs/retrieve-log-events-using-mgmt-api#retrieve-logs-by-checkpoint).
**To search from a checkpoint log ID, use the following parameters:**
-
from: Log Event ID from which to start retrieving logs. You can limit the number of logs returned using
the ‘take` parameter. If you use `from` at the same time as `q`, `from` takes precedence and `q` is ignored.
-
take: Number of entries to retrieve when using the ‘from` parameter.
Important: When fetching logs from a checkpoint log ID, any parameter other than ‘from` and `take` will be ignored, and date ordering is not guaranteed.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/auth0/logs/client.rb', line 68 def list(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["page"] = params.fetch(:page, 0) query_params["per_page"] = params.fetch(:per_page, 50) query_params["sort"] = params[:sort] if params.key?(:sort) query_params["fields"] = params[:fields] if params.key?(:fields) query_params["include_fields"] = params[:include_fields] if params.key?(:include_fields) query_params["include_totals"] = params.fetch(:include_totals, true) query_params["search"] = params[:search] if params.key?(:search) Auth0::Internal::OffsetItemIterator.new( initial_page: query_params["page"], item_field: :logs, has_next_field: nil, step: false ) do |next_page| query_params["page"] = next_page request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "logs", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) parsed_response = Auth0::Types::ListLogOffsetPaginatedResponseContent.load(response.body) [parsed_response, response] else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end end |