createLocationS3 method

Future<CreateLocationS3Response> createLocationS3({
  1. required String s3BucketArn,
  2. required S3Config s3Config,
  3. List<String>? agentArns,
  4. S3StorageClass? s3StorageClass,
  5. String? subdirectory,
  6. List<TagListEntry>? tags,
})

Creates an endpoint for an Amazon S3 bucket.

For more information, see https://docs.aws.amazon.com/datasync/latest/userguide/create-locations-cli.html#create-location-s3-cli in the AWS DataSync User Guide.

May throw InvalidRequestException. May throw InternalException.

Parameter s3BucketArn : The ARN of the Amazon S3 bucket. If the bucket is on an AWS Outpost, this must be an access point ARN.

Parameter agentArns : If you are using DataSync on an AWS Outpost, specify the Amazon Resource Names (ARNs) of the DataSync agents deployed on your Outpost. For more information about launching a DataSync agent on an AWS Outpost, see outposts-agent.

Parameter s3StorageClass : The Amazon S3 storage class that you want to store your files in when this location is used as a task destination. For buckets in AWS Regions, the storage class defaults to Standard. For buckets on AWS Outposts, the storage class defaults to AWS S3 Outposts.

For more information about S3 storage classes, see Amazon S3 Storage Classes. Some storage classes have behaviors that can affect your S3 storage cost. For detailed information, see using-storage-classes.

Parameter subdirectory : A subdirectory in the Amazon S3 bucket. This subdirectory in Amazon S3 is used to read data from the S3 source location or write data to the S3 destination.

Parameter tags : The key-value pair that represents the tag that you want to add to the location. The value can be an empty string. We recommend using tags to name your resources.

Implementation

Future<CreateLocationS3Response> createLocationS3({
  required String s3BucketArn,
  required S3Config s3Config,
  List<String>? agentArns,
  S3StorageClass? s3StorageClass,
  String? subdirectory,
  List<TagListEntry>? tags,
}) async {
  ArgumentError.checkNotNull(s3BucketArn, 's3BucketArn');
  _s.validateStringLength(
    's3BucketArn',
    s3BucketArn,
    0,
    156,
    isRequired: true,
  );
  ArgumentError.checkNotNull(s3Config, 's3Config');
  _s.validateStringLength(
    'subdirectory',
    subdirectory,
    0,
    4096,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'FmrsService.CreateLocationS3'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'S3BucketArn': s3BucketArn,
      'S3Config': s3Config,
      if (agentArns != null) 'AgentArns': agentArns,
      if (s3StorageClass != null) 'S3StorageClass': s3StorageClass.toValue(),
      if (subdirectory != null) 'Subdirectory': subdirectory,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateLocationS3Response.fromJson(jsonResponse.body);
}