Skip to content

Commit

Permalink
feat: add sharedConfig file for un-runtime default values
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP committed Dec 5, 2019
1 parent f04fb7a commit 56b206d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 31 deletions.
36 changes: 9 additions & 27 deletions clients/client-rds-data/RdsDataServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
RollbackTransactionRequest,
RollbackTransactionResponse
} from "./models/index";
import { RDSRuntimeConfiguration } from "./runtimeConfig";
import { RDSDefaultValues } from "./runtimeConfig";
import {
Credentials,
Provider,
Expand Down Expand Up @@ -73,25 +73,13 @@ export type ServiceOutputTypes =
| ExecuteStatementResponse
| BatchExecuteStatementResponse;

export interface RDSDataSharedConfig {
/**
* The function that will be used to populate serializing protocol
*/
protocol?: string;
/**
* The service name with which to sign requests.
*/
export interface RDSDataDefaults
extends Partial<SmithyResolvedConfiguration<__HttpOptions>> {
// protocol?: string;
signingName?: string;
/**
* The service name with which to construct endpoints.
*/
// apiVersion?: string;
service?: string;
/**
* Major version of the API model in YYYY-MM-DD format
*/
apiVersion?: string;
}
export interface RDSDataRuntimeDependencies {

/**
* The HTTP handler to use. Fetch in browser and Https in Nodejs
*/
Expand Down Expand Up @@ -153,8 +141,7 @@ export interface RDSDataRuntimeDependencies {
defaultUserAgent?: string;
}

export type RdsDataServiceConfig = RDSDataSharedConfig &
RDSDataRuntimeDependencies &
export type RdsDataServiceConfig = RDSDataDefaults &
AwsAuthInputConfig &
RegionInputConfig &
RetryInputConfig &
Expand All @@ -164,8 +151,7 @@ export type RdsDataServiceConfig = RDSDataSharedConfig &
export type RdsDataServiceResolvedConfig = SmithyResolvedConfiguration<
__HttpOptions
> &
Required<RDSDataSharedConfig> &
Required<RDSDataRuntimeDependencies> &
Required<RDSDataDefaults> &
AwsAuthResolvedConfig &
RegionResolvedConfig &
RetryResolvedConfig &
Expand All @@ -182,11 +168,7 @@ export class RdsDataService extends SmithyClient<

constructor(configuration: RdsDataServiceConfig) {
const _config_0 = {
apiVersion: "2018-08-01",
protocol: "aws.rest-json-1.1",
signingName: "rds-data", //TODO: signing name and service should not be generated as they will be populated by RIP
service: "rds-data",
...RDSRuntimeConfiguration,
...RDSDefaultValues,
...configuration
};
let _config_1 = resolveRegionConfig(_config_0);
Expand Down
6 changes: 4 additions & 2 deletions clients/client-rds-data/runtimeConfig.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-browser";
import { fromBase64, toBase64 } from "@aws-sdk/util-base64-browser";
import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
import { name, version } from "./package.json";
import { RDSDataRuntimeDependencies } from "./RdsDataServiceClient";
import { RDSDataDefaults } from "./RdsDataServiceClient";
import { RDSDataSharedConfigDefaults } from "./sharedConfig";

export const RDSRuntimeConfiguration: Required<RDSDataRuntimeDependencies> = {
export const RDSRuntimeConfiguration: Required<RDSDataDefaults> = {
...RDSDataSharedConfigDefaults,
requestHandler: new FetchHttpHandler(),
sha256: Sha256,
credentialDefaultProvider: invalidFunction("Credential is missing") as any,
Expand Down
6 changes: 4 additions & 2 deletions clients/client-rds-data/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { fromUtf8, toUtf8 } from "@aws-sdk/util-utf8-node";
import { fromBase64, toBase64 } from "@aws-sdk/util-base64-node";
import { defaultUserAgent } from "@aws-sdk/util-user-agent-node";
import { name, version } from "./package.json";
import { RDSDataRuntimeDependencies } from "./RdsDataServiceClient";
import { RDSDataDefaults } from "./RdsDataServiceClient";
import { RDSDataSharedConfig } from "./sharedConfig";

export const RDSRuntimeConfiguration: Required<RDSDataRuntimeDependencies> = {
export const RDSDefaultValues: Required<RDSDataDefaults> = {
...RDSDataSharedConfig,
requestHandler: new NodeHttpHandler(),
sha256: Hash.bind(null, "sha256"),
credentialDefaultProvider,
Expand Down
6 changes: 6 additions & 0 deletions clients/client-rds-data/sharedConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const RDSDataSharedConfigDefaults = {
protocol: "rds-data",
signingName: "rds-data",
apiVersion: "2018-08-01",
service: "rds-data"
};
1 change: 1 addition & 0 deletions packages/smithy-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
export interface SmithyConfiguration<HandlerOptions> {
requestHandler: RequestHandler<any, any, HandlerOptions>;
readonly apiVersion: string;
readonly protocol: string;
}

export type SmithyResolvedConfiguration<HandlerOptions> = SmithyConfiguration<
Expand Down

0 comments on commit 56b206d

Please sign in to comment.