Skip to content

Commit

Permalink
Remove group logic
Browse files Browse the repository at this point in the history
  • Loading branch information
TobsA13 committed Apr 7, 2024
1 parent 3f00560 commit 95e113c
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import secrets
from pprint import pprint
from typing import Annotated

from fastapi import Depends, FastAPI, HTTPException, status
Expand All @@ -7,8 +8,9 @@

import requests
import logging

CLUSTER_GROUPS = {5649: [22697, 138070], 9685: [138069]}
# 5649 = FFW
# 9685 = FFW Test
CLUSTERS = [5649, 9685]

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -59,17 +61,10 @@ def login_divera(credentials: Annotated[HTTPBasicCredentials, Depends(security)]
clusters[v["cluster_id"]] = k

for cluster, ucr in clusters.items():
if cluster in CLUSTER_GROUPS.keys():
resp_ucr = requests.get('https://www.divera247.com/api/v2/pull/all',
params={"accesskey": accesskey, "ucr": ucr})
resp_ucr = resp_ucr.json()
if not resp_ucr["success"]:
continue
for g in CLUSTER_GROUPS[cluster]:
if g in resp_ucr["data"]["cluster"]["consumer"][ucr]["groups"]:
return {"username": credentials.username, "cluster": cluster, "ucr": ucr}

return_error("Divera group failed")
if cluster in CLUSTERS:
return {"username": credentials.username, "cluster": cluster, "ucr": ucr}

return_error("Divera cluster failed")


@app.get("/login")
Expand Down

0 comments on commit 95e113c

Please sign in to comment.