Skip to content

Commit f8dccdd

Browse files
authored
feat!: change language type to be more strict in magic link options (#137)
1 parent 596f743 commit f8dccdd

9 files changed

+63
-9
lines changed

passageidentity/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
CreateUserArgs,
1313
MagicLink,
1414
MagicLinkChannel,
15+
MagicLinkLanguage,
1516
MagicLinkType,
1617
PassageUser,
1718
UpdateUserArgs,
@@ -26,6 +27,7 @@
2627
"MagicLink",
2728
"MagicLinkArgs",
2829
"MagicLinkChannel",
30+
"MagicLinkLanguage",
2931
"MagicLinkOptions",
3032
"MagicLinkType",
3133
"MagicLinkWithEmailArgs",

passageidentity/models/magic_link_options.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22

33
from __future__ import annotations
44

5+
from typing import TYPE_CHECKING
6+
7+
if TYPE_CHECKING:
8+
from passageidentity.openapi_client.models.magic_link_language import MagicLinkLanguage
9+
510

611
class MagicLinkOptions:
712
"""Options for creating a Magic Link."""
813

9-
language: str | None
14+
language: MagicLinkLanguage | None
1015
magic_link_path: str | None
1116
redirect_url: str | None
1217
ttl: int | None
1318

1419
def __init__(
1520
self,
1621
*,
17-
language: str | None = None,
22+
language: MagicLinkLanguage | None = None,
1823
magic_link_path: str | None = None,
1924
redirect_url: str | None = None,
2025
ttl: int | None = None,

passageidentity/openapi_client/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from passageidentity.openapi_client.models.list_paginated_users_response import ListPaginatedUsersResponse
4747
from passageidentity.openapi_client.models.magic_link import MagicLink
4848
from passageidentity.openapi_client.models.magic_link_channel import MagicLinkChannel
49+
from passageidentity.openapi_client.models.magic_link_language import MagicLinkLanguage
4950
from passageidentity.openapi_client.models.magic_link_response import MagicLinkResponse
5051
from passageidentity.openapi_client.models.magic_link_type import MagicLinkType
5152
from passageidentity.openapi_client.models.model400_error import Model400Error

passageidentity/openapi_client/models/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from passageidentity.openapi_client.models.list_paginated_users_response import ListPaginatedUsersResponse
2727
from passageidentity.openapi_client.models.magic_link import MagicLink
2828
from passageidentity.openapi_client.models.magic_link_channel import MagicLinkChannel
29+
from passageidentity.openapi_client.models.magic_link_language import MagicLinkLanguage
2930
from passageidentity.openapi_client.models.magic_link_response import MagicLinkResponse
3031
from passageidentity.openapi_client.models.magic_link_type import MagicLinkType
3132
from passageidentity.openapi_client.models.model400_error import Model400Error

passageidentity/openapi_client/models/create_magic_link_request.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
import re # noqa: F401
1919
import json
2020

21-
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
21+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
2222
from typing import Any, ClassVar, Dict, List, Optional
23+
from typing_extensions import Annotated
2324
from passageidentity.openapi_client.models.magic_link_channel import MagicLinkChannel
25+
from passageidentity.openapi_client.models.magic_link_language import MagicLinkLanguage
2426
from passageidentity.openapi_client.models.magic_link_type import MagicLinkType
2527
from typing import Optional, Set
2628
from typing_extensions import Self
@@ -31,12 +33,12 @@ class CreateMagicLinkRequest(BaseModel):
3133
""" # noqa: E501
3234
channel: Optional[MagicLinkChannel] = None
3335
email: Optional[StrictStr] = None
34-
language: Optional[StrictStr] = Field(default=None, description="language of the email to send (optional)")
36+
language: Optional[MagicLinkLanguage] = None
3537
magic_link_path: Optional[StrictStr] = Field(default=None, description="must be a relative url")
3638
phone: Optional[StrictStr] = None
3739
redirect_url: Optional[StrictStr] = None
3840
send: Optional[StrictBool] = None
39-
ttl: Optional[StrictInt] = None
41+
ttl: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="time to live in minutes")
4042
type: Optional[MagicLinkType] = None
4143
user_id: Optional[StrictStr] = None
4244
__properties: ClassVar[List[str]] = ["channel", "email", "language", "magic_link_path", "phone", "redirect_url", "send", "ttl", "type", "user_id"]

passageidentity/openapi_client/models/magic_link.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import re # noqa: F401
1919
import json
2020

21-
from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr
21+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
2222
from typing import Any, ClassVar, Dict, List
2323
from passageidentity.openapi_client.models.magic_link_type import MagicLinkType
2424
from typing import Optional, Set
@@ -34,7 +34,7 @@ class MagicLink(BaseModel):
3434
identifier: StrictStr
3535
redirect_url: StrictStr
3636
secret: StrictStr
37-
ttl: StrictInt
37+
ttl: StrictInt = Field(description="time to live in minutes")
3838
type: MagicLinkType
3939
url: StrictStr
4040
user_id: StrictStr

passageidentity/openapi_client/models/magic_link_channel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class MagicLinkChannel(str, Enum):
2323
"""
24-
MagicLinkChannel
24+
The channel for magic link delivery: \"email\" or \"phone\". Required if \"send\" is true.
2525
"""
2626

2727
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# coding: utf-8
2+
3+
"""
4+
Passage Management API
5+
6+
Passage's management API to manage your Passage apps and users.
7+
8+
The version of the OpenAPI document: 1
9+
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
11+
12+
Do not edit the class manually.
13+
""" # noqa: E501
14+
15+
16+
from __future__ import annotations
17+
import json
18+
from enum import Enum
19+
from typing_extensions import Self
20+
21+
22+
class MagicLinkLanguage(str, Enum):
23+
"""
24+
language of the email or sms to send
25+
"""
26+
27+
"""
28+
allowed enum values
29+
"""
30+
DE = 'de'
31+
EN = 'en'
32+
ES = 'es'
33+
IT = 'it'
34+
PL = 'pl'
35+
PT = 'pt'
36+
ZH = 'zh'
37+
38+
@classmethod
39+
def from_json(cls, json_str: str) -> Self:
40+
"""Create an instance of MagicLinkLanguage from a JSON string"""
41+
return cls(json.loads(json_str))
42+
43+

passageidentity/openapi_client/models/magic_link_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class MagicLinkType(str, Enum):
2323
"""
24-
MagicLinkType
24+
The type of magic link to create: \"login\" or \"verify_identifier\". Defaults to \"login\".
2525
"""
2626

2727
"""

0 commit comments

Comments
 (0)