putClusterPolicy method
Attaches a resource-based policy to a cluster. This policy defines access permissions and conditions for the cluster, allowing you to control which principals can perform actions on the cluster.
May throw ConflictException.
May throw ResourceNotFoundException.
May throw ValidationException.
Parameter policy :
The resource-based policy document to attach to the cluster. This should
be a valid JSON policy document that defines permissions and conditions.
Parameter bypassPolicyLockoutSafetyCheck :
A flag that allows you to bypass the policy lockout safety check. When set
to true, this parameter allows you to apply a policy that might lock you
out of the cluster. Use with caution.
Parameter expectedPolicyVersion :
The expected version of the current policy. This parameter ensures that
you're updating the correct version of the policy and helps prevent
concurrent modification conflicts.
Implementation
Future<PutClusterPolicyOutput> putClusterPolicy({
required String identifier,
required String policy,
bool? bypassPolicyLockoutSafetyCheck,
String? clientToken,
String? expectedPolicyVersion,
}) async {
final $payload = <String, dynamic>{
'policy': policy,
if (bypassPolicyLockoutSafetyCheck != null)
'bypassPolicyLockoutSafetyCheck': bypassPolicyLockoutSafetyCheck,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (expectedPolicyVersion != null)
'expectedPolicyVersion': expectedPolicyVersion,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/cluster/${Uri.encodeComponent(identifier)}/policy',
exceptionFnMap: _exceptionFns,
);
return PutClusterPolicyOutput.fromJson(response);
}