我在弄清楚如何生成与“未知”“ account_type”匹配的owner_id列表,然后将它们与与csv中与owner_id匹配的帐户进行比较时遇到问题。任何帮助,将不胜感激。我已经列出了我所获得的距离以及从api获得的一个帐户的简短摘要。谢谢!
# This is what I started with:
import requests
import json
r = requests.get ("https://chapi.cloudhealthtech.com/v1/aws_accounts?api_key=xxxxxxxxxxxxxxxx")
data = r.json()
响应数据:
{
"aws_accounts": [
{
"id": XXXXXXXXXXXX,
"name": "XXXXXXXXXXXX",
"amazon_name": "XXXXXXXX",
"owner_id": "XXXXXXXXXX",
"hide_public_fields": false,
"region": "global",
"created_at": "2018-05-09T10:31:19Z",
"updated_at": "2018-10-24T22:02:49Z",
"account_type": "Linked",
"vpc_only": true,
"cluster_name": "XXX",
"status": {
"level": "yellow",
"last_update": "2018-12-09T13:25:01Z"
},
"authentication": {
"protocol": "assume_role",
"assume_role_arn": "arn:aws:iam::XXXXXXXXXXXXX:role/CloudHealthXAccountReaderRole",
"assume_role_external_id": "XXXXXXXXXXXXXXXXXXXXX"
},
"billing": {
"is_consolidated": false
},
"cloudtrail": {
"enabled": false
}
}
]
}
答案 0 :(得分:0)
例如,如果您的csv文件如下所示:
parents[i]
尝试以下代码:
id,sample_data
1,sample
2,sample
3,sample
4,sample
5,sample
由于您的问题的细节有些模糊,因此可能会非常复杂。另外我也不知道如何将您的帐户输出到api,所以我带来了最简单的解决方案。