

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

# 编辑通知规则
<a name="notification-rule-edit"></a>

您可以通过编辑通知规则来更改其名称、其发送通知的事件、详细信息类型或其发送通知的一个或多个目标。您可以使用开发者工具控制台或编辑通知规则。 AWS CLI <a name="notification-rule-edit-console"></a>

# 编辑通知规则（控制台）
<a name="notification-rule-edit-console"></a>

1. 在[https://console.aws.amazon.com/codesuite/设置/ AWS](https://console.aws.amazon.com/codesuite/settings/notifications/) 通知中打开开发者工具控制台。

1. 在导航栏中，展开**设置**，然后选择**通知规则**。

1. 在**通知规则**中，查看在您当前登录 AWS 区域 的 AWS 账户中为资源配置的规则。使用选择器更改 AWS 区域。

1. 从列表中选择规则，然后选择 **Edit (编辑)**。进行更改，然后选择 **Submit (提交)**。<a name="notification-rule-edit-cli"></a>

# 编辑通知规则 (AWS CLI)
<a name="notification-rule-edit-cli"></a>

1. 在终端或命令提示符处，运行[describe-notification-rule命令](notification-rule-view.md#notification-rule-view-details-cli)以查看通知规则的结构。

1. 运行 **update-notification rule** 命令可生成 JSON 骨架并将其保存到文件中。

   ```
   aws codestar-notifications update-notification-rule --generate-cli-skeleton > {{update.json}}
   ```

   您可以将此文件命名为所需的任意名称。在本示例中，该文件为 {{update.json}}。

1. 在纯文本编辑器中打开 JSON 文件并更改规则。

   以下示例显示了名为 ID 的 AWS 账户{{MyDemoRepo}}中名**MyNotificationRule**为存储库的通知规则{{123456789012}}。通知会发送到创建分支和标签{{MyNotificationTopic}}时命名的 Amazon SNS 主题。规则名称已更改为{{MyNewNotificationRule}}。

   ```
   {
       "Name": "{{MyNewNotificationRule}}",
       "EventTypeIds": [
           "codecommit-repository-branches-and-tags-created"
       ],
       "Resource": "arn:aws:codecommit:{{us-east-1}}:{{123456789012}}:{{MyDemoRepo}}",
       "Targets": [
           {
               "TargetType": "SNS",
               "TargetAddress": "arn:aws:sns:{{us-east-1}}:{{123456789012}}:{{MyNotificationTopic}}"
           }
       ],
       "Status": "ENABLED",
       "DetailType": "FULL"
   }
   ```

   保存该文件。

1. 通过使用您刚编辑的文件，在终端或命令行上，再次运行 **update-notification-rule** 命令以更新通知规则。

   ```
   aws codestar-notifications update-notification-rule --cli-input-json  file://{{update}}.json
   ```

1. 如果成功，该命令将返回通知规则的 Amazon 资源名称 (ARN)，类似于以下内容。

   ```
   {
       "Arn": "arn:aws:codestar-notifications:{{us-east-1}}:{{123456789012}}:notificationrule/dc82df7a-EXAMPLE"
   }
   ```<a name="notification-rule-remove-tag-cli"></a>

# 从通知规则中删除标签 (AWS CLI)
<a name="notification-rule-remove-tag-cli"></a>

1. 在终端或命令提示符处，运行 **untag-resource** 命令。例如，以下命令删除名称为的标签{{Team}}。

   ```
   aws codestar-notifications untag-resource --arn arn:aws:codestar-notifications:us-east-1:123456789012:notificationrule/fe1efd35-EXAMPLE --tag-keys Team
   ```

1. 如果成功，该命令不返回任何内容。

## 另请参阅
<a name="notification-rule-edit-also"></a>
+ [添加或删除通知规则的目标](notification-target-change-rule.md)
+ [为通知规则启用或禁用通知](notification-rule-enable-disable.md)
+ [Events](concepts.md#events)