Skip to content

Commit 18d6d94

Browse files
author
awstools
committed
feat(client-marketplace-entitlement-service): Add paginators to GetEntitlements.
1 parent ec1318c commit 18d6d94

File tree

5 files changed

+81
-2
lines changed

5 files changed

+81
-2
lines changed

clients/client-marketplace-entitlement-service/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export { ClientInputEndpointParameters } from "./endpoint/EndpointParameters";
2727
export { RuntimeExtension } from "./runtimeExtensions";
2828
export { MarketplaceEntitlementServiceExtensionConfiguration } from "./extensionConfiguration";
2929
export * from "./commands";
30+
export * from "./pagination";
3031
export * from "./models";
3132

3233
import "@aws-sdk/util-endpoints";
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// smithy-typescript generated code
2+
import { Paginator } from "@smithy/types";
3+
4+
import {
5+
GetEntitlementsCommand,
6+
GetEntitlementsCommandInput,
7+
GetEntitlementsCommandOutput,
8+
} from "../commands/GetEntitlementsCommand";
9+
import { MarketplaceEntitlementServiceClient } from "../MarketplaceEntitlementServiceClient";
10+
import { MarketplaceEntitlementServicePaginationConfiguration } from "./Interfaces";
11+
12+
/**
13+
* @internal
14+
*/
15+
const makePagedClientRequest = async (
16+
client: MarketplaceEntitlementServiceClient,
17+
input: GetEntitlementsCommandInput,
18+
...args: any
19+
): Promise<GetEntitlementsCommandOutput> => {
20+
// @ts-ignore
21+
return await client.send(new GetEntitlementsCommand(input), ...args);
22+
};
23+
/**
24+
* @public
25+
*/
26+
export async function* paginateGetEntitlements(
27+
config: MarketplaceEntitlementServicePaginationConfiguration,
28+
input: GetEntitlementsCommandInput,
29+
...additionalArguments: any
30+
): Paginator<GetEntitlementsCommandOutput> {
31+
// ToDo: replace with actual type instead of typeof input.NextToken
32+
let token: typeof input.NextToken | undefined = config.startingToken || undefined;
33+
let hasNext = true;
34+
let page: GetEntitlementsCommandOutput;
35+
while (hasNext) {
36+
input.NextToken = token;
37+
input["MaxResults"] = config.pageSize;
38+
if (config.client instanceof MarketplaceEntitlementServiceClient) {
39+
page = await makePagedClientRequest(config.client, input, ...additionalArguments);
40+
} else {
41+
throw new Error("Invalid client, expected MarketplaceEntitlementService | MarketplaceEntitlementServiceClient");
42+
}
43+
yield page;
44+
const prevToken = token;
45+
token = page.NextToken;
46+
hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
47+
}
48+
// @ts-ignore
49+
return undefined;
50+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// smithy-typescript generated code
2+
import { PaginationConfiguration } from "@smithy/types";
3+
4+
import { MarketplaceEntitlementServiceClient } from "../MarketplaceEntitlementServiceClient";
5+
6+
/**
7+
* @public
8+
*/
9+
export interface MarketplaceEntitlementServicePaginationConfiguration extends PaginationConfiguration {
10+
client: MarketplaceEntitlementServiceClient;
11+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from "./GetEntitlementsPaginator";
2+
// smithy-typescript generated code
3+
export * from "./Interfaces";

codegen/sdk-codegen/aws-models/marketplace-entitlement-service.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,12 @@
857857
}
858858
],
859859
"traits": {
860-
"smithy.api#documentation": "<p>GetEntitlements retrieves entitlement values for a given product. The results can be\n filtered based on customer identifier or product dimensions.</p>"
860+
"smithy.api#documentation": "<p>GetEntitlements retrieves entitlement values for a given product. The results can be\n filtered based on customer identifier or product dimensions.</p>",
861+
"smithy.api#paginated": {
862+
"inputToken": "NextToken",
863+
"outputToken": "NextToken",
864+
"pageSize": "MaxResults"
865+
}
861866
}
862867
},
863868
"com.amazonaws.marketplaceentitlementservice#GetEntitlementsRequest": {
@@ -883,7 +888,7 @@
883888
}
884889
},
885890
"MaxResults": {
886-
"target": "com.amazonaws.marketplaceentitlementservice#Integer",
891+
"target": "com.amazonaws.marketplaceentitlementservice#PageSizeInteger",
887892
"traits": {
888893
"smithy.api#documentation": "<p>The maximum number of items to retrieve from the GetEntitlements operation. For\n pagination, use the NextToken field in subsequent calls to GetEntitlements.</p>"
889894
}
@@ -948,6 +953,15 @@
948953
"smithy.api#pattern": "^\\S+$"
949954
}
950955
},
956+
"com.amazonaws.marketplaceentitlementservice#PageSizeInteger": {
957+
"type": "integer",
958+
"traits": {
959+
"smithy.api#range": {
960+
"min": 1,
961+
"max": 25
962+
}
963+
}
964+
},
951965
"com.amazonaws.marketplaceentitlementservice#ProductCode": {
952966
"type": "string",
953967
"traits": {

0 commit comments

Comments
 (0)