我有一个使用boto3创建IoT Analytics路径的python程序。我的程序能够成功创建通道和数据存储,但是当我尝试通过创建管道功能将两者连接时失败。我的代码如下:
dactivity = [{
"channel": {
"channelName": channel["channelName"],
"name": IoTAConfig["channelName"],
"next" : IoTAConfig["datastoreName"]
},
"datastore": {
"datastoreName": ds["datastoreName"],
"name": IoTAConfig["datastoreName"]
}
}]
pipeline = iota.create_pipeline(
pipelineActivities = dactivity,
pipelineName = IoTAConfig["pipelineName"]
)
错误代码如下:
Traceback (most recent call last):
File "createFullGG.py", line 478, in <module>
createIoTA()
File "createFullGG.py", line 268, in createIoTA
pipelineName = IoTAConfig["pipelineName"]
File "/usr/lib/python2.7/site-packages/botocore/client.py", line 320, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/lib/python2.7/site-packages/botocore/client.py", line 623, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidRequestException: An error occurred (InvalidRequestException) when calling the UpdatePipeline operation: PipelineActivity must have one and only one member
根据文档流水线活动可以包含1到25个条目,只要它们在1个对象的数组中即可。我不知道为什么这继续失败。任何帮助表示赞赏。
答案 0 :(得分:0)
public documentation看起来有点混乱,因为可选元素的表示方式是个好消息。
您尝试的内容的更正版本将写为;
dactivity=[
{
"channel": {
"channelName": channel["channelName"],
"name": IoTAConfig["channelName"],
"next" : IoTAConfig["datastoreName"]
}
},
{
"datastore": {
"datastoreName": ds["datastoreName"],
"name": IoTAConfig["datastoreName"]
}
}
]
response = client.create_pipeline(
pipelineActivities = dactivity,
pipelineName = IoTAConfig["pipelineName"]
)
那么,这是您要提供的一系列活动,例如[{A1},{A2}]是否可行?
有帮助吗?