我想google-cloud-os-config
在 python 中使用客户端 sdk 发出批处理 API 请求来查询列表instanceOsPoliciesCompliances
目前,我正在for
通过一个列表循环运行下面的代码zones
,但我认为对它们进行批处理会更好:
def list_policy_compliance(projectId, zones):
res_list = []
try:
service = build('osconfig', 'v1alpha', cache_discovery=False)
for item in zones:
zone = item.split('/')[-1].split('.')[0]
compliance_request = service.projects().locations(
).instanceOsPoliciesCompliances().list(
parent='projects/%s/locations/%s' % (
projectId, zone))
while compliance_request is not None:
compliance_response = compliance_request.execute()
res_list.append(compliance_response)
compliance_request = service.projects().locations(
).instanceOsPoliciesCompliances().list_next(
previous_request=compliance_request,
previous_response=compliance_response)
return compliance_response
except Exception as e:
logger.error("Unable to retrieve instance OS compliance - %s."
+ str(e))
raise Exception("Unable to retrieve instance OS compliance")
知道此客户端是否支持批处理请求吗?