putResourcePolicy method

Future<PutResourcePolicyResult> putResourcePolicy({
  1. required String policyDocument,
  2. required String policyName,
  3. bool? bypassPolicyLockoutCheck,
  4. String? policyRevisionId,
})

Sets the resource policy to grant one or more Amazon Web Services services and accounts permissions to access X-Ray. Each resource policy will be associated with a specific Amazon Web Services account. Each Amazon Web Services account can have a maximum of 5 resource policies, and each policy name must be unique within that account. The maximum size of each resource policy is 5KB.

May throw InvalidPolicyRevisionIdException. May throw LockoutPreventionException. May throw MalformedPolicyDocumentException. May throw PolicyCountLimitExceededException. May throw PolicySizeLimitExceededException. May throw ThrottledException.

Parameter policyDocument : The resource policy document, which can be up to 5kb in size.

Parameter policyName : The name of the resource policy. Must be unique within a specific Amazon Web Services account.

Parameter bypassPolicyLockoutCheck : A flag to indicate whether to bypass the resource policy lockout safety check. Use this parameter only when you include a policy in the request and you intend to prevent the principal that is making the request from making a subsequent PutResourcePolicy request.

The default value is false.

Parameter policyRevisionId : Specifies a specific policy revision, to ensure an atomic create operation. By default the resource policy is created if it does not exist, or updated with an incremented revision id. The revision id is unique to each policy in the account.

If the policy revision id does not match the latest revision id, the operation will fail with an InvalidPolicyRevisionIdException exception. You can also provide a PolicyRevisionId of 0. In this case, the operation will fail with an InvalidPolicyRevisionIdException exception if a resource policy with the same name already exists.

Implementation

Future<PutResourcePolicyResult> putResourcePolicy({
  required String policyDocument,
  required String policyName,
  bool? bypassPolicyLockoutCheck,
  String? policyRevisionId,
}) async {
  final $payload = <String, dynamic>{
    'PolicyDocument': policyDocument,
    'PolicyName': policyName,
    if (bypassPolicyLockoutCheck != null)
      'BypassPolicyLockoutCheck': bypassPolicyLockoutCheck,
    if (policyRevisionId != null) 'PolicyRevisionId': policyRevisionId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/PutResourcePolicy',
    exceptionFnMap: _exceptionFns,
  );
  return PutResourcePolicyResult.fromJson(response);
}