UNPKG

3.26 kBTypeScriptView Raw
1import {Request} from './request';
2import {AWSError} from './error';
3import {ConfigurationOptions, ConfigBase} from './config';
4import {Endpoint} from './endpoint';
5
6export interface WaiterConfiguration {
7 /**
8 * The number of seconds to wait between requests
9 */
10 delay?: number;
11
12 /**
13 * The maximum number of requests to send while waiting
14 */
15 maxAttempts?: number;
16}
17
18export class Service {
19 /**
20 * Creates a new service object with a configuration object.
21 */
22 constructor(config?: ServiceConfigurationOptions);
23
24 /**
25 * Defines a new Service class using a service identifier and list of versions including an optional set of features (functions) to apply to the class prototype.
26 *
27 * @param {string} serviceIdentifier - the identifier for the service.
28 * @param {string[]} versions - a list of versions that work with this service.
29 * @param {Object} features - an object to attach to the prototype.
30 */
31 defineService(serviceIdentifier: string, versions: string[], features?: any): typeof Service;
32 /**
33 * Calls an operation on a service with the given input parameters.
34 *
35 * @param {string} operation - the name of the operation to call on the service.
36 * @param {map} params - a map of input options for the operation.
37 */
38 makeRequest(operation: string, params?: {[key: string]: any}, callback?: (err: AWSError, data: any) => void): Request<any, AWSError>;
39 /**
40 * Calls an operation on a service with the given input parameters, without any authentication data.
41 *
42 * @param {string} operation - the name of the operation to call on the service.
43 * @param {map} params - a map of input options for the operation.
44 */
45 makeUnauthenticatedRequest(operation: string, params?: {[key: string]: any}, callback?: (err: AWSError, data: any) => void): Request<any, AWSError>;
46 /**
47 * Override this method to setup any custom request listeners for each new request to the service.
48 */
49 setupRequestListeners(request: Request<any, AWSError>): void;
50 /**
51 * Waits for a given state.
52 */
53 waitFor(state: string, params?: {[key: string]: any, $waiter?: WaiterConfiguration}, callback?: (err: AWSError, data: any) => void): Request<any, AWSError>;
54 waitFor(state: string, callback?: (err: AWSError, data: any) => void): Request<any, AWSError>;
55
56 /**
57 * The list of API versions supported by this service.
58 */
59 apiVersions: string[];
60
61 config: ConfigBase & ServiceConfigurationOptions;
62
63 /**
64 * An Endpoint object representing the endpoint URL for service requests.
65 */
66 endpoint: Endpoint;
67}
68
69export interface ServiceConfigurationOptions extends ConfigurationOptions {
70 /**
71 * The endpoint URI to send requests to. The default endpoint is built from the configured region.
72 * The endpoint should be a string like 'https://{service}.{region}.amazonaws.com'.
73 */
74 endpoint?: string;
75 /**
76 * An optional map of parameters to bind to every request sent by this service object.
77 * For more information on bound parameters, see "Working with Services" in the Getting Started Guide.
78 */
79 params?: {
80 [key: string]: any;
81 }
82}
83