GCP - vulnerabilityReports.get() 和 Python

GCP - vulnerabilityReports.get() with Python

我正在尝试获取实例的漏洞报告作为 Python 脚本的一部分。为此,我正在关注此处的文档:

https://cloud.google.com/compute/docs/osconfig/rest/v1alpha/projects.locations.instances.vulnerabilityReports/get

我的函数看起来像这样:

    def getVulnerability()
        project = "my-project"
        location = "my-zone"
        instance = "my-instance-id"
        service.projects().locations().instances().vulnerabilityReports().get(
        parent='projects/{}/locations/{}/instances/{}'.format(project, location, instance)
        )

然而,当我 运行 时,我收到一条错误消息

TypeError: Got an unexpected keyword argument "parent"

我究竟该怎么做才能解决这个问题,或者我应该如何更改我的查询?

根据文档,参数似乎不再是 parent。您能否尝试使用 v1 版本(而不是 v1alpha)并传递参数 name

def getVulnerability()
   project = "my-project"
   location = "my-zone"
   instance = "my-instance-id"
   service.projects().locations().instances().vulnerabilityReports().get(
        name='projects/{}/locations/{}/instances/{}'.format(project, location, instance)
    )

参考:https://cloud.google.com/compute/docs/osconfig/rest/v1/projects.locations.instances.vulnerabilityReports/get