rb-commons 0.5.14__py3-none-any.whl → 0.5.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rb_commons/configs/config.py +0 -13
- rb_commons/configs/v2/__init__.py +0 -0
- rb_commons/configs/v2/config.py +52 -0
- rb_commons/utils/media.py +12 -3
- {rb_commons-0.5.14.dist-info → rb_commons-0.5.15.dist-info}/METADATA +1 -1
- {rb_commons-0.5.14.dist-info → rb_commons-0.5.15.dist-info}/RECORD +8 -6
- {rb_commons-0.5.14.dist-info → rb_commons-0.5.15.dist-info}/WHEEL +0 -0
- {rb_commons-0.5.14.dist-info → rb_commons-0.5.15.dist-info}/top_level.txt +0 -0
rb_commons/configs/config.py
CHANGED
@@ -25,19 +25,6 @@ class CommonConfigs(BaseSettings):
|
|
25
25
|
DIGITALOCEAN_STORAGE_BUCKET_NAME: Optional[str] = None
|
26
26
|
DIGITALOCEAN_S3_ENDPOINT_URL: Optional[str] = None
|
27
27
|
|
28
|
-
@field_validator("POSTGRES_PORT", mode="before")
|
29
|
-
@classmethod
|
30
|
-
def convert_port(cls, value):
|
31
|
-
print("DEBUG: POSTGRES_PORT from env =", value)
|
32
|
-
|
33
|
-
if value is None:
|
34
|
-
return None
|
35
|
-
try:
|
36
|
-
print(value)
|
37
|
-
return int(value)
|
38
|
-
except ValueError:
|
39
|
-
raise ValueError(f"POSTGRES_PORT must be an integer, got: {value}")
|
40
|
-
|
41
28
|
@property
|
42
29
|
def database_url(self) -> Optional[str]:
|
43
30
|
"""Construct the database URL if all required fields are present."""
|
File without changes
|
@@ -0,0 +1,52 @@
|
|
1
|
+
from typing import Optional, Any
|
2
|
+
|
3
|
+
from pydantic import field_validator
|
4
|
+
from pydantic_settings import BaseSettings
|
5
|
+
|
6
|
+
class CommonConfigs(BaseSettings):
|
7
|
+
service_name: Optional[str] = None
|
8
|
+
service_port: Optional[int] = None
|
9
|
+
service_id: Optional[str] = None
|
10
|
+
service_hostname: Optional[Any] = '127.0.0.1'
|
11
|
+
service_host: Optional[str] = None
|
12
|
+
|
13
|
+
# db
|
14
|
+
POSTGRES_HOST: Optional[str] = None
|
15
|
+
POSTGRES_USER: Optional[str] = None
|
16
|
+
POSTGRES_PORT: Optional[int] = None
|
17
|
+
POSTGRES_PASSWORD: Optional[str] = None
|
18
|
+
POSTGRES_DB: Optional[str] = None
|
19
|
+
DB_ALEMBIC_URL: Optional[str] = None
|
20
|
+
|
21
|
+
# Broker
|
22
|
+
|
23
|
+
RABBITMQ_URL: Optional[str] = None
|
24
|
+
|
25
|
+
DIGITALOCEAN_STORAGE_BUCKET_NAME: Optional[str] = None
|
26
|
+
DIGITALOCEAN_S3_ENDPOINT_URL: Optional[str] = None
|
27
|
+
|
28
|
+
@property
|
29
|
+
def database_url(self) -> Optional[str]:
|
30
|
+
"""Construct the database URL if all required fields are present."""
|
31
|
+
required_fields = [
|
32
|
+
self.POSTGRES_USER,
|
33
|
+
self.POSTGRES_PASSWORD,
|
34
|
+
self.POSTGRES_HOST,
|
35
|
+
self.POSTGRES_PORT,
|
36
|
+
self.POSTGRES_DB
|
37
|
+
]
|
38
|
+
if all(required_fields):
|
39
|
+
return (
|
40
|
+
f"postgresql+asyncpg://{self.POSTGRES_USER}:"
|
41
|
+
f"{self.POSTGRES_PASSWORD}@{self.POSTGRES_HOST}:"
|
42
|
+
f"{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
|
43
|
+
)
|
44
|
+
return None
|
45
|
+
|
46
|
+
class Config:
|
47
|
+
env_file = "/robosell/.env"
|
48
|
+
env_file_encoding = "utf-8"
|
49
|
+
extra = "ignore"
|
50
|
+
|
51
|
+
|
52
|
+
configs = CommonConfigs()
|
rb_commons/utils/media.py
CHANGED
@@ -1,9 +1,18 @@
|
|
1
|
-
from
|
1
|
+
from pydantic import ValidationError
|
2
2
|
|
3
3
|
class MediaUtils:
|
4
4
|
|
5
5
|
@staticmethod
|
6
6
|
def url_builder(key: str):
|
7
|
+
try:
|
8
|
+
from rb_commons.configs.config import configs
|
9
|
+
DIGITALOCEAN_S3_ENDPOINT_URL = configs.DIGITALOCEAN_S3_ENDPOINT_URL
|
10
|
+
DIGITALOCEAN_STORAGE_BUCKET_NAME = configs.DIGITALOCEAN_STORAGE_BUCKET_NAME
|
11
|
+
except ValidationError as e:
|
12
|
+
from rb_commons.configs.v2.config import configs
|
13
|
+
DIGITALOCEAN_S3_ENDPOINT_URL = configs.DIGITALOCEAN_S3_ENDPOINT_URL
|
14
|
+
DIGITALOCEAN_STORAGE_BUCKET_NAME = configs.DIGITALOCEAN_STORAGE_BUCKET_NAME
|
15
|
+
|
7
16
|
return "{endpoint_url}/{bucket_name}/{key}" \
|
8
|
-
.format(endpoint_url=
|
9
|
-
bucket_name=
|
17
|
+
.format(endpoint_url=DIGITALOCEAN_S3_ENDPOINT_URL,
|
18
|
+
bucket_name=DIGITALOCEAN_STORAGE_BUCKET_NAME, key=key)
|
@@ -2,9 +2,11 @@ rb_commons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
rb_commons/broker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
rb_commons/broker/consumer.py,sha256=84yLq8kJIGNYAH9_ySSTDpOMNL54NSs3cA8lNG8CTGY,1264
|
4
4
|
rb_commons/configs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
rb_commons/configs/config.py,sha256=
|
5
|
+
rb_commons/configs/config.py,sha256=1XVqxb9QY0E3P3n7vRJF_w238WgRpArfPVcpeT3geUE,1571
|
6
6
|
rb_commons/configs/injections.py,sha256=6B1EOgIGnkWv3UrFaV9PRgG0-CJAbLu1UZ3kq-SjPVU,273
|
7
7
|
rb_commons/configs/rabbitmq.py,sha256=vUqa_PcZkPp1lX0B6HLSAXVMUcPR2_8-8cN-C7xFxRI,741
|
8
|
+
rb_commons/configs/v2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
+
rb_commons/configs/v2/config.py,sha256=kZ02y_HIMD-SXqA990yR1r9qrkpvzwn4Nda6fhVMcmo,1581
|
8
10
|
rb_commons/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
11
|
rb_commons/http/base_api.py,sha256=Kpr8qSbRtoAqB9oBzXJvZjspJpMoCmq8EDGSrItPFSA,5169
|
10
12
|
rb_commons/http/consul.py,sha256=Ioq72VD1jGwoC96set7n2SgxN40olzI-myA2lwKkYi4,1864
|
@@ -19,8 +21,8 @@ rb_commons/schemes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
19
21
|
rb_commons/schemes/jwt.py,sha256=4MLw3J1-LiU2CXIgm0kP1mlGoDmNfMXmj9iav2s-1Iw,2056
|
20
22
|
rb_commons/schemes/pagination.py,sha256=8VZW1wZGJIPR9jEBUgppZUoB4uqP8ORudHkMwvEJSxg,1866
|
21
23
|
rb_commons/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
|
-
rb_commons/utils/media.py,sha256=
|
23
|
-
rb_commons-0.5.
|
24
|
-
rb_commons-0.5.
|
25
|
-
rb_commons-0.5.
|
26
|
-
rb_commons-0.5.
|
24
|
+
rb_commons/utils/media.py,sha256=J2Zi0J28DhcVQVzt-myNNVuzj9Msaetul53VjZtdDdc,820
|
25
|
+
rb_commons-0.5.15.dist-info/METADATA,sha256=SpqJikfOad52mTulqsU3-1xfNDnzz_cekxNyV_w-fH0,6571
|
26
|
+
rb_commons-0.5.15.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
27
|
+
rb_commons-0.5.15.dist-info/top_level.txt,sha256=HPx_WAYo3_fbg1WCeGHsz3wPGio1ucbnrlm2lmqlJog,11
|
28
|
+
rb_commons-0.5.15.dist-info/RECORD,,
|
File without changes
|
File without changes
|