putLifecyclePolicy method

Future<void> putLifecyclePolicy({
  1. required String containerName,
  2. required String lifecyclePolicy,
})

Writes an object lifecycle policy to a container. If the container already has an object lifecycle policy, the service replaces the existing policy with the new policy. It takes up to 20 minutes for the change to take effect.

For information about how to construct an object lifecycle policy, see Components of an Object Lifecycle Policy.

May throw ContainerInUseException. May throw ContainerNotFoundException. May throw InternalServerError.

Parameter containerName : The name of the container that you want to assign the object lifecycle policy to.

Parameter lifecyclePolicy : The object lifecycle policy to apply to the container.

Implementation

Future<void> putLifecyclePolicy({
  required String containerName,
  required String lifecyclePolicy,
}) async {
  ArgumentError.checkNotNull(containerName, 'containerName');
  _s.validateStringLength(
    'containerName',
    containerName,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(lifecyclePolicy, 'lifecyclePolicy');
  _s.validateStringLength(
    'lifecyclePolicy',
    lifecyclePolicy,
    0,
    8192,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'MediaStore_20170901.PutLifecyclePolicy'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ContainerName': containerName,
      'LifecyclePolicy': lifecyclePolicy,
    },
  );
}