2023-02-16 15:11:29 +02:00
|
|
|
from typing import Literal
|
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
|
2023-02-16 15:11:29 +02:00
|
|
|
class AlbumNotFoundError(Exception):
|
2023-02-16 16:32:56 +02:00
|
|
|
"""Raises HTTP 404 if no album with this ID found."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:11:29 +02:00
|
|
|
def __init__(self, id: str):
|
|
|
|
self.id = id
|
|
|
|
self.openapi = {
|
2023-02-16 15:55:03 +02:00
|
|
|
"description": "Album Does Not Exist",
|
2023-02-16 15:11:29 +02:00
|
|
|
"content": {
|
|
|
|
"application/json": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"example": {"detail": "Could not find album with id '{id}'."}
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
class AlbumNameNotFoundError(Exception):
|
2023-02-16 16:32:56 +02:00
|
|
|
"""Raises HTTP 404 if no album with this name found."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
def __init__(self, name: str):
|
|
|
|
self.name = name
|
|
|
|
self.openapi = {
|
|
|
|
"description": "Album Does Not Exist",
|
|
|
|
"content": {
|
|
|
|
"application/json": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"example": {"detail": "Could not find album with name '{name}'."}
|
2023-02-16 15:11:29 +02:00
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 15:11:29 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:11:29 +02:00
|
|
|
class AlbumAlreadyExistsError(Exception):
|
2023-02-16 16:32:56 +02:00
|
|
|
"""Raises HTTP 409 if album with this name already exists."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:11:29 +02:00
|
|
|
def __init__(self, name: str):
|
|
|
|
self.name = name
|
|
|
|
self.openapi = {
|
2023-02-16 15:55:03 +02:00
|
|
|
"description": "Album Already Exists",
|
2023-02-16 15:11:29 +02:00
|
|
|
"content": {
|
|
|
|
"application/json": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"example": {"detail": "Album with name '{name}' already exists."}
|
2023-02-16 15:11:29 +02:00
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 15:11:29 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:11:29 +02:00
|
|
|
class AlbumIncorrectError(Exception):
|
2023-02-16 16:32:56 +02:00
|
|
|
"""Raises HTTP 406 if album's title or name is invalid."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:11:29 +02:00
|
|
|
def __init__(self, place: Literal["name", "title"], error: str) -> None:
|
|
|
|
self.place = place
|
|
|
|
self.error = error
|
|
|
|
self.openapi = {
|
2023-02-16 15:55:03 +02:00
|
|
|
"description": "Album Name/Title Invalid",
|
2023-02-16 15:11:29 +02:00
|
|
|
"content": {
|
|
|
|
"application/json": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"example": {"detail": "Album {name/title} invalid: {error}"}
|
2023-02-16 15:11:29 +02:00
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
class PhotoNotFoundError(Exception):
|
2023-02-16 16:32:56 +02:00
|
|
|
"""Raises HTTP 404 if no photo with this ID found."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
def __init__(self, id: str):
|
|
|
|
self.id = id
|
|
|
|
self.openapi = {
|
|
|
|
"description": "Photo Does Not Exist",
|
|
|
|
"content": {
|
|
|
|
"application/json": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"example": {"detail": "Could not find photo with id '{id}'."}
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 16:32:56 +02:00
|
|
|
class PhotoSearchQueryEmptyError(Exception):
|
|
|
|
"""Raises HTTP 422 if no photo search query provided."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 16:32:56 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.openapi = {
|
|
|
|
"description": "Invalid Query",
|
|
|
|
"content": {
|
|
|
|
"application/json": {
|
|
|
|
"example": {
|
|
|
|
"detail": "You must provide query, caption or coordinates to look for photos."
|
|
|
|
}
|
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 16:32:56 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 16:32:56 +02:00
|
|
|
class VideoNotFoundError(Exception):
|
|
|
|
"""Raises HTTP 404 if no video with this ID found."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 16:32:56 +02:00
|
|
|
def __init__(self, id: str):
|
|
|
|
self.id = id
|
|
|
|
self.openapi = {
|
|
|
|
"description": "Video Does Not Exist",
|
|
|
|
"content": {
|
|
|
|
"application/json": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"example": {"detail": "Could not find video with id '{id}'."}
|
2023-02-16 16:32:56 +02:00
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 16:32:56 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 16:32:56 +02:00
|
|
|
class VideoSearchQueryEmptyError(Exception):
|
|
|
|
"""Raises HTTP 422 if no video search query provided."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 16:32:56 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.openapi = {
|
|
|
|
"description": "Invalid Query",
|
|
|
|
"content": {
|
|
|
|
"application/json": {
|
|
|
|
"example": {
|
|
|
|
"detail": "You must provide query or caption to look for videos."
|
|
|
|
}
|
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 16:32:56 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
class SearchPageInvalidError(Exception):
|
2023-02-16 16:32:56 +02:00
|
|
|
"""Raises HTTP 400 if page or page size are not in valid range."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.openapi = {
|
|
|
|
"description": "Invalid Page",
|
|
|
|
"content": {
|
|
|
|
"application/json": {
|
|
|
|
"example": {
|
|
|
|
"detail": "Parameters 'page' and 'page_size' must be greater or equal to 1."
|
|
|
|
}
|
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
class SearchTokenInvalidError(Exception):
|
2023-02-16 16:32:56 +02:00
|
|
|
"""Raises HTTP 401 if search token is not valid."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.openapi = {
|
|
|
|
"description": "Invalid Token",
|
|
|
|
"content": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"application/json": {"example": {"detail": "Invalid search token."}}
|
|
|
|
},
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
class UserEmailCodeInvalid(Exception):
|
2023-02-16 16:32:56 +02:00
|
|
|
"""Raises HTTP 400 if email confirmation code is not valid."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.openapi = {
|
|
|
|
"description": "Invalid Email Code",
|
|
|
|
"content": {
|
|
|
|
"application/json": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"example": {"detail": "Confirmation code is invalid."}
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
class UserAlreadyExists(Exception):
|
2023-02-16 16:32:56 +02:00
|
|
|
"""Raises HTTP 409 if user with this name already exists."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.openapi = {
|
|
|
|
"description": "User Already Exists",
|
|
|
|
"content": {
|
|
|
|
"application/json": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"example": {"detail": "User with this username already exists."}
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
2023-03-12 15:59:13 +02:00
|
|
|
},
|
2023-02-16 15:55:03 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-18 01:19:46 +02:00
|
|
|
class AccessTokenInvalidError(Exception):
|
|
|
|
"""Raises HTTP 401 if access token is not valid."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-18 01:19:46 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.openapi = {
|
|
|
|
"description": "Invalid Access Token",
|
|
|
|
"content": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"application/json": {"example": {"detail": "Invalid access token."}}
|
|
|
|
},
|
2023-02-18 01:19:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
class UserCredentialsInvalid(Exception):
|
2023-02-16 16:32:56 +02:00
|
|
|
"""Raises HTTP 401 if user credentials are not valid."""
|
2023-03-12 15:59:13 +02:00
|
|
|
|
2023-02-16 15:55:03 +02:00
|
|
|
def __init__(self):
|
|
|
|
self.openapi = {
|
|
|
|
"description": "Invalid Credentials",
|
|
|
|
"content": {
|
2023-03-12 15:59:13 +02:00
|
|
|
"application/json": {"example": {"detail": "Invalid credentials."}}
|
|
|
|
},
|
|
|
|
}
|