使用 API 购买基于支出的承诺

本文档介绍了如何使用 Cloud Commerce Consumer Procurement API 购买基于支出的承诺,以用于 Cloud Marketplace 购买。

此 API 仅支持购买基于支出的承诺,不支持购买基于资源的承诺。

准备工作

确定要购买的优惠

如需购买基于支出的承诺,请使用优惠名称,该名称应指明您要购买的产品和折扣期限,并且必须与您的 Cloud Billing 帐号的模式相符。

以下优惠可供购买,并遵循新的使用模式(直接折扣,无赠金)

产品 术语 范围 优惠名称 必需参数
AlloyDB for PostgreSQL 1 年 全球 services/alloydb.googleapis.com/standardOffers/ff04ec3e-278c-4ec8-8278-12f875a8cea2 commitment_amount(推荐)
hourly_commit
AlloyDB for PostgreSQL 3 年 全球 services/alloydb.googleapis.com/standardOffers/9522b4d8-bff7-4141-81d6-b71d9113c69a commitment_amount(推荐)
hourly_commit
Backup and DR (Oracle) 1 年 全球 services/backupdr.googleapis.com/standardOffers/16e6132e-8a72-4a7f-8941-bf52246afc82 commitment_amount(推荐)
hourly_commit
Backup and DR (Oracle) 3 年 全球 services/backupdr.googleapis.com/standardOffers/1e028b05-4344-4bca-87e7-235ee3536354 commitment_amount(推荐)
hourly_commit
BigQuery 1 年 区域 services/bigqueryreservation.googleapis.com/standardOffers/d73ae4d8-d096-4c9b-9c20-cd92c3c53724 commitment_amount(推荐)
hourly_commit,

region
BigQuery 3 年 区域 services/bigqueryreservation.googleapis.com/standardOffers/f43d480d-3e77-4079-946c-e1b2ab640a8a commitment_amount(推荐)
hourly_commit,

region
Bigtable 1 年 全球 services/bigtable.googleapis.com/standardOffers/c0bf8ba5-65ee-4f7d-9e1e-3953433cf193 commitment_amount(推荐)
hourly_commit
Bigtable 3 年 全球 services/bigtable.googleapis.com/standardOffers/460fb2ef-456d-4263-a070-4f993fa37996 commitment_amount(推荐)
hourly_commit
Cloud Run 3 年 区域 services/run.googleapis.com/standardOffers/88a5fc51-d63b-4865-bf3b-c49e05a8c5c0 commitment_amount(推荐)
hourly_commit,

region
Cloud Run 区域 services/run.googleapis.com/standardOffers/392802d4-e57b-40d3-9684-a1e8cdca6fb5 commitment_amount(推荐)
hourly_commit,

region
Cloud SQL 1 年 区域 services/cloudsql.googleapis.com/standardOffers/d31cf078-36a2-4a8a-a2e6-b23caec0e7a3 commitment_amount(推荐)
hourly_commit,

region
Cloud SQL 3 年 区域 services/cloudsql.googleapis.com/standardOffers/48960309-1646-4fa2-9bf8-d7e72090d2b8 commitment_amount(推荐)
hourly_commit,

region
Compute Engine 灵活承诺 1 年 全球 services/compute.googleapis.com/standardOffers/1b2601a4-9d76-462d-bd5b-5b835d245f93 commitment_amount(推荐)
hourly_commit
Compute Engine 灵活承诺 3 年 全球 services/compute.googleapis.com/standardOffers/61612674-a9a9-4687-8449-baca71fbd0d1 commitment_amount(推荐)
hourly_commit
Dataflow 1 年 全球 services/dataflow.googleapis.com/standardOffers/127d79e4-1d52-48b0-9f31-8ba02586ff95 commitment_amount(推荐)
hourly_commit
Dataflow 3 年 全球 services/dataflow.googleapis.com/standardOffers/03f4d3b1-44b8-4e88-9e75-b1d4e2d04573 commitment_amount(推荐)
hourly_commit
Firestore 1 年 全球 services/firestore.googleapis.com/standardOffers/de6aa077-3170-4250-89b6-0ccd470f9e21 commitment_amount(推荐)
hourly_commit
Firestore 3 年 全球 services/firestore.googleapis.com/standardOffers/e8f59240-c088-4a22-87c3-e58722cca300 commitment_amount(推荐)
hourly_commit
Gemini Enterprise Flexible Savings Plan 1 年 全球 services/aiplatform.googleapis.com/standardOffers/740fd2e8-ff1d-4304-9e85-61c0f8d75811 commitment_amount
Gemini Enterprise Flexible Savings Plan 3 年 全球 services/aiplatform.googleapis.com/standardOffers/4733352d-24b5-4609-b3ff-d2a694f51654 commitment_amount
Google Kubernetes Engine 1 年 区域 services/container.googleapis.com/standardOffers/2f48e468-a86a-452d-88df-edacd94a3c44 commitment_amount(推荐)
hourly_commit,

region
Google Kubernetes Engine 3 年 区域 services/container.googleapis.com/standardOffers/89027902-6f83-40aa-8861-7c2446b11015 commitment_amount(推荐)
hourly_commit,

region
Managed Service for Apache Kafka 1 年 全球 services/managedkafka.googleapis.com/standardOffers/647db981-009c-4e95-b62e-6aff19384956 commitment_amount(推荐)
hourly_commit
Managed Service for Apache Kafka 3 年 全球 services/managedkafka.googleapis.com/standardOffers/9a7ed994-d3df-4680-b4e6-7c3d932add66 commitment_amount(推荐)
hourly_commit
Memorystore for Redis 1 年 全球 services/redis.googleapis.com/standardOffers/8e0da7cb-196b-4351-bc32-6a6ba94f1456 commitment_amount(推荐)
hourly_commit
Memorystore 3 年 全球 services/redis.googleapis.com/standardOffers/2a3729ac-1e38-4a34-bc96-bd988028351f commitment_amount(推荐)
hourly_commit
Spanner 1 年 全球 services/spanner.googleapis.com/standardOffers/359db5c2-8c2c-49e3-a21d-26176c4cd403 commitment_amount(推荐)
hourly_commit
Spanner 3 年 全球 services/spanner.googleapis.com/standardOffers/a6a32e10-1d76-4df8-8485-eee10d08a1cf commitment_amount(推荐)
hourly_commit

以下优惠可供购买,并遵循旧版赠金模式(标价收费 + 赠金抵扣)

产品 术语 范围 优惠名称 必需参数
Backup and DR (VMWare) 1 年 区域 services/backupdr.googleapis.com/standardOffers/30c7e770-724f-4a7d-8369-b726a397b53a hourly_commit,

region
Backup and DR (VMWare) 3 年 区域 services/backupdr.googleapis.com/standardOffers/6748e93c-4114-4fa2-bf3e-cb4d3534bb48 hourly_commit,

region
NetApp Volumes 1 年 全球 services/netapp.googleapis.com/standardOffers/90520cfa-14b6-42ae-92b9-129671bf2aca hourly_commit
NetApp Volumes 3 年 全球 services/netapp.googleapis.com/standardOffers/c852fef8-e699-4524-90f4-e7b89edeb33c hourly_commit

确定优惠参数

以下是您应设置的参数,以便购买优惠:

  • Commitment_amount(推荐)或 Hourly_commit

    • 对于基于支出的新 CUD 模式下的承诺commitment_amount(推荐)或 hourly_commit。最终,hourly_commit 参数将被弃用,并将在未来被通用 commitment_amount 参数取代,以用于新模式下的承诺。某些 CUD 支持不同的重复周期(每小时、每月等),并且仅支持 commitment_amount 参数,请查看优惠表格中的“必需参数”列,了解具体要求。

    • 对于不受新 CUD 模式影响的优惠:指定 hourly_commit。这表示每小时应用于 Cloud Billing 帐号的赠金。旧版 CUD 不支持 commitment_amount

  • 区域 (region):此承诺的优惠适用的区域。

    • 对于区域承诺:指定目标区域(例如 us-central1)。如需查找每个产品的文件夹和支持的区域,请参阅相应产品的文档或承诺使用折扣概览
    • 对于全球承诺:省略此参数,因为全球承诺适用于所有区域。

购买优惠

如需购买优惠,请调用 billingAccounts.orders.place, 并在请求正文中提供以下参数:

  • 与您的 CUD 类型匹配的承诺值参数:

    • 对于基于支出的新 CUD 模式下的承诺:提供 commitment_amount(推荐)或 hourly_commit(已弃用,未来将被移除)。对于新的 CUD 优惠(例如 AI Platform),您必须指定 commitment_amount
    • 对于旧版 CUD:提供 hourly_commit
  • region(仅适用于区域承诺)。如果您要购买全球承诺,请省略 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": "commitment_amount",
        "value": {
            "doubleValue": COMMITMENT_AMOUNT
        }
        }, {
        "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'

长时间运行的操作应在一秒内完成。

查看订单

您可以直接在 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'

控制台

  1. 在 Google Cloud 控制台中,进入您的 Cloud Billing 帐号。

    进入您的 Cloud Billing 账号

  2. 从边栏中选择承诺使用折扣 (CUD)

  3. 系统会显示您购买的承诺。