Adds type and endpoint for username validation.

identity is not simple_endpoint anymore.
This commit is contained in:
Carlos Nihelton 2022-05-04 19:02:25 -03:00
parent 7d6d50d66d
commit 8525a363e0
No known key found for this signature in database
GPG Key ID: 6FE346D245197E9A
2 changed files with 13 additions and 1 deletions

View File

@ -54,6 +54,7 @@ from subiquity.common.types import (
TimeZoneInfo, TimeZoneInfo,
UbuntuProInfo, UbuntuProInfo,
UbuntuProCheckTokenAnswer, UbuntuProCheckTokenAnswer,
UsernameValidation,
WLANSupportInstallState, WLANSupportInstallState,
ZdevInfo, ZdevInfo,
WSLConfigurationBase, WSLConfigurationBase,
@ -64,7 +65,6 @@ from subiquity.common.types import (
@api @api
class API: class API:
"""The API offered by the subiquity installer process.""" """The API offered by the subiquity installer process."""
identity = simple_endpoint(IdentityData)
locale = simple_endpoint(str) locale = simple_endpoint(str)
proxy = simple_endpoint(str) proxy = simple_endpoint(str)
ssh = simple_endpoint(SSHData) ssh = simple_endpoint(SSHData)
@ -334,6 +334,11 @@ class API:
class check_token: class check_token:
def GET(token: Payload[str]) \ def GET(token: Payload[str]) \
-> UbuntuProCheckTokenAnswer: ... -> UbuntuProCheckTokenAnswer: ...
class identity:
def GET() -> IdentityData: ...
def POST(data: Payload[IdentityData]): ...
class validate:
def GET(username: str) ->UsernameValidation: ...
class LinkAction(enum.Enum): class LinkAction(enum.Enum):

View File

@ -354,6 +354,13 @@ class IdentityData:
crypted_password: str = attr.ib(default='', repr=False) crypted_password: str = attr.ib(default='', repr=False)
hostname: str = '' hostname: str = ''
class UsernameValidation(enum.Enum):
OK = enum.auto()
ALREADY_IN_USE = enum.auto()
SYSTEM_RESERVED = enum.auto()
INVALID_CHARS = enum.auto()
TOO_LONG = enum.auto()
@attr.s(auto_attribs=True) @attr.s(auto_attribs=True)
class SSHData: class SSHData: