Api v1.13.0 release (#1337)

* refactor(chalice): removed client endpoint
* refactor(chalice): removed unused schemas
This commit is contained in:
Kraiem Taha Yassine 2023-06-12 17:44:17 +02:00 committed by GitHub
parent 994c1db1f7
commit 9c051c8412
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 72 deletions

View file

@ -1,7 +1,6 @@
import schemas
from chalicelib.utils import pg_client
from chalicelib.core import license
from chalicelib.utils import helper
from chalicelib.core import users, license
from chalicelib.utils import pg_client
def get_by_tenant_id(tenant_id):
@ -43,7 +42,7 @@ def generate_new_api_key(tenant_id):
return helper.dict_to_camel_case(cur.fetchone())
def edit_client(tenant_id, changes):
def edit_tenant(tenant_id, changes):
with pg_client.PostgresClient() as cur:
query = cur.mogrify(f"""UPDATE public.tenants
SET {", ".join([f"{helper.key_to_snake_case(k)} = %({k})s" for k in changes.keys()])}
@ -53,21 +52,6 @@ def edit_client(tenant_id, changes):
return helper.dict_to_camel_case(cur.fetchone())
def update(tenant_id, user_id, data: schemas.UpdateTenantSchema):
admin = users.get(user_id=user_id, tenant_id=tenant_id)
if not admin["admin"] and not admin["superAdmin"]:
return {"errors": ["unauthorized, needs admin or owner"]}
if data.name is None and data.opt_out is None:
return {"errors": ["please provide 'name' of 'optOut' attribute for update"]}
changes = {}
if data.name is not None and len(data.name) > 0:
changes["name"] = data.name
if data.opt_out is not None:
changes["optOut"] = data.opt_out
return edit_client(tenant_id=tenant_id, changes=changes)
def tenants_exists(use_pool=True):
with pg_client.PostgresClient(use_pool=use_pool) as cur:
cur.execute(f"SELECT EXISTS(SELECT 1 FROM public.tenants)")

View file

@ -291,7 +291,7 @@ def edit_account(user_id, tenant_id, changes: schemas.EditAccountSchema):
if changes.opt_out is not None:
_tenant_changes["opt_out"] = changes.opt_out
if len(_tenant_changes.keys()) > 0:
tenants.edit_client(tenant_id=tenant_id, changes=_tenant_changes)
tenants.edit_tenant(tenant_id=tenant_id, changes=_tenant_changes)
return {"data": __get_account_info(tenant_id=tenant_id, user_id=user_id)}

View file

@ -655,13 +655,6 @@ async def generate_new_tenant_token(context: schemas.CurrentContext = Depends(OR
}
@app.post('/client', tags=['client'])
@app.put('/client', tags=['client'])
async def edit_client(data: schemas.UpdateTenantSchema = Body(...),
context: schemas.CurrentContext = Depends(OR_context)):
return tenants.update(tenant_id=context.tenant_id, user_id=context.user_id, data=data)
@app.get('/notifications', tags=['notifications'])
async def get_notifications(context: schemas.CurrentContext = Depends(OR_context)):
return {"data": notifications.get_all(tenant_id=context.tenant_id, user_id=context.user_id)}

View file

@ -265,32 +265,6 @@ class MetadataListSchema(BaseModel):
list: List[MetadataBasicSchema] = Field(...)
class EmailPayloadSchema(BaseModel):
auth: str = Field(...)
email: EmailStr = Field(...)
link: str = Field(...)
message: str = Field(...)
_transform_email = validator('email', pre=True, allow_reuse=True)(transform_email)
class MemberInvitationPayloadSchema(BaseModel):
auth: str = Field(...)
email: EmailStr = Field(...)
invitation_link: str = Field(...)
client_id: str = Field(...)
sender_name: str = Field(...)
_transform_email = validator('email', pre=True, allow_reuse=True)(transform_email)
class Config:
alias_generator = attribute_to_camel_case
class ErrorIdsPayloadSchema(BaseModel):
errors: List[str] = Field([])
class _AlertMessageSchema(BaseModel):
type: str = Field(...)
value: str = Field(...)

View file

@ -1,5 +1,4 @@
import schemas
from chalicelib.core import users, license
from chalicelib.core import license
from chalicelib.utils import helper
from chalicelib.utils import pg_client
@ -68,7 +67,7 @@ def generate_new_api_key(tenant_id):
return helper.dict_to_camel_case(cur.fetchone())
def edit_client(tenant_id, changes):
def edit_tenant(tenant_id, changes):
with pg_client.PostgresClient() as cur:
query = cur.mogrify(f"""UPDATE public.tenants
SET {", ".join([f"{helper.key_to_snake_case(k)} = %({k})s" for k in changes.keys()])}
@ -79,21 +78,6 @@ def edit_client(tenant_id, changes):
return helper.dict_to_camel_case(cur.fetchone())
def update(tenant_id, user_id, data: schemas.UpdateTenantSchema):
admin = users.get(user_id=user_id, tenant_id=tenant_id)
if not admin["admin"] and not admin["superAdmin"]:
return {"errors": ["unauthorized, needs admin or owner"]}
if data.name is None and data.opt_out is None:
return {"errors": ["please provide 'name' of 'optOut' attribute for update"]}
changes = {}
if data.name is not None and len(data.name) > 0:
changes["name"] = data.name
if data.opt_out is not None:
changes["optOut"] = data.opt_out
return edit_client(tenant_id=tenant_id, changes=changes)
def tenants_exists(use_pool=True):
with pg_client.PostgresClient(use_pool=use_pool) as cur:
cur.execute(f"SELECT EXISTS(SELECT 1 FROM public.tenants)")

View file

@ -339,7 +339,7 @@ def edit_account(user_id, tenant_id, changes: schemas.EditAccountSchema):
if changes.opt_out is not None:
_tenant_changes["opt_out"] = changes.opt_out
if len(_tenant_changes.keys()) > 0:
tenants.edit_client(tenant_id=tenant_id, changes=_tenant_changes)
tenants.edit_tenant(tenant_id=tenant_id, changes=_tenant_changes)
return {"data": __get_account_info(tenant_id=tenant_id, user_id=user_id)}