-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client-marketplace-entitlement-service): Add paginators to GetEn…
…titlements.
- Loading branch information
awstools
committed
Nov 10, 2023
1 parent
ec1318c
commit 18d6d94
Showing
5 changed files
with
81 additions
and
2 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
50 changes: 50 additions & 0 deletions
50
clients/client-marketplace-entitlement-service/src/pagination/GetEntitlementsPaginator.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,50 @@ | ||
// smithy-typescript generated code | ||
import { Paginator } from "@smithy/types"; | ||
|
||
import { | ||
GetEntitlementsCommand, | ||
GetEntitlementsCommandInput, | ||
GetEntitlementsCommandOutput, | ||
} from "../commands/GetEntitlementsCommand"; | ||
import { MarketplaceEntitlementServiceClient } from "../MarketplaceEntitlementServiceClient"; | ||
import { MarketplaceEntitlementServicePaginationConfiguration } from "./Interfaces"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
const makePagedClientRequest = async ( | ||
client: MarketplaceEntitlementServiceClient, | ||
input: GetEntitlementsCommandInput, | ||
...args: any | ||
): Promise<GetEntitlementsCommandOutput> => { | ||
// @ts-ignore | ||
return await client.send(new GetEntitlementsCommand(input), ...args); | ||
}; | ||
/** | ||
* @public | ||
*/ | ||
export async function* paginateGetEntitlements( | ||
config: MarketplaceEntitlementServicePaginationConfiguration, | ||
input: GetEntitlementsCommandInput, | ||
...additionalArguments: any | ||
): Paginator<GetEntitlementsCommandOutput> { | ||
// ToDo: replace with actual type instead of typeof input.NextToken | ||
let token: typeof input.NextToken | undefined = config.startingToken || undefined; | ||
let hasNext = true; | ||
let page: GetEntitlementsCommandOutput; | ||
while (hasNext) { | ||
input.NextToken = token; | ||
input["MaxResults"] = config.pageSize; | ||
if (config.client instanceof MarketplaceEntitlementServiceClient) { | ||
page = await makePagedClientRequest(config.client, input, ...additionalArguments); | ||
} else { | ||
throw new Error("Invalid client, expected MarketplaceEntitlementService | MarketplaceEntitlementServiceClient"); | ||
} | ||
yield page; | ||
const prevToken = token; | ||
token = page.NextToken; | ||
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken)); | ||
} | ||
// @ts-ignore | ||
return undefined; | ||
} |
11 changes: 11 additions & 0 deletions
11
clients/client-marketplace-entitlement-service/src/pagination/Interfaces.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,11 @@ | ||
// smithy-typescript generated code | ||
import { PaginationConfiguration } from "@smithy/types"; | ||
|
||
import { MarketplaceEntitlementServiceClient } from "../MarketplaceEntitlementServiceClient"; | ||
|
||
/** | ||
* @public | ||
*/ | ||
export interface MarketplaceEntitlementServicePaginationConfiguration extends PaginationConfiguration { | ||
client: MarketplaceEntitlementServiceClient; | ||
} |
3 changes: 3 additions & 0 deletions
3
clients/client-marketplace-entitlement-service/src/pagination/index.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,3 @@ | ||
export * from "./GetEntitlementsPaginator"; | ||
// smithy-typescript generated code | ||
export * from "./Interfaces"; |
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