Skip to content

update_resource_policy async

update_resource_policy(
    resource_arn: AmazonResourceName,
    policy: Policy,
    *,
    config_overrides: Optional[AsyncLexModelsV2ClientConfig] = None,
    expected_revision_id: Optional[RevisionId] = None,
) -> UpdateResourcePolicyResponse

Replaces the existing resource policy for a bot or bot alias with a new one. If the policy doesn't exist, Amazon Lex returns an exception.

Parameters:

  • resource_arn (AmazonResourceName) –

    The Amazon Resource Name (ARN) of the bot or bot alias that the resource policy is attached to.

  • policy (Policy) –

    A resource policy to add to the resource. The policy is a JSON structure that contains one or more statements that define the policy. The policy must follow the IAM syntax. For more information about the contents of a JSON policy document, see IAM JSON policy reference .

    If the policy isn't valid, Amazon Lex returns a validation exception.

  • expected_revision_id (Optional[RevisionId], default: None ) –

    The identifier of the revision of the policy to update. If this revision ID doesn't match the current revision ID, Amazon Lex throws an exception.

    If you don't specify a revision, Amazon Lex overwrites the contents of the policy with the new values.

Raises:

Source code in docs_src/capo_lex_models_v2/_services/async_lex_models_v2.py
async def update_resource_policy(
    self,
    resource_arn: "capo_lex_models_v2.types.amazon_resource_name.AmazonResourceName",
    policy: "capo_lex_models_v2.types.policy.Policy",
    *,
    config_overrides: Optional[AsyncLexModelsV2ClientConfig] = None,
    expected_revision_id: Optional[
        "capo_lex_models_v2.types.revision_id.RevisionId"
    ] = None,
) -> "capo_lex_models_v2.types.update_resource_policy_response.UpdateResourcePolicyResponse":
    """<p>Replaces the existing resource policy for a bot or bot alias with a new one. If the policy doesn't exist, Amazon Lex returns an exception.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the bot or bot alias that the resource policy is attached to.</p>
        policy: <p>A resource policy to add to the resource. The policy is a JSON structure that contains one or more statements that define the policy. The policy must follow the IAM syntax. For more information about the contents of a JSON policy document, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies.html"> IAM JSON policy reference </a>. </p> <p>If the policy isn't valid, Amazon Lex returns a validation exception.</p>
        expected_revision_id: <p>The identifier of the revision of the policy to update. If this revision ID doesn't match the current revision ID, Amazon Lex throws an exception.</p> <p>If you don't specify a revision, Amazon Lex overwrites the contents of the policy with the new values.</p>

    Raises:
        capo_lex_models_v2.errors.internal_server_exception.InternalServerException: <p>The service encountered an unexpected condition. Try your request again.</p>
        capo_lex_models_v2.errors.precondition_failed_exception.PreconditionFailedException: <p>Your request couldn't be completed because one or more request fields aren't valid. Check the fields in your request and try again.</p>
        capo_lex_models_v2.errors.resource_not_found_exception.ResourceNotFoundException: <p>You asked to describe a resource that doesn't exist. Check the resource that you are requesting and try again.</p>
        capo_lex_models_v2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You have reached a quota for your bot. </p>
        capo_lex_models_v2.errors.throttling_exception.ThrottlingException: <p>Your request rate is too high. Reduce the frequency of requests.</p>
        capo_lex_models_v2.errors.validation_exception.ValidationException: <p>One of the input parameters in your request isn't valid. Check the parameters and try your request again.</p>
        capo_lex_models_v2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lex_models_v2.types.update_resource_policy_request.UpdateResourcePolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_lex_models_v2.types.update_resource_policy_response.UpdateResourcePolicyResponse"
    ]:
        import capo_lex_models_v2._operations.lex_model_building_service_v2.update_resource_policy

        (
            output,
            http_response,
        ) = await capo_lex_models_v2._operations.lex_model_building_service_v2.update_resource_policy.async_update_resource_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateResourcePolicy")
    )
    input_: capo_lex_models_v2.types.update_resource_policy_request.UpdateResourcePolicyRequest = {
        "resource_arn": resource_arn,
        "policy": policy,
    }
    if expected_revision_id is not None:
        input_["expected_revision_id"] = expected_revision_id

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