The import/export pattern structures large data transfers around configurable destinations, transformations, and asynchronous processing. It improves on a simple export endpoint that returns only a download location by making request choices reusable in the response and exposing operation progress. section 2.4.3
A practical design should:
- Accept an output configuration containing a destination and optional compression or encryption settings. section 2.4.3
- Represent the transfer as a long-running operation with completion state, results, errors, and percentage progress. section 2.4.3
- Support destination variants such as a hosted file or an Amazon S3 location, while making access requirements explicit. section 2.4.3
Listing 2.3 Simple API to export messages
abstract class Twapi {
static version = "v1";
static title = "Twapi API";
@post("/{parent=users/*}/messages:export") #1
ExportMessages(req: ExportMessagesRequest):
ExportMessagesResponse; #2
}
interface ExportMessagesRequest {
// The parent user of the messages to be exported.
parent: string; #3
}
interface ExportMessagesResponse {
// The location of a compressed file
// containing the messages requested.
exportDownloadUri: string; #4
}
Compare a simple message-export endpoint with the pattern-based design: the latter returns an operation rather than an immediate download URI. section 2.4.3
Exporting user messages
POST /{parent=users/*}/messages:export accepts an outputConfig specifying an Amazon S3 destination, gzip compression, and optional encryption. The response exposes the same configuration through an asynchronous operation, whose metadata reports progress from 0% to 100%. section 2.4.3
