Skip to content

create_notification_rule async

create_notification_rule(
    name: NotificationRuleName,
    event_type_ids: EventTypeIds,
    resource: NotificationRuleResource,
    targets: Targets,
    detail_type: DetailType,
    *,
    config_overrides: Optional[AsynccodestarnotificationsClientConfig] = None,
    client_request_token: Optional[ClientRequestToken] = None,
    tags: Optional[Tags] = None,
    status: Optional[NotificationRuleStatus] = None,
) -> CreateNotificationRuleResult

Creates a notification rule for a resource. The rule specifies the events you want notifications about and the targets (such as Amazon Q Developer in chat applications topics or Amazon Q Developer in chat applications clients configured for Slack) where you want to receive them.

Parameters:

  • name (NotificationRuleName) –

    The name for the notification rule. Notification rule names must be unique in your Amazon Web Services account.

  • event_type_ids (EventTypeIds) –

    A list of event types associated with this notification rule. For a list of allowed events, see EventTypeSummary.

  • resource (NotificationRuleResource) –

    The Amazon Resource Name (ARN) of the resource to associate with the notification rule. Supported resources include pipelines in CodePipeline, repositories in CodeCommit, and build projects in CodeBuild.

  • targets (Targets) –

    A list of Amazon Resource Names (ARNs) of Amazon Simple Notification Service topics and Amazon Q Developer in chat applications clients to associate with the notification rule.

  • detail_type (DetailType) –

    The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in Amazon CloudWatch. FULL will include any supplemental information provided by CodeStar Notifications and/or the service for the resource for which the notification is created.

  • client_request_token (Optional[ClientRequestToken], default: None ) –

    A unique, client-generated idempotency token that, when provided in a request, ensures the request cannot be repeated with a changed parameter. If a request with the same parameters is received and a token is included, the request returns information about the initial request that used that token.

    The Amazon Web Services SDKs prepopulate client request tokens. If you are using an Amazon Web Services SDK, an idempotency token is created for you.

  • tags (Optional[Tags], default: None ) –

    A list of tags to apply to this notification rule. Key names cannot start with "aws".

  • status (Optional[NotificationRuleStatus], default: None ) –

    The status of the notification rule. The default value is ENABLED. If the status is set to DISABLED, notifications aren't sent for the notification rule.

Raises:

  • AccessDeniedException –

    CodeStar Notifications can't create the notification rule because you do not have sufficient permissions.

  • ConcurrentModificationException –

    CodeStar Notifications can't complete the request because the resource is being modified by another process. Wait a few minutes and try again.

  • ConfigurationException –

    Some or all of the configuration is incomplete, missing, or not valid.

  • LimitExceededException –

    One of the CodeStar Notifications limits has been exceeded. Limits apply to accounts, notification rules, notifications, resources, and targets. For more information, see Limits.

  • ResourceAlreadyExistsException –

    A resource with the same name or ID already exists. Notification rule names must be unique in your Amazon Web Services account.

  • ValidationException –

    One or more parameter values are not valid.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_codestar_notifications/_services/async_codestarnotifications.py
async def create_notification_rule(
    self,
    name: "capo_codestar_notifications.types.notification_rule_name.NotificationRuleName",
    event_type_ids: "capo_codestar_notifications.types.event_type_ids.EventTypeIds",
    resource: "capo_codestar_notifications.types.notification_rule_resource.NotificationRuleResource",
    targets: "capo_codestar_notifications.types.targets.Targets",
    detail_type: "capo_codestar_notifications.types.detail_type.DetailType",
    *,
    config_overrides: Optional[AsynccodestarnotificationsClientConfig] = None,
    client_request_token: Optional[
        "capo_codestar_notifications.types.client_request_token.ClientRequestToken"
    ] = None,
    tags: Optional["capo_codestar_notifications.types.tags.Tags"] = None,
    status: Optional[
        "capo_codestar_notifications.types.notification_rule_status.NotificationRuleStatus"
    ] = None,
) -> "capo_codestar_notifications.types.create_notification_rule_result.CreateNotificationRuleResult":
    """<p>Creates a notification rule for a resource. The rule specifies the events you want notifications about and the targets (such as Amazon Q Developer in chat applications topics or Amazon Q Developer in chat applications clients configured for Slack) where you want to receive them.</p>

    Args:
        name: <p>The name for the notification rule. Notification rule names must be unique in your Amazon Web Services account.</p>
        event_type_ids: <p>A list of event types associated with this notification rule. For a list of allowed events, see <a>EventTypeSummary</a>.</p>
        resource: <p>The Amazon Resource Name (ARN) of the resource to associate with the notification rule. Supported resources include pipelines in CodePipeline, repositories in CodeCommit, and build projects in CodeBuild.</p>
        targets: <p>A list of Amazon Resource Names (ARNs) of Amazon Simple Notification Service topics and Amazon Q Developer in chat applications clients to associate with the notification rule.</p>
        detail_type: <p>The level of detail to include in the notifications for this resource. <code>BASIC</code> will include only the contents of the event as it would appear in Amazon CloudWatch. <code>FULL</code> will include any supplemental information provided by CodeStar Notifications and/or the service for the resource for which the notification is created.</p>
        client_request_token: <p>A unique, client-generated idempotency token that, when provided in a request, ensures the request cannot be repeated with a changed parameter. If a request with the same parameters is received and a token is included, the request returns information about the initial request that used that token.</p> <note> <p>The Amazon Web Services SDKs prepopulate client request tokens. If you are using an Amazon Web Services SDK, an idempotency token is created for you.</p> </note>
        tags: <p>A list of tags to apply to this notification rule. Key names cannot start with "<code>aws</code>". </p>
        status: <p>The status of the notification rule. The default value is <code>ENABLED</code>. If the status is set to <code>DISABLED</code>, notifications aren't sent for the notification rule.</p>

    Raises:
        capo_codestar_notifications.errors.access_denied_exception.AccessDeniedException: <p>CodeStar Notifications can't create the notification rule because you do not have sufficient permissions.</p>
        capo_codestar_notifications.errors.concurrent_modification_exception.ConcurrentModificationException: <p>CodeStar Notifications can't complete the request because the resource is being modified by another process. Wait a few minutes and try again.</p>
        capo_codestar_notifications.errors.configuration_exception.ConfigurationException: <p>Some or all of the configuration is incomplete, missing, or not valid.</p>
        capo_codestar_notifications.errors.limit_exceeded_exception.LimitExceededException: <p>One of the CodeStar Notifications limits has been exceeded. Limits apply to accounts, notification rules, notifications, resources, and targets. For more information, see Limits.</p>
        capo_codestar_notifications.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>A resource with the same name or ID already exists. Notification rule names must be unique in your Amazon Web Services account.</p>
        capo_codestar_notifications.errors.validation_exception.ValidationException: <p>One or more parameter values are not valid.</p>
        capo_codestar_notifications.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_codestar_notifications.types.create_notification_rule_request.CreateNotificationRuleRequest]",
    ) -> AsyncOperationResponse[
        "capo_codestar_notifications.types.create_notification_rule_result.CreateNotificationRuleResult"
    ]:
        import capo_codestar_notifications._operations.code_star_notifications_20191015.create_notification_rule

        (
            output,
            http_response,
        ) = await capo_codestar_notifications._operations.code_star_notifications_20191015.create_notification_rule.async_create_notification_rule(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_codestar_notifications.types.create_notification_rule_request.CreateNotificationRuleRequest",
    ) -> dict[str, Any]:
        import capo_codestar_notifications.types.create_notification_rule_request

        return capo_codestar_notifications.types.create_notification_rule_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateNotificationRule", redact_input=_redact_input),
    )
    input_: capo_codestar_notifications.types.create_notification_rule_request.CreateNotificationRuleRequest = {
        "name": name,
        "event_type_ids": event_type_ids,
        "resource": resource,
        "targets": targets,
        "detail_type": detail_type,
    }
    if client_request_token is None:
        client_request_token = str(uuid.uuid4())
    input_["client_request_token"] = client_request_token
    if tags is not None:
        input_["tags"] = tags
    if status is not None:
        input_["status"] = status

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output