# This file was auto-generated by Fern from our API Definition. import typing from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions from ...types.create_email_provider_response_content import CreateEmailProviderResponseContent from ...types.email_provider_credentials_schema import EmailProviderCredentialsSchema from ...types.email_provider_name_enum import EmailProviderNameEnum from ...types.email_specific_provider_settings_with_additional_properties import ( EmailSpecificProviderSettingsWithAdditionalProperties, ) from ...types.get_email_provider_response_content import GetEmailProviderResponseContent from ...types.update_email_provider_response_content import UpdateEmailProviderResponseContent from .raw_client import AsyncRawProviderClient, RawProviderClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) class ProviderClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._raw_client = RawProviderClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> RawProviderClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- RawProviderClient """ return self._raw_client def get( self, *, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetEmailProviderResponseContent: """ Retrieve details of the [email provider configuration](https://auth0.com/docs/customize/email/smtp-email-providers) in your tenant. A list of fields to include or exclude may also be specified. Parameters ---------- fields : typing.Optional[str] Comma-separated list of fields to include or exclude (dependent upon include_fields) from the result. Leave empty to retrieve `name` and `enabled`. Additional fields available include `credentials`, `default_from_address`, and `settings`. include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false). request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- GetEmailProviderResponseContent Email provider successfully retrieved. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.emails.provider.get( fields="fields", include_fields=True, ) """ _response = self._raw_client.get(fields=fields, include_fields=include_fields, request_options=request_options) return _response.data def create( self, *, name: EmailProviderNameEnum, credentials: EmailProviderCredentialsSchema, enabled: typing.Optional[bool] = OMIT, default_from_address: typing.Optional[str] = OMIT, settings: typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateEmailProviderResponseContent: """ Create an [email provider](https://auth0.com/docs/email/providers). The `credentials` object requires different properties depending on the email provider (which is specified using the `name` property): - `mandrill` requires `api_key` - `sendgrid` requires `api_key` - `sparkpost` requires `api_key`. Optionally, set `region` to `eu` to use the SparkPost service hosted in Western Europe; set to `null` to use the SparkPost service hosted in North America. `eu` or `null` are the only valid values for `region`. - `mailgun` requires `api_key` and `domain`. Optionally, set `region` to `eu` to use the Mailgun service hosted in Europe; set to `null` otherwise. `eu` or `null` are the only valid values for `region`. - `ses` requires `accessKeyId`, `secretAccessKey`, and `region` - `smtp` requires `smtp_host`, `smtp_port`, `smtp_user`, and `smtp_pass` Depending on the type of provider it is possible to specify `settings` object with different configuration options, which will be used when sending an email: - `smtp` provider, `settings` may contain `headers` object. - When using AWS SES SMTP host, you may provide a name of configuration set in `X-SES-Configuration-Set` header. Value must be a string. - When using Sparkpost host, you may provide value for `X-MSYS_API` header. Value must be an object. - For `ses` provider, `settings` may contain `message` object, where you can provide a name of configuration set in `configuration_set_name` property. Value must be a string. Parameters ---------- name : EmailProviderNameEnum credentials : EmailProviderCredentialsSchema enabled : typing.Optional[bool] Whether the provider is enabled (true) or disabled (false). default_from_address : typing.Optional[str] Email address to use as "from" when no other address specified. settings : typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- CreateEmailProviderResponseContent Email provider successfully created. Examples -------- from auth0 import Auth0, EmailProviderCredentialsSchemaZero client = Auth0( token="YOUR_TOKEN", ) client.emails.provider.create( name="mailgun", credentials=EmailProviderCredentialsSchemaZero( api_key="api_key", ), ) """ _response = self._raw_client.create( name=name, credentials=credentials, enabled=enabled, default_from_address=default_from_address, settings=settings, request_options=request_options, ) return _response.data def delete(self, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ Delete the email provider. Parameters ---------- request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- None Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.emails.provider.delete() """ _response = self._raw_client.delete(request_options=request_options) return _response.data def update( self, *, name: typing.Optional[EmailProviderNameEnum] = OMIT, enabled: typing.Optional[bool] = OMIT, default_from_address: typing.Optional[str] = OMIT, credentials: typing.Optional[EmailProviderCredentialsSchema] = OMIT, settings: typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpdateEmailProviderResponseContent: """ Update an [email provider](https://auth0.com/docs/email/providers). The `credentials` object requires different properties depending on the email provider (which is specified using the `name` property): - `mandrill` requires `api_key` - `sendgrid` requires `api_key` - `sparkpost` requires `api_key`. Optionally, set `region` to `eu` to use the SparkPost service hosted in Western Europe; set to `null` to use the SparkPost service hosted in North America. `eu` or `null` are the only valid values for `region`. - `mailgun` requires `api_key` and `domain`. Optionally, set `region` to `eu` to use the Mailgun service hosted in Europe; set to `null` otherwise. `eu` or `null` are the only valid values for `region`. - `ses` requires `accessKeyId`, `secretAccessKey`, and `region` - `smtp` requires `smtp_host`, `smtp_port`, `smtp_user`, and `smtp_pass` Depending on the type of provider it is possible to specify `settings` object with different configuration options, which will be used when sending an email: - `smtp` provider, `settings` may contain `headers` object. - When using AWS SES SMTP host, you may provide a name of configuration set in `X-SES-Configuration-Set` header. Value must be a string. - When using Sparkpost host, you may provide value for `X-MSYS_API` header. Value must be an object. For `ses` provider, `settings` may contain `message` object, where you can provide a name of configuration set in `configuration_set_name` property. Value must be a string. Parameters ---------- name : typing.Optional[EmailProviderNameEnum] enabled : typing.Optional[bool] Whether the provider is enabled (true) or disabled (false). default_from_address : typing.Optional[str] Email address to use as "from" when no other address specified. credentials : typing.Optional[EmailProviderCredentialsSchema] settings : typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- UpdateEmailProviderResponseContent Email provider successfully updated. Examples -------- from auth0 import Auth0 client = Auth0( token="YOUR_TOKEN", ) client.emails.provider.update() """ _response = self._raw_client.update( name=name, enabled=enabled, default_from_address=default_from_address, credentials=credentials, settings=settings, request_options=request_options, ) return _response.data class AsyncProviderClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._raw_client = AsyncRawProviderClient(client_wrapper=client_wrapper) @property def with_raw_response(self) -> AsyncRawProviderClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- AsyncRawProviderClient """ return self._raw_client async def get( self, *, fields: typing.Optional[str] = None, include_fields: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetEmailProviderResponseContent: """ Retrieve details of the [email provider configuration](https://auth0.com/docs/customize/email/smtp-email-providers) in your tenant. A list of fields to include or exclude may also be specified. Parameters ---------- fields : typing.Optional[str] Comma-separated list of fields to include or exclude (dependent upon include_fields) from the result. Leave empty to retrieve `name` and `enabled`. Additional fields available include `credentials`, `default_from_address`, and `settings`. include_fields : typing.Optional[bool] Whether specified fields are to be included (true) or excluded (false). request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- GetEmailProviderResponseContent Email provider successfully retrieved. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.emails.provider.get( fields="fields", include_fields=True, ) asyncio.run(main()) """ _response = await self._raw_client.get( fields=fields, include_fields=include_fields, request_options=request_options ) return _response.data async def create( self, *, name: EmailProviderNameEnum, credentials: EmailProviderCredentialsSchema, enabled: typing.Optional[bool] = OMIT, default_from_address: typing.Optional[str] = OMIT, settings: typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> CreateEmailProviderResponseContent: """ Create an [email provider](https://auth0.com/docs/email/providers). The `credentials` object requires different properties depending on the email provider (which is specified using the `name` property): - `mandrill` requires `api_key` - `sendgrid` requires `api_key` - `sparkpost` requires `api_key`. Optionally, set `region` to `eu` to use the SparkPost service hosted in Western Europe; set to `null` to use the SparkPost service hosted in North America. `eu` or `null` are the only valid values for `region`. - `mailgun` requires `api_key` and `domain`. Optionally, set `region` to `eu` to use the Mailgun service hosted in Europe; set to `null` otherwise. `eu` or `null` are the only valid values for `region`. - `ses` requires `accessKeyId`, `secretAccessKey`, and `region` - `smtp` requires `smtp_host`, `smtp_port`, `smtp_user`, and `smtp_pass` Depending on the type of provider it is possible to specify `settings` object with different configuration options, which will be used when sending an email: - `smtp` provider, `settings` may contain `headers` object. - When using AWS SES SMTP host, you may provide a name of configuration set in `X-SES-Configuration-Set` header. Value must be a string. - When using Sparkpost host, you may provide value for `X-MSYS_API` header. Value must be an object. - For `ses` provider, `settings` may contain `message` object, where you can provide a name of configuration set in `configuration_set_name` property. Value must be a string. Parameters ---------- name : EmailProviderNameEnum credentials : EmailProviderCredentialsSchema enabled : typing.Optional[bool] Whether the provider is enabled (true) or disabled (false). default_from_address : typing.Optional[str] Email address to use as "from" when no other address specified. settings : typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- CreateEmailProviderResponseContent Email provider successfully created. Examples -------- import asyncio from auth0 import AsyncAuth0, EmailProviderCredentialsSchemaZero client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.emails.provider.create( name="mailgun", credentials=EmailProviderCredentialsSchemaZero( api_key="api_key", ), ) asyncio.run(main()) """ _response = await self._raw_client.create( name=name, credentials=credentials, enabled=enabled, default_from_address=default_from_address, settings=settings, request_options=request_options, ) return _response.data async def delete(self, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ Delete the email provider. Parameters ---------- request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- None Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.emails.provider.delete() asyncio.run(main()) """ _response = await self._raw_client.delete(request_options=request_options) return _response.data async def update( self, *, name: typing.Optional[EmailProviderNameEnum] = OMIT, enabled: typing.Optional[bool] = OMIT, default_from_address: typing.Optional[str] = OMIT, credentials: typing.Optional[EmailProviderCredentialsSchema] = OMIT, settings: typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> UpdateEmailProviderResponseContent: """ Update an [email provider](https://auth0.com/docs/email/providers). The `credentials` object requires different properties depending on the email provider (which is specified using the `name` property): - `mandrill` requires `api_key` - `sendgrid` requires `api_key` - `sparkpost` requires `api_key`. Optionally, set `region` to `eu` to use the SparkPost service hosted in Western Europe; set to `null` to use the SparkPost service hosted in North America. `eu` or `null` are the only valid values for `region`. - `mailgun` requires `api_key` and `domain`. Optionally, set `region` to `eu` to use the Mailgun service hosted in Europe; set to `null` otherwise. `eu` or `null` are the only valid values for `region`. - `ses` requires `accessKeyId`, `secretAccessKey`, and `region` - `smtp` requires `smtp_host`, `smtp_port`, `smtp_user`, and `smtp_pass` Depending on the type of provider it is possible to specify `settings` object with different configuration options, which will be used when sending an email: - `smtp` provider, `settings` may contain `headers` object. - When using AWS SES SMTP host, you may provide a name of configuration set in `X-SES-Configuration-Set` header. Value must be a string. - When using Sparkpost host, you may provide value for `X-MSYS_API` header. Value must be an object. For `ses` provider, `settings` may contain `message` object, where you can provide a name of configuration set in `configuration_set_name` property. Value must be a string. Parameters ---------- name : typing.Optional[EmailProviderNameEnum] enabled : typing.Optional[bool] Whether the provider is enabled (true) or disabled (false). default_from_address : typing.Optional[str] Email address to use as "from" when no other address specified. credentials : typing.Optional[EmailProviderCredentialsSchema] settings : typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- UpdateEmailProviderResponseContent Email provider successfully updated. Examples -------- import asyncio from auth0 import AsyncAuth0 client = AsyncAuth0( token="YOUR_TOKEN", ) async def main() -> None: await client.emails.provider.update() asyncio.run(main()) """ _response = await self._raw_client.update( name=name, enabled=enabled, default_from_address=default_from_address, credentials=credentials, settings=settings, request_options=request_options, ) return _response.data