D AWS oc AWS SDK 示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
为现有 AMI 产品添加维度并使用更新优惠定价条款 AWS SDK
以下代码示例演示如何为现有 AMI 产品添加维度并更新优惠定价条款。
- Java
-
- 适用于 Java 的 SDK 2.x
-
注意
还有更多相关信息 GitHub。在 AWS Marketplace API Reference Code Library
存储库中查找完整示例,了解如何进行设置和运行。 要运行此示例,请将以下 JSON 更改集传递到实用程序部分的启动更改集的实用程序中的
RunChangesets。{ "Catalog": "AWSMarketplace", "ChangeSet": [ { "ChangeType": "AddDimensions", "Entity": { "Identifier": "prod-1111111111111", "Type": "AmiProduct@1.0" }, "DetailsDocument": [ { "Key": "m7g.8xlarge", "Description": "m7g.8xlarge", "Name": "m7g.8xlarge", "Types": [ "Metered" ], "Unit": "Hrs" } ] }, { "ChangeType": "UpdatePricingTerms", "Entity": { "Type": "Offer@1.0", "Identifier": "offer-1111111111111" }, "DetailsDocument": { "PricingModel": "Usage", "Terms": [ { "Type": "UsageBasedPricingTerm", "CurrencyCode": "USD", "RateCards": [ { "RateCard": [ { "DimensionKey": "m5.large", "Price": "0.15" }, { "DimensionKey": "m7g.4xlarge", "Price": "0.45" }, { "DimensionKey": "m7g.2xlarge", "Price": "0.45" }, { "DimensionKey": "m7g.8xlarge", "Price": "0.55" } ] } ] } ] } } ] }-
有关 API 的详细信息,请参阅 AWS SDK for Java 2.x API 参考StartChangeSet中的。
-
- Python
-
- 适用于 Python 的 SDK(Boto3)
-
注意
还有更多相关信息 GitHub。在 AWS Marketplace API Reference Code Library
存储库中查找完整示例,了解如何进行设置和运行。 { "Catalog": "AWSMarketplace", "ChangeSet": [ { "ChangeType": "AddDimensions", "Entity": { "Identifier": "prod-1111111111111", "Type": "AmiProduct@1.0" }, "DetailsDocument": [ { "Key": "m7g.8xlarge", "Description": "m7g.8xlarge", "Name": "m7g.8xlarge", "Types": [ "Metered" ], "Unit": "Hrs" } ] }, { "ChangeType": "UpdatePricingTerms", "Entity": { "Type": "Offer@1.0", "Identifier": "offer-1111111111111" }, "DetailsDocument": { "PricingModel": "Usage", "Terms": [ { "Type": "UsageBasedPricingTerm", "CurrencyCode": "USD", "RateCards": [ { "RateCard": [ { "DimensionKey": "m5.large", "Price": "0.15" }, { "DimensionKey": "m7g.4xlarge", "Price": "0.45" }, { "DimensionKey": "m7g.2xlarge", "Price": "0.45" }, { "DimensionKey": "m7g.8xlarge", "Price": "0.55" } ] } ] } ] } } ] }运行此脚本以启动更改集。辅助函数在实用程序部分的启动更改集的实用程序中定义。
# 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 add a dimension to an existing AMI product and update the offer pricing terms. CAPI-23 """ import os import utils.start_changeset as sc import utils.stringify_details as sd fname = "changeset.json" change_set_file = os.path.join(os.path.dirname(__file__), fname) change_set = sd.stringify_changeset(change_set_file) def main(): sc.usage_demo(change_set, "Add dimension for AMI product") if __name__ == "__main__": main()-
有关 API 的详细信息,请参阅适用StartChangeSet于 Python 的AWS SDK (Boto3) API 参考。
-
AMI 产品
添加部署 AMI 产品的区域