Search code examples
google-cloud-cdn

How can I get google cloud cdn Invalidate cache result


I have sent the task of clearing the cache through the python client library of google cloud cdn, and got the request id of the GCP response. However, where can I query the progress of the task of clearing the cache according to the request id.

The address where I send the request: https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps/invalidateCache

The address where I send the request: https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps/invalidateCache


Solution

  • I query the Invalidate cache result of Google Cloud CDN through the API in the following document: https://cloud.google.com/compute/docs/reference/rest/v1/globalOperations/get

    And I got the information I want through the following python code:

    def get_operation_result(gcp_request_id):
        credentials = GoogleCredentials.get_application_default()
    
        service = discovery.build('compute', 'v1', credentials=credentials)
    
        # Project ID for this request.
        project = 'my-project'  # TODO: Update placeholder value.
    
        # Name of the Operations resource to return.
        operation = gcp_request_id  # TODO: Update placeholder value.
    
        request = service.globalOperations().get(project=project, operation=operation)
        response = request.execute()
    
        # TODO: Change code below to process the `response` dict:
        mission_status = response['status']
        return mission_status