Long-running Operations

Long-running operations

The Submission API is asynchronous and returns a long-running operation. The operation may not be completed when the method returns a response.

Get an operation status

The following shows how to poll an operation's status.

Call the GET method for the Operations type.

Before using any of the request data, make the following replacements:

  • project-id: your GCP project ID
  • operation-id: your operation ID

HTTP method and URL:

GET https://webrisk.googleapis.com/v1/projects/project-id/operations/operation-id

To send your request, choose one of these options:

curl

Execute the following command:

curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
"https://webrisk.googleapis.com/v1/projects/project-id/operations/operation-id"

PowerShell

Execute the following command:

$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://webrisk.googleapis.com/v1/projects/project-id/operations/operation-id" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
  "name": "projects/project-id/operations/operation-id",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.webrisk.v1.SubmitUriMetadata",
    "state": "RUNNING"
  }
  "done": false,
  ...
}

When the operation has completed, a state value of SUCCEEDED is returned.