

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

# CreateEntity
<a name="API_CreateEntity"></a>

创建一个实体。

## 请求语法
<a name="API_CreateEntity_RequestSyntax"></a>

```
POST /workspaces/workspaceId/entities HTTP/1.1
Content-type: application/json

{
   "components": { 
      "string" : { 
         "componentTypeId": "string",
         "description": "string",
         "properties": { 
            "string" : { 
               "definition": { 
                  "configuration": { 
                     "string" : "string" 
                  },
                  "dataType": { 
                     "allowedValues": [ 
                        { 
                           "booleanValue": boolean,
                           "doubleValue": number,
                           "expression": "string",
                           "integerValue": number,
                           "listValue": [ 
                              "DataValue"
                           ],
                           "longValue": number,
                           "mapValue": { 
                              "string" : "DataValue"
                           },
                           "relationshipValue": { 
                              "targetComponentName": "string",
                              "targetEntityId": "string"
                           },
                           "stringValue": "string"
                        }
                     ],
                     "nestedType": "DataType",
                     "relationship": { 
                        "relationshipType": "string",
                        "targetComponentTypeId": "string"
                     },
                     "type": "string",
                     "unitOfMeasure": "string"
                  },
                  "defaultValue": { 
                     "booleanValue": boolean,
                     "doubleValue": number,
                     "expression": "string",
                     "integerValue": number,
                     "listValue": [ 
                        "DataValue"
                     ],
                     "longValue": number,
                     "mapValue": { 
                        "string" : "DataValue"
                     },
                     "relationshipValue": { 
                        "targetComponentName": "string",
                        "targetEntityId": "string"
                     },
                     "stringValue": "string"
                  },
                  "displayName": "string",
                  "isExternalId": boolean,
                  "isRequiredInEntity": boolean,
                  "isStoredExternally": boolean,
                  "isTimeSeries": boolean
               },
               "updateType": "string",
               "value": { 
                  "booleanValue": boolean,
                  "doubleValue": number,
                  "expression": "string",
                  "integerValue": number,
                  "listValue": [ 
                     "DataValue"
                  ],
                  "longValue": number,
                  "mapValue": { 
                     "string" : "DataValue"
                  },
                  "relationshipValue": { 
                     "targetComponentName": "string",
                     "targetEntityId": "string"
                  },
                  "stringValue": "string"
               }
            }
         },
         "propertyGroups": { 
            "string" : { 
               "groupType": "string",
               "propertyNames": [ "string" ],
               "updateType": "string"
            }
         }
      }
   },
   "compositeComponents": { 
      "string" : { 
         "description": "string",
         "properties": { 
            "string" : { 
               "definition": { 
                  "configuration": { 
                     "string" : "string" 
                  },
                  "dataType": { 
                     "allowedValues": [ 
                        { 
                           "booleanValue": boolean,
                           "doubleValue": number,
                           "expression": "string",
                           "integerValue": number,
                           "listValue": [ 
                              "DataValue"
                           ],
                           "longValue": number,
                           "mapValue": { 
                              "string" : "DataValue"
                           },
                           "relationshipValue": { 
                              "targetComponentName": "string",
                              "targetEntityId": "string"
                           },
                           "stringValue": "string"
                        }
                     ],
                     "nestedType": "DataType",
                     "relationship": { 
                        "relationshipType": "string",
                        "targetComponentTypeId": "string"
                     },
                     "type": "string",
                     "unitOfMeasure": "string"
                  },
                  "defaultValue": { 
                     "booleanValue": boolean,
                     "doubleValue": number,
                     "expression": "string",
                     "integerValue": number,
                     "listValue": [ 
                        "DataValue"
                     ],
                     "longValue": number,
                     "mapValue": { 
                        "string" : "DataValue"
                     },
                     "relationshipValue": { 
                        "targetComponentName": "string",
                        "targetEntityId": "string"
                     },
                     "stringValue": "string"
                  },
                  "displayName": "string",
                  "isExternalId": boolean,
                  "isRequiredInEntity": boolean,
                  "isStoredExternally": boolean,
                  "isTimeSeries": boolean
               },
               "updateType": "string",
               "value": { 
                  "booleanValue": boolean,
                  "doubleValue": number,
                  "expression": "string",
                  "integerValue": number,
                  "listValue": [ 
                     "DataValue"
                  ],
                  "longValue": number,
                  "mapValue": { 
                     "string" : "DataValue"
                  },
                  "relationshipValue": { 
                     "targetComponentName": "string",
                     "targetEntityId": "string"
                  },
                  "stringValue": "string"
               }
            }
         },
         "propertyGroups": { 
            "string" : { 
               "groupType": "string",
               "propertyNames": [ "string" ],
               "updateType": "string"
            }
         }
      }
   },
   "description": "string",
   "entityId": "string",
   "entityName": "string",
   "parentEntityId": "string",
   "tags": { 
      "string" : "string" 
   }
}
```

## URI 请求参数
<a name="API_CreateEntity_RequestParameters"></a>

请求使用以下 URI 参数。

 ** [workspaceId](#API_CreateEntity_RequestSyntax) **   <a name="tm-CreateEntity-request-uri-workspaceId"></a>
包含实体的工作区 ID。  
长度限制：最小长度为 1。最大长度为 128。  
模式：`[a-zA-Z_0-9][a-zA-Z_\-0-9]*[a-zA-Z0-9]+`  
必需：是

## 请求体
<a name="API_CreateEntity_RequestBody"></a>

请求接受采用 JSON 格式的以下数据。

 ** [components](#API_CreateEntity_RequestSyntax) **   <a name="tm-CreateEntity-request-components"></a>
将字符串映射到实体中的组件的对象。映射中的每个字符串对于该对象都必须是唯一的。  
类型：字符串到 [ComponentRequest](API_ComponentRequest.md) 对象的映射  
密钥长度限制：最小长度为 1。最大长度为 256。  
密钥模式：`[a-zA-Z_\-0-9]+`  
必需：否

 ** [compositeComponents](#API_CreateEntity_RequestSyntax) **   <a name="tm-CreateEntity-request-compositeComponents"></a>
这是一个将字符串映射到请求中 `compositeComponent` 更新的对象。映射的每个键都代表 `compositeComponent` 的 `componentPath`。  
类型：字符串到 [CompositeComponentRequest](API_CompositeComponentRequest.md) 对象的映射  
密钥长度限制：最小长度为 1。最大长度为 2048。  
密钥模式：`[a-zA-Z_\-0-9/]+`  
必需：否

 ** [description](#API_CreateEntity_RequestSyntax) **   <a name="tm-CreateEntity-request-description"></a>
实体的描述。  
类型：字符串  
长度约束：最小长度为 0。最大长度为 2048。  
模式：`.*`  
必需：否

 ** [entityId](#API_CreateEntity_RequestSyntax) **   <a name="tm-CreateEntity-request-entityId"></a>
实体的 ID。  
类型：字符串  
长度限制：最小长度为 1。最大长度为 128。  
模式：`[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|^[a-zA-Z0-9][a-zA-Z_\-0-9.:]*[a-zA-Z0-9]+`  
必需：否

 ** [entityName](#API_CreateEntity_RequestSyntax) **   <a name="tm-CreateEntity-request-entityName"></a>
实体名称。  
类型：字符串  
长度限制：最小长度为 1。最大长度为 256。  
模式：`[^\u0000-\u001F\u007F]+`  
是否必需：是

 ** [parentEntityId](#API_CreateEntity_RequestSyntax) **   <a name="tm-CreateEntity-request-parentEntityId"></a>
实体的父实体 ID。  
类型：字符串  
长度限制：最小长度为 1。最大长度为 128。  
模式：`\$ROOT|^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|^[a-zA-Z0-9][a-zA-Z_\-0-9.:]*[a-zA-Z0-9]+`  
必需：否

 ** [tags](#API_CreateEntity_RequestSyntax) **   <a name="tm-CreateEntity-request-tags"></a>
可用于管理实体的元数据。  
类型：字符串到字符串映射  
映射条目：最低 0 项。最多 50 项。  
密钥长度限制：最小长度为 1。最大长度为 128。  
键模式：`([\p{L}\p{Z}\p{N}_.:/=+\-@]*)`  
值长度限制：最小长度为 1。最大长度为 256。  
价值模式：`.*`  
必需：否

## 响应语法
<a name="API_CreateEntity_ResponseSyntax"></a>

```
HTTP/1.1 200
Content-type: application/json

{
   "arn": "string",
   "creationDateTime": number,
   "entityId": "string",
   "state": "string"
}
```

## 响应元素
<a name="API_CreateEntity_ResponseElements"></a>

如果此操作成功，则该服务将会发送回 HTTP 200 响应。

服务以 JSON 格式返回以下数据。

 ** [arn](#API_CreateEntity_ResponseSyntax) **   <a name="tm-CreateEntity-response-arn"></a>
实体的 ARN。  
类型：字符串  
长度约束：最小长度为 20。最大长度为 2048。  
模式：`arn:((aws)|(aws-cn)|(aws-us-gov)):iottwinmaker:[a-z0-9-]+:[0-9]{12}:[\/a-zA-Z0-9_\-\.:]+`

 ** [creationDateTime](#API_CreateEntity_ResponseSyntax) **   <a name="tm-CreateEntity-response-creationDateTime"></a>
创建实体的日期和时间。  
类型：时间戳

 ** [entityId](#API_CreateEntity_ResponseSyntax) **   <a name="tm-CreateEntity-response-entityId"></a>
实体的 ID。  
类型：字符串  
长度限制：最小长度为 1。最大长度为 128。  
模式：`[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|^[a-zA-Z0-9][a-zA-Z_\-0-9.:]*[a-zA-Z0-9]+`

 ** [state](#API_CreateEntity_ResponseSyntax) **   <a name="tm-CreateEntity-response-state"></a>
实体的当前状态。  
类型：字符串  
有效值：`CREATING | UPDATING | DELETING | ACTIVE | ERROR`

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

有关所有操作的常见错误的信息，请参阅[常见错误](CommonErrors.md)。

 ** AccessDeniedException **   
访问被拒绝。  
HTTP 状态代码：403

 ** ConflictException **   
发生冲突。  
HTTP 状态代码：409

 ** InternalServerException **   
出现意外错误。  
HTTP 状态代码：500

 ** ServiceQuotaExceededException **   
已超出服务限额。  
HTTP 状态代码：402

 ** ThrottlingException **   
速率超过限制。  
HTTP 状态代码：429

 ** ValidationException **   
失败  
HTTP 状态代码：400

## 另请参阅
<a name="API_CreateEntity_SeeAlso"></a>

有关以特定语言之一使用此 API 的更多信息 AWS SDKs，请参阅以下内容：
+  [AWS 命令行界面 V2](https://docs.aws.amazon.com/goto/cli2/iottwinmaker-2021-11-29/CreateEntity) 
+  [AWS 适用于.NET 的 SDK V4](https://docs.aws.amazon.com/goto/DotNetSDKV4/iottwinmaker-2021-11-29/CreateEntity) 
+  [AWS 适用于 C\$1\$1 的 SDK](https://docs.aws.amazon.com/goto/SdkForCpp/iottwinmaker-2021-11-29/CreateEntity) 
+  [AWS 适用于 Go v2 的 SDK](https://docs.aws.amazon.com/goto/SdkForGoV2/iottwinmaker-2021-11-29/CreateEntity) 
+  [AWS 适用于 Java 的 SDK V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/iottwinmaker-2021-11-29/CreateEntity) 
+  [AWS JavaScript V3 版 SDK](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/iottwinmaker-2021-11-29/CreateEntity) 
+  [AWS 适用于 Kotlin 的 SDK](https://docs.aws.amazon.com/goto/SdkForKotlin/iottwinmaker-2021-11-29/CreateEntity) 
+  [AWS 适用于 PHP 的 SDK V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/iottwinmaker-2021-11-29/CreateEntity) 
+  [AWS Python 软件开发工具包](https://docs.aws.amazon.com/goto/boto3/iottwinmaker-2021-11-29/CreateEntity) 
+  [AWS 适用于 Ruby V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForRubyV3/iottwinmaker-2021-11-29/CreateEntity) 