-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(temp codegen): generate clients
- Loading branch information
Steven Yuan
committed
Nov 13, 2023
1 parent
e3b85d6
commit 9a6a5ff
Showing
13 changed files
with
353 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
clients/client-codecatalyst/src/auth/httpAuthExtensionConfiguration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// smithy-typescript generated code | ||
import { HttpAuthScheme, TokenIdentity, TokenIdentityProvider } from "@smithy/types"; | ||
|
||
import { CodeCatalystHttpAuthSchemeProvider } from "./httpAuthSchemeProvider"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface HttpAuthExtensionConfiguration { | ||
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void; | ||
httpAuthSchemes(): HttpAuthScheme[]; | ||
setHttpAuthSchemeProvider(httpAuthSchemeProvider: CodeCatalystHttpAuthSchemeProvider): void; | ||
httpAuthSchemeProvider(): CodeCatalystHttpAuthSchemeProvider; | ||
setToken(token: TokenIdentity | TokenIdentityProvider): void; | ||
token(): TokenIdentity | TokenIdentityProvider | undefined; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export type HttpAuthRuntimeConfig = Partial<{ | ||
httpAuthSchemes: HttpAuthScheme[]; | ||
httpAuthSchemeProvider: CodeCatalystHttpAuthSchemeProvider; | ||
token: TokenIdentity | TokenIdentityProvider; | ||
}>; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const getHttpAuthExtensionConfiguration = ( | ||
runtimeConfig: HttpAuthRuntimeConfig | ||
): HttpAuthExtensionConfiguration => { | ||
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes!; | ||
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider!; | ||
let _token = runtimeConfig.token; | ||
return { | ||
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void { | ||
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId); | ||
if (index === -1) { | ||
_httpAuthSchemes.push(httpAuthScheme); | ||
} else { | ||
_httpAuthSchemes.splice(index, 1, httpAuthScheme); | ||
} | ||
}, | ||
httpAuthSchemes(): HttpAuthScheme[] { | ||
return _httpAuthSchemes; | ||
}, | ||
setHttpAuthSchemeProvider(httpAuthSchemeProvider: CodeCatalystHttpAuthSchemeProvider): void { | ||
_httpAuthSchemeProvider = httpAuthSchemeProvider; | ||
}, | ||
httpAuthSchemeProvider(): CodeCatalystHttpAuthSchemeProvider { | ||
return _httpAuthSchemeProvider; | ||
}, | ||
setToken(token: TokenIdentity | TokenIdentityProvider): void { | ||
_token = token; | ||
}, | ||
token(): TokenIdentity | TokenIdentityProvider | undefined { | ||
return _token; | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const resolveHttpAuthRuntimeConfig = (config: HttpAuthExtensionConfiguration): HttpAuthRuntimeConfig => { | ||
return { | ||
httpAuthSchemes: config.httpAuthSchemes(), | ||
httpAuthSchemeProvider: config.httpAuthSchemeProvider(), | ||
token: config.token(), | ||
}; | ||
}; |
126 changes: 126 additions & 0 deletions
126
clients/client-codecatalyst/src/auth/httpAuthSchemeProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// smithy-typescript generated code | ||
import { doesIdentityRequireRefresh, isIdentityExpired, memoizeIdentityProvider } from "@smithy/core"; | ||
import { | ||
HandlerExecutionContext, | ||
HttpAuthOption, | ||
HttpAuthScheme, | ||
HttpAuthSchemeParameters, | ||
HttpAuthSchemeParametersProvider, | ||
HttpAuthSchemeProvider, | ||
TokenIdentity, | ||
TokenIdentityProvider, | ||
} from "@smithy/types"; | ||
import { getSmithyContext } from "@smithy/util-middleware"; | ||
|
||
import { CodeCatalystClientResolvedConfig } from "../CodeCatalystClient"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface CodeCatalystHttpAuthSchemeParameters extends HttpAuthSchemeParameters {} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface CodeCatalystHttpAuthSchemeParametersProvider | ||
extends HttpAuthSchemeParametersProvider< | ||
CodeCatalystClientResolvedConfig, | ||
HandlerExecutionContext, | ||
CodeCatalystHttpAuthSchemeParameters, | ||
object | ||
> {} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const defaultCodeCatalystHttpAuthSchemeParametersProvider = async ( | ||
config: CodeCatalystClientResolvedConfig, | ||
context: HandlerExecutionContext, | ||
input: object | ||
): Promise<CodeCatalystHttpAuthSchemeParameters> => { | ||
return { | ||
operation: getSmithyContext(context).operation as string, | ||
}; | ||
}; | ||
|
||
function createSmithyApiHttpBearerAuthHttpAuthOption( | ||
authParameters: CodeCatalystHttpAuthSchemeParameters | ||
): HttpAuthOption { | ||
return { | ||
schemeId: "smithy.api#httpBearerAuth", | ||
}; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface CodeCatalystHttpAuthSchemeProvider | ||
extends HttpAuthSchemeProvider<CodeCatalystHttpAuthSchemeParameters> {} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const defaultCodeCatalystHttpAuthSchemeProvider: CodeCatalystHttpAuthSchemeProvider = (authParameters) => { | ||
const options: HttpAuthOption[] = []; | ||
switch (authParameters.operation) { | ||
default: { | ||
options.push(createSmithyApiHttpBearerAuthHttpAuthOption(authParameters)); | ||
} | ||
} | ||
return options; | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface HttpAuthSchemeInputConfig { | ||
/** | ||
* experimentalIdentityAndAuth: Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme. | ||
* @internal | ||
*/ | ||
httpAuthSchemes?: HttpAuthScheme[]; | ||
|
||
/** | ||
* experimentalIdentityAndAuth: Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use. | ||
* @internal | ||
*/ | ||
httpAuthSchemeProvider?: CodeCatalystHttpAuthSchemeProvider; | ||
|
||
/** | ||
* The token used to authenticate requests. | ||
*/ | ||
token?: TokenIdentity | TokenIdentityProvider; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface HttpAuthSchemeResolvedConfig { | ||
/** | ||
* experimentalIdentityAndAuth: Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme. | ||
* @internal | ||
*/ | ||
readonly httpAuthSchemes: HttpAuthScheme[]; | ||
|
||
/** | ||
* experimentalIdentityAndAuth: Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use. | ||
* @internal | ||
*/ | ||
readonly httpAuthSchemeProvider: CodeCatalystHttpAuthSchemeProvider; | ||
|
||
/** | ||
* The token used to authenticate requests. | ||
*/ | ||
readonly token?: TokenIdentityProvider; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const resolveHttpAuthSchemeConfig = (config: HttpAuthSchemeInputConfig): HttpAuthSchemeResolvedConfig => { | ||
const token = memoizeIdentityProvider(config.token, isIdentityExpired, doesIdentityRequireRefresh); | ||
return { | ||
...config, | ||
token, | ||
} as HttpAuthSchemeResolvedConfig; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.