-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sample diff for paginator factory
- Loading branch information
Showing
11 changed files
with
88 additions
and
374 deletions.
There are no files selected for viewing
42 changes: 8 additions & 34 deletions
42
clients/client-lambda/src/pagination/ListAliasesPaginator.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 |
---|---|---|
@@ -1,46 +1,20 @@ | ||
// smithy-typescript generated code | ||
import { createPaginator } from "@smithy/core"; | ||
import { Paginator } from "@smithy/types"; | ||
|
||
import { ListAliasesCommand, ListAliasesCommandInput, ListAliasesCommandOutput } from "../commands/ListAliasesCommand"; | ||
import { LambdaClient } from "../LambdaClient"; | ||
import { LambdaPaginationConfiguration } from "./Interfaces"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
const makePagedClientRequest = async ( | ||
client: LambdaClient, | ||
input: ListAliasesCommandInput, | ||
...args: any | ||
): Promise<ListAliasesCommandOutput> => { | ||
// @ts-ignore | ||
return await client.send(new ListAliasesCommand(input), ...args); | ||
}; | ||
/** | ||
* @public | ||
*/ | ||
export async function* paginateListAliases( | ||
export const paginateListAliases: ( | ||
config: LambdaPaginationConfiguration, | ||
input: ListAliasesCommandInput, | ||
...additionalArguments: any | ||
): Paginator<ListAliasesCommandOutput> { | ||
// ToDo: replace with actual type instead of typeof input.Marker | ||
let token: typeof input.Marker | undefined = config.startingToken || undefined; | ||
let hasNext = true; | ||
let page: ListAliasesCommandOutput; | ||
while (hasNext) { | ||
input.Marker = token; | ||
input["MaxItems"] = config.pageSize; | ||
if (config.client instanceof LambdaClient) { | ||
page = await makePagedClientRequest(config.client, input, ...additionalArguments); | ||
} else { | ||
throw new Error("Invalid client, expected Lambda | LambdaClient"); | ||
} | ||
yield page; | ||
const prevToken = token; | ||
token = page.NextMarker; | ||
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken)); | ||
} | ||
// @ts-ignore | ||
return undefined; | ||
} | ||
...rest: any[] | ||
) => Paginator<ListAliasesCommandOutput> = createPaginator< | ||
LambdaPaginationConfiguration, | ||
ListAliasesCommandInput, | ||
ListAliasesCommandOutput | ||
>(LambdaClient, ListAliasesCommand, "Marker", "NextMarker", "MaxItems"); |
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
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.