File size: 3,798 Bytes
4d96490
 
0d4024a
4d96490
 
 
 
 
 
 
 
0d4024a
4d96490
 
 
 
 
 
 
0d4024a
4d96490
 
 
 
 
 
 
0d4024a
4d96490
 
 
 
 
 
 
0d4024a
4d96490
 
 
 
 
 
 
0d4024a
4d96490
 
 
 
 
 
 
0d4024a
 
4d96490
 
 
0d4024a
 
 
 
 
4d96490
 
 
 
 
0d4024a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4d96490
 
 
 
 
0d4024a
 
 
 
 
 
 
 
4d96490
 
 
 
 
 
 
 
 
 
0d4024a
10931f7
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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": "cloud.admin@company.com",
        "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": "dev.lead@company.com",
        "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": "azure.admin@company.com",
        "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": "research.lead@company.com",
        "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": "gcp.admin@company.com",
        "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": "ml.ops@company.com",
        "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",
)