mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-06-06 23:46:19 +00:00
Add environment variable checks for OMADA_SITE_ID, OMADA_GROUP_ID, and OMADA_PROXY_URL inside function calls
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m15s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m15s
This commit is contained in:
parent
5600a5e8e6
commit
e0dfc28590
29
api/tasks.py
29
api/tasks.py
@ -19,19 +19,6 @@ OMADA_PROXY_URL = env("OMADA_PROXY_URL", default="") # type: ignore
|
|||||||
OMADA_SITE_ID = env("OMADA_SITE_ID", default="") # type: ignore
|
OMADA_SITE_ID = env("OMADA_SITE_ID", default="") # type: ignore
|
||||||
OMADA_GROUP_ID = env("OMADA_GROUP_ID", default="") # type: ignore
|
OMADA_GROUP_ID = env("OMADA_GROUP_ID", default="") # type: ignore
|
||||||
|
|
||||||
if not OMADA_SITE_ID:
|
|
||||||
raise ValueError(
|
|
||||||
"OMADA_SITE_ID is not set. Please set it in your environment variables."
|
|
||||||
)
|
|
||||||
if not OMADA_GROUP_ID:
|
|
||||||
raise ValueError(
|
|
||||||
"OMADA_GROUP_ID is not set. Please set it in your environment variables."
|
|
||||||
)
|
|
||||||
if not OMADA_PROXY_URL:
|
|
||||||
raise ValueError(
|
|
||||||
"OMADA_PROXY_URL is not set. Please set it in your environment variables."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def add(x, y):
|
def add(x, y):
|
||||||
@ -76,6 +63,10 @@ def get_existing_omada_devices():
|
|||||||
Get existing Omada devices from the database.
|
Get existing Omada devices from the database.
|
||||||
:return: List of existing device names.
|
:return: List of existing device names.
|
||||||
"""
|
"""
|
||||||
|
if not OMADA_PROXY_URL:
|
||||||
|
raise ValueError(
|
||||||
|
"OMADA_PROXY_URL is not set. Please set it in your environment variables."
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
f"{OMADA_PROXY_URL}/9fd0cffa3475a74ae4e4d37de0d12414/api/v2/sites/66dcddb804aa0d2978cf145f/setting/profiles/groups",
|
f"{OMADA_PROXY_URL}/9fd0cffa3475a74ae4e4d37de0d12414/api/v2/sites/66dcddb804aa0d2978cf145f/setting/profiles/groups",
|
||||||
@ -102,6 +93,18 @@ def add_new_devices_to_omada(new_devices: list[dict]):
|
|||||||
Add new devices to Omada.
|
Add new devices to Omada.
|
||||||
:param new_devices: List of new device names to add.
|
:param new_devices: List of new device names to add.
|
||||||
"""
|
"""
|
||||||
|
if not OMADA_SITE_ID:
|
||||||
|
raise ValueError(
|
||||||
|
"OMADA_SITE_ID is not set. Please set it in your environment variables."
|
||||||
|
)
|
||||||
|
if not OMADA_GROUP_ID:
|
||||||
|
raise ValueError(
|
||||||
|
"OMADA_GROUP_ID is not set. Please set it in your environment variables."
|
||||||
|
)
|
||||||
|
if not OMADA_PROXY_URL:
|
||||||
|
raise ValueError(
|
||||||
|
"OMADA_PROXY_URL is not set. Please set it in your environment variables."
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
PAYLOAD = {
|
PAYLOAD = {
|
||||||
"name": "REGISTERED_DEVICES",
|
"name": "REGISTERED_DEVICES",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user