Debian Codegraph @

src/auth0/management/emails/provider/client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 import typing
4
5 from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6 from ...core.request_options import RequestOptions
7 from ...types.create_email_provider_response_content import CreateEmailProviderResponseContent
8 from ...types.email_provider_credentials_schema import EmailProviderCredentialsSchema
9 from ...types.email_provider_name_enum import EmailProviderNameEnum
10 from ...types.email_specific_provider_settings_with_additional_properties import (
11 EmailSpecificProviderSettingsWithAdditionalProperties,
12 )
13 from ...types.get_email_provider_response_content import GetEmailProviderResponseContent
14 from ...types.update_email_provider_response_content import UpdateEmailProviderResponseContent
15 from .raw_client import AsyncRawProviderClient, RawProviderClient
16
17 # this is used as the default value for optional parameters
18 OMIT = typing.cast(typing.Any, ...)
19
20
21 class ProviderClient:
22 def __init__(self, *, client_wrapper: SyncClientWrapper):
23 self._raw_client = RawProviderClient(client_wrapper=client_wrapper)
24
25 @property
26 def with_raw_response(self) -> RawProviderClient:
27 """
28 Retrieves a raw implementation of this client that returns raw responses.
29
30 Returns
31 -------
32 RawProviderClient
33 """
34 return self._raw_client
35
36 def get(
37 self,
38 *,
39 fields: typing.Optional[str] = None,
40 include_fields: typing.Optional[bool] = None,
41 request_options: typing.Optional[RequestOptions] = None,
42 ) -> GetEmailProviderResponseContent:
43 """
44 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.
45
46 Parameters
47 ----------
48 fields : typing.Optional[str]
49 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`.
50
51 include_fields : typing.Optional[bool]
52 Whether specified fields are to be included (true) or excluded (false).
53
54 request_options : typing.Optional[RequestOptions]
55 Request-specific configuration.
56
57 Returns
58 -------
59 GetEmailProviderResponseContent
60 Email provider successfully retrieved.
61
62 Examples
63 --------
64 from auth0 import Auth0
65
66 client = Auth0(
67 token="YOUR_TOKEN",
68 )
69 client.emails.provider.get(
70 fields="fields",
71 include_fields=True,
72 )
73 """
74 _response = self._raw_client.get(fields=fields, include_fields=include_fields, request_options=request_options)
75 return _response.data
76
77 def create(
78 self,
79 *,
80 name: EmailProviderNameEnum,
81 credentials: EmailProviderCredentialsSchema,
82 enabled: typing.Optional[bool] = OMIT,
83 default_from_address: typing.Optional[str] = OMIT,
84 settings: typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] = OMIT,
85 request_options: typing.Optional[RequestOptions] = None,
86 ) -> CreateEmailProviderResponseContent:
87 """
88 Create an [email provider](https://auth0.com/docs/email/providers). The `credentials` object
89 requires different properties depending on the email provider (which is specified using the `name` property):
90
91 - `mandrill` requires `api_key`
92 - `sendgrid` requires `api_key`
93 - `sparkpost` requires `api_key`. Optionally, set `region` to `eu` to use
94 the SparkPost service hosted in Western Europe; set to `null` to use the SparkPost service hosted in
95 North America. `eu` or `null` are the only valid values for `region`.
96 - `mailgun` requires `api_key` and `domain`. Optionally, set `region` to
97 `eu` to use the Mailgun service hosted in Europe; set to `null` otherwise. `eu` or
98 `null` are the only valid values for `region`.
99 - `ses` requires `accessKeyId`, `secretAccessKey`, and `region`
100 - `smtp` requires `smtp_host`, `smtp_port`, `smtp_user`, and
101 `smtp_pass`
102
103 Depending on the type of provider it is possible to specify `settings` object with different configuration
104 options, which will be used when sending an email:
105
106 - `smtp` provider, `settings` may contain `headers` object.
107 - When using AWS SES SMTP host, you may provide a name of configuration set in
108 `X-SES-Configuration-Set` header. Value must be a string.
109 - When using Sparkpost host, you may provide value for
110 `X-MSYS_API` header. Value must be an object.
111 - For `ses` provider, `settings` may contain `message` object, where you can provide
112 a name of configuration set in `configuration_set_name` property. Value must be a string.
113
114 Parameters
115 ----------
116 name : EmailProviderNameEnum
117
118 credentials : EmailProviderCredentialsSchema
119
120 enabled : typing.Optional[bool]
121 Whether the provider is enabled (true) or disabled (false).
122
123 default_from_address : typing.Optional[str]
124 Email address to use as "from" when no other address specified.
125
126 settings : typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties]
127
128 request_options : typing.Optional[RequestOptions]
129 Request-specific configuration.
130
131 Returns
132 -------
133 CreateEmailProviderResponseContent
134 Email provider successfully created.
135
136 Examples
137 --------
138 from auth0 import Auth0, EmailProviderCredentialsSchemaZero
139
140 client = Auth0(
141 token="YOUR_TOKEN",
142 )
143 client.emails.provider.create(
144 name="mailgun",
145 credentials=EmailProviderCredentialsSchemaZero(
146 api_key="api_key",
147 ),
148 )
149 """
150 _response = self._raw_client.create(
151 name=name,
152 credentials=credentials,
153 enabled=enabled,
154 default_from_address=default_from_address,
155 settings=settings,
156 request_options=request_options,
157 )
158 return _response.data
159
160 def delete(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
161 """
162 Delete the email provider.
163
164 Parameters
165 ----------
166 request_options : typing.Optional[RequestOptions]
167 Request-specific configuration.
168
169 Returns
170 -------
171 None
172
173 Examples
174 --------
175 from auth0 import Auth0
176
177 client = Auth0(
178 token="YOUR_TOKEN",
179 )
180 client.emails.provider.delete()
181 """
182 _response = self._raw_client.delete(request_options=request_options)
183 return _response.data
184
185 def update(
186 self,
187 *,
188 name: typing.Optional[EmailProviderNameEnum] = OMIT,
189 enabled: typing.Optional[bool] = OMIT,
190 default_from_address: typing.Optional[str] = OMIT,
191 credentials: typing.Optional[EmailProviderCredentialsSchema] = OMIT,
192 settings: typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] = OMIT,
193 request_options: typing.Optional[RequestOptions] = None,
194 ) -> UpdateEmailProviderResponseContent:
195 """
196 Update an [email provider](https://auth0.com/docs/email/providers). The `credentials` object
197 requires different properties depending on the email provider (which is specified using the `name` property):
198
199 - `mandrill` requires `api_key`
200 - `sendgrid` requires `api_key`
201 - `sparkpost` requires `api_key`. Optionally, set `region` to `eu` to use
202 the SparkPost service hosted in Western Europe; set to `null` to use the SparkPost service hosted in
203 North America. `eu` or `null` are the only valid values for `region`.
204 - `mailgun` requires `api_key` and `domain`. Optionally, set `region` to
205 `eu` to use the Mailgun service hosted in Europe; set to `null` otherwise. `eu` or
206 `null` are the only valid values for `region`.
207 - `ses` requires `accessKeyId`, `secretAccessKey`, and `region`
208 - `smtp` requires `smtp_host`, `smtp_port`, `smtp_user`, and
209 `smtp_pass`
210
211 Depending on the type of provider it is possible to specify `settings` object with different configuration
212 options, which will be used when sending an email:
213
214 - `smtp` provider, `settings` may contain `headers` object.
215 - When using AWS SES SMTP host, you may provide a name of configuration set in
216 `X-SES-Configuration-Set` header. Value must be a string.
217 - When using Sparkpost host, you may provide value for
218 `X-MSYS_API` header. Value must be an object.
219
220 For `ses` provider, `settings` may contain `message` object, where you can provide
221 a name of configuration set in `configuration_set_name` property. Value must be a string.
222
223 Parameters
224 ----------
225 name : typing.Optional[EmailProviderNameEnum]
226
227 enabled : typing.Optional[bool]
228 Whether the provider is enabled (true) or disabled (false).
229
230 default_from_address : typing.Optional[str]
231 Email address to use as "from" when no other address specified.
232
233 credentials : typing.Optional[EmailProviderCredentialsSchema]
234
235 settings : typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties]
236
237 request_options : typing.Optional[RequestOptions]
238 Request-specific configuration.
239
240 Returns
241 -------
242 UpdateEmailProviderResponseContent
243 Email provider successfully updated.
244
245 Examples
246 --------
247 from auth0 import Auth0
248
249 client = Auth0(
250 token="YOUR_TOKEN",
251 )
252 client.emails.provider.update()
253 """
254 _response = self._raw_client.update(
255 name=name,
256 enabled=enabled,
257 default_from_address=default_from_address,
258 credentials=credentials,
259 settings=settings,
260 request_options=request_options,
261 )
262 return _response.data
263
264
265 class AsyncProviderClient:
266 def __init__(self, *, client_wrapper: AsyncClientWrapper):
267 self._raw_client = AsyncRawProviderClient(client_wrapper=client_wrapper)
268
269 @property
270 def with_raw_response(self) -> AsyncRawProviderClient:
271 """
272 Retrieves a raw implementation of this client that returns raw responses.
273
274 Returns
275 -------
276 AsyncRawProviderClient
277 """
278 return self._raw_client
279
280 async def get(
281 self,
282 *,
283 fields: typing.Optional[str] = None,
284 include_fields: typing.Optional[bool] = None,
285 request_options: typing.Optional[RequestOptions] = None,
286 ) -> GetEmailProviderResponseContent:
287 """
288 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.
289
290 Parameters
291 ----------
292 fields : typing.Optional[str]
293 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`.
294
295 include_fields : typing.Optional[bool]
296 Whether specified fields are to be included (true) or excluded (false).
297
298 request_options : typing.Optional[RequestOptions]
299 Request-specific configuration.
300
301 Returns
302 -------
303 GetEmailProviderResponseContent
304 Email provider successfully retrieved.
305
306 Examples
307 --------
308 import asyncio
309
310 from auth0 import AsyncAuth0
311
312 client = AsyncAuth0(
313 token="YOUR_TOKEN",
314 )
315
316
317 async def main() -> None:
318 await client.emails.provider.get(
319 fields="fields",
320 include_fields=True,
321 )
322
323
324 asyncio.run(main())
325 """
326 _response = await self._raw_client.get(
327 fields=fields, include_fields=include_fields, request_options=request_options
328 )
329 return _response.data
330
331 async def create(
332 self,
333 *,
334 name: EmailProviderNameEnum,
335 credentials: EmailProviderCredentialsSchema,
336 enabled: typing.Optional[bool] = OMIT,
337 default_from_address: typing.Optional[str] = OMIT,
338 settings: typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] = OMIT,
339 request_options: typing.Optional[RequestOptions] = None,
340 ) -> CreateEmailProviderResponseContent:
341 """
342 Create an [email provider](https://auth0.com/docs/email/providers). The `credentials` object
343 requires different properties depending on the email provider (which is specified using the `name` property):
344
345 - `mandrill` requires `api_key`
346 - `sendgrid` requires `api_key`
347 - `sparkpost` requires `api_key`. Optionally, set `region` to `eu` to use
348 the SparkPost service hosted in Western Europe; set to `null` to use the SparkPost service hosted in
349 North America. `eu` or `null` are the only valid values for `region`.
350 - `mailgun` requires `api_key` and `domain`. Optionally, set `region` to
351 `eu` to use the Mailgun service hosted in Europe; set to `null` otherwise. `eu` or
352 `null` are the only valid values for `region`.
353 - `ses` requires `accessKeyId`, `secretAccessKey`, and `region`
354 - `smtp` requires `smtp_host`, `smtp_port`, `smtp_user`, and
355 `smtp_pass`
356
357 Depending on the type of provider it is possible to specify `settings` object with different configuration
358 options, which will be used when sending an email:
359
360 - `smtp` provider, `settings` may contain `headers` object.
361 - When using AWS SES SMTP host, you may provide a name of configuration set in
362 `X-SES-Configuration-Set` header. Value must be a string.
363 - When using Sparkpost host, you may provide value for
364 `X-MSYS_API` header. Value must be an object.
365 - For `ses` provider, `settings` may contain `message` object, where you can provide
366 a name of configuration set in `configuration_set_name` property. Value must be a string.
367
368 Parameters
369 ----------
370 name : EmailProviderNameEnum
371
372 credentials : EmailProviderCredentialsSchema
373
374 enabled : typing.Optional[bool]
375 Whether the provider is enabled (true) or disabled (false).
376
377 default_from_address : typing.Optional[str]
378 Email address to use as "from" when no other address specified.
379
380 settings : typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties]
381
382 request_options : typing.Optional[RequestOptions]
383 Request-specific configuration.
384
385 Returns
386 -------
387 CreateEmailProviderResponseContent
388 Email provider successfully created.
389
390 Examples
391 --------
392 import asyncio
393
394 from auth0 import AsyncAuth0, EmailProviderCredentialsSchemaZero
395
396 client = AsyncAuth0(
397 token="YOUR_TOKEN",
398 )
399
400
401 async def main() -> None:
402 await client.emails.provider.create(
403 name="mailgun",
404 credentials=EmailProviderCredentialsSchemaZero(
405 api_key="api_key",
406 ),
407 )
408
409
410 asyncio.run(main())
411 """
412 _response = await self._raw_client.create(
413 name=name,
414 credentials=credentials,
415 enabled=enabled,
416 default_from_address=default_from_address,
417 settings=settings,
418 request_options=request_options,
419 )
420 return _response.data
421
422 async def delete(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
423 """
424 Delete the email provider.
425
426 Parameters
427 ----------
428 request_options : typing.Optional[RequestOptions]
429 Request-specific configuration.
430
431 Returns
432 -------
433 None
434
435 Examples
436 --------
437 import asyncio
438
439 from auth0 import AsyncAuth0
440
441 client = AsyncAuth0(
442 token="YOUR_TOKEN",
443 )
444
445
446 async def main() -> None:
447 await client.emails.provider.delete()
448
449
450 asyncio.run(main())
451 """
452 _response = await self._raw_client.delete(request_options=request_options)
453 return _response.data
454
455 async def update(
456 self,
457 *,
458 name: typing.Optional[EmailProviderNameEnum] = OMIT,
459 enabled: typing.Optional[bool] = OMIT,
460 default_from_address: typing.Optional[str] = OMIT,
461 credentials: typing.Optional[EmailProviderCredentialsSchema] = OMIT,
462 settings: typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties] = OMIT,
463 request_options: typing.Optional[RequestOptions] = None,
464 ) -> UpdateEmailProviderResponseContent:
465 """
466 Update an [email provider](https://auth0.com/docs/email/providers). The `credentials` object
467 requires different properties depending on the email provider (which is specified using the `name` property):
468
469 - `mandrill` requires `api_key`
470 - `sendgrid` requires `api_key`
471 - `sparkpost` requires `api_key`. Optionally, set `region` to `eu` to use
472 the SparkPost service hosted in Western Europe; set to `null` to use the SparkPost service hosted in
473 North America. `eu` or `null` are the only valid values for `region`.
474 - `mailgun` requires `api_key` and `domain`. Optionally, set `region` to
475 `eu` to use the Mailgun service hosted in Europe; set to `null` otherwise. `eu` or
476 `null` are the only valid values for `region`.
477 - `ses` requires `accessKeyId`, `secretAccessKey`, and `region`
478 - `smtp` requires `smtp_host`, `smtp_port`, `smtp_user`, and
479 `smtp_pass`
480
481 Depending on the type of provider it is possible to specify `settings` object with different configuration
482 options, which will be used when sending an email:
483
484 - `smtp` provider, `settings` may contain `headers` object.
485 - When using AWS SES SMTP host, you may provide a name of configuration set in
486 `X-SES-Configuration-Set` header. Value must be a string.
487 - When using Sparkpost host, you may provide value for
488 `X-MSYS_API` header. Value must be an object.
489
490 For `ses` provider, `settings` may contain `message` object, where you can provide
491 a name of configuration set in `configuration_set_name` property. Value must be a string.
492
493 Parameters
494 ----------
495 name : typing.Optional[EmailProviderNameEnum]
496
497 enabled : typing.Optional[bool]
498 Whether the provider is enabled (true) or disabled (false).
499
500 default_from_address : typing.Optional[str]
501 Email address to use as "from" when no other address specified.
502
503 credentials : typing.Optional[EmailProviderCredentialsSchema]
504
505 settings : typing.Optional[EmailSpecificProviderSettingsWithAdditionalProperties]
506
507 request_options : typing.Optional[RequestOptions]
508 Request-specific configuration.
509
510 Returns
511 -------
512 UpdateEmailProviderResponseContent
513 Email provider successfully updated.
514
515 Examples
516 --------
517 import asyncio
518
519 from auth0 import AsyncAuth0
520
521 client = AsyncAuth0(
522 token="YOUR_TOKEN",
523 )
524
525
526 async def main() -> None:
527 await client.emails.provider.update()
528
529
530 asyncio.run(main())
531 """
532 _response = await self._raw_client.update(
533 name=name,
534 enabled=enabled,
535 default_from_address=default_from_address,
536 credentials=credentials,
537 settings=settings,
538 request_options=request_options,
539 )
540 return _response.data