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.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/auth0/logs/client.rb', line 135 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) (response.body.to_s.empty? ? nil : 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.
To set custom search criteria, use the following parameters:
- q: Search Criteria using Query String 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
:1for ascending and:-1for 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
For more information on the list of fields that can be used in fields and sort, see Searchable
Fields.
Auth0 limits the number of logs 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.
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
takeparameter. If you usefromat the same time asq,fromtakes precedence andqis ignored. - take: Number of entries to retrieve when using the
fromparameter.
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.
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 117 118 |
# File 'lib/auth0/logs/client.rb', line 79 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 = (response.body.to_s.empty? ? nil : 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 |