| 1 |
|
| 2 |
|
| 3 |
import typing |
| 4 |
|
| 5 |
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 6 |
from ...core.request_options import RequestOptions |
| 7 |
from ...types.create_guardian_enrollment_ticket_response_content import CreateGuardianEnrollmentTicketResponseContent |
| 8 |
from ...types.get_guardian_enrollment_response_content import GetGuardianEnrollmentResponseContent |
| 9 |
from ...types.guardian_enrollment_factor_enum import GuardianEnrollmentFactorEnum |
| 10 |
from .raw_client import AsyncRawEnrollmentsClient, RawEnrollmentsClient |
| 11 |
|
| 12 |
|
| 13 |
OMIT = typing.cast(typing.Any, ...) |
| 14 |
|
| 15 |
|
| 16 |
class EnrollmentsClient: |
| 17 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 18 |
self._raw_client = RawEnrollmentsClient(client_wrapper=client_wrapper) |
| 19 |
|
| 20 |
@property |
| 21 |
def with_raw_response(self) -> RawEnrollmentsClient: |
| 22 |
""" |
| 23 |
Retrieves a raw implementation of this client that returns raw responses. |
| 24 |
|
| 25 |
Returns |
| 26 |
------- |
| 27 |
RawEnrollmentsClient |
| 28 |
""" |
| 29 |
return self._raw_client |
| 30 |
|
| 31 |
def create_ticket( |
| 32 |
self, |
| 33 |
*, |
| 34 |
user_id: str, |
| 35 |
email: typing.Optional[str] = OMIT, |
| 36 |
send_mail: typing.Optional[bool] = OMIT, |
| 37 |
email_locale: typing.Optional[str] = OMIT, |
| 38 |
factor: typing.Optional[GuardianEnrollmentFactorEnum] = OMIT, |
| 39 |
allow_multiple_enrollments: typing.Optional[bool] = OMIT, |
| 40 |
request_options: typing.Optional[RequestOptions] = None, |
| 41 |
) -> CreateGuardianEnrollmentTicketResponseContent: |
| 42 |
""" |
| 43 |
Create a [multi-factor authentication (MFA) enrollment ticket](https://auth0.com/docs/secure/multi-factor-authentication/auth0-guardian/create-custom-enrollment-tickets), and optionally send an email with the created ticket to a given user. Enrollment tickets can specify which factor users must enroll with or allow existing MFA users to enroll in additional factors. |
| 44 |
|
| 45 |
Parameters |
| 46 |
---------- |
| 47 |
user_id : str |
| 48 |
user_id for the enrollment ticket |
| 49 |
|
| 50 |
email : typing.Optional[str] |
| 51 |
alternate email to which the enrollment email will be sent. Optional - by default, the email will be sent to the user's default address |
| 52 |
|
| 53 |
send_mail : typing.Optional[bool] |
| 54 |
Send an email to the user to start the enrollment |
| 55 |
|
| 56 |
email_locale : typing.Optional[str] |
| 57 |
Optional. Specify the locale of the enrollment email. Used with send_email. |
| 58 |
|
| 59 |
factor : typing.Optional[GuardianEnrollmentFactorEnum] |
| 60 |
|
| 61 |
allow_multiple_enrollments : typing.Optional[bool] |
| 62 |
Optional. Allows a user who has previously enrolled in MFA to enroll with additional factors.<br />Note: Parameter can only be used with Universal Login; it cannot be used with Classic Login or custom MFA pages. |
| 63 |
|
| 64 |
request_options : typing.Optional[RequestOptions] |
| 65 |
Request-specific configuration. |
| 66 |
|
| 67 |
Returns |
| 68 |
------- |
| 69 |
CreateGuardianEnrollmentTicketResponseContent |
| 70 |
Enrollment ticket successfully created. |
| 71 |
|
| 72 |
Examples |
| 73 |
-------- |
| 74 |
from auth0 import Auth0 |
| 75 |
|
| 76 |
client = Auth0( |
| 77 |
token="YOUR_TOKEN", |
| 78 |
) |
| 79 |
client.guardian.enrollments.create_ticket( |
| 80 |
user_id="user_id", |
| 81 |
) |
| 82 |
""" |
| 83 |
_response = self._raw_client.create_ticket( |
| 84 |
user_id=user_id, |
| 85 |
email=email, |
| 86 |
send_mail=send_mail, |
| 87 |
email_locale=email_locale, |
| 88 |
factor=factor, |
| 89 |
allow_multiple_enrollments=allow_multiple_enrollments, |
| 90 |
request_options=request_options, |
| 91 |
) |
| 92 |
return _response.data |
| 93 |
|
| 94 |
def get( |
| 95 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 96 |
) -> GetGuardianEnrollmentResponseContent: |
| 97 |
""" |
| 98 |
Retrieve details, such as status and type, for a specific multi-factor authentication enrollment registered to a user account. |
| 99 |
|
| 100 |
Parameters |
| 101 |
---------- |
| 102 |
id : str |
| 103 |
ID of the enrollment to be retrieve. |
| 104 |
|
| 105 |
request_options : typing.Optional[RequestOptions] |
| 106 |
Request-specific configuration. |
| 107 |
|
| 108 |
Returns |
| 109 |
------- |
| 110 |
GetGuardianEnrollmentResponseContent |
| 111 |
Enrollment successfully retrieved. |
| 112 |
|
| 113 |
Examples |
| 114 |
-------- |
| 115 |
from auth0 import Auth0 |
| 116 |
|
| 117 |
client = Auth0( |
| 118 |
token="YOUR_TOKEN", |
| 119 |
) |
| 120 |
client.guardian.enrollments.get( |
| 121 |
id="id", |
| 122 |
) |
| 123 |
""" |
| 124 |
_response = self._raw_client.get(id, request_options=request_options) |
| 125 |
return _response.data |
| 126 |
|
| 127 |
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: |
| 128 |
""" |
| 129 |
Remove a specific multi-factor authentication (MFA) enrollment from a user's account. This allows the user to re-enroll with MFA. For more information, review [Reset User Multi-Factor Authentication and Recovery Codes](https://auth0.com/docs/secure/multi-factor-authentication/reset-user-mfa). |
| 130 |
|
| 131 |
Parameters |
| 132 |
---------- |
| 133 |
id : str |
| 134 |
ID of the enrollment to be deleted. |
| 135 |
|
| 136 |
request_options : typing.Optional[RequestOptions] |
| 137 |
Request-specific configuration. |
| 138 |
|
| 139 |
Returns |
| 140 |
------- |
| 141 |
None |
| 142 |
|
| 143 |
Examples |
| 144 |
-------- |
| 145 |
from auth0 import Auth0 |
| 146 |
|
| 147 |
client = Auth0( |
| 148 |
token="YOUR_TOKEN", |
| 149 |
) |
| 150 |
client.guardian.enrollments.delete( |
| 151 |
id="id", |
| 152 |
) |
| 153 |
""" |
| 154 |
_response = self._raw_client.delete(id, request_options=request_options) |
| 155 |
return _response.data |
| 156 |
|
| 157 |
|
| 158 |
class AsyncEnrollmentsClient: |
| 159 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 160 |
self._raw_client = AsyncRawEnrollmentsClient(client_wrapper=client_wrapper) |
| 161 |
|
| 162 |
@property |
| 163 |
def with_raw_response(self) -> AsyncRawEnrollmentsClient: |
| 164 |
""" |
| 165 |
Retrieves a raw implementation of this client that returns raw responses. |
| 166 |
|
| 167 |
Returns |
| 168 |
------- |
| 169 |
AsyncRawEnrollmentsClient |
| 170 |
""" |
| 171 |
return self._raw_client |
| 172 |
|
| 173 |
async def create_ticket( |
| 174 |
self, |
| 175 |
*, |
| 176 |
user_id: str, |
| 177 |
email: typing.Optional[str] = OMIT, |
| 178 |
send_mail: typing.Optional[bool] = OMIT, |
| 179 |
email_locale: typing.Optional[str] = OMIT, |
| 180 |
factor: typing.Optional[GuardianEnrollmentFactorEnum] = OMIT, |
| 181 |
allow_multiple_enrollments: typing.Optional[bool] = OMIT, |
| 182 |
request_options: typing.Optional[RequestOptions] = None, |
| 183 |
) -> CreateGuardianEnrollmentTicketResponseContent: |
| 184 |
""" |
| 185 |
Create a [multi-factor authentication (MFA) enrollment ticket](https://auth0.com/docs/secure/multi-factor-authentication/auth0-guardian/create-custom-enrollment-tickets), and optionally send an email with the created ticket to a given user. Enrollment tickets can specify which factor users must enroll with or allow existing MFA users to enroll in additional factors. |
| 186 |
|
| 187 |
Parameters |
| 188 |
---------- |
| 189 |
user_id : str |
| 190 |
user_id for the enrollment ticket |
| 191 |
|
| 192 |
email : typing.Optional[str] |
| 193 |
alternate email to which the enrollment email will be sent. Optional - by default, the email will be sent to the user's default address |
| 194 |
|
| 195 |
send_mail : typing.Optional[bool] |
| 196 |
Send an email to the user to start the enrollment |
| 197 |
|
| 198 |
email_locale : typing.Optional[str] |
| 199 |
Optional. Specify the locale of the enrollment email. Used with send_email. |
| 200 |
|
| 201 |
factor : typing.Optional[GuardianEnrollmentFactorEnum] |
| 202 |
|
| 203 |
allow_multiple_enrollments : typing.Optional[bool] |
| 204 |
Optional. Allows a user who has previously enrolled in MFA to enroll with additional factors.<br />Note: Parameter can only be used with Universal Login; it cannot be used with Classic Login or custom MFA pages. |
| 205 |
|
| 206 |
request_options : typing.Optional[RequestOptions] |
| 207 |
Request-specific configuration. |
| 208 |
|
| 209 |
Returns |
| 210 |
------- |
| 211 |
CreateGuardianEnrollmentTicketResponseContent |
| 212 |
Enrollment ticket successfully created. |
| 213 |
|
| 214 |
Examples |
| 215 |
-------- |
| 216 |
import asyncio |
| 217 |
|
| 218 |
from auth0 import AsyncAuth0 |
| 219 |
|
| 220 |
client = AsyncAuth0( |
| 221 |
token="YOUR_TOKEN", |
| 222 |
) |
| 223 |
|
| 224 |
|
| 225 |
async def main() -> None: |
| 226 |
await client.guardian.enrollments.create_ticket( |
| 227 |
user_id="user_id", |
| 228 |
) |
| 229 |
|
| 230 |
|
| 231 |
asyncio.run(main()) |
| 232 |
""" |
| 233 |
_response = await self._raw_client.create_ticket( |
| 234 |
user_id=user_id, |
| 235 |
email=email, |
| 236 |
send_mail=send_mail, |
| 237 |
email_locale=email_locale, |
| 238 |
factor=factor, |
| 239 |
allow_multiple_enrollments=allow_multiple_enrollments, |
| 240 |
request_options=request_options, |
| 241 |
) |
| 242 |
return _response.data |
| 243 |
|
| 244 |
async def get( |
| 245 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 246 |
) -> GetGuardianEnrollmentResponseContent: |
| 247 |
""" |
| 248 |
Retrieve details, such as status and type, for a specific multi-factor authentication enrollment registered to a user account. |
| 249 |
|
| 250 |
Parameters |
| 251 |
---------- |
| 252 |
id : str |
| 253 |
ID of the enrollment to be retrieve. |
| 254 |
|
| 255 |
request_options : typing.Optional[RequestOptions] |
| 256 |
Request-specific configuration. |
| 257 |
|
| 258 |
Returns |
| 259 |
------- |
| 260 |
GetGuardianEnrollmentResponseContent |
| 261 |
Enrollment successfully retrieved. |
| 262 |
|
| 263 |
Examples |
| 264 |
-------- |
| 265 |
import asyncio |
| 266 |
|
| 267 |
from auth0 import AsyncAuth0 |
| 268 |
|
| 269 |
client = AsyncAuth0( |
| 270 |
token="YOUR_TOKEN", |
| 271 |
) |
| 272 |
|
| 273 |
|
| 274 |
async def main() -> None: |
| 275 |
await client.guardian.enrollments.get( |
| 276 |
id="id", |
| 277 |
) |
| 278 |
|
| 279 |
|
| 280 |
asyncio.run(main()) |
| 281 |
""" |
| 282 |
_response = await self._raw_client.get(id, request_options=request_options) |
| 283 |
return _response.data |
| 284 |
|
| 285 |
async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: |
| 286 |
""" |
| 287 |
Remove a specific multi-factor authentication (MFA) enrollment from a user's account. This allows the user to re-enroll with MFA. For more information, review [Reset User Multi-Factor Authentication and Recovery Codes](https://auth0.com/docs/secure/multi-factor-authentication/reset-user-mfa). |
| 288 |
|
| 289 |
Parameters |
| 290 |
---------- |
| 291 |
id : str |
| 292 |
ID of the enrollment to be deleted. |
| 293 |
|
| 294 |
request_options : typing.Optional[RequestOptions] |
| 295 |
Request-specific configuration. |
| 296 |
|
| 297 |
Returns |
| 298 |
------- |
| 299 |
None |
| 300 |
|
| 301 |
Examples |
| 302 |
-------- |
| 303 |
import asyncio |
| 304 |
|
| 305 |
from auth0 import AsyncAuth0 |
| 306 |
|
| 307 |
client = AsyncAuth0( |
| 308 |
token="YOUR_TOKEN", |
| 309 |
) |
| 310 |
|
| 311 |
|
| 312 |
async def main() -> None: |
| 313 |
await client.guardian.enrollments.delete( |
| 314 |
id="id", |
| 315 |
) |
| 316 |
|
| 317 |
|
| 318 |
asyncio.run(main()) |
| 319 |
""" |
| 320 |
_response = await self._raw_client.delete(id, request_options=request_options) |
| 321 |
return _response.data |