# 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.action_module_version import ActionModuleVersion from ....types.create_action_module_version_response_content import CreateActionModuleVersionResponseContent from ....types.get_action_module_version_response_content import GetActionModuleVersionResponseContent from ....types.get_action_module_versions_response_content import GetActionModuleVersionsResponseContent from .raw_client import AsyncRawVersionsClient, RawVersionsClient class VersionsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawVersionsClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> RawVersionsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- RawVersionsClient """ return self._raw_client def list( self, id: str, *, page: typing.Optional[int] = 0, per_page: typing.Optional[int] = 50, request_options: typing.Optional[RequestOptions] = None, ) -> SyncPager[ActionModuleVersion, GetActionModuleVersionsResponseContent]: """ List all published versions of a specific Actions Module. Parameters ---------- id : str The unique ID of the module. page : typing.Optional[int] Use this field to request a specific page of the list results. per_page : typing.Optional[int] The maximum number of results to be returned by the server in a single response. 20 by default. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- SyncPager[ActionModuleVersion, GetActionModuleVersionsResponseContent] The module versions were retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) response = client.actions.modules.versions.list( id="id", page=1, per_page=1, ) 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(id, page=page, per_page=per_page, request_options=request_options) def create( self, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> CreateActionModuleVersionResponseContent: """ Creates a new immutable version of an Actions Module from the current draft version. This publishes the draft as a new version that can be referenced by actions, while maintaining the existing draft for continued development. Parameters ---------- id : str The ID of the action module to create a version for. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- CreateActionModuleVersionResponseContent The action module version was created. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.actions.modules.versions.create( id="id", ) """ _response = self._raw_client.create(id, request_options=request_options) return _response.data def get( self, id: str, version_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> GetActionModuleVersionResponseContent: """ Retrieve the details of a specific, immutable version of an Actions Module. Parameters ---------- id : str The unique ID of the module. version_id : str The unique ID of the module version to retrieve. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- GetActionModuleVersionResponseContent The module version was retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.actions.modules.versions.get( id="id", version_id="versionId", ) """ _response = self._raw_client.get(id, version_id, request_options=request_options) return _response.data class AsyncVersionsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawVersionsClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> AsyncRawVersionsClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- AsyncRawVersionsClient """ return self._raw_client async def list( self, id: str, *, page: typing.Optional[int] = 0, per_page: typing.Optional[int] = 50, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncPager[ActionModuleVersion, GetActionModuleVersionsResponseContent]: """ List all published versions of a specific Actions Module. Parameters ---------- id : str The unique ID of the module. page : typing.Optional[int] Use this field to request a specific page of the list results. per_page : typing.Optional[int] The maximum number of results to be returned by the server in a single response. 20 by default. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- AsyncPager[ActionModuleVersion, GetActionModuleVersionsResponseContent] The module versions were retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: response = await client.actions.modules.versions.list( id="id", page=1, per_page=1, ) 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(id, page=page, per_page=per_page, request_options=request_options) async def create( self, id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> CreateActionModuleVersionResponseContent: """ Creates a new immutable version of an Actions Module from the current draft version. This publishes the draft as a new version that can be referenced by actions, while maintaining the existing draft for continued development. Parameters ---------- id : str The ID of the action module to create a version for. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- CreateActionModuleVersionResponseContent The action module version was created. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.actions.modules.versions.create( id="id", ) asyncio.run(main()) """ _response = await self._raw_client.create(id, request_options=request_options) return _response.data async def get( self, id: str, version_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> GetActionModuleVersionResponseContent: """ Retrieve the details of a specific, immutable version of an Actions Module. Parameters ---------- id : str The unique ID of the module. version_id : str The unique ID of the module version to retrieve. request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- GetActionModuleVersionResponseContent The module version was retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.actions.modules.versions.get( id="id", version_id="versionId", ) asyncio.run(main()) """ _response = await self._raw_client.get(id, version_id, request_options=request_options) return _response.data