本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
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 参考。
-
- SAP ABAP
-
- 适用于 SAP ABAP 的 SDK
-
注意
还有更多相关信息 GitHub。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 CONSTANTS cv_pfl TYPE /aws1/rt_profile_id VALUE 'ZCODE_DEMO'. DATA(lo_session) = /aws1/cl_rt_session_aws=>create( cv_pfl ). DATA(lo_iot) = /aws1/cl_iot_factory=>create( lo_session ). TRY. lo_iot->deletetopicrule( iv_rulename = iv_rule_name ). MESSAGE |IoT topic rule deleted: { iv_rule_name }| TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_ex). MESSAGE lo_ex->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_ex. ENDTRY.-
有关 API 的详细信息,请参阅适用DeleteTopicRule于 S AP 的Amazon SDK ABAP API 参考。
-
有关 S Amazon DK 开发者指南和代码示例的完整列表,请参阅使用 Amazon IoT 用 Amazon SDK。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。
DeleteThing
DescribeEndpoint