TDAgentTools / tdagent /tools /lookup_company_cloud_account_information.py
pedrobento988's picture
WHOIS and fixes (#3)
0d4024a verified
import gradio as gr
# Fake cloud accounts database
cloud_accounts = {
("AWS", "123456789012"): {
"public_cloud_provider": "AWS",
"account_id": "123456789012",
"cloud_account_name": "Production-Main",
"owner_user_id": "AWS001",
"owner_email": "[email protected]",
"deployed_applications": ["ERP System", "Customer Portal", "Data Lake"],
},
("AWS", "098765432109"): {
"public_cloud_provider": "AWS",
"account_id": "098765432109",
"cloud_account_name": "Development-Team1",
"owner_user_id": "AWS002",
"owner_email": "[email protected]",
"deployed_applications": ["Test Environment", "CI/CD Pipeline"],
},
("Azure", "sub-abc-123-def-456"): {
"public_cloud_provider": "Azure",
"account_id": "sub-abc-123-def-456",
"cloud_account_name": "Enterprise-Solutions",
"owner_user_id": "AZ001",
"owner_email": "[email protected]",
"deployed_applications": ["Microsoft 365 Integration", "Azure AD Connect"],
},
("Azure", "sub-xyz-789-uvw-321"): {
"public_cloud_provider": "Azure",
"account_id": "sub-xyz-789-uvw-321",
"cloud_account_name": "Research-Division",
"owner_user_id": "AZ002",
"owner_email": "[email protected]",
"deployed_applications": ["ML Platform", "Research Portal"],
},
("GCP", "project-id-123456"): {
"public_cloud_provider": "GCP",
"account_id": "project-id-123456",
"cloud_account_name": "Analytics-Platform",
"owner_user_id": "GCP001",
"owner_email": "[email protected]",
"deployed_applications": ["BigQuery Data Warehouse", "Kubernetes Cluster"],
},
("GCP", "project-id-789012"): {
"public_cloud_provider": "GCP",
"account_id": "project-id-789012",
"cloud_account_name": "ML-Operations",
"owner_user_id": "GCP002",
"owner_email": "[email protected]",
"deployed_applications": ["TensorFlow Training", "Model Serving Platform"],
},
}
def lookup_cloud_account(public_cloud_provider: str, account_id: str) -> dict[str, str]:
"""Function to lookup cloud account information.
Returns a formatted string with account details if
found, otherwise returns error message.
"""
account_key = (public_cloud_provider, account_id)
if account_key in cloud_accounts:
account = cloud_accounts[account_key]
return {
"public_cloud_provider": f"{account['public_cloud_provider']}",
"account_id": f"{account['account_id']}",
"cloud_account_name": f"{account['cloud_account_name']}",
"owner_user_id": f"{account['owner_user_id']}",
"owner_email": f"{account['owner_email']}",
"deployed_applications": f"{account['deployed_applications']!s}",
}
return {
"error": "Account not found",
"public_cloud_provider": f"{public_cloud_provider}",
"account_id": f"{account_id}",
"message": "No cloud account information found",
}
# Create Gradio Interface
gr_lookup_company_cloud_account_information = gr.Interface(
fn=lookup_cloud_account,
inputs=[
gr.Dropdown(
choices=["AWS", "Azure", "GCP"],
label="Cloud Provider",
info="Select the cloud provider",
),
"text",
],
outputs="text",
title="Company Cloud Account Lookup System",
description="""
Look up Company cloud account information by provider and account ID.
Sample Account IDs:
AWS: 123456789012, 098765432109
Azure: sub-abc-123-def-456, sub-xyz-789-uvw-321
GCP: project-id-123456, project-id-789012
""",
theme="default",
)