liveBook · Manning

Output configuration interface

As explained in API Design Patterns

An output configuration interface is an API interface that specifies the destination and processing options for exported data.

An output configuration interface specifies where exported data goes and how it is processed. Encapsulating these options lets a request carry configuration in and receive the same configuration as confirmation. section 2.4.3

A typical configuration can include:

  • A destination, such as a hosted file or an Amazon S3 location. section 2.4.3
  • Optional compression, including a gzip compression level from 1 to 9. section 2.4.3
  • Optional encryption settings that can be extended with additional configuration. section 2.4.3

Exporting messages

An ExportMessages request accepts a parent user and MessageOutputConfig. The export response returns that output configuration, while a long-running operation reports progress and eventually returns the result or an error. section 2.4.3

Listing 2.4 API to export messages using a design pattern
abstract class Twapi {
  static version = "v1";
  static title = "Twapi API";
 
  @post("/{parent=users/*}/messages:export")
  ExportMessages(req: ExportMessagesRequest):
      Operation<ExportMessagesResponse,
                ExportMessagesMetadata>;           #1
}
 
interface ExportMessagesRequest {
  // The parent user of the messages to be exported.
  parent: string;
  outputConfig: MessageOutputConfig;               #2
}
 
interface MessageOutputConfig {
  destination: Destination;                        #3
  compressionConfig?: CompressionConfig;           #4
  encryptionConfig?: EncryptionConfig;
}
 
interface ExportMessagesResponse {
  outputConfig: MessageOutputConfig;               #5
}
 
interface ExportMessagesMetadata {
  // An integer between 0 and 100
  // representing the progress of the operation.
  progressPercent: number;                         #6
}

Use the API definition to see how outputConfig connects the export request and response to an asynchronous operation. section 2.4.3

How API Design Patterns covers it

How deep it goes
Defines destination, compression, and encryption interfaces, but leaves long-running operation mechanics at a high level.
Examples
Uses message exports targeting hosted files or Amazon S3, with optional gzip compression and encryption configuration.
What you can do after
Build it into an export API that accepts configurable destinations and processing options while tracking asynchronous progress.
How it connects
Connects import/export patterns with long-running operations, destinations, compression, encryption, and common error interfaces.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.