Skip to content

create_event_subscription async

create_event_subscription(
    *,
    config_overrides: Optional[AsyncDocDBClientConfig] = None,
    subscription_name: Optional[String] = None,
    sns_topic_arn: Optional[String] = None,
    source_type: Optional[String] = None,
    event_categories: Optional[EventCategoriesList] = None,
    source_ids: Optional[SourceIdsList] = None,
    enabled: Optional[BooleanOptional] = None,
    tags: Optional[TagList] = None,
) -> CreateEventSubscriptionResult

Creates an Amazon DocumentDB event notification subscription. This action requires a topic Amazon Resource Name (ARN) created by using the Amazon DocumentDB console, the Amazon SNS console, or the Amazon SNS API. To obtain an ARN with Amazon SNS, you must create a topic in Amazon SNS and subscribe to the topic. The ARN is displayed in the Amazon SNS console.

You can specify the type of source (SourceType) that you want to be notified of. You can also provide a list of Amazon DocumentDB sources (SourceIds) that trigger the events, and you can provide a list of event categories (EventCategories) for events that you want to be notified of. For example, you can specify SourceType = db-instance, SourceIds = mydbinstance1, mydbinstance2 and EventCategories = Availability, Backup.

If you specify both the SourceType and SourceIds (such as SourceType = db-instance and SourceIdentifier = myDBInstance1), you are notified of all the db-instance events for the specified source. If you specify a SourceType but do not specify a SourceIdentifier, you receive notice of the events for that source type for all your Amazon DocumentDB sources. If you do not specify either the SourceType or the SourceIdentifier, you are notified of events generated from all Amazon DocumentDB sources belonging to your customer account.

Parameters:

  • subscription_name (Optional[String], default: None ) –

    The name of the subscription.

    Constraints: The name must be fewer than 255 characters.

  • sns_topic_arn (Optional[String], default: None ) –

    The Amazon Resource Name (ARN) of the SNS topic created for event notification. Amazon SNS creates the ARN when you create a topic and subscribe to it.

  • source_type (Optional[String], default: None ) –

    The type of source that is generating the events. For example, if you want to be notified of events generated by an instance, you would set this parameter to db-instance. If this value is not specified, all events are returned.

    Valid values: db-instance, db-cluster, db-parameter-group, db-security-group, db-cluster-snapshot

  • event_categories (Optional[EventCategoriesList], default: None ) –

    A list of event categories for a SourceType that you want to subscribe to.

  • source_ids (Optional[SourceIdsList], default: None ) –

    The list of identifiers of the event sources for which events are returned. If not specified, then all sources are included in the response. An identifier must begin with a letter and must contain only ASCII letters, digits, and hyphens; it can't end with a hyphen or contain two consecutive hyphens.

    Constraints:

    • If SourceIds are provided, SourceType must also be provided.

    • If the source type is an instance, a DBInstanceIdentifier must be provided.

    • If the source type is a security group, a DBSecurityGroupName must be provided.

    • If the source type is a parameter group, a DBParameterGroupName must be provided.

    • If the source type is a snapshot, a DBSnapshotIdentifier must be provided.

  • enabled (Optional[BooleanOptional], default: None ) –

    A Boolean value; set to true to activate the subscription, set to false to create the subscription but not active it.

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

    The tags to be assigned to the event subscription.

Raises:

Source code in docs_src/capo_docdb/_services/async_doc_db.py
async def create_event_subscription(
    self,
    *,
    config_overrides: Optional[AsyncDocDBClientConfig] = None,
    subscription_name: Optional["capo_docdb.types.string.String"] = None,
    sns_topic_arn: Optional["capo_docdb.types.string.String"] = None,
    source_type: Optional["capo_docdb.types.string.String"] = None,
    event_categories: Optional[
        "capo_docdb.types.event_categories_list.EventCategoriesList"
    ] = None,
    source_ids: Optional["capo_docdb.types.source_ids_list.SourceIdsList"] = None,
    enabled: Optional["capo_docdb.types.boolean_optional.BooleanOptional"] = None,
    tags: Optional["capo_docdb.types.tag_list.TagList"] = None,
) -> "capo_docdb.types.create_event_subscription_result.CreateEventSubscriptionResult":
    """<p>Creates an Amazon DocumentDB event notification subscription. This action requires a topic Amazon Resource Name (ARN) created by using the Amazon DocumentDB console, the Amazon SNS console, or the Amazon SNS API. To obtain an ARN with Amazon SNS, you must create a topic in Amazon SNS and subscribe to the topic. The ARN is displayed in the Amazon SNS console.</p> <p>You can specify the type of source (<code>SourceType</code>) that you want to be notified of. You can also provide a list of Amazon DocumentDB sources (<code>SourceIds</code>) that trigger the events, and you can provide a list of event categories (<code>EventCategories</code>) for events that you want to be notified of. For example, you can specify <code>SourceType = db-instance</code>, <code>SourceIds = mydbinstance1, mydbinstance2</code> and <code>EventCategories = Availability, Backup</code>.</p> <p>If you specify both the <code>SourceType</code> and <code>SourceIds</code> (such as <code>SourceType = db-instance</code> and <code>SourceIdentifier = myDBInstance1</code>), you are notified of all the <code>db-instance</code> events for the specified source. If you specify a <code>SourceType</code> but do not specify a <code>SourceIdentifier</code>, you receive notice of the events for that source type for all your Amazon DocumentDB sources. If you do not specify either the <code>SourceType</code> or the <code>SourceIdentifier</code>, you are notified of events generated from all Amazon DocumentDB sources belonging to your customer account.</p>

    Args:
        subscription_name: <p>The name of the subscription.</p> <p>Constraints: The name must be fewer than 255 characters.</p>
        sns_topic_arn: <p>The Amazon Resource Name (ARN) of the SNS topic created for event notification. Amazon SNS creates the ARN when you create a topic and subscribe to it.</p>
        source_type: <p>The type of source that is generating the events. For example, if you want to be notified of events generated by an instance, you would set this parameter to <code>db-instance</code>. If this value is not specified, all events are returned.</p> <p>Valid values: <code>db-instance</code>, <code>db-cluster</code>, <code>db-parameter-group</code>, <code>db-security-group</code>, <code>db-cluster-snapshot</code> </p>
        event_categories: <p> A list of event categories for a <code>SourceType</code> that you want to subscribe to. </p>
        source_ids: <p>The list of identifiers of the event sources for which events are returned. If not specified, then all sources are included in the response. An identifier must begin with a letter and must contain only ASCII letters, digits, and hyphens; it can't end with a hyphen or contain two consecutive hyphens.</p> <p>Constraints:</p> <ul> <li> <p>If <code>SourceIds</code> are provided, <code>SourceType</code> must also be provided.</p> </li> <li> <p>If the source type is an instance, a <code>DBInstanceIdentifier</code> must be provided.</p> </li> <li> <p>If the source type is a security group, a <code>DBSecurityGroupName</code> must be provided.</p> </li> <li> <p>If the source type is a parameter group, a <code>DBParameterGroupName</code> must be provided.</p> </li> <li> <p>If the source type is a snapshot, a <code>DBSnapshotIdentifier</code> must be provided.</p> </li> </ul>
        enabled: <p> A Boolean value; set to <code>true</code> to activate the subscription, set to <code>false</code> to create the subscription but not active it. </p>
        tags: <p>The tags to be assigned to the event subscription.</p>

    Raises:
        capo_docdb.errors.event_subscription_quota_exceeded_fault.EventSubscriptionQuotaExceededFault: <p>You have reached the maximum number of event subscriptions. </p>
        capo_docdb.errors.sns_invalid_topic_fault.SNSInvalidTopicFault: <p>Amazon SNS has responded that there is a problem with the specified topic. </p>
        capo_docdb.errors.sns_no_authorization_fault.SNSNoAuthorizationFault: <p>You do not have permission to publish to the SNS topic Amazon Resource Name (ARN). </p>
        capo_docdb.errors.sns_topic_arn_not_found_fault.SNSTopicArnNotFoundFault: <p>The SNS topic Amazon Resource Name (ARN) does not exist. </p>
        capo_docdb.errors.source_not_found_fault.SourceNotFoundFault: <p>The requested source could not be found. </p>
        capo_docdb.errors.subscription_already_exist_fault.SubscriptionAlreadyExistFault: <p>The provided subscription name already exists. </p>
        capo_docdb.errors.subscription_category_not_found_fault.SubscriptionCategoryNotFoundFault: <p>The provided category does not exist. </p>
        capo_docdb.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_docdb.types.create_event_subscription_message.CreateEventSubscriptionMessage]",
    ) -> AsyncOperationResponse[
        "capo_docdb.types.create_event_subscription_result.CreateEventSubscriptionResult"
    ]:
        import capo_docdb._operations.amazon_rd_sv19.create_event_subscription

        (
            output,
            http_response,
        ) = await capo_docdb._operations.amazon_rd_sv19.create_event_subscription.async_create_event_subscription(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateEventSubscription")
    )
    input_: capo_docdb.types.create_event_subscription_message.CreateEventSubscriptionMessage = {}
    if subscription_name is not None:
        input_["subscription_name"] = subscription_name
    if sns_topic_arn is not None:
        input_["sns_topic_arn"] = sns_topic_arn
    if source_type is not None:
        input_["source_type"] = source_type
    if event_categories is not None:
        input_["event_categories"] = event_categories
    if source_ids is not None:
        input_["source_ids"] = source_ids
    if enabled is not None:
        input_["enabled"] = enabled
    if tags is not None:
        input_["tags"] = tags

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