putContainerPolicy method

Future<void> putContainerPolicy({
  1. required String containerName,
  2. required String policy,
})

Creates an access policy for the specified container to restrict the users and clients that can access it. For information about the data that is included in an access policy, see the AWS Identity and Access Management User Guide.

For this release of the REST API, you can create only one policy for a container. If you enter PutContainerPolicy twice, the second command modifies the existing policy.

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

Parameter containerName : The name of the container.

Parameter policy : The contents of the policy, which includes the following:

  • One Version tag
  • One Statement tag that contains the standard tags for the policy.

Implementation

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