# This file was auto-generated by Fern from our API Definition. import typing from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.pagination import AsyncPager, SyncPager from ..core.request_options import RequestOptions from ..types.get_log_response_content import GetLogResponseContent from ..types.list_log_offset_paginated_response_content import ListLogOffsetPaginatedResponseContent from ..types.log import Log from .raw_client import AsyncRawLogsClient, RawLogsClient class LogsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawLogsClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> RawLogsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- RawLogsClient """ return self._raw_client def list( self, *, page: typing.Optional[int] = 0, per_page: typing.Optional[int] = 50, sort: typing.Optional[str] = None, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, include_totals: typing.Optional[bool] = True, search: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[Log, 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](https://auth0.com/docs/logs/log-event-type-codes). **To set custom search criteria, use the following parameters:** - **q:** Search Criteria using [Query String Syntax](https://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](https://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](https://auth0.com/docs/logs/log-search-query-syntax#searchable-fields). Auth0 [limits the number of logs](https://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](https://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. Parameters ---------- page : typing.Optional[int] Page index of the results to return. First page is 0. per_page : typing.Optional[int] Number of results per page. Paging is disabled if parameter not sent. Default: 50. Max value: 100 sort : typing.Optional[str] Field to use for sorting appended with :1 for ascending and :-1 for descending. e.g. date:-1 fields : typing.Optional[str] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false) include_totals : typing.Optional[bool] Return results as an array when false (default). Return results inside an object that also contains a total result count when true. search : typing.Optional[str] Retrieves logs that match the specified search criteria. This parameter can be combined with all the others in the /api/logs endpoint but is specified separately for clarity. If no fields are provided a case insensitive 'starts with' search is performed on all of the following fields: client_name, connection, user_name. Otherwise, you can specify multiple fields and specify the search using the %field%:%search%, for example: application:node user:"John@contoso.com". Values specified without quotes are matched using a case insensitive 'starts with' search. If quotes are used a case insensitve exact search is used. If multiple fields are used, the AND operator is used to join the clauses. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- SyncPager[Log, ListLogOffsetPaginatedResponseContent] Logs successfully retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) response = client.logs.list( page=1, per_page=1, sort="sort", fields="fields", include_fields=True, include_totals=True, search="search", ) for item in response: yield item # alternatively, you can paginate page-by-page for page in response.iter_pages(): yield page """ return self._raw_client.list( page=page, per_page=per_page, sort=sort, fields=fields, include_fields=include_fields, include_totals=include_totals, search=search, request_options=request_options, ) def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetLogResponseContent: """ Retrieve an individual log event. Parameters ---------- id : str log_id of the log to retrieve. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- GetLogResponseContent Log successfully retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.logs.get( id="id", ) """ _response = self._raw_client.get(id, request_options=request_options) return _response.data class AsyncLogsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawLogsClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> AsyncRawLogsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- AsyncRawLogsClient """ return self._raw_client async def list( self, *, page: typing.Optional[int] = 0, per_page: typing.Optional[int] = 50, sort: typing.Optional[str] = None, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, include_totals: typing.Optional[bool] = True, search: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[Log, 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](https://auth0.com/docs/logs/log-event-type-codes). **To set custom search criteria, use the following parameters:** - **q:** Search Criteria using [Query String Syntax](https://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](https://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](https://auth0.com/docs/logs/log-search-query-syntax#searchable-fields). Auth0 [limits the number of logs](https://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](https://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. Parameters ---------- page : typing.Optional[int] Page index of the results to return. First page is 0. per_page : typing.Optional[int] Number of results per page. Paging is disabled if parameter not sent. Default: 50. Max value: 100 sort : typing.Optional[str] Field to use for sorting appended with :1 for ascending and :-1 for descending. e.g. date:-1 fields : typing.Optional[str] Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields. include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false) include_totals : typing.Optional[bool] Return results as an array when false (default). Return results inside an object that also contains a total result count when true. search : typing.Optional[str] Retrieves logs that match the specified search criteria. This parameter can be combined with all the others in the /api/logs endpoint but is specified separately for clarity. If no fields are provided a case insensitive 'starts with' search is performed on all of the following fields: client_name, connection, user_name. Otherwise, you can specify multiple fields and specify the search using the %field%:%search%, for example: application:node user:"John@contoso.com". Values specified without quotes are matched using a case insensitive 'starts with' search. If quotes are used a case insensitve exact search is used. If multiple fields are used, the AND operator is used to join the clauses. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncPager[Log, ListLogOffsetPaginatedResponseContent] Logs successfully retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: response = await client.logs.list( page=1, per_page=1, sort="sort", fields="fields", include_fields=True, include_totals=True, search="search", ) async for item in response: yield item # alternatively, you can paginate page-by-page async for page in response.iter_pages(): yield page asyncio.run(main()) """ return await self._raw_client.list( page=page, per_page=per_page, sort=sort, fields=fields, include_fields=include_fields, include_totals=include_totals, search=search, request_options=request_options, ) async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetLogResponseContent: """ Retrieve an individual log event. Parameters ---------- id : str log_id of the log to retrieve. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- GetLogResponseContent Log successfully retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.logs.get( id="id", ) asyncio.run(main()) """ _response = await self._raw_client.get(id, request_options=request_options) return _response.data