latest version of apis event and cahce ablitites added
This commit is contained in:
18
ApiLayers/AllConfigs/Email/configs.py
Normal file
18
ApiLayers/AllConfigs/Email/configs.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from ApiLayers.AllConfigs import HostConfig
|
||||
|
||||
|
||||
class EmailConfig:
|
||||
EMAIL_HOST: str = HostConfig.EMAIL_HOST
|
||||
EMAIL_USERNAME: str = "karatay@mehmetkaratay.com.tr"
|
||||
EMAIL_PASSWORD: str = "system"
|
||||
EMAIL_PORT: int = 587
|
||||
EMAIL_SEND: bool = False
|
||||
|
||||
@classmethod
|
||||
def as_dict(cls):
|
||||
return dict(
|
||||
host=EmailConfig.EMAIL_HOST,
|
||||
port=EmailConfig.EMAIL_PORT,
|
||||
username=EmailConfig.EMAIL_USERNAME,
|
||||
password=EmailConfig.EMAIL_PASSWORD,
|
||||
)
|
||||
13
ApiLayers/AllConfigs/Email/email_send_model.py
Normal file
13
ApiLayers/AllConfigs/Email/email_send_model.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Dict, Optional
|
||||
|
||||
|
||||
class EmailSendModel(BaseModel):
|
||||
subject: str
|
||||
html: str = ""
|
||||
receivers: List[str]
|
||||
text: Optional[str] = ""
|
||||
cc: Optional[List[str]] = None
|
||||
bcc: Optional[List[str]] = None
|
||||
headers: Optional[Dict] = None
|
||||
attachments: Optional[Dict] = None
|
||||
10
ApiLayers/AllConfigs/NoSqlDatabase/configs.py
Normal file
10
ApiLayers/AllConfigs/NoSqlDatabase/configs.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from ApiLayers.AllConfigs import HostConfig
|
||||
|
||||
|
||||
class MongoConfig:
|
||||
PASSWORD = "mongo_password"
|
||||
USER_NAME = "mongo_user"
|
||||
DATABASE_NAME = "mongo_database"
|
||||
HOST = HostConfig.MAIN_HOST
|
||||
PORT = 11777
|
||||
URL = f"mongodb://{USER_NAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE_NAME}?retryWrites=true&w=majority"
|
||||
125
ApiLayers/AllConfigs/Redis/configs.py
Normal file
125
ApiLayers/AllConfigs/Redis/configs.py
Normal file
@@ -0,0 +1,125 @@
|
||||
from ApiLayers.AllConfigs import HostConfig
|
||||
|
||||
|
||||
class WagRedis:
|
||||
|
||||
REDIS_HOST = HostConfig.MAIN_HOST
|
||||
REDIS_PASSWORD: str = "commercial_redis_password"
|
||||
REDIS_PORT: int = 11222
|
||||
REDIS_DB: int = 0
|
||||
|
||||
@classmethod
|
||||
def as_dict(cls):
|
||||
return dict(
|
||||
host=WagRedis.REDIS_HOST,
|
||||
password=WagRedis.REDIS_PASSWORD,
|
||||
port=WagRedis.REDIS_PORT,
|
||||
db=WagRedis.REDIS_DB,
|
||||
)
|
||||
|
||||
|
||||
class RedisValidationKeys:
|
||||
ENDPOINTS: str = "ENDPOINTS"
|
||||
VALIDATIONS: str = "VALIDATIONS"
|
||||
HEADERS: str = "HEADERS"
|
||||
ERRORCODES: str = "ERRORCODES"
|
||||
RESPONSES: str = "RESPONSES"
|
||||
REQUESTS: str = "REQUESTS"
|
||||
RESPONSE: str = "RESPONSE"
|
||||
LANGUAGE_MODELS: str = "LANGUAGE_MODELS"
|
||||
STATIC: str = "STATIC"
|
||||
DYNAMIC: str = "DYNAMIC"
|
||||
# REQUEST: str = "REQUEST"
|
||||
# VALIDATION_USER: str = "VALIDATION_USER"
|
||||
|
||||
|
||||
class RedisAuthKeys:
|
||||
AUTH: str = "AUTH"
|
||||
OCCUPANT: str = "OCCUPANT"
|
||||
EMPLOYEE: str = "EMPLOYEE"
|
||||
CACHE: str = "CACHE"
|
||||
|
||||
|
||||
class RedisCategoryKeys:
|
||||
REBUILD: str = "REBUILD"
|
||||
ENDPOINT2CLASS: str = "ENDPOINT2CLASS"
|
||||
CLUSTER_INDEX: str = "CLUSTER_INDEX"
|
||||
CLUSTER_FUNCTION_CODES: str = "CLUSTER_FUNCTION_CODES"
|
||||
METHOD_FUNCTION_CODES: str = "METHOD_FUNCTION_CODES"
|
||||
MENU_FIRST_LAYER: str = "MENU_FIRST_LAYER"
|
||||
PAGE_MAPPER: str = "PAGE_MAPPER"
|
||||
MENU_MAPPER: str = "MENU_MAPPER"
|
||||
|
||||
|
||||
class RedisCategoryPageInfoKeys:
|
||||
"""
|
||||
### /create?site=BuildingCluster, #/update?site=BuildingCluster, #/dashboard?site=BuildingCluster
|
||||
PAGE_URL: /dashboard?site=BuildingCluster
|
||||
PAGE_NAME: BuildingCluster
|
||||
PAGE_INFO: {LANGUAGE_MODELS: "", ICON: "", URL: ""}
|
||||
PAGE_MENU_INDEX: 1 # {build_living_space: "uuid4", LAYER: 1, MENU_INDEX: 1}
|
||||
|
||||
PAGE_MENU_COMPONENT: {..., lang: {"tr"}: {...}, lang: {"en"}: {...}}
|
||||
PAGE_LANGUAGE: {{"tr"}: {...},{"en"}: {...}}
|
||||
"""
|
||||
|
||||
PAGE_URL: str = "PAGE_URL"
|
||||
PAGE_NAME: str = "PAGE_NAME"
|
||||
PAGE_INFO: str = "PAGE_INFO"
|
||||
PAGE_COMPONENT: str = "PAGE_COMPONENT"
|
||||
PAGE_MENU_INDEX: str = "PAGE_MENU_INDEX"
|
||||
PAGE_MENU_COMPONENT: str = "PAGE_MENU_COMPONENT"
|
||||
PAGE_LANGUAGE: str = "PAGE_LANGUAGE"
|
||||
|
||||
|
||||
class RedisCategoryPageInfoKeysAction:
|
||||
"""
|
||||
PAGE_MAPPER: {PAGE_URL: /dashboard?site=BuildingCluster, PAGE_NAME: BuildingCluster, PAGE_INFO: {LANGUAGE_MODELS: "", ICON: "", URL: ""}}
|
||||
value : {RedisCategoryPageInfoKeys.PAGE_INFO}
|
||||
MENU_MAPPER: {PAGE_MENU_INDEX: 1, PAGE_MENU_COMPONENT: {..., lang: {"tr"}: {...}, lang: {"en"}: {...}}}
|
||||
value : {RedisCategoryPageInfoKeys.PAGE_INFO}
|
||||
"""
|
||||
|
||||
page_index: str = (
|
||||
f"{RedisCategoryPageInfoKeys.PAGE_MENU_INDEX}:{RedisCategoryPageInfoKeys.PAGE_URL}"
|
||||
)
|
||||
|
||||
page_mapper_key: str = (
|
||||
f"{RedisCategoryPageInfoKeys.PAGE_MENU_INDEX}:{RedisCategoryPageInfoKeys.PAGE_URL}"
|
||||
)
|
||||
page_mapper_key: str = (
|
||||
f"{page_mapper_key}:{RedisCategoryPageInfoKeys.PAGE_LANGUAGE}"
|
||||
)
|
||||
menu_mapper_key: str = (
|
||||
f"{RedisCategoryPageInfoKeys.PAGE_URL}:{RedisCategoryPageInfoKeys.PAGE_MENU_INDEX}"
|
||||
)
|
||||
menu_mapper_key: str = (
|
||||
f"{menu_mapper_key}:{RedisCategoryPageInfoKeys.PAGE_MENU_COMPONENT}"
|
||||
)
|
||||
|
||||
|
||||
class RedisValidationKeysAction:
|
||||
# LANGUAGE_MODELS:DYNAMIC:VALIDATIONS:
|
||||
dynamic_validation_key: str = (
|
||||
f"{RedisValidationKeys.LANGUAGE_MODELS}:{RedisValidationKeys.DYNAMIC}:{RedisValidationKeys.VALIDATIONS}"
|
||||
)
|
||||
# LANGUAGE_MODELS:DYNAMIC:HEADERS:REQUEST
|
||||
dynamic_header_request_key: str = (
|
||||
f"{RedisValidationKeys.LANGUAGE_MODELS}:{RedisValidationKeys.DYNAMIC}:{RedisValidationKeys.HEADERS}:{RedisValidationKeys.REQUESTS}"
|
||||
)
|
||||
# LANGUAGE_MODELS:DYNAMIC:HEADERS:RESPONSE
|
||||
dynamic_header_response_key: str = (
|
||||
f"{RedisValidationKeys.LANGUAGE_MODELS}:{RedisValidationKeys.DYNAMIC}:{RedisValidationKeys.HEADERS}:{RedisValidationKeys.RESPONSES}"
|
||||
)
|
||||
# LANGUAGE_MODELS:STATIC:ERRORCODES:
|
||||
static_error_code_key: str = (
|
||||
f"{RedisValidationKeys.LANGUAGE_MODELS}:{RedisValidationKeys.STATIC}:{RedisValidationKeys.ERRORCODES}"
|
||||
)
|
||||
# LANGUAGE_MODELS:STATIC:RESPONSES:
|
||||
static_response_key: str = (
|
||||
f"{RedisValidationKeys.LANGUAGE_MODELS}:{RedisValidationKeys.STATIC}:{RedisValidationKeys.RESPONSES}"
|
||||
)
|
||||
# LANGUAGE_MODELS:STATIC:REQUESTS:
|
||||
static_request_key: str = (
|
||||
f"{RedisValidationKeys.LANGUAGE_MODELS}:{RedisValidationKeys.STATIC}:{RedisValidationKeys.REQUESTS}"
|
||||
)
|
||||
17
ApiLayers/AllConfigs/SqlDatabase/configs.py
Normal file
17
ApiLayers/AllConfigs/SqlDatabase/configs.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from ApiLayers.AllConfigs import HostConfig
|
||||
|
||||
|
||||
class WagDatabase:
|
||||
HOST: str = HostConfig.MAIN_HOST
|
||||
PORT: str = "5444"
|
||||
SQL: str = "postgresql+psycopg2"
|
||||
USERNAME: str = "berkay_wag_user"
|
||||
PASSWORD: str = "berkay_wag_user_password"
|
||||
DATABASE_NAME: str = "wag_database"
|
||||
DATABASE_URL: str = f"{SQL}://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DATABASE_NAME}"
|
||||
|
||||
|
||||
class PaginateConfig:
|
||||
DEFAULT_SIZE = 10
|
||||
MIN_SIZE = 10
|
||||
MAX_SIZE = 50
|
||||
243
ApiLayers/AllConfigs/Templates/password_templates.py
Normal file
243
ApiLayers/AllConfigs/Templates/password_templates.py
Normal file
@@ -0,0 +1,243 @@
|
||||
import datetime
|
||||
|
||||
|
||||
def change_your_password_template(**kwargs):
|
||||
user_name, forgot_link, current_year = (
|
||||
kwargs["user_name"],
|
||||
kwargs["forgot_link"],
|
||||
str(datetime.datetime.now().year),
|
||||
)
|
||||
template = """<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Bootstrap demo</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.email-container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background-color: #ffffff;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.header {
|
||||
text-align: center;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
.header img {
|
||||
max-width: 100px;
|
||||
}
|
||||
.content {
|
||||
padding: 20px 0;
|
||||
}
|
||||
.footer {
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
color: #777777;
|
||||
}
|
||||
.btn-success {
|
||||
color: #fff;
|
||||
background-color: #198754;
|
||||
border-color: #198754;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
vertical-align: middle;
|
||||
width: 150px;
|
||||
height: 40px;
|
||||
border-radius: 5px;
|
||||
font-weight: 400;
|
||||
padding: .375rem .75rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="email-container">
|
||||
<div class="header">
|
||||
<img src="" alt="Company Logo">
|
||||
<h2>Reset Password</h2>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>Dear %s,</p>
|
||||
<p>We have received a request to reset your password for your account with Let's Program Blog. To complete the password reset process, please click on the button below:</p>
|
||||
<p>Please note that this link is only valid for a day only. If you did not request a password reset, please disregard this message.</p>
|
||||
<a href="%s"><button type="button" class="btn-success">Reset Password</button></a>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p>© %s Evyos Ltd Şti. All rights reserved.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
""" % (
|
||||
user_name,
|
||||
forgot_link,
|
||||
current_year,
|
||||
)
|
||||
|
||||
return template
|
||||
|
||||
|
||||
def password_is_changed_template(**kwargs):
|
||||
user_name, current_year = kwargs["user_name"], str(datetime.datetime.now().year)
|
||||
template = """
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Thank You for Changing Your Password</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.email-container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background-color: #ffffff;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.header {
|
||||
text-align: center;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
.header img {
|
||||
max-width: 100px;
|
||||
}
|
||||
.content {
|
||||
padding: 20px 0;
|
||||
}
|
||||
.footer {
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
color: #777777;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="email-container">
|
||||
<div class="header">
|
||||
<img src="" alt="Company Logo">
|
||||
<h2>Your Password has changed</h2>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>Dear %s,</p>
|
||||
<p>We wanted to let you know that your password has been successfully updated.
|
||||
If you did not make this change or if you believe an unauthorized person has accessed your account,
|
||||
please contact our support team immediately.</p>
|
||||
<p>Thank you for helping us keep your account secure.</p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p>© %s Evyos Ltd Şti. All rights reserved.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
""" % (
|
||||
user_name,
|
||||
current_year,
|
||||
)
|
||||
|
||||
return template
|
||||
|
||||
|
||||
def invalid_ip_or_address_found(**kwargs):
|
||||
user_name, current_year, address = (
|
||||
kwargs["user_name"],
|
||||
str(datetime.datetime.now().year),
|
||||
kwargs.get("address"),
|
||||
)
|
||||
template = """
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Thank You for Changing Your Password</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.email-container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background-color: #ffffff;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.header {
|
||||
text-align: center;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
.header img {
|
||||
max-width: 100px;
|
||||
}
|
||||
.content {
|
||||
padding: 20px 0;
|
||||
}
|
||||
.footer {
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
color: #777777;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="email-container">
|
||||
<div class="header">
|
||||
<img src="" alt="Company Logo">
|
||||
<h2>An Unknown login has been attempted</h2>
|
||||
</div>
|
||||
<div class="content">
|
||||
<p>Dear %s,</p>
|
||||
<p>We wanted to let you know that an unusual login attempt has been tried from address below.
|
||||
If you have login from address below please ignore this message</p>
|
||||
<p>Thank you for helping us keep your account secure.</p>
|
||||
<h1>Address of ip attempt</h1>
|
||||
<p>City : %s</p>
|
||||
<p>Zip Code : %s</p>
|
||||
<p>Country : %s</p>
|
||||
<p>Region : %s</p>
|
||||
<p>Region Name : %s</p>
|
||||
<p>If you are not login from this address lets us now by clicking link below</p>
|
||||
<a href="%s"><button type="button" class="btn-success">Reset Password</button></a>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p>© %s Evyos Ltd Şti. All rights reserved.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
""" % (
|
||||
user_name,
|
||||
address["city"],
|
||||
address["zip"],
|
||||
address["country"],
|
||||
address["region"],
|
||||
address["regionName"],
|
||||
kwargs["notice_link"],
|
||||
current_year,
|
||||
)
|
||||
return template
|
||||
27
ApiLayers/AllConfigs/Token/config.py
Normal file
27
ApiLayers/AllConfigs/Token/config.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import datetime
|
||||
|
||||
|
||||
class Auth:
|
||||
ACCESS_EMAIL_EXT = "evyos.com.tr"
|
||||
ACCESS_TOKEN_TAG = "evyos-session-key"
|
||||
REFRESHER_TOKEN_TAG = "eys-session-refresher"
|
||||
SECRET_KEY_72 = (
|
||||
"t3sUAmjTGeTgDc6dAUrB41u2SNg0ZHzj4HTjem95y3fRH1nZXOHIBj163kib6iLybT0gLaxq"
|
||||
)
|
||||
SECRET_KEY_96 = "7ct8VpiwaP1hR2bVSet4dEEAgepuTZUOnO1QxOgKyDqBR2PkqNhcubSrbUUigQKoQA1PBoeeQn5ZCo24pESmVtKs76nA4EKq"
|
||||
SECRET_KEY_144 = (
|
||||
"R2p5Rq6KCr6PCfjFYUeH1keF2VWHFEuqINVjBGGnvRA2m10pYUKqfOtIGBcaj2v5wZmElDndzSHGOS7roQsoTelPSok0"
|
||||
+ "qqMucurMWE0FGexGpFuJkfPEm9tH2OjMOqegvEetpSVywH0W4Kh4"
|
||||
)
|
||||
|
||||
ALGORITHM = "HS256"
|
||||
ACCESS_TOKEN_LENGTH: int = 90
|
||||
REFRESHER_TOKEN_LENGTH: int = 144
|
||||
PASSWORD_EXPIRE_DAY = datetime.timedelta(days=30)
|
||||
TOKEN_EXPIRE_MINUTES_1 = datetime.timedelta(minutes=1)
|
||||
TOKEN_EXPIRE_MINUTES_15 = datetime.timedelta(minutes=15)
|
||||
TOKEN_EXPIRE_MINUTES_30 = datetime.timedelta(minutes=30)
|
||||
TOKEN_EXPIRE_DAY_1 = datetime.timedelta(days=1)
|
||||
TOKEN_EXPIRE_DAY_5 = datetime.timedelta(days=5)
|
||||
TOKEN_EXPIRE_DAY_15 = datetime.timedelta(days=15)
|
||||
TOKEN_EXPIRE_DAY_30 = datetime.timedelta(days=30)
|
||||
3
ApiLayers/AllConfigs/__init__.py
Normal file
3
ApiLayers/AllConfigs/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .main import HostConfig
|
||||
|
||||
__all__ = ["HostConfig"]
|
||||
31
ApiLayers/AllConfigs/main.py
Normal file
31
ApiLayers/AllConfigs/main.py
Normal file
@@ -0,0 +1,31 @@
|
||||
class HostConfig:
|
||||
MAIN_HOST = "10.10.2.36" # http://10.10.2.36
|
||||
EMAIL_HOST = "10.10.2.34" # http://10.10.2.34
|
||||
|
||||
|
||||
class MainConfig:
|
||||
|
||||
APP_NAME = "evyos-web-api-gateway"
|
||||
TITLE = "WAG API Web Api Gateway"
|
||||
DESCRIPTION = "This api is serves as web api gateway only to evyos web services."
|
||||
APP_URL = "https://www.wag.eys.gen.tr"
|
||||
|
||||
DATETIME_FORMAT = "YYYY-MM-DD HH:mm:ss Z"
|
||||
DATETIME_FORMAT_JS = "YYYY-MM-DD HH:mm:ss +0"
|
||||
|
||||
# Timezone Configuration
|
||||
DEFAULT_TIMEZONE = "GMT+3" # Default timezone for the application
|
||||
SYSTEM_TIMEZONE = "GMT+0" # System timezone (used for internal operations)
|
||||
SUPPORTED_TIMEZONES = ["GMT+0", "GMT+3"] # List of supported timezones
|
||||
|
||||
|
||||
class LanguageConfig:
|
||||
|
||||
SUPPORTED_LANGUAGES = ["en", "tr"]
|
||||
DEFAULT_LANGUAGE = "tr"
|
||||
|
||||
|
||||
class ValidationsConfig:
|
||||
|
||||
SUPPORTED_VALIDATIONS = ["header", "validation", "all"]
|
||||
DEFAULT_VALIDATION = "all"
|
||||
Reference in New Issue
Block a user