updateLifecyclePolicy method

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

Updates an OpenSearch Serverless access policy. For more information, see Updating data lifecycle policies.

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

Parameter name : The name of the policy.

Parameter policyVersion : The version of the policy being updated.

Parameter type : The type of lifecycle policy.

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

Parameter description : A description of the lifecycle policy.

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

Implementation

Future<UpdateLifecyclePolicyResponse> updateLifecyclePolicy({
  required String name,
  required String policyVersion,
  required LifecyclePolicyType type,
  String? clientToken,
  String? description,
  String? policy,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'OpenSearchServerless.UpdateLifecyclePolicy'
  };
  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 UpdateLifecyclePolicyResponse.fromJson(jsonResponse.body);
}