feat(chalice): changed health-check endpoint behaviour
feat(chalice): refactored code
This commit is contained in:
parent
9ae93ddd95
commit
cb22ba7568
20 changed files with 29 additions and 41 deletions
|
|
@ -4,8 +4,7 @@ from os.path import exists as path_exists, getsize
|
|||
import jwt
|
||||
import requests
|
||||
from decouple import config
|
||||
from starlette import status
|
||||
from fastapi import HTTPException
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import projects
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ import json
|
|||
|
||||
import requests
|
||||
from decouple import config
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import webhook
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import requests
|
||||
from decouple import config
|
||||
from datetime import datetime
|
||||
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
import requests
|
||||
from decouple import config
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import webhook
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ import json
|
|||
from typing import Union
|
||||
|
||||
from decouple import config
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import sessions, funnels, errors, issues, metrics, click_maps, sessions_mobs
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import re
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
from chalicelib.core import projects
|
||||
from chalicelib.utils import pg_client
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import json
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import users
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from chalicelib.utils import pg_client
|
|||
from chalicelib.utils.TimeUTC import TimeUTC
|
||||
|
||||
|
||||
def create_step1(data: schemas.UserSignupSchema):
|
||||
def create_tenant(data: schemas.UserSignupSchema):
|
||||
print(f"===================== SIGNUP STEP 1 AT {TimeUTC.to_human_readable(TimeUTC.now())} UTC")
|
||||
errors = []
|
||||
if tenants.tenants_exists():
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ import logging
|
|||
from typing import Optional
|
||||
|
||||
import requests
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas
|
||||
from chalicelib.utils import pg_client, helper
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import requests
|
||||
from datetime import datetime
|
||||
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
import requests
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
|
||||
class github_formatters:
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@ import time
|
|||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from fastapi import HTTPException, status
|
||||
from jira import JIRA
|
||||
from jira.exceptions import JIRAError
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from starlette import status
|
||||
from fastapi import HTTPException
|
||||
|
||||
fields = "id, summary, description, creator, reporter, created, assignee, status, updated, comment, issuetype, labels"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
from typing import Union
|
||||
|
||||
from decouple import config
|
||||
from fastapi import Depends, Body, HTTPException, Response
|
||||
from fastapi import Depends, Body, HTTPException, Response, status
|
||||
from fastapi.responses import JSONResponse
|
||||
from starlette import status
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import log_tool_rollbar, sourcemaps, events, sessions_assignments, projects, \
|
||||
|
|
@ -11,7 +10,7 @@ from chalicelib.core import log_tool_rollbar, sourcemaps, events, sessions_assig
|
|||
log_tool_elasticsearch, log_tool_datadog, \
|
||||
log_tool_stackdriver, reset_password, log_tool_cloudwatch, log_tool_sentry, log_tool_sumologic, log_tools, sessions, \
|
||||
log_tool_newrelic, announcements, log_tool_bugsnag, weekly_report, integration_jira_cloud, integration_github, \
|
||||
assist, mobile, signup, tenants, boarding, notifications, webhook, users, \
|
||||
assist, mobile, tenants, boarding, notifications, webhook, users, \
|
||||
custom_metrics, saved_search, integrations_global
|
||||
from chalicelib.core.collaboration_msteams import MSTeams
|
||||
from chalicelib.core.collaboration_slack import Slack
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ if not tenants.tenants_exists(use_pool=False):
|
|||
@public_app.post('/signup', tags=['signup'])
|
||||
@public_app.put('/signup', tags=['signup'])
|
||||
async def signup_handler(data: schemas.UserSignupSchema = Body(...)):
|
||||
return signup.create_step1(data)
|
||||
return signup.create_tenant(data)
|
||||
|
||||
|
||||
@app.get('/account', tags=['accounts'])
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from fastapi import HTTPException, status
|
||||
|
||||
from chalicelib.core import health, tenants
|
||||
from routers.base import get_routers
|
||||
|
||||
|
|
@ -11,4 +13,6 @@ if tenants.tenants_exists(use_pool=False):
|
|||
|
||||
@health_router.get('/health', tags=["health-check"])
|
||||
def get_global_health_status():
|
||||
if tenants.tenants_exists():
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Not Found")
|
||||
return {"data": health.get_health()}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ import json
|
|||
from typing import Union
|
||||
|
||||
from decouple import config
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas
|
||||
import schemas_ee
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import json
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import users
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from typing import Optional
|
||||
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas_ee
|
||||
from chalicelib.core import users, projects
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ from chalicelib.utils import pg_client
|
|||
from chalicelib.utils.TimeUTC import TimeUTC
|
||||
|
||||
|
||||
def create_step1(data: schemas.UserSignupSchema):
|
||||
def create_tenant(data: schemas.UserSignupSchema):
|
||||
print(f"===================== SIGNUP STEP 1 AT {TimeUTC.to_human_readable(TimeUTC.now())} UTC")
|
||||
errors = []
|
||||
if not config("MULTI_TENANTS", cast=bool, default=False) and tenants.tenants_exists():
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@ import logging
|
|||
from typing import Optional
|
||||
|
||||
import requests
|
||||
from fastapi import HTTPException
|
||||
from starlette import status
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
import schemas
|
||||
from chalicelib.utils import pg_client, helper
|
||||
|
|
@ -113,7 +112,7 @@ def add(tenant_id, endpoint, auth_header=None, webhook_type='webhook', name="",
|
|||
|
||||
|
||||
def exists_by_name(tenant_id: int, name: str, exclude_id: Optional[int],
|
||||
webhook_type: str = schemas.WebhookType.webhook) -> bool:
|
||||
webhook_type: str = schemas.WebhookType.webhook) -> bool:
|
||||
with pg_client.PostgresClient() as cur:
|
||||
query = cur.mogrify(f"""SELECT EXISTS(SELECT 1
|
||||
FROM public.webhooks
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ async def get_all_signup():
|
|||
"edition": license.EDITION}}
|
||||
|
||||
|
||||
if not tenants.tenants_exists(use_pool=False):
|
||||
if config("MULTI_TENANTS", cast=bool, default=False) or not tenants.tenants_exists(use_pool=False):
|
||||
@public_app.post('/signup', tags=['signup'])
|
||||
@public_app.put('/signup', tags=['signup'])
|
||||
async def signup_handler(data: schemas.UserSignupSchema = Body(...)):
|
||||
return signup.create_step1(data)
|
||||
return signup.create_tenant(data)
|
||||
|
||||
|
||||
@app.get('/account', tags=['accounts'])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from fastapi import HTTPException
|
||||
from fastapi import Request, Response
|
||||
from fastapi import HTTPException, Request, Response, status
|
||||
|
||||
from chalicelib.utils import SAML2_helper
|
||||
from chalicelib.utils.SAML2_helper import prepare_request, init_saml_auth
|
||||
|
|
@ -12,7 +11,6 @@ from onelogin.saml2.auth import OneLogin_Saml2_Logout_Request
|
|||
|
||||
from chalicelib.core import users, tenants, roles
|
||||
from starlette.responses import RedirectResponse
|
||||
from starlette import status
|
||||
|
||||
|
||||
@public_app.get("/sso/saml2", tags=["saml2"])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue