Skip to content

Commit

Permalink
feat: paginator simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Dec 19, 2023
1 parent 8406c30 commit 229643c
Show file tree
Hide file tree
Showing 2,748 changed files with 22,095 additions and 93,442 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { createPaginator } from "@smithy/core";
import { Paginator } from "@smithy/types";

import { AccessAnalyzerClient } from "../AccessAnalyzerClient";
Expand All @@ -9,42 +10,15 @@ import {
} from "../commands/GetFindingV2Command";
import { AccessAnalyzerPaginationConfiguration } from "./Interfaces";

/**
* @internal
*/
const makePagedClientRequest = async (
client: AccessAnalyzerClient,
input: GetFindingV2CommandInput,
...args: any
): Promise<GetFindingV2CommandOutput> => {
// @ts-ignore
return await client.send(new GetFindingV2Command(input), ...args);
};
/**
* @public
*/
export async function* paginateGetFindingV2(
export const paginateGetFindingV2: (
config: AccessAnalyzerPaginationConfiguration,
input: GetFindingV2CommandInput,
...additionalArguments: any
): Paginator<GetFindingV2CommandOutput> {
// ToDo: replace with actual type instead of typeof input.nextToken
let token: typeof input.nextToken | undefined = config.startingToken || undefined;
let hasNext = true;
let page: GetFindingV2CommandOutput;
while (hasNext) {
input.nextToken = token;
input["maxResults"] = config.pageSize;
if (config.client instanceof AccessAnalyzerClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected AccessAnalyzer | AccessAnalyzerClient");
}
yield page;
const prevToken = token;
token = page.nextToken;
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
// @ts-ignore
return undefined;
}
...rest: any[]
) => Paginator<GetFindingV2CommandOutput> = createPaginator<
AccessAnalyzerPaginationConfiguration,
GetFindingV2CommandInput,
GetFindingV2CommandOutput
>(AccessAnalyzerClient, GetFindingV2Command, "nextToken", "nextToken", "maxResults");
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { createPaginator } from "@smithy/core";
import { Paginator } from "@smithy/types";

import { AccessAnalyzerClient } from "../AccessAnalyzerClient";
Expand All @@ -9,42 +10,15 @@ import {
} from "../commands/ListAccessPreviewFindingsCommand";
import { AccessAnalyzerPaginationConfiguration } from "./Interfaces";

/**
* @internal
*/
const makePagedClientRequest = async (
client: AccessAnalyzerClient,
input: ListAccessPreviewFindingsCommandInput,
...args: any
): Promise<ListAccessPreviewFindingsCommandOutput> => {
// @ts-ignore
return await client.send(new ListAccessPreviewFindingsCommand(input), ...args);
};
/**
* @public
*/
export async function* paginateListAccessPreviewFindings(
export const paginateListAccessPreviewFindings: (
config: AccessAnalyzerPaginationConfiguration,
input: ListAccessPreviewFindingsCommandInput,
...additionalArguments: any
): Paginator<ListAccessPreviewFindingsCommandOutput> {
// ToDo: replace with actual type instead of typeof input.nextToken
let token: typeof input.nextToken | undefined = config.startingToken || undefined;
let hasNext = true;
let page: ListAccessPreviewFindingsCommandOutput;
while (hasNext) {
input.nextToken = token;
input["maxResults"] = config.pageSize;
if (config.client instanceof AccessAnalyzerClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected AccessAnalyzer | AccessAnalyzerClient");
}
yield page;
const prevToken = token;
token = page.nextToken;
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
// @ts-ignore
return undefined;
}
...rest: any[]
) => Paginator<ListAccessPreviewFindingsCommandOutput> = createPaginator<
AccessAnalyzerPaginationConfiguration,
ListAccessPreviewFindingsCommandInput,
ListAccessPreviewFindingsCommandOutput
>(AccessAnalyzerClient, ListAccessPreviewFindingsCommand, "nextToken", "nextToken", "maxResults");
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { createPaginator } from "@smithy/core";
import { Paginator } from "@smithy/types";

import { AccessAnalyzerClient } from "../AccessAnalyzerClient";
Expand All @@ -9,42 +10,15 @@ import {
} from "../commands/ListAccessPreviewsCommand";
import { AccessAnalyzerPaginationConfiguration } from "./Interfaces";

/**
* @internal
*/
const makePagedClientRequest = async (
client: AccessAnalyzerClient,
input: ListAccessPreviewsCommandInput,
...args: any
): Promise<ListAccessPreviewsCommandOutput> => {
// @ts-ignore
return await client.send(new ListAccessPreviewsCommand(input), ...args);
};
/**
* @public
*/
export async function* paginateListAccessPreviews(
export const paginateListAccessPreviews: (
config: AccessAnalyzerPaginationConfiguration,
input: ListAccessPreviewsCommandInput,
...additionalArguments: any
): Paginator<ListAccessPreviewsCommandOutput> {
// ToDo: replace with actual type instead of typeof input.nextToken
let token: typeof input.nextToken | undefined = config.startingToken || undefined;
let hasNext = true;
let page: ListAccessPreviewsCommandOutput;
while (hasNext) {
input.nextToken = token;
input["maxResults"] = config.pageSize;
if (config.client instanceof AccessAnalyzerClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected AccessAnalyzer | AccessAnalyzerClient");
}
yield page;
const prevToken = token;
token = page.nextToken;
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
// @ts-ignore
return undefined;
}
...rest: any[]
) => Paginator<ListAccessPreviewsCommandOutput> = createPaginator<
AccessAnalyzerPaginationConfiguration,
ListAccessPreviewsCommandInput,
ListAccessPreviewsCommandOutput
>(AccessAnalyzerClient, ListAccessPreviewsCommand, "nextToken", "nextToken", "maxResults");
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { createPaginator } from "@smithy/core";
import { Paginator } from "@smithy/types";

import { AccessAnalyzerClient } from "../AccessAnalyzerClient";
Expand All @@ -9,42 +10,15 @@ import {
} from "../commands/ListAnalyzedResourcesCommand";
import { AccessAnalyzerPaginationConfiguration } from "./Interfaces";

/**
* @internal
*/
const makePagedClientRequest = async (
client: AccessAnalyzerClient,
input: ListAnalyzedResourcesCommandInput,
...args: any
): Promise<ListAnalyzedResourcesCommandOutput> => {
// @ts-ignore
return await client.send(new ListAnalyzedResourcesCommand(input), ...args);
};
/**
* @public
*/
export async function* paginateListAnalyzedResources(
export const paginateListAnalyzedResources: (
config: AccessAnalyzerPaginationConfiguration,
input: ListAnalyzedResourcesCommandInput,
...additionalArguments: any
): Paginator<ListAnalyzedResourcesCommandOutput> {
// ToDo: replace with actual type instead of typeof input.nextToken
let token: typeof input.nextToken | undefined = config.startingToken || undefined;
let hasNext = true;
let page: ListAnalyzedResourcesCommandOutput;
while (hasNext) {
input.nextToken = token;
input["maxResults"] = config.pageSize;
if (config.client instanceof AccessAnalyzerClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected AccessAnalyzer | AccessAnalyzerClient");
}
yield page;
const prevToken = token;
token = page.nextToken;
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
// @ts-ignore
return undefined;
}
...rest: any[]
) => Paginator<ListAnalyzedResourcesCommandOutput> = createPaginator<
AccessAnalyzerPaginationConfiguration,
ListAnalyzedResourcesCommandInput,
ListAnalyzedResourcesCommandOutput
>(AccessAnalyzerClient, ListAnalyzedResourcesCommand, "nextToken", "nextToken", "maxResults");
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { createPaginator } from "@smithy/core";
import { Paginator } from "@smithy/types";

import { AccessAnalyzerClient } from "../AccessAnalyzerClient";
Expand All @@ -9,42 +10,15 @@ import {
} from "../commands/ListAnalyzersCommand";
import { AccessAnalyzerPaginationConfiguration } from "./Interfaces";

/**
* @internal
*/
const makePagedClientRequest = async (
client: AccessAnalyzerClient,
input: ListAnalyzersCommandInput,
...args: any
): Promise<ListAnalyzersCommandOutput> => {
// @ts-ignore
return await client.send(new ListAnalyzersCommand(input), ...args);
};
/**
* @public
*/
export async function* paginateListAnalyzers(
export const paginateListAnalyzers: (
config: AccessAnalyzerPaginationConfiguration,
input: ListAnalyzersCommandInput,
...additionalArguments: any
): Paginator<ListAnalyzersCommandOutput> {
// ToDo: replace with actual type instead of typeof input.nextToken
let token: typeof input.nextToken | undefined = config.startingToken || undefined;
let hasNext = true;
let page: ListAnalyzersCommandOutput;
while (hasNext) {
input.nextToken = token;
input["maxResults"] = config.pageSize;
if (config.client instanceof AccessAnalyzerClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected AccessAnalyzer | AccessAnalyzerClient");
}
yield page;
const prevToken = token;
token = page.nextToken;
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
// @ts-ignore
return undefined;
}
...rest: any[]
) => Paginator<ListAnalyzersCommandOutput> = createPaginator<
AccessAnalyzerPaginationConfiguration,
ListAnalyzersCommandInput,
ListAnalyzersCommandOutput
>(AccessAnalyzerClient, ListAnalyzersCommand, "nextToken", "nextToken", "maxResults");
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { createPaginator } from "@smithy/core";
import { Paginator } from "@smithy/types";

import { AccessAnalyzerClient } from "../AccessAnalyzerClient";
Expand All @@ -9,42 +10,15 @@ import {
} from "../commands/ListArchiveRulesCommand";
import { AccessAnalyzerPaginationConfiguration } from "./Interfaces";

/**
* @internal
*/
const makePagedClientRequest = async (
client: AccessAnalyzerClient,
input: ListArchiveRulesCommandInput,
...args: any
): Promise<ListArchiveRulesCommandOutput> => {
// @ts-ignore
return await client.send(new ListArchiveRulesCommand(input), ...args);
};
/**
* @public
*/
export async function* paginateListArchiveRules(
export const paginateListArchiveRules: (
config: AccessAnalyzerPaginationConfiguration,
input: ListArchiveRulesCommandInput,
...additionalArguments: any
): Paginator<ListArchiveRulesCommandOutput> {
// ToDo: replace with actual type instead of typeof input.nextToken
let token: typeof input.nextToken | undefined = config.startingToken || undefined;
let hasNext = true;
let page: ListArchiveRulesCommandOutput;
while (hasNext) {
input.nextToken = token;
input["maxResults"] = config.pageSize;
if (config.client instanceof AccessAnalyzerClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected AccessAnalyzer | AccessAnalyzerClient");
}
yield page;
const prevToken = token;
token = page.nextToken;
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
// @ts-ignore
return undefined;
}
...rest: any[]
) => Paginator<ListArchiveRulesCommandOutput> = createPaginator<
AccessAnalyzerPaginationConfiguration,
ListArchiveRulesCommandInput,
ListArchiveRulesCommandOutput
>(AccessAnalyzerClient, ListArchiveRulesCommand, "nextToken", "nextToken", "maxResults");
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { createPaginator } from "@smithy/core";
import { Paginator } from "@smithy/types";

import { AccessAnalyzerClient } from "../AccessAnalyzerClient";
Expand All @@ -9,42 +10,15 @@ import {
} from "../commands/ListFindingsCommand";
import { AccessAnalyzerPaginationConfiguration } from "./Interfaces";

/**
* @internal
*/
const makePagedClientRequest = async (
client: AccessAnalyzerClient,
input: ListFindingsCommandInput,
...args: any
): Promise<ListFindingsCommandOutput> => {
// @ts-ignore
return await client.send(new ListFindingsCommand(input), ...args);
};
/**
* @public
*/
export async function* paginateListFindings(
export const paginateListFindings: (
config: AccessAnalyzerPaginationConfiguration,
input: ListFindingsCommandInput,
...additionalArguments: any
): Paginator<ListFindingsCommandOutput> {
// ToDo: replace with actual type instead of typeof input.nextToken
let token: typeof input.nextToken | undefined = config.startingToken || undefined;
let hasNext = true;
let page: ListFindingsCommandOutput;
while (hasNext) {
input.nextToken = token;
input["maxResults"] = config.pageSize;
if (config.client instanceof AccessAnalyzerClient) {
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
} else {
throw new Error("Invalid client, expected AccessAnalyzer | AccessAnalyzerClient");
}
yield page;
const prevToken = token;
token = page.nextToken;
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
}
// @ts-ignore
return undefined;
}
...rest: any[]
) => Paginator<ListFindingsCommandOutput> = createPaginator<
AccessAnalyzerPaginationConfiguration,
ListFindingsCommandInput,
ListFindingsCommandOutput
>(AccessAnalyzerClient, ListFindingsCommand, "nextToken", "nextToken", "maxResults");
Loading

0 comments on commit 229643c

Please sign in to comment.