updated login/select
This commit is contained in:
@@ -21,7 +21,7 @@ class BaseEndpointResponse:
|
||||
return {"message": f"{self.code} -> Language model not found"}
|
||||
|
||||
|
||||
class EndpointSuccessResponse(BaseEndpointResponse): # 200 OK
|
||||
class EndpointSuccessResponse(BaseEndpointResponse): # 200 OK
|
||||
|
||||
def as_dict(self, data: Optional[dict] = None):
|
||||
return JSONResponse(
|
||||
@@ -30,7 +30,7 @@ class EndpointSuccessResponse(BaseEndpointResponse): # 200 OK
|
||||
)
|
||||
|
||||
|
||||
class EndpointCreatedResponse(BaseEndpointResponse): # 201 Created
|
||||
class EndpointCreatedResponse(BaseEndpointResponse): # 201 Created
|
||||
|
||||
def as_dict(self, data: Optional[dict] = None):
|
||||
return JSONResponse(
|
||||
@@ -39,7 +39,7 @@ class EndpointCreatedResponse(BaseEndpointResponse): # 201 Created
|
||||
)
|
||||
|
||||
|
||||
class EndpointAcceptedResponse(BaseEndpointResponse): # 202 Accepted
|
||||
class EndpointAcceptedResponse(BaseEndpointResponse): # 202 Accepted
|
||||
|
||||
def as_dict(self, data: Optional[dict] = None):
|
||||
return JSONResponse(
|
||||
@@ -48,7 +48,16 @@ class EndpointAcceptedResponse(BaseEndpointResponse): # 202 Accepted
|
||||
)
|
||||
|
||||
|
||||
class EndpointBadRequestResponse(BaseEndpointResponse): # 400 Bad Request
|
||||
class EndpointNotModifiedResponse(BaseEndpointResponse): # 304 Not Modified
|
||||
|
||||
def as_dict(self):
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_304_NOT_MODIFIED,
|
||||
content=dict(completed=False, **self.response, lang=self.lang),
|
||||
)
|
||||
|
||||
|
||||
class EndpointBadRequestResponse(BaseEndpointResponse): # 400 Bad Request
|
||||
|
||||
def as_dict(self, data: Optional[dict] = None):
|
||||
return JSONResponse(
|
||||
@@ -57,7 +66,7 @@ class EndpointBadRequestResponse(BaseEndpointResponse): # 400 Bad Reques
|
||||
)
|
||||
|
||||
|
||||
class EndpointUnauthorizedResponse(BaseEndpointResponse): # 401 Unauthorized
|
||||
class EndpointUnauthorizedResponse(BaseEndpointResponse): # 401 Unauthorized
|
||||
|
||||
def as_dict(self):
|
||||
return JSONResponse(
|
||||
@@ -66,16 +75,7 @@ class EndpointUnauthorizedResponse(BaseEndpointResponse): # 401 Unauthoriz
|
||||
)
|
||||
|
||||
|
||||
class EndpointNotFoundResponse(BaseEndpointResponse): # 404 Not Found
|
||||
|
||||
def as_dict(self):
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
content=dict(completed=False, **self.response, lang=self.lang),
|
||||
)
|
||||
|
||||
|
||||
class EndpointForbiddenResponse(BaseEndpointResponse): # 403 Forbidden
|
||||
class EndpointForbiddenResponse(BaseEndpointResponse): # 403 Forbidden
|
||||
|
||||
def as_dict(self):
|
||||
return JSONResponse(
|
||||
@@ -84,7 +84,34 @@ class EndpointForbiddenResponse(BaseEndpointResponse): # 403 Forbidden
|
||||
)
|
||||
|
||||
|
||||
class EndpointConflictResponse(BaseEndpointResponse): # 409 Conflict
|
||||
class EndpointNotFoundResponse(BaseEndpointResponse): # 404 Not Found
|
||||
|
||||
def as_dict(self):
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
content=dict(completed=False, **self.response, lang=self.lang),
|
||||
)
|
||||
|
||||
|
||||
class EndpointMethodNotAllowedResponse(BaseEndpointResponse): # 405 Method Not Allowed
|
||||
|
||||
def as_dict(self):
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_405_METHOD_NOT_ALLOWED,
|
||||
content=dict(completed=False, **self.response, lang=self.lang),
|
||||
)
|
||||
|
||||
|
||||
class EndpointNotAcceptableResponse(BaseEndpointResponse): # 406 Not Acceptable
|
||||
|
||||
def as_dict(self):
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_406_NOT_ACCEPTABLE,
|
||||
content=dict(completed=False, **self.response, lang=self.lang),
|
||||
)
|
||||
|
||||
|
||||
class EndpointConflictResponse(BaseEndpointResponse): # 409 Conflict
|
||||
|
||||
def as_dict(self):
|
||||
return JSONResponse(
|
||||
@@ -93,7 +120,16 @@ class EndpointConflictResponse(BaseEndpointResponse): # 409 Conflict
|
||||
)
|
||||
|
||||
|
||||
class EndpointTooManyRequestsResponse(BaseEndpointResponse): # 429 Too Many Requests
|
||||
class EndpointUnprocessableEntityResponse(BaseEndpointResponse): # 422 Unprocessable Entity
|
||||
|
||||
def as_dict(self, data: Optional[dict] = None):
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
content=dict(completed=False, **self.response, lang=self.lang, data=data),
|
||||
)
|
||||
|
||||
|
||||
class EndpointTooManyRequestsResponse(BaseEndpointResponse): # 429 Too Many Requests
|
||||
|
||||
def __init__(self, retry_after: int, lang: str, code: str):
|
||||
super().__init__(lang=lang, code=code)
|
||||
@@ -107,19 +143,10 @@ class EndpointTooManyRequestsResponse(BaseEndpointResponse): # 429 Too Many R
|
||||
)
|
||||
|
||||
|
||||
class EndpointInternalErrorResponse(BaseEndpointResponse): # 500 Internal Server Error
|
||||
class EndpointInternalErrorResponse(BaseEndpointResponse): # 500 Internal Server Error
|
||||
|
||||
def as_dict(self):
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
content=dict(completed=False, **self.response, lang=self.lang),
|
||||
)
|
||||
|
||||
|
||||
class EndpointErrorResponse(BaseEndpointResponse):
|
||||
|
||||
def as_dict(self):
|
||||
return JSONResponse(
|
||||
status_code=status.HTTP_304_NOT_MODIFIED,
|
||||
content=dict(completed=False, **self.response, lang=self.lang),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user