-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdd_fs_integration_list
More file actions
executable file
·68 lines (57 loc) · 1.8 KB
/
Copy pathdd_fs_integration_list
File metadata and controls
executable file
·68 lines (57 loc) · 1.8 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
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
#!/bin/env python3
import os
import requests
import pandas as pd
# TODO:
# dataframe to_excel
# Is there a dynamic way to include growing list of applications?
api_key = os.getenv("DD_API_KEY")
app_key = os.getenv("DD_APP_KEY")
account_ids = {
"007911250085": "FEMS",
"066399073050": "CIAO",
"107895115286": "LLC",
"112364832438": "UAVS",
"114245151275": "WFWEB",
"171226545153": "NRMBP",
"175560568060": "HWP",
"227101269271": "HDWI",
"328762180115": "CFTEAM",
"403938590038": "GPH",
"407464523575": "WFSAFE",
"504420026195": "INCIWEB",
"515022543707": "FSAPPSE",
"583937734902": "VDR",
"744281823657": "PAT",
"748257752168": "NMIS-GrowHub",
"878733051466": "Admin",
"899201081254": "AFF",
}
headers = {
"Accept": "application/json",
"DD-API-KEY": api_key,
"DD-APPLICATION-KEY": app_key,
}
def integrations(id):
link = f"https://api.ddog-gov.com/api/v1/integration/aws/filtering?account_id={id}"
url = link
response = requests.get(url, headers=headers)
if response.status_code != 200:
# TODO: add name to error and no just id
print(f"{response.status_code} for {id}")
return pd.DataFrame()
else:
result = [item["namespace"] for item in response.json()["filters"]]
df = pd.DataFrame(result, columns=['namespace'])
return df
def integrtion_writer(list):
all_data = pd.DataFrame()
for account_id, account_name in list.items():
print(account_name)
df = integrations(account_id)
if not df.empty:
df['account_name'] = account_name
df['account_id'] = account_id
all_data = pd.concat([all_data, df], ignore_index=True)
all_data.to_excel('fs_integrations_list.xlsx', index=False)
integrtion_writer(account_ids)