putResourcePolicy method

Future<PutResourcePolicyResponse> putResourcePolicy({
  1. required Object policy,
  2. required String resourceArn,
  3. String? expectedRevisionId,
})

Associates a resource policy with a knowledge base. A resource policy allows other AWS accounts to access the knowledge base. For more information, see Cross-account access for knowledge bases.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter policy : The JSON-formatted resource policy to associate with the knowledge base.

Parameter resourceArn : The Amazon Resource Name (ARN) of the knowledge base to attach the resource policy to.

Parameter expectedRevisionId : The expected revision identifier of the resource policy. Use this to prevent conflicts when multiple users update the same policy concurrently. Specify the revisionId from the most recent GetResourcePolicy or PutResourcePolicy response.

Implementation

Future<PutResourcePolicyResponse> putResourcePolicy({
  required Object policy,
  required String resourceArn,
  String? expectedRevisionId,
}) async {
  final $payload = <String, dynamic>{
    'policy': jsonEncode(policy),
    if (expectedRevisionId != null) 'expectedRevisionId': expectedRevisionId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/resourcepolicy/${Uri.encodeComponent(resourceArn)}',
    exceptionFnMap: _exceptionFns,
  );
  return PutResourcePolicyResponse.fromJson(response);
}