Search code examples
pythonapigoogle-cloud-platformgoogle-api-python-client

GCP - vulnerabilityReports.get() with Python


I am trying to get the vulnerability report for an instance as part of a Python script. For that I am following the documentation here:

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

My function looks something like this:

    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)
        )

However, when I run that I get an error saying

TypeError: Got an unexpected keyword argument "parent"

What exactly can I do to resolve this or how should I change my query?


Solution

  • Based on the documentation, it seems like the parameter is no longer parent. Can you please try it using the v1 version (rather than v1alpha) and passing the parameter name instead?

    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)
        )
    

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