Skip to content

create_event_subscription

create_event_subscription(
    *,
    config_overrides: Optional[NeptuneClientConfig] = 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 event notification subscription. This action requires a topic ARN (Amazon Resource Name) created by either the Neptune console, the SNS console, or the SNS API. To obtain an ARN with SNS, you must create a topic in Amazon SNS and subscribe to the topic. The ARN is displayed in the SNS console.

You can specify the type of source (SourceType) you want to be notified of, provide a list of Neptune sources (SourceIds) that triggers the events, and provide a list of event categories (EventCategories) for events 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 Neptune sources. If you do not specify either the SourceType nor the SourceIdentifier, you are notified of events generated from all Neptune sources belonging to your customer account.

Parameters:

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

    The name of the subscription.

    Constraints: The name must be less than 255 characters.

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

    The Amazon Resource Name (ARN) of the SNS topic created for event notification. The ARN is created by Amazon SNS 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 a DB 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-snapshot | db-cluster-snapshot

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

    A list of event categories for a SourceType that you want to subscribe to. You can see a list of the categories for a given SourceType by using the DescribeEventCategories action.

  • 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 supplied, SourceType must also be provided.

    • If the source type is a DB instance, then a DBInstanceIdentifier must be supplied.

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

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

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

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

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

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

    The tags to be applied to the new event subscription.

Raises:

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

    Args:
        subscription_name: <p>The name of the subscription.</p> <p>Constraints: The name must be less than 255 characters.</p>
        sns_topic_arn: <p>The Amazon Resource Name (ARN) of the SNS topic created for event notification. The ARN is created by Amazon SNS 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 a DB instance, you would set this parameter to db-instance. 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-snapshot</code> | <code>db-cluster-snapshot</code> </p>
        event_categories: <p> A list of event categories for a SourceType that you want to subscribe to. You can see a list of the categories for a given SourceType by using the <b>DescribeEventCategories</b> action.</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 SourceIds are supplied, SourceType must also be provided.</p> </li> <li> <p>If the source type is a DB instance, then a <code>DBInstanceIdentifier</code> must be supplied.</p> </li> <li> <p>If the source type is a DB security group, a <code>DBSecurityGroupName</code> must be supplied.</p> </li> <li> <p>If the source type is a DB parameter group, a <code>DBParameterGroupName</code> must be supplied.</p> </li> <li> <p>If the source type is a DB snapshot, a <code>DBSnapshotIdentifier</code> must be supplied.</p> </li> </ul>
        enabled: <p> A Boolean value; set to <b>true</b> to activate the subscription, set to <b>false</b> to create the subscription but not activate it.</p>
        tags: <p>The tags to be applied to the new event subscription.</p>

    Raises:
        capo_neptune.errors.event_subscription_quota_exceeded_fault.EventSubscriptionQuotaExceededFault: <p>You have exceeded the number of events you can subscribe to.</p>
        capo_neptune.errors.sns_invalid_topic_fault.SNSInvalidTopicFault: <p>The SNS topic is invalid.</p>
        capo_neptune.errors.sns_no_authorization_fault.SNSNoAuthorizationFault: <p>There is no SNS authorization.</p>
        capo_neptune.errors.sns_topic_arn_not_found_fault.SNSTopicArnNotFoundFault: <p>The ARN of the SNS topic could not be found.</p>
        capo_neptune.errors.source_not_found_fault.SourceNotFoundFault: <p>The source could not be found.</p>
        capo_neptune.errors.subscription_already_exist_fault.SubscriptionAlreadyExistFault: <p>This subscription already exists.</p>
        capo_neptune.errors.subscription_category_not_found_fault.SubscriptionCategoryNotFoundFault: <p>The designated subscription category could not be found.</p>
        capo_neptune.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_neptune.types.create_event_subscription_message.CreateEventSubscriptionMessage]",
    ) -> OperationResponse[
        "capo_neptune.types.create_event_subscription_result.CreateEventSubscriptionResult"
    ]:
        import capo_neptune._operations.amazon_rd_sv19.create_event_subscription

        output, http_response = (
            capo_neptune._operations.amazon_rd_sv19.create_event_subscription.create_event_subscription(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateEventSubscription")
    )
    input_: capo_neptune.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 = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output