本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
UpdateIndexingConfiguration与 Amazon SDK 或 CLI 配合使用
以下代码示例演示如何使用 UpdateIndexingConfiguration。
- C++
-
- SDK for C++
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 //! Update the indexing configuration. /*! \param thingIndexingConfiguration: A ThingIndexingConfiguration object which is ignored if not set. \param thingGroupIndexingConfiguration: A ThingGroupIndexingConfiguration object which is ignored if not set. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::IoT::updateIndexingConfiguration( const Aws::IoT::Model::ThingIndexingConfiguration &thingIndexingConfiguration, const Aws::IoT::Model::ThingGroupIndexingConfiguration &thingGroupIndexingConfiguration, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::IoT::IoTClient iotClient(clientConfiguration); Aws::IoT::Model::UpdateIndexingConfigurationRequest request; if (thingIndexingConfiguration.ThingIndexingModeHasBeenSet()) { request.SetThingIndexingConfiguration(thingIndexingConfiguration); } if (thingGroupIndexingConfiguration.ThingGroupIndexingModeHasBeenSet()) { request.SetThingGroupIndexingConfiguration(thingGroupIndexingConfiguration); } Aws::IoT::Model::UpdateIndexingConfigurationOutcome outcome = iotClient.UpdateIndexingConfiguration( request); if (outcome.IsSuccess()) { std::cout << "UpdateIndexingConfiguration succeeded." << std::endl; } else { std::cerr << "UpdateIndexingConfiguration failed." << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }-
有关 API 的详细信息,请参阅 适用于 C++ 的 Amazon SDK API 参考UpdateIndexingConfiguration中的。
-
- CLI
-
- Amazon CLI
-
启用事物索引
以下
update-indexing-configuration示例启用事物索引,以支持使用 Amazon_Things 索引搜索注册表数据、影子数据和事物连接状态。aws iot update-indexing-configuration --thing-indexing-configurationthingIndexingMode=REGISTRY_AND_SHADOW,thingConnectivityIndexingMode=STATUS此命令不生成任何输出。
有关更多信息,请参阅《Amazon 物联网开发人员指南》中的管理事物索引。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考UpdateIndexingConfiguration
中的。
-
- Python
-
- 适用于 Python 的 SDK(Boto3)
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 class IoTWrapper: """Encapsulates AWS IoT actions.""" def __init__(self, iot_client, iot_data_client=None): """ :param iot_client: A Boto3 AWS IoT client. :param iot_data_client: A Boto3 AWS IoT Data Plane client. """ self.iot_client = iot_client self.iot_data_client = iot_data_client @classmethod def from_client(cls): iot_client = boto3.client("iot") iot_data_client = boto3.client("iot-data") return cls(iot_client, iot_data_client) def update_indexing_configuration(self): """ Updates the AWS IoT indexing configuration to enable thing indexing. """ try: self.iot_client.update_indexing_configuration( thingIndexingConfiguration={"thingIndexingMode": "REGISTRY"} ) logger.info("Updated indexing configuration.") except ClientError as err: logger.error( "Couldn't update indexing configuration. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise-
有关 API 的详细信息,请参阅适用UpdateIndexingConfiguration于 Python 的Amazon SDK (Boto3) API 参考。
-
有关 S Amazon DK 开发者指南和代码示例的完整列表,请参阅Amazon IoT 与 Amazon SDK 一起使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。
SearchIndex
UpdateThing