putLifecyclePolicy method

Future<PutLifecyclePolicyResponse> putLifecyclePolicy({
  1. required String lifecyclePolicyText,
  2. required String repositoryName,
  3. String? registryId,
})

Creates or updates the lifecycle policy for the specified repository. For more information, see Lifecycle Policy Template.

May throw ServerException. May throw InvalidParameterException. May throw RepositoryNotFoundException.

Parameter lifecyclePolicyText : The JSON repository policy text to apply to the repository.

Parameter repositoryName : The name of the repository to receive the policy.

Parameter registryId : The AWS account ID associated with the registry that contains the repository. If you do
 not specify a registry, the default registry is assumed.

Implementation

Future<PutLifecyclePolicyResponse> putLifecyclePolicy({
  required String lifecyclePolicyText,
  required String repositoryName,
  String? registryId,
}) async {
  ArgumentError.checkNotNull(lifecyclePolicyText, 'lifecyclePolicyText');
  _s.validateStringLength(
    'lifecyclePolicyText',
    lifecyclePolicyText,
    100,
    30720,
    isRequired: true,
  );
  ArgumentError.checkNotNull(repositoryName, 'repositoryName');
  _s.validateStringLength(
    'repositoryName',
    repositoryName,
    2,
    256,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonEC2ContainerRegistry_V20150921.PutLifecyclePolicy'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'lifecyclePolicyText': lifecyclePolicyText,
      'repositoryName': repositoryName,
      if (registryId != null) 'registryId': registryId,
    },
  );

  return PutLifecyclePolicyResponse.fromJson(jsonResponse.body);
}