Polling Long Running Operations

This page describes how to programmatically poll the long-running operation resources returned by methods in Service Infrastructure APIs that take a substantial amount of time to complete, such as service.rollouts.create. After an operation is done, the done field will be set to true.

To poll an operation, repeatedly invoke the operations.get method with a recommended 10 seconds backoff until the operation is done:

# This is an example of getting a pending `Operation` resource.
gcurlhttps://servicemanagement.googleapis.com/v1/operations/rollouts.endpointsapis.appspot.com:2016-07-16r2
{
"name":"operations/rollouts.endpointsapis.appspot.com:2016年07月16日r2",
"metadata":{
"@type":"type.googleapis.com/google.api.servicemanagement.v1.OperationMetadata",
"resourceNames":[
"services/endpointsapis.appspot.com/rollouts/2016-07-16r2"
],
"steps":[
{
"description":"update Service Controller",
"status":"In_PROGRESS"
}
],
"progressPercentage":0,
"startTime":"2016-07-16T00:56:55.737Z",
}
"response":{
"@type":"type.googleapis.com/google.api.servicemanagement.v1.Rollout",
"rolloutId":"2016-07-16r2",
"createTime":"2016-07-16T00:56:55.724Z",
"serviceSelectionStrategy":{
"serviceConfigIds":[
"2016-07-16r1"
]
},
"serviceName":"endpointsapis.appspot.com"
}
# This is an example of getting a done `Operation` resource.
gcurlhttps://servicemanagement.googleapis.com/v1/operations/rollouts.endpointsapis.appspot.com:2016-07-16r2
{
"name":"operations/rollouts.endpointsapis.appspot.com:2016年07月16日r2",
"metadata":{
"@type":"type.googleapis.com/google.api.servicemanagement.v1.OperationMetadata",
"resourceNames":[
"services/endpointsapis.appspot.com/rollouts/2016-07-16r2"
],
"steps":[
{
"description":"update Service Controller",
"status":"Done"
}
],
"progressPercentage":100,
"startTime":"2016-07-16T00:56:55.737Z",
}
"done":true,
"response":{
"@type":"type.googleapis.com/google.api.servicemanagement.v1.Rollout",
"rolloutId":"2016-07-16r2",
"createTime":"2016-07-16T00:56:55.724Z",
"serviceSelectionStrategy":{
"serviceConfigIds":[
"2016-07-16r1"
]
},
"serviceName":"endpointsapis.appspot.com"
}

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月24日 UTC.