使用 AWS SDK 更新 CPPO 到期日期 - AWS SDK 代码示例

AWS 文档 SDK 示例 GitHub 存储库中还有更多 AWS SDK 示例。

使用 AWS SDK 更新 CPPO 到期日期

以下代码示例演示如何更新 CPPO 的到期日期,让买家有更多时间评估和接受优惠。

Java
适用于 Java 的 SDK 2.x
注意

查看 GitHub,了解更多信息。在 AWS Marketplace API Reference Code Library 存储库中查找完整示例,了解如何进行设置和运行。

要运行此示例,请将以下 JSON 更改集传递到实用程序部分的启动更改集的实用程序中的 RunChangesets

{ "Catalog": "AWSMarketplace", "ChangeSet": [ { "ChangeType": "UpdateAvailability", "Entity": { "Type": "Offer@1.0", "Identifier": "offer-1111111111111" }, "DetailsDocument": { "AvailabilityEndDate": "2025-07-31" } } ] }
  • 有关 API 详细信息,请参阅《AWS SDK for Java 2.x API Reference》中的 StartChangeSet

Python
适用于 Python 的 SDK (Boto3)
注意

查看 GitHub,了解更多信息。在 AWS Marketplace API Reference Code Library 存储库中查找完整示例,了解如何进行设置和运行。

{ "Catalog": "AWSMarketplace", "ChangeSet": [ { "ChangeType": "UpdateAvailability", "Entity": { "Type": "Offer@1.0", "Identifier": "offer-1111111111111" }, "DetailsDocument": { "AvailabilityEndDate": "2025-07-31" } } ] }

运行此脚本以启动更改集。辅助函数在实用程序部分的启动更改集的实用程序中定义。

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 """ Purpose Shows how to use the AWS SDK for Python (Boto3) to update the expiry date of a CPPO offer """ import os import utils.start_changeset as sc import utils.stringify_details as sd def main(change_set=None): if change_set is None: fname = "changeset.json" change_set_file = os.path.join(os.path.dirname(__file__), fname) stringified_change_set = sd.stringify_changeset(change_set_file) else: stringified_change_set = change_set response = sc.usage_demo( stringified_change_set, "Update the expiry date of a CPPO offer" ) return response if __name__ == "__main__": main()
  • 有关 API 详细信息,请参阅《AWS SDK for Python (Boto3) API Reference》中的 StartChangeSet