updateAccessPolicy method

Future<UpdateAccessPolicyResponse> updateAccessPolicy({
  1. required String name,
  2. required String policyVersion,
  3. required AccessPolicyType type,
  4. String? clientToken,
  5. String? description,
  6. String? policy,
})

Updates an OpenSearch Serverless access policy. For more information, see Data access control for Amazon OpenSearch Serverless.

May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ValidationException.

Parameter name : The name of the policy.

Parameter policyVersion : The version of the policy being updated.

Parameter type : The type of policy.

Parameter clientToken : Unique, case-sensitive identifier to ensure idempotency of the request.

Parameter description : A description of the policy. Typically used to store information about the permissions defined in the policy.

Parameter policy : The JSON policy document to use as the content for the policy.

Implementation

Future<UpdateAccessPolicyResponse> updateAccessPolicy({
  required String name,
  required String policyVersion,
  required AccessPolicyType type,
  String? clientToken,
  String? description,
  String? policy,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'OpenSearchServerless.UpdateAccessPolicy'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'name': name,
      'policyVersion': policyVersion,
      'type': type.value,
      'clientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'description': description,
      if (policy != null) 'policy': policy,
    },
  );

  return UpdateAccessPolicyResponse.fromJson(jsonResponse.body);
}