Formatted everything with black
This commit is contained in:
@@ -3,51 +3,52 @@ from typing import Literal
|
||||
|
||||
class AlbumNotFoundError(Exception):
|
||||
"""Raises HTTP 404 if no album with this ID found."""
|
||||
|
||||
def __init__(self, id: str):
|
||||
self.id = id
|
||||
self.openapi = {
|
||||
"description": "Album Does Not Exist",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "Could not find album with id '{id}'."
|
||||
}
|
||||
"example": {"detail": "Could not find album with id '{id}'."}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class AlbumNameNotFoundError(Exception):
|
||||
"""Raises HTTP 404 if no album with this name found."""
|
||||
|
||||
def __init__(self, name: str):
|
||||
self.name = name
|
||||
self.openapi = {
|
||||
"description": "Album Does Not Exist",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "Could not find album with name '{name}'."
|
||||
}
|
||||
"example": {"detail": "Could not find album with name '{name}'."}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class AlbumAlreadyExistsError(Exception):
|
||||
"""Raises HTTP 409 if album with this name already exists."""
|
||||
|
||||
def __init__(self, name: str):
|
||||
self.name = name
|
||||
self.openapi = {
|
||||
"description": "Album Already Exists",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "Album with name '{name}' already exists."
|
||||
}
|
||||
"example": {"detail": "Album with name '{name}' already exists."}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class AlbumIncorrectError(Exception):
|
||||
"""Raises HTTP 406 if album's title or name is invalid."""
|
||||
|
||||
def __init__(self, place: Literal["name", "title"], error: str) -> None:
|
||||
self.place = place
|
||||
self.error = error
|
||||
@@ -55,30 +56,30 @@ class AlbumIncorrectError(Exception):
|
||||
"description": "Album Name/Title Invalid",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "Album {name/title} invalid: {error}"
|
||||
}
|
||||
"example": {"detail": "Album {name/title} invalid: {error}"}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class PhotoNotFoundError(Exception):
|
||||
"""Raises HTTP 404 if no photo with this ID found."""
|
||||
|
||||
def __init__(self, id: str):
|
||||
self.id = id
|
||||
self.openapi = {
|
||||
"description": "Photo Does Not Exist",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "Could not find photo with id '{id}'."
|
||||
}
|
||||
"example": {"detail": "Could not find photo with id '{id}'."}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class PhotoSearchQueryEmptyError(Exception):
|
||||
"""Raises HTTP 422 if no photo search query provided."""
|
||||
|
||||
def __init__(self):
|
||||
self.openapi = {
|
||||
"description": "Invalid Query",
|
||||
@@ -88,26 +89,28 @@ class PhotoSearchQueryEmptyError(Exception):
|
||||
"detail": "You must provide query, caption or coordinates to look for photos."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class VideoNotFoundError(Exception):
|
||||
"""Raises HTTP 404 if no video with this ID found."""
|
||||
|
||||
def __init__(self, id: str):
|
||||
self.id = id
|
||||
self.openapi = {
|
||||
"description": "Video Does Not Exist",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "Could not find video with id '{id}'."
|
||||
}
|
||||
"example": {"detail": "Could not find video with id '{id}'."}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class VideoSearchQueryEmptyError(Exception):
|
||||
"""Raises HTTP 422 if no video search query provided."""
|
||||
|
||||
def __init__(self):
|
||||
self.openapi = {
|
||||
"description": "Invalid Query",
|
||||
@@ -117,11 +120,13 @@ class VideoSearchQueryEmptyError(Exception):
|
||||
"detail": "You must provide query or caption to look for videos."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class SearchPageInvalidError(Exception):
|
||||
"""Raises HTTP 400 if page or page size are not in valid range."""
|
||||
|
||||
def __init__(self):
|
||||
self.openapi = {
|
||||
"description": "Invalid Page",
|
||||
@@ -131,75 +136,69 @@ class SearchPageInvalidError(Exception):
|
||||
"detail": "Parameters 'page' and 'page_size' must be greater or equal to 1."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class SearchTokenInvalidError(Exception):
|
||||
"""Raises HTTP 401 if search token is not valid."""
|
||||
|
||||
def __init__(self):
|
||||
self.openapi = {
|
||||
"description": "Invalid Token",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "Invalid search token."
|
||||
}
|
||||
}
|
||||
}
|
||||
"application/json": {"example": {"detail": "Invalid search token."}}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class UserEmailCodeInvalid(Exception):
|
||||
"""Raises HTTP 400 if email confirmation code is not valid."""
|
||||
|
||||
def __init__(self):
|
||||
self.openapi = {
|
||||
"description": "Invalid Email Code",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "Confirmation code is invalid."
|
||||
}
|
||||
"example": {"detail": "Confirmation code is invalid."}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class UserAlreadyExists(Exception):
|
||||
"""Raises HTTP 409 if user with this name already exists."""
|
||||
|
||||
def __init__(self):
|
||||
self.openapi = {
|
||||
"description": "User Already Exists",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "User with this username already exists."
|
||||
}
|
||||
"example": {"detail": "User with this username already exists."}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class AccessTokenInvalidError(Exception):
|
||||
"""Raises HTTP 401 if access token is not valid."""
|
||||
|
||||
def __init__(self):
|
||||
self.openapi = {
|
||||
"description": "Invalid Access Token",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "Invalid access token."
|
||||
}
|
||||
}
|
||||
}
|
||||
"application/json": {"example": {"detail": "Invalid access token."}}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class UserCredentialsInvalid(Exception):
|
||||
"""Raises HTTP 401 if user credentials are not valid."""
|
||||
|
||||
def __init__(self):
|
||||
self.openapi = {
|
||||
"description": "Invalid Credentials",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"detail": "Invalid credentials."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"application/json": {"example": {"detail": "Invalid credentials."}}
|
||||
},
|
||||
}
|
||||
|
@@ -8,11 +8,13 @@ class Photo(BaseModel):
|
||||
hash: str
|
||||
filename: str
|
||||
|
||||
|
||||
class PhotoPublic(BaseModel):
|
||||
id: str
|
||||
caption: str
|
||||
filename: str
|
||||
|
||||
|
||||
class PhotoSearch(BaseModel):
|
||||
id: str
|
||||
filename: str
|
||||
@@ -25,11 +27,13 @@ class Video(BaseModel):
|
||||
hash: str
|
||||
filename: str
|
||||
|
||||
|
||||
class VideoPublic(BaseModel):
|
||||
id: str
|
||||
caption: str
|
||||
filename: str
|
||||
|
||||
|
||||
class VideoSearch(BaseModel):
|
||||
id: str
|
||||
filename: str
|
||||
@@ -41,11 +45,13 @@ class Album(BaseModel):
|
||||
name: str
|
||||
title: str
|
||||
|
||||
|
||||
class AlbumSearch(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
title: str
|
||||
|
||||
|
||||
class AlbumModified(BaseModel):
|
||||
name: str
|
||||
title: str
|
||||
@@ -56,10 +62,12 @@ class SearchResultsAlbum(BaseModel):
|
||||
results: List[Album]
|
||||
next_page: Union[str, None]
|
||||
|
||||
|
||||
class SearchResultsPhoto(BaseModel):
|
||||
results: List[PhotoSearch]
|
||||
next_page: Union[str, None]
|
||||
|
||||
|
||||
class SearchResultsVideo(BaseModel):
|
||||
results: List[VideoSearch]
|
||||
next_page: Union[str, None]
|
||||
next_page: Union[str, None]
|
||||
|
Reference in New Issue
Block a user