main
py 83 lines 1.63 KB
Raw
1 from enum import IntEnum
2 from typing import Any
3 from typing import List
4 from typing import Optional
5
6 from pydantic import BaseModel
7
8
9 class StackStatus(IntEnum):
10 """Enum for Portainer stack status values"""
11
12 ACTIVE = 1
13 DOWN = 2
14 INACTIVE = 3
15
16 @classmethod
17 def _missing_(cls, value: int) -> "StackStatus":
18 """Handle unknown status values"""
19 return cls.INACTIVE
20
21 def __str__(self) -> str:
22 """Return human-readable status"""
23 return self.name.title()
24
25
26 class ResourceControlResponse(BaseModel):
27 Id: int
28 ResourceId: str
29 SubResourceIds: List[str]
30 Type: int
31 UserAccesses: List[str]
32 TeamAccesses: List[str]
33 Public: bool
34 AdministratorsOnly: bool
35 System: bool
36
37
38 class StackData(BaseModel):
39 Id: int
40 Name: str
41 Type: int
42 EndpointId: int
43 SwarmId: str
44 EntryPoint: str
45 Env: List[Any]
46 ResourceControl: Optional[ResourceControlResponse] = None
47 Status: int
48 ProjectPath: str
49 CreationDate: int
50 CreatedBy: str
51 UpdateDate: int
52 UpdatedBy: str
53 AdditionalFiles: Optional[Any] = None
54 AutoUpdate: Optional[Any] = None
55 Option: Optional[Any] = None
56 GitConfig: Optional[Any] = None
57 FromAppTemplate: bool
58 Namespace: str
59 IsComposeFormat: bool
60
61
62 class StackResponse(BaseModel):
63 data: StackData
64 success: bool
65 message: str
66
67
68 class StacksResponse(BaseModel):
69 data: List[StackData]
70 success: bool
71 message: str
72
73
74 class DeleteStackResponse(BaseModel):
75 data: Optional[Any] = None
76 success: bool
77 message: str
78
79
80 class StackIDResponse(BaseModel):
81 stack_id: int
82 success: bool
83 message: str