-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcredentials_get.py
More file actions
33 lines (28 loc) · 1.1 KB
/
credentials_get.py
File metadata and controls
33 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from f.controller.config import DatabaseConfig
from f.controller.database import MetadataDatabaseRepository
from f.shared.otel_logging import get_logger
logger = get_logger(__name__)
def main(request_data=None):
"""Get list of all credentials"""
try:
meta_db = MetadataDatabaseRepository(DatabaseConfig.META_DB)
meta_db.create_credentials_table()
credentials = meta_db.fetch_credentials_list()
return {
"result": "SUCCESS",
"data": [
{
"id": str(cred[0]),
"name": cred[1],
"credentialType": cred[2],
"description": cred[3],
"windmillVariable": cred[4],
"createdAt": cred[5].isoformat() if cred[5] else None,
"lastUsedAt": cred[6].isoformat() if cred[6] else None
}
for cred in credentials
]
}
except Exception as e:
logger.error(f"Failed to fetch credentials: {e}", exc_info=True)
return {"result": "FAILURE", "error": str(e)}