Coverage for chalicelib/core/log_tools/sumologic.py: 91%
26 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:56 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:56 +0000
1from chalicelib.core.log_tools import log_tools
2from schemas import schemas
4IN_TY = "sumologic"
7def get_all(tenant_id):
8 return log_tools.get_all_by_tenant(tenant_id=tenant_id, integration=IN_TY)
11def get(project_id):
12 return log_tools.get(project_id=project_id, integration=IN_TY)
15def update(tenant_id, project_id, changes):
16 options = {}
18 if "region" in changes: 18 ↛ 21line 18 didn't jump to line 21 because the condition on line 18 was always true
19 options["region"] = changes["region"]
21 if "accessId" in changes: 21 ↛ 24line 21 didn't jump to line 24 because the condition on line 21 was always true
22 options["accessId"] = changes["accessId"]
24 if "accessKey" in changes: 24 ↛ 26line 24 didn't jump to line 26 because the condition on line 24 was always true
25 options["accessKey"] = changes["accessKey"]
26 return log_tools.edit(project_id=project_id, integration=IN_TY, changes=options)
29def add(tenant_id, project_id, access_id, access_key, region):
30 options = {
31 "accessId": access_id,
32 "accessKey": access_key,
33 "region": region
34 }
35 return log_tools.add(project_id=project_id, integration=IN_TY, options=options)
38def delete(tenant_id, project_id):
39 return log_tools.delete(project_id=project_id, integration=IN_TY)
42def add_edit(tenant_id, project_id, data: schemas.IntegrationSumologicSchema):
43 s = get(project_id)
44 if s is not None:
45 return update(tenant_id=tenant_id, project_id=project_id,
46 changes={"accessId": data.access_id,
47 "accessKey": data.access_key,
48 "region": data.region})
49 else:
50 return add(tenant_id=tenant_id,
51 project_id=project_id,
52 access_id=data.access_id,
53 access_key=data.access_key,
54 region=data.region)