Pedro Bento commited on
Commit
4d96490
·
1 Parent(s): 826aac3

added lookup_company_cloud_account_information

Browse files
app.py CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
3
  from tdagent.tools.get_url_content import gr_get_url_http_content
4
  from tdagent.tools.internal_company_user_search import gr_internal_company
5
  from tdagent.tools.letter_counter import gr_letter_counter
 
6
  from tdagent.tools.query_abuse_ip_db import gr_query_abuseipdb
7
  from tdagent.tools.virus_total import gr_virus_total
8
 
@@ -13,6 +14,7 @@ gr_app = gr.TabbedInterface(
13
  gr_query_abuseipdb,
14
  gr_virus_total,
15
  gr_internal_company,
 
16
  ],
17
  )
18
 
 
3
  from tdagent.tools.get_url_content import gr_get_url_http_content
4
  from tdagent.tools.internal_company_user_search import gr_internal_company
5
  from tdagent.tools.letter_counter import gr_letter_counter
6
+ from tdagent.tools.lookup_company_cloud_account_information import gr_lookup_company_cloud_account_information
7
  from tdagent.tools.query_abuse_ip_db import gr_query_abuseipdb
8
  from tdagent.tools.virus_total import gr_virus_total
9
 
 
14
  gr_query_abuseipdb,
15
  gr_virus_total,
16
  gr_internal_company,
17
+ gr_lookup_company_cloud_account_information,
18
  ],
19
  )
20
 
tdagent/tools/lookup_company_cloud_account_information.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Fake cloud accounts database
4
+ cloud_accounts = {
5
+ ("AWS", "123456789012"): {
6
+ "public_cloud_provider": "AWS",
7
+ "account_id": "123456789012",
8
+ "cloud_account_name": "Production-Main",
9
+ "owner_user_id": "AWS001",
10
+ "owner_email": "[email protected]",
11
+ "deployed_applications": ["ERP System", "Customer Portal", "Data Lake"]
12
+ },
13
+ ("AWS", "098765432109"): {
14
+ "public_cloud_provider": "AWS",
15
+ "account_id": "098765432109",
16
+ "cloud_account_name": "Development-Team1",
17
+ "owner_user_id": "AWS002",
18
+ "owner_email": "[email protected]",
19
+ "deployed_applications": ["Test Environment", "CI/CD Pipeline"]
20
+ },
21
+ ("Azure", "sub-abc-123-def-456"): {
22
+ "public_cloud_provider": "Azure",
23
+ "account_id": "sub-abc-123-def-456",
24
+ "cloud_account_name": "Enterprise-Solutions",
25
+ "owner_user_id": "AZ001",
26
+ "owner_email": "[email protected]",
27
+ "deployed_applications": ["Microsoft 365 Integration", "Azure AD Connect"]
28
+ },
29
+ ("Azure", "sub-xyz-789-uvw-321"): {
30
+ "public_cloud_provider": "Azure",
31
+ "account_id": "sub-xyz-789-uvw-321",
32
+ "cloud_account_name": "Research-Division",
33
+ "owner_user_id": "AZ002",
34
+ "owner_email": "[email protected]",
35
+ "deployed_applications": ["ML Platform", "Research Portal"]
36
+ },
37
+ ("GCP", "project-id-123456"): {
38
+ "public_cloud_provider": "GCP",
39
+ "account_id": "project-id-123456",
40
+ "cloud_account_name": "Analytics-Platform",
41
+ "owner_user_id": "GCP001",
42
+ "owner_email": "[email protected]",
43
+ "deployed_applications": ["BigQuery Data Warehouse", "Kubernetes Cluster"]
44
+ },
45
+ ("GCP", "project-id-789012"): {
46
+ "public_cloud_provider": "GCP",
47
+ "account_id": "project-id-789012",
48
+ "cloud_account_name": "ML-Operations",
49
+ "owner_user_id": "GCP002",
50
+ "owner_email": "[email protected]",
51
+ "deployed_applications": ["TensorFlow Training", "Model Serving Platform"]
52
+ }
53
+ }
54
+
55
+
56
+ def lookup_cloud_account(public_cloud_provider, account_id):
57
+ """
58
+ Function to lookup cloud account information
59
+ Returns a formatted string with account details if found, otherwise returns error message
60
+ """
61
+ account_key = (public_cloud_provider, account_id)
62
+
63
+ if account_key in cloud_accounts:
64
+ account = cloud_accounts[account_key]
65
+ return f"""{{
66
+ "public_cloud_provider": "{account['public_cloud_provider']}",
67
+ "account_id": "{account['account_id']}",
68
+ "cloud_account_name": "{account['cloud_account_name']}",
69
+ "owner_user_id": "{account['owner_user_id']}",
70
+ "owner_email": "{account['owner_email']}",
71
+ "deployed_applications": {str(account['deployed_applications'])}
72
+ }}"""
73
+ else:
74
+ return f"""{{
75
+ "error": "Account not found",
76
+ "public_cloud_provider": "{public_cloud_provider}",
77
+ "account_id": "{account_id}",
78
+ "message": "No cloud account found with these credentials"
79
+ }}"""
80
+
81
+
82
+ # Create Gradio Interface
83
+ gr_lookup_company_cloud_account_information = gr.Interface(
84
+ fn=lookup_cloud_account,
85
+ inputs=["text","text"],
86
+ outputs="text",
87
+ title="Company Cloud Account Lookup System",
88
+ description="""
89
+ Look up Company cloud account information by provider and account ID.
90
+
91
+ Sample Account IDs:
92
+ AWS: 123456789012, 098765432109
93
+ Azure: sub-abc-123-def-456, sub-xyz-789-uvw-321
94
+ GCP: project-id-123456, project-id-789012
95
+ """,
96
+ theme="default"
97
+ )