目前,只有所选产品的基于支出的承诺可以通过该 API 购买。本方法介绍如何购买基于支出的承诺。
准备工作
为您的 Google Cloud 项目启用 Cloud Commerce Consumer Procurement API。
确保您对要用于购买承诺的 Cloud Billing 帐号拥有以下 Identity and Access Management (IAM) 角色之一:
目标 Cloud Billing 帐号或您的结算帐号所在的 Google Cloud 组织的 Billing Administrator (
roles/billing.admin
)。目标 Cloud Billing 帐号或您的结算帐号所在的 Google Cloud 组织的 Consumer Procurement Order Administrator (
roles/consumerprocurement.orderAdmin
)。
指明您要购买的优惠
如需购买基于支出的承诺,请使用优惠名称,指明您要购买的产品和折扣期限。
您可以购买以下优惠:
Product | 期限 | 优惠名称 |
---|---|---|
VMWare Engine | 1 年 | services/vmwareengine.googleapis.com/standardOffers/094acb28-d4fc-49fb-9490-0c469cc7048e |
VMWare Engine | 3 年 | services/vmwareengine.googleapis.com/standardOffers/f179581e-c899-4271-9462-9f9e0ed1526c |
Compute Engine 灵活承诺 | 1 年 | services/compute.googleapis.com/standardOffers/ffe0f6a3-2f98-437e-8d49-fc443a05d3c2 |
Compute Engine 灵活承诺 | 3 年 | services/compute.googleapis.com/standardOffers/062a285d-8989-4ce7-8f9a-bed8d183236f |
AlloyDB for PostgreSQL | 1 年 | services/alloydb.googleapis.com/standardOffers/adbca020-a973-48c9-b9b6-f5d70527790c |
AlloyDB for PostgreSQL | 3 年 | services/alloydb.googleapis.com/standardOffers/56e5948f-f1ed-45ce-84d6-a8408092e7d5 |
Cloud Bigtable | 1 年 | services/bigtable.googleapis.com/standardOffers/5a0a5567-1552-445e-9f1b-f1ac69fb0f39 |
Cloud Bigtable | 3 年 | services/bigtable.googleapis.com/standardOffers/26e8485e-acef-4e73-9a13-f0b2109befff |
Cloud Run | 1 年 | services/run.googleapis.com/standardOffers/55435965-baf5-485f-baea-3fde53566e5e |
Cloud Run | 3 年 | services/run.googleapis.com/standardOffers/a8b22b6c-2992-48d3-9b73-98fc7a47d61c |
Cloud Spanner | 1 年 | services/spanner.googleapis.com/standardOffers/29829e5f-681c-4810-a471-8e4611a8042b |
Cloud Spanner | 3 年 | services/spanner.googleapis.com/standardOffers/709f6c69-8a49-4032-97f7-ce21fe340603 |
Cloud SQL | 1 年 | services/cloudsql.googleapis.com/standardOffers/266e6a8c-2a0d-4b92-af9c-5795760f1fc9 |
Cloud SQL | 3 年 | services/cloudsql.googleapis.com/standardOffers/4998bf0a-51dd-4ce0-8405-aa529dd86d33 |
Kubernetes Engine | 1 年 | services/container.googleapis.com/standardOffers/ae2672e6-47a8-41dc-9448-6956d7f4fbc1 |
Kubernetes Engine | 3 年 | services/container.googleapis.com/standardOffers/fcf378c1-fbe0-4aaa-b05e-9597f8b45578 |
Memorystore | 1 年 | services/redis.googleapis.com/standardOffers/fe93270a-f338-4a76-b303-c323608a9d37 |
Memorystore | 3 年 | services/redis.googleapis.com/standardOffers/8f20579e-7630-4592-8fa6-0d7d3b749354 |
确定 Offer 参数
承诺有两个参数:
- 承诺金额 (
hourly_commit
):在您购买此承诺后,每小时应用于您的 Cloud Billing 帐号的赠金。 - 区域 (
region
):此承诺的赠金适用的区域。
在购买承诺时,您必须同时指定这两个参数。
产品具有特定的值并具有其参数限制。例如,如果您要购买 VMWare Engine,可以参考以下值和限制条件:
Product | 最低承诺 | 承诺数上限 | 区域 |
---|---|---|---|
VMWare Engine | 每小时 $5 | 每小时 $10,000 | asia-northeast1 asia-south1 asia-southeast1 australia-southeast1 europe-west2 europe-west3 europe-west4 northamerica-northeast northamerica-northeast1 southamerica-east1 us-central1 us-east4 us-west2 |
购买优惠
如需购买优惠,请调用 billingAccounts.orders.place
并提供以下参数:
hourly_commit
,表示承诺的货币价值。要为其购买承诺的
region
。
如需下单,请运行以下命令:
curl 'https://cloudcommerceconsumerprocurement.googleapis.com/v1alpha1/billingAccounts/BILLING_ACCOUNT_ID/orders:place' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'X-Goog-User-Project: CONSUMER_PROJECT_ID' \
-d '@-' <<EOF
{
"displayName": "DISPLAY_NAME",
"lineItemInfo": [{
"parameters": [{
"name": "hourly_commit",
"value": {
"doubleValue": HOURLY_COMMIT
}
}, {
"name": "region",
"value": {
"stringValue": "REGION"
}
}],
"offer": "OFFER_NAME"
}]
}
EOF
这将返回长时间运行的操作的名称:
{
"name": "OPERATION_NAME"
}
如需验证返回的长时间运行的操作是否成功完成,请运行以下命令:
curl 'https://cloudcommerceconsumerprocurement.googleapis.com/v1alpha1/OPERATION_NAME' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'X-Goog-User-Project: CONSUMER_PROJECT_ID'
这个长时间运行的操作应在 1 秒内完成。
查看您的订单
您可以直接在 Google Cloud 控制台中查看承诺的当前状态,也可以调用 billingAccounts.orders.get
进行查看。已创建订单的 name
字段指定订单名称。
cURL
如需查看订单,请运行以下命令:
curl 'https://cloudcommerceconsumerprocurement.googleapis.com/v1alpha1/ORDER_NAME' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'X-Goog-User-Project: CONSUMER_PROJECT_ID'
控制台
- 前往 https://console.cloud.google.com/billing。
- 选择您的 Cloud Billing 账号。
- 从边栏中选择承诺。
- 显示的表格中会显示您购买的承诺。