-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.py
More file actions
78 lines (57 loc) · 1.9 KB
/
Copy pathstorage.py
File metadata and controls
78 lines (57 loc) · 1.9 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
"""Storage-related types and models."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any
from typing_extensions import TypedDict
class StorageParamsRequired(TypedDict):
"""Required fields for adding a new storage configuration."""
title: str
region: str
access_key_id: str
secret_access_key: str
bucket: str
class StorageParamsOptional(StorageParamsRequired, total=False):
"""Storage configuration parameters. All required except `endpoint`."""
endpoint: str # For non-AWS S3-compatible services
@dataclass
class StorageListItem:
"""A storage configuration summary from list endpoint."""
id: str
title: str
@classmethod
def from_dict(cls, data: dict[str, Any]) -> StorageListItem:
"""Create a StorageListItem from an API response dict."""
return cls(
id=data.get("id", ""),
title=data.get("title", ""),
)
@dataclass
class StorageDetail:
"""A full storage configuration detail."""
data: str
id: str
title: str
uid: str
@classmethod
def from_dict(cls, data: dict[str, Any]) -> StorageDetail:
"""Create a StorageDetail from an API response dict."""
return cls(
data=data.get("data", ""),
id=data.get("id", ""),
title=data.get("title", ""),
uid=data.get("uid", ""),
)
@dataclass
class StorageNotAllowedResponse:
"""Response when storage operations are not allowed on the user's plan."""
allowed: bool
reason: str
status_code: int
@classmethod
def from_dict(cls, data: dict[str, Any]) -> StorageNotAllowedResponse:
"""Create a StorageNotAllowedResponse from an API response dict."""
return cls(
allowed=data.get("allowed", False),
reason=data.get("reason", ""),
status_code=data.get("statusCode", 0),
)