-
Notifications
You must be signed in to change notification settings - Fork 676
Expand file tree
/
Copy pathmodels.py
More file actions
118 lines (88 loc) · 3.28 KB
/
Copy pathmodels.py
File metadata and controls
118 lines (88 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from typing import Optional, List
from uuid import UUID
from pydantic import BaseModel, Field
from fastapi import HTTPException
from oss.src.utils.exceptions import Support
from oss.src.core.folders.types import (
Folder,
FolderCreate,
FolderEdit,
FolderQuery,
)
class FolderCreateRequest(BaseModel):
folder: FolderCreate = Field(
...,
description="Folder to create. `slug` is required; `parent_id` nests the new folder under an existing one.",
)
class FolderEditRequest(BaseModel):
folder: FolderEdit = Field(
...,
description="Folder edit payload. `id` must match the path parameter. Only fields present in the payload are changed.",
)
class FolderQueryRequest(BaseModel):
folder: FolderQuery = Field(
...,
description="Filter object. Any combination of `id`/`ids`, `slug`/`slugs`, `kind`/`kinds`, `parent_id`/`parent_ids`, `path`/`paths`, and `prefix`/`prefixes` narrows the result.",
)
class FolderResponse(Support):
count: int = Field(
default=0,
description="Number of folders returned (`0` or `1`).",
)
folder: Optional[Folder] = Field(
default=None,
description="The folder, when found. Omitted when `count` is `0`.",
)
class FoldersResponse(Support):
count: int = Field(
default=0,
description="Number of folders in `folders`.",
)
folders: List[Folder] = Field(
default_factory=list,
description="Matching folders for the query. Ordering is not guaranteed.",
)
class FolderIdResponse(Support):
count: int = Field(
default=0,
description="`1` if a folder was deleted, `0` if no folder matched.",
)
id: Optional[UUID] = Field(
default=None,
description="Id of the deleted folder. Omitted when nothing was deleted.",
)
class FolderNameInvalidException(HTTPException):
"""Exception raised when a folder name is invalid."""
def __init__(
self,
message: str = "Folder name contains invalid characters.",
):
super().__init__(status_code=400, detail=message)
class FolderPathConflictException(HTTPException):
"""Exception raised when a folder path already exists in the project."""
def __init__(
self,
message: str = "A folder with this path already exists in this project.",
):
super().__init__(status_code=409, detail=message)
class FolderParentMissingException(HTTPException):
"""Exception raised when a parent folder is not found."""
def __init__(
self,
message: str = "Parent folder not found.",
):
super().__init__(status_code=404, detail=message)
class FolderPathDepthExceededException(HTTPException):
"""Exception raised when folder path depth exceeds maximum allowed nesting level."""
def __init__(
self,
message: str = "Folder path depth exceeds maximum allowed nesting level (10 levels).",
):
super().__init__(status_code=400, detail=message)
class FolderPathLengthExceededException(HTTPException):
"""Exception raised when folder slug/path is too long."""
def __init__(
self,
message: str = "Folder slug exceeds maximum length (64 characters).",
):
super().__init__(status_code=400, detail=message)