From 8525a363e0d7c0a030017bc288b64e2519b0ab91 Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Wed, 4 May 2022 19:02:25 -0300 Subject: [PATCH] Adds type and endpoint for username validation. identity is not simple_endpoint anymore. --- subiquity/common/apidef.py | 7 ++++++- subiquity/common/types.py | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/subiquity/common/apidef.py b/subiquity/common/apidef.py index acd2a3ff..9df41689 100644 --- a/subiquity/common/apidef.py +++ b/subiquity/common/apidef.py @@ -54,6 +54,7 @@ from subiquity.common.types import ( TimeZoneInfo, UbuntuProInfo, UbuntuProCheckTokenAnswer, + UsernameValidation, WLANSupportInstallState, ZdevInfo, WSLConfigurationBase, @@ -64,7 +65,6 @@ from subiquity.common.types import ( @api class API: """The API offered by the subiquity installer process.""" - identity = simple_endpoint(IdentityData) locale = simple_endpoint(str) proxy = simple_endpoint(str) ssh = simple_endpoint(SSHData) @@ -334,6 +334,11 @@ class API: class check_token: def GET(token: Payload[str]) \ -> UbuntuProCheckTokenAnswer: ... + class identity: + def GET() -> IdentityData: ... + def POST(data: Payload[IdentityData]): ... + class validate: + def GET(username: str) ->UsernameValidation: ... class LinkAction(enum.Enum): diff --git a/subiquity/common/types.py b/subiquity/common/types.py index bafc7ed9..7b60ea48 100644 --- a/subiquity/common/types.py +++ b/subiquity/common/types.py @@ -354,6 +354,13 @@ class IdentityData: crypted_password: str = attr.ib(default='', repr=False) 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) class SSHData: