使用 Cloud Commerce Consumer Procurement API 购买承诺方案

您可以使用 Cloud Commerce Consumer Procurement API(用于进行 Cloud Marketplace 购买交易的 API)购买优惠。

目前,该 API 处于预览版阶段,只能通过该 API 购买基于支出的承诺。本方法介绍了如何购买基于支出的承诺。

准备工作

识别您想要购买的优惠

如需购买基于支出的承诺,请使用优惠名称,指明您要购买的产品以及折扣期限。

以下优惠可供购买:

产品 期限 优惠名称
VMWare 引擎 1 年 services/vmwareengine.googleapis.com/standardOffers/094acb28-d4fc-49fb-9490-0c469cc7048e
VMWare 引擎 3 年 services/vmwareengine.googleapis.com/standardOffers/f179581e-c899-4271-9462-9f9e0ed1526c

确定优惠参数

承诺有两个参数:

  • 承诺金额 (hourly_commit):在您购买此承诺后每小时向您的 Cloud Billing 帐号发放的赠金。
  • 区域 (region):此承诺的适用区域。

购买承诺时,您必须指定两个参数。

商品的参数有具体值和限制。例如,如果您要购买 VMWare Engine,则可以参阅以下值和限制条件:

产品 最低承诺使用期限 最高承诺 区域
VMWare 引擎 每小时 5 美元 $10000/小时 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 'http://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 'http://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 Console 中或通过调用 billingAccounts.orders.get 查看承诺的当前状态。所创建的订单的 name 字段指定订单名称。

cURL

如需查看订单,请运行以下命令:

curl 'http://cloudcommerceconsumerprocurement.googleapis.com/v1alpha1/ORDER_NAME' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer ACCESS_TOKEN' \
    --header 'X-Goog-User-Project: CONSUMER_PROJECT_ID'

控制台

  1. 转到 http://console.cloud.go888ogle.com.fqhub.com/billing
  2. 选择您的 Cloud Billing 帐号。
  3. 从边栏中选择承诺
  4. 您购买的承诺会显示在显示的表格中。