42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
from http import HTTPStatus
|
|
from typing import Annotated
|
|
|
|
from aws_lambda_powertools.event_handler.api_gateway import Router
|
|
from aws_lambda_powertools.event_handler.exceptions import ServiceError
|
|
from aws_lambda_powertools.event_handler.openapi.params import Body
|
|
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair, SortKey
|
|
from layercake.extra_types import CnpjStr, CpfStr, NameStr
|
|
from pydantic import BaseModel, EmailStr
|
|
|
|
from boto3clients import dynamodb_client
|
|
from config import OAUTH2_TABLE
|
|
|
|
router = Router()
|
|
dyn = DynamoDBPersistenceLayer(OAUTH2_TABLE, dynamodb_client)
|
|
|
|
|
|
class UserConflictError(ServiceError):
|
|
def __init__(self, msg: str | dict):
|
|
super().__init__(HTTPStatus.CONFLICT, msg)
|
|
|
|
|
|
class Org(BaseModel):
|
|
id: str | None
|
|
name: str
|
|
cnpj: CnpjStr
|
|
|
|
|
|
@router.get('/register')
|
|
def register(
|
|
name: Annotated[NameStr, Body(embed=True)],
|
|
email: Annotated[EmailStr, Body(embed=True)],
|
|
password: Annotated[str, Body(min_length=6, embed=True)],
|
|
cpf: Annotated[CpfStr, Body(embed=True)],
|
|
user_id: Annotated[str | None, Body(embed=True)] = None,
|
|
org: Annotated[Org | None, Body(embed=True)] = None,
|
|
):
|
|
if user_id:
|
|
...
|
|
|
|
return {}
|