本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
DeleteTopicRule与 Amazon SDK 或 CLI 配合使用
以下代码示例演示如何使用 DeleteTopicRule。
- C++
-
- SDK for C++
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 //! Delete an AWS IoT rule. /*! \param ruleName: The name for the rule. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::IoT::deleteTopicRule(const Aws::String &ruleName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::IoT::IoTClient iotClient(clientConfiguration); Aws::IoT::Model::DeleteTopicRuleRequest request; request.SetRuleName(ruleName); Aws::IoT::Model::DeleteTopicRuleOutcome outcome = iotClient.DeleteTopicRule( request); if (outcome.IsSuccess()) { std::cout << "Successfully deleted rule " << ruleName << std::endl; } else { std::cerr << "Failed to delete rule " << ruleName << ": " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }-
有关 API 的详细信息,请参阅 适用于 C++ 的 Amazon SDK API 参考DeleteTopicRule中的。
-
- CLI
-
- Amazon CLI
-
删除规则
以下
delete-topic-rule示例删除指定规则。aws iot delete-topic-rule \ --rule-name"LowMoistureRule"此命令不生成任何输出。
有关更多信息,请参阅《Amazon 物联网开发人员指南》中的删除规则。
-
有关 API 的详细信息,请参阅Amazon CLI 命令参考DeleteTopicRule
中的。
-
- 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 delete_topic_rule(self, rule_name): """ Deletes an AWS IoT topic rule. :param rule_name: The name of the rule to delete. """ try: self.iot_client.delete_topic_rule(ruleName=rule_name) logger.info("Deleted topic rule %s.", rule_name) except ClientError as err: logger.error( "Couldn't delete topic rule. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise-
有关 API 的详细信息,请参阅适用DeleteTopicRule于 Python 的Amazon SDK (Boto3) API 参考。
-
有关 S Amazon DK 开发者指南和代码示例的完整列表,请参阅Amazon IoT 与 Amazon SDK 一起使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。
DeleteThing
DescribeEndpoint