Skip to content

Commit

Permalink
feat(client-marketplace-entitlement-service): Add paginators to GetEn…
Browse files Browse the repository at this point in the history
…titlements.
  • Loading branch information
awstools committed Nov 10, 2023
1 parent ec1318c commit 18d6d94
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export { ClientInputEndpointParameters } from "./endpoint/EndpointParameters";
export { RuntimeExtension } from "./runtimeExtensions";
export { MarketplaceEntitlementServiceExtensionConfiguration } from "./extensionConfiguration";
export * from "./commands";
export * from "./pagination";
export * from "./models";

import "@aws-sdk/util-endpoints";
Expand Down
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;
}
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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./GetEntitlementsPaginator";
// smithy-typescript generated code
export * from "./Interfaces";
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,12 @@
}
],
"traits": {
"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>"
"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>",
"smithy.api#paginated": {
"inputToken": "NextToken",
"outputToken": "NextToken",
"pageSize": "MaxResults"
}
}
},
"com.amazonaws.marketplaceentitlementservice#GetEntitlementsRequest": {
Expand All @@ -883,7 +888,7 @@
}
},
"MaxResults": {
"target": "com.amazonaws.marketplaceentitlementservice#Integer",
"target": "com.amazonaws.marketplaceentitlementservice#PageSizeInteger",
"traits": {
"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>"
}
Expand Down Expand Up @@ -948,6 +953,15 @@
"smithy.api#pattern": "^\\S+$"
}
},
"com.amazonaws.marketplaceentitlementservice#PageSizeInteger": {
"type": "integer",
"traits": {
"smithy.api#range": {
"min": 1,
"max": 25
}
}
},
"com.amazonaws.marketplaceentitlementservice#ProductCode": {
"type": "string",
"traits": {
Expand Down

0 comments on commit 18d6d94

Please sign in to comment.