Deletes a policy statement from a resource policy. If you delete the last statement from a policy, the policy is deleted. If you specify a statement ID that doesn't exist in the policy, or if the bot or bot alias doesn't have a policy attached, Amazon Lex returns an exception.
You need to add the DeleteResourcePolicy or UpdateResourcePolicy action to the bot role in order to call the API.
Parameters:
-
resource_arn
(AmazonResourceName)
–
The Amazon Resource Name (ARN) of the bot or bot alias that the resource policy is attached to.
-
statement_id
(Name)
–
The name of the statement (SID) to delete from the policy.
-
expected_revision_id
(Optional[RevisionId], default:
None
)
–
The identifier of the revision of the policy to delete the statement from. 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 removes the current contents of the statement.
Raises:
-
InternalServerException
–
The service encountered an unexpected condition. Try your request again.
-
PreconditionFailedException
–
Your request couldn't be completed because one or more request fields aren't valid. Check the fields in your request and try again.
-
ResourceNotFoundException
–
You asked to describe a resource that doesn't exist. Check the resource that you are requesting and try again.
-
ThrottlingException
–
Your request rate is too high. Reduce the frequency of requests.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_lex_models_v2/_services/lex_models_v2.py
| def delete_resource_policy_statement(
self,
resource_arn: "capo_lex_models_v2.types.amazon_resource_name.AmazonResourceName",
statement_id: "capo_lex_models_v2.types.name.Name",
*,
config_overrides: Optional[LexModelsV2ClientConfig] = None,
expected_revision_id: Optional[
"capo_lex_models_v2.types.revision_id.RevisionId"
] = None,
) -> "capo_lex_models_v2.types.delete_resource_policy_statement_response.DeleteResourcePolicyStatementResponse":
"""<p>Deletes a policy statement from a resource policy. If you delete the last statement from a policy, the policy is deleted. If you specify a statement ID that doesn't exist in the policy, or if the bot or bot alias doesn't have a policy attached, Amazon Lex returns an exception.</p> <p>You need to add the <code>DeleteResourcePolicy</code> or <code>UpdateResourcePolicy</code> action to the bot role in order to call the API.</p>
Args:
resource_arn: <p>The Amazon Resource Name (ARN) of the bot or bot alias that the resource policy is attached to.</p>
statement_id: <p>The name of the statement (SID) to delete from the policy.</p>
expected_revision_id: <p>The identifier of the revision of the policy to delete the statement from. 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 removes the current contents of the statement. </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.throttling_exception.ThrottlingException: <p>Your request rate is too high. Reduce the frequency of requests.</p>
capo_lex_models_v2.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_lex_models_v2.types.delete_resource_policy_statement_request.DeleteResourcePolicyStatementRequest]",
) -> OperationResponse[
"capo_lex_models_v2.types.delete_resource_policy_statement_response.DeleteResourcePolicyStatementResponse"
]:
import capo_lex_models_v2._operations.lex_model_building_service_v2.delete_resource_policy_statement
output, http_response = (
capo_lex_models_v2._operations.lex_model_building_service_v2.delete_resource_policy_statement.delete_resource_policy_statement(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("DeleteResourcePolicyStatement")
)
input_: capo_lex_models_v2.types.delete_resource_policy_statement_request.DeleteResourcePolicyStatementRequest = {
"resource_arn": resource_arn,
"statement_id": statement_id,
}
if expected_revision_id is not None:
input_["expected_revision_id"] = expected_revision_id
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|