createAttachedFile method

Future<CreateAttachedFileResponse> createAttachedFile({
  1. required String associatedResourceArn,
  2. required String fileSourceUri,
  3. required FileUseCaseType fileUseCaseType,
  4. required String instanceId,
  5. String? clientToken,
  6. Map<String, String>? tags,
})

Creates an attached file for a completed voice contact by copying a recording from a source S3 URI into Connect Customer managed storage. Use this API to attach voice recordings to contacts for downstream processing such as conversational analytics.

May throw AccessDeniedException. May throw InternalServiceException. May throw InvalidRequestException. May throw ResourceConflictException. May throw ServiceQuotaExceededException. May throw ThrottlingException.

Parameter associatedResourceArn : The ARN of the completed voice contact to attach the file to. Only voice contacts with Telephony subtype are supported.

Parameter fileSourceUri : The S3 URI of the file to be attached. Only S3 source URIs are supported.

Parameter fileUseCaseType : The use case for the file.

Parameter instanceId : The identifier of the Connect Customer instance. You can find the instance ID in the Amazon Resource Name (ARN) of the instance.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

Parameter tags : The tags used to organize, track, or control access for this resource. For example, { "Tags": {"key1":"value1", "key2":"value2"} }.

Implementation

Future<CreateAttachedFileResponse> createAttachedFile({
  required String associatedResourceArn,
  required String fileSourceUri,
  required FileUseCaseType fileUseCaseType,
  required String instanceId,
  String? clientToken,
  Map<String, String>? tags,
}) async {
  final $query = <String, List<String>>{
    'associatedResourceArn': [associatedResourceArn],
  };
  final $payload = <String, dynamic>{
    'FileSourceUri': fileSourceUri,
    'FileUseCaseType': fileUseCaseType.value,
    'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (tags != null) 'Tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/attached-files/${Uri.encodeComponent(instanceId)}/files',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return CreateAttachedFileResponse.fromJson(response);
}