putResourcePolicy method

Future<PutResourcePolicyResponse> putResourcePolicy({
  1. required String resourceArn,
  2. required String resourcePolicy,
  3. String? clientToken,
  4. String? policyRevisionId,
})

Creates a resource control policy for a given resource.

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

Parameter resourceArn : The Amazon Resource Name (ARN) of the resource for which the policy is being created.

Parameter resourcePolicy : The JSON-formatted resource policy to create.

Parameter clientToken : A unique identifier for the request. If you do not set the client request token, Amazon Lookout for Equipment generates one.

Parameter policyRevisionId : A unique identifier for a revision of the resource policy.

Implementation

Future<PutResourcePolicyResponse> putResourcePolicy({
  required String resourceArn,
  required String resourcePolicy,
  String? clientToken,
  String? policyRevisionId,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AWSLookoutEquipmentFrontendService.PutResourcePolicy'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ResourceArn': resourceArn,
      'ResourcePolicy': resourcePolicy,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (policyRevisionId != null) 'PolicyRevisionId': policyRevisionId,
    },
  );

  return PutResourcePolicyResponse.fromJson(jsonResponse.body);
}