createBusinessReportSchedule method

Future<CreateBusinessReportScheduleResponse> createBusinessReportSchedule({
  1. required BusinessReportContentRange contentRange,
  2. required BusinessReportFormat format,
  3. String? clientRequestToken,
  4. BusinessReportRecurrence? recurrence,
  5. String? s3BucketName,
  6. String? s3KeyPrefix,
  7. String? scheduleName,
  8. List<Tag>? tags,
})

Creates a recurring schedule for usage reports to deliver to the specified S3 location with a specified daily or weekly interval.

May throw AlreadyExistsException.

Parameter contentRange : The content range of the reports.

Parameter format : The format of the generated report (individual CSV files or zipped files of individual files).

Parameter clientRequestToken : The client request token.

Parameter recurrence : The recurrence of the reports. If this isn't specified, the report will only be delivered one time when the API is called.

Parameter s3BucketName : The S3 bucket name of the output reports. If this isn't specified, the report can be retrieved from a download link by calling ListBusinessReportSchedule.

Parameter s3KeyPrefix : The S3 key where the report is delivered.

Parameter scheduleName : The name identifier of the schedule.

Parameter tags : The tags for the business report schedule.

Implementation

Future<CreateBusinessReportScheduleResponse> createBusinessReportSchedule({
  required BusinessReportContentRange contentRange,
  required BusinessReportFormat format,
  String? clientRequestToken,
  BusinessReportRecurrence? recurrence,
  String? s3BucketName,
  String? s3KeyPrefix,
  String? scheduleName,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(contentRange, 'contentRange');
  ArgumentError.checkNotNull(format, 'format');
  _s.validateStringLength(
    'clientRequestToken',
    clientRequestToken,
    10,
    150,
  );
  _s.validateStringLength(
    's3KeyPrefix',
    s3KeyPrefix,
    0,
    100,
  );
  _s.validateStringLength(
    'scheduleName',
    scheduleName,
    0,
    64,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AlexaForBusiness.CreateBusinessReportSchedule'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ContentRange': contentRange,
      'Format': format.toValue(),
      'ClientRequestToken':
          clientRequestToken ?? _s.generateIdempotencyToken(),
      if (recurrence != null) 'Recurrence': recurrence,
      if (s3BucketName != null) 'S3BucketName': s3BucketName,
      if (s3KeyPrefix != null) 'S3KeyPrefix': s3KeyPrefix,
      if (scheduleName != null) 'ScheduleName': scheduleName,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateBusinessReportScheduleResponse.fromJson(jsonResponse.body);
}