Skip to content

Commit

Permalink
feat(smithy-client): factory for aggregated clients
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Apr 17, 2023
1 parent 73f539d commit 53224b2
Show file tree
Hide file tree
Showing 10 changed files with 1,737 additions and 11,834 deletions.
7,401 changes: 480 additions & 6,921 deletions clients/client-s3/src/S3.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/smithy-client/src/index.ts
Expand Up @@ -2,6 +2,7 @@ export * from "./NoOpLogger";
export * from "./client";
export * from "./command";
export * from "./constants";
export * from "./create-aggregated-client";
export * from "./date-utils";
export * from "./default-error-handler";
export * from "./defaults-mode";
Expand Down
71 changes: 25 additions & 46 deletions private/aws-echo-service/src/EchoService.ts
@@ -1,62 +1,41 @@
// smithy-typescript generated code
import { EchoServiceClient } from "./EchoServiceClient";
import { EchoServiceClient, EchoServiceClientConfig } from "./EchoServiceClient";
import { EchoCommand, EchoCommandInput, EchoCommandOutput } from "./commands/EchoCommand";
import { LengthCommand, LengthCommandInput, LengthCommandOutput } from "./commands/LengthCommand";
import { createProxyClient } from "@aws-sdk/smithy-client";
import { HttpHandlerOptions as __HttpHandlerOptions } from "@aws-sdk/types";

/**
* @public
*/
export class EchoService extends EchoServiceClient {
const commands = {
EchoCommand,
LengthCommand,
};
export interface EchoService {
/**
* @public
* @see {@link EchoCommand}
*/
public echo(args: EchoCommandInput, options?: __HttpHandlerOptions): Promise<EchoCommandOutput>;
public echo(args: EchoCommandInput, cb: (err: any, data?: EchoCommandOutput) => void): void;
public echo(
args: EchoCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: EchoCommandOutput) => void
): void;
public echo(
args: EchoCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: EchoCommandOutput) => void),
cb?: (err: any, data?: EchoCommandOutput) => void
): Promise<EchoCommandOutput> | void {
const command = new EchoCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}
echo(args: EchoCommandInput, options?: __HttpHandlerOptions): Promise<EchoCommandOutput>;
echo(args: EchoCommandInput, cb: (err: any, data?: EchoCommandOutput) => void): void;
echo(args: EchoCommandInput, options: __HttpHandlerOptions, cb: (err: any, data?: EchoCommandOutput) => void): void;

/**
* @public
* @see {@link LengthCommand}
*/
public length(args: LengthCommandInput, options?: __HttpHandlerOptions): Promise<LengthCommandOutput>;
public length(args: LengthCommandInput, cb: (err: any, data?: LengthCommandOutput) => void): void;
public length(
length(args: LengthCommandInput, options?: __HttpHandlerOptions): Promise<LengthCommandOutput>;
length(args: LengthCommandInput, cb: (err: any, data?: LengthCommandOutput) => void): void;
length(
args: LengthCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: LengthCommandOutput) => void
): void;
public length(
args: LengthCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: LengthCommandOutput) => void),
cb?: (err: any, data?: LengthCommandOutput) => void
): Promise<LengthCommandOutput> | void {
const command = new LengthCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* @public
*/
export class EchoService extends EchoServiceClient implements EchoService {
public constructor(config: EchoServiceClientConfig) {
super(config);
const target: any = {};
return createProxyClient(target, commands, this);
}
}

0 comments on commit 53224b2

Please sign in to comment.