Skip to content

add_permission async

add_permission(
    topic_arn: topicARN,
    label: label,
    aws_account_id: DelegatesList,
    action_name: ActionsList,
    *,
    config_overrides: Optional[AsyncSNSClientConfig] = None,
) -> None

Adds a statement to a topic's access control policy, granting access for the specified Amazon Web Services accounts to the specified actions.

To remove the ability to change topic permissions, you must deny permissions to the AddPermission, RemovePermission, and SetTopicAttributes actions in your IAM policy.

Parameters:

  • topic_arn (topicARN) –

    The ARN of the topic whose access control policy you wish to modify.

  • label (label) –

    A unique identifier for the new policy statement.

  • aws_account_id (DelegatesList) –

    The Amazon Web Services account IDs of the users (principals) who will be given access to the specified actions. The users must have Amazon Web Services account, but do not need to be signed up for this service.

  • action_name (ActionsList) –

    The action you want to allow for the specified principal(s).

    Valid values: Any Amazon SNS action name, for example Publish.

Raises:

Source code in docs_src/capo_sns/_services/async_sns.py
async def add_permission(
    self,
    topic_arn: "capo_sns.types.topic_arn.topicARN",
    label: "capo_sns.types.label.label",
    aws_account_id: "capo_sns.types.delegates_list.DelegatesList",
    action_name: "capo_sns.types.actions_list.ActionsList",
    *,
    config_overrides: Optional[AsyncSNSClientConfig] = None,
) -> None:
    """<p>Adds a statement to a topic's access control policy, granting access for the specified Amazon Web Services accounts to the specified actions.</p> <note> <p>To remove the ability to change topic permissions, you must deny permissions to the <code>AddPermission</code>, <code>RemovePermission</code>, and <code>SetTopicAttributes</code> actions in your IAM policy.</p> </note>

    Args:
        topic_arn: <p>The ARN of the topic whose access control policy you wish to modify.</p>
        label: <p>A unique identifier for the new policy statement.</p>
        aws_account_id: <p>The Amazon Web Services account IDs of the users (principals) who will be given access to the specified actions. The users must have Amazon Web Services account, but do not need to be signed up for this service.</p>
        action_name: <p>The action you want to allow for the specified principal(s).</p> <p>Valid values: Any Amazon SNS action name, for example <code>Publish</code>.</p>

    Raises:
        capo_sns.errors.authorization_error_exception.AuthorizationErrorException: <p>Indicates that the user has been denied access to the requested resource.</p>
        capo_sns.errors.internal_error_exception.InternalErrorException: <p>Indicates an internal service error.</p>
        capo_sns.errors.invalid_parameter_exception.InvalidParameterException: <p>Indicates that a request parameter does not comply with the associated constraints.</p>
        capo_sns.errors.not_found_exception.NotFoundException: <p>Indicates that the requested resource does not exist.</p>
        capo_sns.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_sns.types.add_permission_input.AddPermissionInput]",
    ) -> AsyncOperationResponse[None]:
        import capo_sns._operations.amazon_simple_notification_service.add_permission

        (
            output,
            http_response,
        ) = await capo_sns._operations.amazon_simple_notification_service.add_permission.async_add_permission(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AddPermission")
    )
    input_: capo_sns.types.add_permission_input.AddPermissionInput = {
        "topic_arn": topic_arn,
        "label": label,
        "aws_account_id": aws_account_id,
        "action_name": action_name,
    }

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