- HTTP request
- Path parameters
- Request body
- Response body
- Authorization scopes
- IAM Permissions
- Try it!
Advice on making real-time decisions (such as choosing zone or machine types) during deployment to maximize your chances of obtaining capacity.
HTTP request
POST https://compute.googleapis.com/compute/beta/projects/{project}/regions/{region}/advice/capacity
The URL uses gRPC Transcoding syntax. To know more about valid error responses that can be thrown by this HTTP request, please refer to the service error catalog
Path parameters
| Parameters | |
|---|---|
project |
Project ID for this request. |
region |
Name of the region for this request. |
Request body
The request body contains data with the following structure:
| JSON representation |
|---|
{ "instanceProperties": { "scheduling": { "provisioningModel": enum } }, "instanceFlexibilityPolicy": { "instanceSelections": { string: { "machineTypes": [ string ], "guestAccelerators": [ { "acceleratorType": string, "acceleratorCount": integer } ], "disks": [ { "type": enum } ] }, ... } }, "size": integer, "distributionPolicy": { "zones": [ { "zone": string } ], "targetShape": enum } } |
| Fields | |
|---|---|
instanceProperties |
Instance properties for this request. |
instanceProperties.scheduling |
Specifies the scheduling options. |
instanceProperties.scheduling.provisioningModel |
Specifies the provisioning model. |
instanceFlexibilityPolicy.instanceSelections[].key |
|
instanceFlexibilityPolicy.instanceSelections[].value.machineTypes[] |
Full machine-type names, e.g. "n1-standard-16". |
instanceFlexibilityPolicy.instanceSelections[].value.guestAccelerators[].acceleratorType |
Full or partial URL of the accelerator type resource to attach to this instance. For example: |
instanceFlexibilityPolicy.instanceSelections[].value.guestAccelerators[].acceleratorCount |
The number of the guest accelerator cards exposed to this instance. |
instanceFlexibilityPolicy.instanceSelections[].value.disks[] |
Local SSDs. |
instanceFlexibilityPolicy.instanceSelections[].value.disks[].type |
Specifies the type of the disk. This field must be set to |
size |
The number of VM instances to request. |
distributionPolicy |
Policy specifying the distribution of instances across zones within the requested region. |
distributionPolicy.zones[] |
Zones where advice.capacity Advisor looks for capacity. |
distributionPolicy.zones[].zone |
The URL of the zone. It can be a partial or full URL. For example, the following are valid values:
|
distributionPolicy.targetShape |
Target distribution shape. You can specify the following values: |
Response body
A response contains scoring recommendations.
If successful, the response body contains data with the following structure:
| JSON representation |
|---|
{ "recommendations": [ { "scores": { "obtainability": number, "estimatedUptime": string }, "shards": [ { "zone": string, "machineType": string, "instanceCount": integer, "provisioningModel": enum } ] } ] } |
| Fields | |
|---|---|
recommendations[] |
Initially the API will provide one recommendation which balances the individual scores according to the service provider's preference. |
recommendations[].scores |
Scores for the recommendation. |
recommendations[].scores.obtainability |
The obtainability score indicates the likelihood of successfully obtaining (provisioning) the requested number of VMs. The score range is 0.0 through 1.0. Higher is better. |
recommendations[].scores.estimatedUptime |
The estimated run time of the majority of Spot VMs in the request before preemption. The estimate is best-effort only. It is based on historical data and current conditions. A duration in seconds with up to nine fractional digits, ending with ' |
recommendations[].shards[] |
Shards represent blocks of uniform capacity in recommendations. |
recommendations[].shards[].zone |
Output only. The zone name for this shard. |
recommendations[].shards[].machineType |
The machine type corresponds to the instance selection in the request. |
recommendations[].shards[].instanceCount |
The number of instances. |
recommendations[].shards[].provisioningModel |
The provisioning model that you want to view recommendations for. |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/computehttps://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.
IAM Permissions
In addition to any permissions specified on the fields above, authorization requires one or more of the following IAM permissions:
compute.advice.capacity
To find predefined roles that contain those permissions, see Compute Engine IAM Roles.