updateResourcePolicy method

Future<UpdateResourcePolicyResponse> updateResourcePolicy({
  1. required String policy,
  2. required String resourceArn,
  3. String? expectedRevisionId,
})

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.

May throw InternalServerException. May throw PreconditionFailedException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter 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.

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

Parameter expectedRevisionId : 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.

Implementation

Future<UpdateResourcePolicyResponse> updateResourcePolicy({
  required String policy,
  required String resourceArn,
  String? expectedRevisionId,
}) async {
  final $query = <String, List<String>>{
    if (expectedRevisionId != null)
      'expectedRevisionId': [expectedRevisionId],
  };
  final $payload = <String, dynamic>{
    'policy': policy,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/policy/${Uri.encodeComponent(resourceArn)}',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return UpdateResourcePolicyResponse.fromJson(response);
}