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.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/auth0/logs/client.rb', line 130 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 <a href=“auth0.com/docs/logs/log-event-type-codes”>Log Event Type Codes</a>.
<h5>To set custom search criteria, use the following parameters:</h5>
<ul> <li>q: Search Criteria using <a href=“auth0.com/docs/logs/log-search-query-syntax”>Query String Syntax</a></li>
<li><b>page:</b> Page index of the results to return. First page is 0.</li>
<li><b>per_page:</b> Number of results per page.</li>
<li>sort: Field to use for sorting appended with ‘:1` for ascending and `:-1` for descending. e.g. `date:-1`</li> <li>fields: Comma-separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields.</li>
<li><b>include_fields:</b> Whether specified fields are to be included (true) or excluded (false).</li>
<li>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 <a href=“auth0.com/docs/product-lifecycle/deprecations-and-migrations/migrate-to-tenant-log-search-v3#pagination”>Search Engine V3 Breaking Changes</a></li> </ul>
For more information on the list of fields that can be used in fields and sort, see <a href=“auth0.com/docs/logs/log-search-query-syntax#searchable-fields”>Searchable Fields</a>.
Auth0 <a href=“auth0.com/docs/logs/retrieve-log-events-using-mgmt-api#limitations”>limits the number of logs</a> 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 <a href=“auth0.com/docs/logs/retrieve-log-events-using-mgmt-api#retrieve-logs-by-checkpoint”>get logs by checkpoint method</a>.
<h5>To search from a checkpoint log ID, use the following parameters:</h5> <ul> <li>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.</li>
<li><b>take:</b> Number of entries to retrieve when using the <code>from</code> parameter.</li>
</ul>
<strong>Important:</strong> When fetching logs from a checkpoint log ID, any parameter other than from and take will be ignored, and date ordering is not guaranteed.
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 108 109 110 111 112 113 114 115 116 |
# File 'lib/auth0/logs/client.rb', line 76 def list(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[page per_page sort fields include_fields include_totals search] 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) params.except(*query_param_names) Auth0::Internal::OffsetItemIterator.new( initial_page: query_params["page"], item_field: :logs, has_next_field: nil, step: true ) 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) Auth0::Types::ListLogOffsetPaginatedResponseContent.load(response.body) else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end end |