-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathoptions.py
81 lines (63 loc) · 2.54 KB
/
options.py
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
from __future__ import annotations
from typing import Any, Dict, Optional, Union
from typing_extensions import Literal, TypedDict
class PossibleB2StorageOptions(TypedDict, total=False):
realm: str # default "production"
application_key_id: str
application_key: str
bucket: str
authorize_on_init: bool
validate_on_init: bool
allow_file_overwrites: bool
account_info: Optional[Union[DjangoCacheAccountInfoConfig, InMemoryAccountInfoConfig, SqliteAccountInfoConfig]]
forbid_file_property_caching: bool
specific_bucket_names: ProxiedBucketNames
cdn_config: Optional[CDNConfig]
# see: https://b2-sdk-python.readthedocs.io/en/master/api/api.html#b2sdk.v1.B2Api.create_bucket
non_existent_bucket_details: Optional[Dict[str, Union[str, Dict[str, Any]]]]
default_file_info: Dict[str, Any]
class BackblazeB2StorageOptions(TypedDict):
realm: str
application_key_id: str
application_key: str
bucket: str
authorize_on_init: bool
validate_on_init: bool
allow_file_overwrites: bool
account_info: Optional[Union[DjangoCacheAccountInfoConfig, InMemoryAccountInfoConfig, SqliteAccountInfoConfig]]
forbid_file_property_caching: bool
specific_bucket_names: ProxiedBucketNames
cdn_config: Optional[CDNConfig]
non_existent_bucket_details: Optional[Dict[str, Union[str, Dict[str, Any]]]]
default_file_info: Dict[str, Any]
def get_default_b2_storage_options() -> BackblazeB2StorageOptions:
return {
"realm": "production",
"application_key_id": "you must set this value yourself",
"application_key": "you must set this value yourself",
"bucket": "django",
"authorize_on_init": True,
"validate_on_init": True,
"allow_file_overwrites": False,
"account_info": {"type": "django-cache", "cache": "django-backblaze-b2"},
"forbid_file_property_caching": False,
"specific_bucket_names": {"public": None, "logged_in": None, "staff": None},
"cdn_config": None,
"non_existent_bucket_details": None,
"default_file_info": {},
}
class ProxiedBucketNames(TypedDict, total=False):
public: Optional[str]
logged_in: Optional[str]
staff: Optional[str]
class DjangoCacheAccountInfoConfig(TypedDict):
type: Literal["django-cache"]
cache: str
class InMemoryAccountInfoConfig(TypedDict):
type: Literal["memory"]
class SqliteAccountInfoConfig(TypedDict):
type: Literal["sqlite"]
database_path: str
class CDNConfig(TypedDict):
base_url: str
include_bucket_url_segments: bool