service.d.ts 3.2 KB

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