

AWS Marketplace API 参考已重组。有关支持的 API 操作的更多信息，请参阅 [AWS Marketplace API 参考](https://docs.aws.amazon.com/marketplace/latest/APIReference/Welcome.html)。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 添加新版本
<a name="ml-add-version"></a>

您可以使用目录 API 或 AWS Marketplace 管理门户向机器学习产品添加新版本。有关使用门户的更多信息，请参阅 *AWS Marketplace 卖家指南*中的[添加新版本](https://docs.aws.amazon.com/marketplace/latest/userguide/machine-learning-products.html)。

**注意**  
对于机器学习产品，版本由单一配送选项组成，该选项代表您提供的产品。在目录 API 中，使用机器学习产品的配送选项可以有效地修改产品的版本。  
添加新的实例类型时，请在`UpdatePricingTerms`更改集中加入更改类型，以指定新实例类型的定价。对于新产品，`UpdatePricingTerms`必须涵盖所有支持的实例类型。 `UpdatePricingDimensions`不是 ML 产品所必需或不支持的，因为维度是为所有支持的实例类型自动生成的。有关更多信息，请参阅[更新定价维度](work-with-seller-products.md#update-dimensions)。

**`StartChangeSet`用于添加版本**

 要添加新版本，请使用`AddDeliveryOptions`更改类型调用该`StartChangeSet`操作：

1.  要在不创建版本的情况下验证您的 API 调用，请将设置`Intent`为`VALIDATE`。

1.  要创建实际版本，`Intent`请设置为`APPLY`。

## 请求语法
<a name="request-syntax"></a>

```
POST /StartChangeSet HTTP/1.1
Content-type: application/json
{
    "Catalog": "AWSMarketplace",
    "ChangeSet": [{
        "ChangeType": "AddDeliveryOptions",
        "Entity": {
            "Identifier": "example1-abcd-1234-5ef6-7890abcdef12@1",
            "Type": "MachineLearningProduct@1.0"
        },
        "DetailsDocument": {
            "Version": {
                "VersionTitle": "version 1.1",
                "ReleaseNotes": "Patch update for small bugfix in version 1.0"
            },
            "DeliveryOptions": [{
                "Details": {
                    "SageMakerAlgorithmDeliveryOptionDetails": {
                       "SageMakerAlgorithmArn": "arn:aws:sagemaker:us-east-2:605142612156:algorithm/scikit-decision-trees-1552343220",
                       "AccessRoleArn": "arn:aws:iam::12345678901:role/AwsMarketplaceSageMakerIngestion",
                        "UsageInstructions":"This is how you use your algorithm", 
                       "SampleNotebookUrl": "https://www.amazon.com",
                        "RepositoryUrl": "https://www,amazon.com",
                        "InputProperties": {
                            "Description": "Input should have all columns in the train/test file except for 'is_fraud' column.",
                            "Limitations": "Can predict on 1 input in the CSV only at a time",
                           "SampleInput": {
                                "RealtimeInferenceText": "{\"prompt\":\"Write summary\",
                                                            \"maxTokens\": 1 }",
                                "BatchTransformUrl": "https://www.sampleData.com",
                            },
                           "Parameters": [{
                                    "Name": "prompt",
                                    "Description": "Represents the instruct-style prompt for the model. DataType is String",
                                    "Constraints": "Minimum length should be 1",
                                    "Required": true
                                },
                                {
                                    "Name": "maxTokens",
                                    "Description": "Denotes the number of tokens to predict per generation. See BPE Tokens for more details.",
                                    "Constraints": "Minvalue: 1, MaxValue: 30"
                                }
                            ],
                            "SageMakerCustomAttributes": [{
                                    "Name": "threshold",
                                    "Description": "Threshold of the confidence score of the detected object",
                                    "Constraints": "Should be an Integer"
                            }]
                    },
                    "OutputProperties": {
                        "Description": "The output is a JSON object that has the generated text along with likelihoods of tokens, if requested. See example json.",
                       "SampleOutput": {
                            "RealtimeInferenceUrl": "https://www.sampledata.com",
                            "BatchTransformUrl": "https://www.sampleData.com",
                        },
                       "Parameters": [{
                                "Name": "id",
                                "Description": "An identifier for response"
                                "AlwaysReturned": true
                            },
                            {
                                "Name": "generations",
                                "Description": "The generated text along with the likelihoods for tokens requested.",
                            }
                        ],
                    },
                   "RecommendedInstanceTypes": {
                        "BatchTransform": "ml.m4.large",
                        "RealtimeInference": "ml.m4.large",
                        "Training": "ml.m4.large"
                   }
                }
            }]
        }
    }],
    "Intent": "APPLY"
}
```

## 必填字段
<a name="add-version-required-fields"></a>
+  `Entity`（对象）-必填 

  包含有关您的机器学习产品的信息。
  +  `Identifier`（字符串）-必填 

    您的产品编号。有关更多信息，请参阅[标识符](https://docs.aws.amazon.com/marketplace/latest/APIReference/catalog-apis.html#identifier)。
  +  `Type`（字符串）-必填 

    指定配送方式（产品类型）。它必须是 `MachineLearningProduct@1.0`。
+ `DetailsDocument`（对象）-必填

  包含有关您的产品新版本的所有详细信息。
  + `Version`（对象）-必填

    有关正在添加的版本的详细信息。
    + `VersionTitle`（字符串）-必填

      版本的标题，例如 “版本 1.1” 或 “1.1”。买家从这些书中选择版本。
    + `ReleaseNotes`（字符串）-必填

      有关此版本的详细说明。必须少于 30,000 个字符。
  + `DeliveryOptions`（数组）-必填

    适用于您的产品版本的一系列交付方式。每个版本仅限一个交付选项。
    + `Details`（对象）-必填
      + `SagemakerModelPackageDeliveryOptionDetails`或`SageMakerAlgorithmDeliveryOptionDetails`（对象）
        + `SageMakerModelPackageArn`或`SageMakerAlgorithmArn`（字符串）-必填

          您的模型包或算法的亚马逊资源名称 (ARN)。
        + `AccessRoleArn`（字符串）-必填 

          AWS Marketplace 的 IAM 角色 ARN 用于访问资源。 SageMaker 
        + `SampleNotebookUrl`（字符串）-必填 

          链接到带有使用代码的 Jupyter 笔记本示例。有关更多信息，请参阅上的[示例笔记本模板](https://github.com/aws/amazon-sagemaker-examples/blob/master/aws_marketplace/curating_aws_marketplace_listing_and_sample_notebook/ModelPackage/Sample_Notebook_Template/title_of_your_product-Model.ipynb) GitHub。
        + `RepositoryUrl`（字符串）-必填 

          用于访问笔记本和示例数据的 Git 存储库 URL。有关更多信息，请参阅上的 [Git 存储库示例](https://github.com/aws/amazon-sagemaker-examples/tree/master/aws_marketplace/curating_aws_marketplace_listing_and_sample_notebook/ModelPackage/Sample_Notebook_Template) GitHub。
        + `UsageInstructions`（字符串）-必填 

          算法的训练信息或模型的使用细节。
        + `InputProperties`（对象）-必填
          + `Description`（字符串）-必填 

             model/algorithm 输入描述
          + `Limitations`（字符串） 

            输入限制
          + `SampleInput`（对象）-必填

            RealtimeInferenceUrl （字符串）\| RealtimeInferenceText （字符串）\| BatchTransformUrl（字符串）\| BatchTransformText （字符串）
          + `Parameters`（数组<Object>）

            名称（字符串）—必填 \| 描述（字符串）—必填 \| 约束（字符串）\| 必需（布尔值）
          + `SageMakerCustomAttributes`（数组<Object>）

            描述您的模型[CustomAttributes](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_runtime_InvokeEndpoint.html#API_runtime_InvokeEndpoint_RequestParameters)支持的任何内容。

            `Name`（字符串）—必填项 \|`Description`（字符串）—必填项 \|`Constraints`（字符串）\|`Required`（布尔值）
        + `OutputProperties`（对象）-必填
          + `Description`（字符串）-必填
          + `SampleOutput`（数组<Object>）-必填

            RealtimeInferenceUrl （字符串）\| RealtimeInferenceText （字符串）\| BatchTransformUrl（字符串）\| BatchTransformText （字符串）
          + `Parameters`（数组）

            名称（字符串）—必填 \| 描述（字符串）—必填 \| AlwaysReturned（布尔值）
        + `RecommendedInstanceTypes`（对象）-必填
          + `BatchTransform`（字符串）-必填
          + `RealtimeInference`（字符串）-必填
          + `Training`（字符串）-仅适用于 SageMaker算法

## 响应语法
<a name="response-syntax"></a>

当您提交请求时，系统会创建一个更改集，API 会返回：

```
{
  "ChangeSetId": "{{example123456789012abcdef}}",
   "ChangeSetArn": "arn:aws:aws-marketplace:us-east-1:{{123456789012}}:AWSMarketplace/ChangeSet/{{example123456789012abcdef}}"
}
```

**变更集处理**  
变更请求进入处理队列，在那里它会经历几个步骤：

1. 验证：系统会进行检查以确保所有信息都符合 AWS Marketplace 指导方针。
   +  处理时间：几分钟到几小时 
   +  有关验证错误，请参阅[更改集合状态和错误](https://docs.aws.amazon.com/marketplace/latest/APIReference/work-with-seller-products.html#seller-product-change-set-errors)。

1.  状态监控：您可以通过两种方式检查请求的状态。
   + 通过 AWS Marketplace 管理门户
   + 使用 `DescribeChangeSet` 操作

1.  完成：获得批准后，将添加新版本。

## 错误
<a name="errors"></a>

**异步错误**  
 以下错误特定于 AWS Marketplace 目录 API 中的`AddDeliveryOptions`操作。当您在处理更改集`DescribeChangeSet`时调用时，会出现这些错误。有关使用`DescribeChangeSet`检查变更请求状态的更多信息，请参阅[使用变更集](https://docs.aws.amazon.com/marketplace-catalog/latest/api-reference/welcome.html#working-with-change-sets)。




| 错误代码 | 错误消息 | 
| --- | --- | 
| 不兼容产品状态 | 我们找不到提供的产品。提供有效的产品。 | 
| 重复版本标题 | 提供的版本标题已在使用中。创建唯一的版本标题。 | 
| 无效\_推荐\_实例\_类型 | 您没有为 [x] 提供有效的实例类型。请输入有效的实例类型，然后重试。有效类型为：[有效] | 
| 不兼容的配送选项 | 您提供的配送选项与您之前的选择：[之前的选择] 不匹配。更新您的配送选项，然后重试。 | 
| INVALID\_ASSET\_ARN | 您没有为提供有效的 ARN。 SageMakerAlgorithmDeliveryOption请输入有效的 ARN 并重试。 | 
| 复制资产 | 您没有为此商品提供唯一的 ARN。请输入唯一的 ARN，然后重试。 | 
| 未找到资产 | 我们找不到您提供的 ARN。验证 ARN 是否正确且具有所需的权限。 | 
| 资产验证异常 | 无法向 AWS Sagemaker 账户提取 SagemakerModelArn/SagemakerAlgorithmArn [x] | 
| 无效的访问权限 | 我们找不到您提供的 IAM 角色 ARN。请验证 ARN 是否正确，然后重试。 | 
| 需要更新定价 | UpdatePricingTerms 是必填的。 | 