createLifecyclePolicy method

Future<CreateLifecyclePolicyResponse> createLifecyclePolicy({
  1. required String executionRole,
  2. required String name,
  3. required List<LifecyclePolicyDetail> policyDetails,
  4. required LifecyclePolicyResourceSelection resourceSelection,
  5. required LifecyclePolicyResourceType resourceType,
  6. String? clientToken,
  7. String? description,
  8. LifecyclePolicyStatus? status,
  9. Map<String, String>? tags,
})

Create a lifecycle policy resource.

May throw CallRateLimitExceededException. May throw ClientException. May throw ForbiddenException. May throw IdempotentParameterMismatchException. May throw InvalidRequestException. May throw ResourceAlreadyExistsException. May throw ResourceInUseException. May throw ServiceException. May throw ServiceQuotaExceededException. May throw ServiceUnavailableException.

Parameter executionRole : The name or Amazon Resource Name (ARN) for the IAM role you create that grants Image Builder access to run lifecycle actions.

Parameter name : The name of the lifecycle policy to create.

Parameter policyDetails : Configuration details for the lifecycle policy rules.

Parameter resourceSelection : Selection criteria for the resources that the lifecycle policy applies to.

Parameter resourceType : The type of Image Builder resource that the lifecycle policy applies to.

Parameter clientToken : Unique, case-sensitive identifier you provide to ensure idempotency of the request. For more information, see Ensuring idempotency in the Amazon EC2 API Reference.

Parameter description : Optional description for the lifecycle policy.

Parameter status : Indicates whether the lifecycle policy resource is enabled.

Parameter tags : Tags to apply to the lifecycle policy resource.

Implementation

Future<CreateLifecyclePolicyResponse> createLifecyclePolicy({
  required String executionRole,
  required String name,
  required List<LifecyclePolicyDetail> policyDetails,
  required LifecyclePolicyResourceSelection resourceSelection,
  required LifecyclePolicyResourceType resourceType,
  String? clientToken,
  String? description,
  LifecyclePolicyStatus? status,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'executionRole': executionRole,
    'name': name,
    'policyDetails': policyDetails,
    'resourceSelection': resourceSelection,
    'resourceType': resourceType.value,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (description != null) 'description': description,
    if (status != null) 'status': status.value,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/CreateLifecyclePolicy',
    exceptionFnMap: _exceptionFns,
  );
  return CreateLifecyclePolicyResponse.fromJson(response);
}