Skip to content

Commit 83885d0

Browse files
author
awstools
committed
feat(client-cost-explorer): This release introduces the new API 'GetApproximateUsageRecords', which retrieves estimated usage records for hourly granularity or resource-level data at daily granularity.
1 parent 4528e88 commit 83885d0

File tree

8 files changed

+411
-46
lines changed

8 files changed

+411
-46
lines changed

clients/client-cost-explorer/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ GetAnomalySubscriptions
297297

298298
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cost-explorer/command/GetAnomalySubscriptionsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cost-explorer/Interface/GetAnomalySubscriptionsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cost-explorer/Interface/GetAnomalySubscriptionsCommandOutput/)
299299

300+
</details>
301+
<details>
302+
<summary>
303+
GetApproximateUsageRecords
304+
</summary>
305+
306+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/cost-explorer/command/GetApproximateUsageRecordsCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cost-explorer/Interface/GetApproximateUsageRecordsCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-cost-explorer/Interface/GetApproximateUsageRecordsCommandOutput/)
307+
300308
</details>
301309
<details>
302310
<summary>

clients/client-cost-explorer/src/CostExplorer.ts

+23
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ import {
5252
GetAnomalySubscriptionsCommandInput,
5353
GetAnomalySubscriptionsCommandOutput,
5454
} from "./commands/GetAnomalySubscriptionsCommand";
55+
import {
56+
GetApproximateUsageRecordsCommand,
57+
GetApproximateUsageRecordsCommandInput,
58+
GetApproximateUsageRecordsCommandOutput,
59+
} from "./commands/GetApproximateUsageRecordsCommand";
5560
import {
5661
GetCostAndUsageCommand,
5762
GetCostAndUsageCommandInput,
@@ -197,6 +202,7 @@ const commands = {
197202
GetAnomaliesCommand,
198203
GetAnomalyMonitorsCommand,
199204
GetAnomalySubscriptionsCommand,
205+
GetApproximateUsageRecordsCommand,
200206
GetCostAndUsageCommand,
201207
GetCostAndUsageWithResourcesCommand,
202208
GetCostCategoriesCommand,
@@ -392,6 +398,23 @@ export interface CostExplorer {
392398
cb: (err: any, data?: GetAnomalySubscriptionsCommandOutput) => void
393399
): void;
394400

401+
/**
402+
* @see {@link GetApproximateUsageRecordsCommand}
403+
*/
404+
getApproximateUsageRecords(
405+
args: GetApproximateUsageRecordsCommandInput,
406+
options?: __HttpHandlerOptions
407+
): Promise<GetApproximateUsageRecordsCommandOutput>;
408+
getApproximateUsageRecords(
409+
args: GetApproximateUsageRecordsCommandInput,
410+
cb: (err: any, data?: GetApproximateUsageRecordsCommandOutput) => void
411+
): void;
412+
getApproximateUsageRecords(
413+
args: GetApproximateUsageRecordsCommandInput,
414+
options: __HttpHandlerOptions,
415+
cb: (err: any, data?: GetApproximateUsageRecordsCommandOutput) => void
416+
): void;
417+
395418
/**
396419
* @see {@link GetCostAndUsageCommand}
397420
*/

clients/client-cost-explorer/src/CostExplorerClient.ts

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ import {
8787
GetAnomalySubscriptionsCommandInput,
8888
GetAnomalySubscriptionsCommandOutput,
8989
} from "./commands/GetAnomalySubscriptionsCommand";
90+
import {
91+
GetApproximateUsageRecordsCommandInput,
92+
GetApproximateUsageRecordsCommandOutput,
93+
} from "./commands/GetApproximateUsageRecordsCommand";
9094
import { GetCostAndUsageCommandInput, GetCostAndUsageCommandOutput } from "./commands/GetCostAndUsageCommand";
9195
import {
9296
GetCostAndUsageWithResourcesCommandInput,
@@ -200,6 +204,7 @@ export type ServiceInputTypes =
200204
| GetAnomaliesCommandInput
201205
| GetAnomalyMonitorsCommandInput
202206
| GetAnomalySubscriptionsCommandInput
207+
| GetApproximateUsageRecordsCommandInput
203208
| GetCostAndUsageCommandInput
204209
| GetCostAndUsageWithResourcesCommandInput
205210
| GetCostCategoriesCommandInput
@@ -243,6 +248,7 @@ export type ServiceOutputTypes =
243248
| GetAnomaliesCommandOutput
244249
| GetAnomalyMonitorsCommandOutput
245250
| GetAnomalySubscriptionsCommandOutput
251+
| GetApproximateUsageRecordsCommandOutput
246252
| GetCostAndUsageCommandOutput
247253
| GetCostAndUsageWithResourcesCommandOutput
248254
| GetCostCategoriesCommandOutput
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// smithy-typescript generated code
2+
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { Command as $Command } from "@smithy/smithy-client";
5+
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
6+
7+
import { CostExplorerClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CostExplorerClient";
8+
import { commonParams } from "../endpoint/EndpointParameters";
9+
import { GetApproximateUsageRecordsRequest, GetApproximateUsageRecordsResponse } from "../models/models_0";
10+
import { de_GetApproximateUsageRecordsCommand, se_GetApproximateUsageRecordsCommand } from "../protocols/Aws_json1_1";
11+
12+
/**
13+
* @public
14+
*/
15+
export { __MetadataBearer, $Command };
16+
/**
17+
* @public
18+
*
19+
* The input for {@link GetApproximateUsageRecordsCommand}.
20+
*/
21+
export interface GetApproximateUsageRecordsCommandInput extends GetApproximateUsageRecordsRequest {}
22+
/**
23+
* @public
24+
*
25+
* The output of {@link GetApproximateUsageRecordsCommand}.
26+
*/
27+
export interface GetApproximateUsageRecordsCommandOutput extends GetApproximateUsageRecordsResponse, __MetadataBearer {}
28+
29+
/**
30+
* @public
31+
* <p>Retrieves estimated usage records for hourly granularity or resource-level data at daily
32+
* granularity.</p>
33+
* @example
34+
* Use a bare-bones client and the command you need to make an API call.
35+
* ```javascript
36+
* import { CostExplorerClient, GetApproximateUsageRecordsCommand } from "@aws-sdk/client-cost-explorer"; // ES Modules import
37+
* // const { CostExplorerClient, GetApproximateUsageRecordsCommand } = require("@aws-sdk/client-cost-explorer"); // CommonJS import
38+
* const client = new CostExplorerClient(config);
39+
* const input = { // GetApproximateUsageRecordsRequest
40+
* Granularity: "DAILY" || "MONTHLY" || "HOURLY", // required
41+
* Services: [ // UsageServices
42+
* "STRING_VALUE",
43+
* ],
44+
* ApproximationDimension: "SERVICE" || "RESOURCE", // required
45+
* };
46+
* const command = new GetApproximateUsageRecordsCommand(input);
47+
* const response = await client.send(command);
48+
* // { // GetApproximateUsageRecordsResponse
49+
* // Services: { // ApproximateUsageRecordsPerService
50+
* // "<keys>": Number("long"),
51+
* // },
52+
* // TotalRecords: Number("long"),
53+
* // LookbackPeriod: { // DateInterval
54+
* // Start: "STRING_VALUE", // required
55+
* // End: "STRING_VALUE", // required
56+
* // },
57+
* // };
58+
*
59+
* ```
60+
*
61+
* @param GetApproximateUsageRecordsCommandInput - {@link GetApproximateUsageRecordsCommandInput}
62+
* @returns {@link GetApproximateUsageRecordsCommandOutput}
63+
* @see {@link GetApproximateUsageRecordsCommandInput} for command's `input` shape.
64+
* @see {@link GetApproximateUsageRecordsCommandOutput} for command's `response` shape.
65+
* @see {@link CostExplorerClientResolvedConfig | config} for CostExplorerClient's `config` shape.
66+
*
67+
* @throws {@link DataUnavailableException} (client fault)
68+
* <p>The requested data is unavailable.</p>
69+
*
70+
* @throws {@link LimitExceededException} (client fault)
71+
* <p>You made too many calls in a short period of time. Try again later.</p>
72+
*
73+
* @throws {@link CostExplorerServiceException}
74+
* <p>Base exception class for all service exceptions from CostExplorer service.</p>
75+
*
76+
*/
77+
export class GetApproximateUsageRecordsCommand extends $Command
78+
.classBuilder<
79+
GetApproximateUsageRecordsCommandInput,
80+
GetApproximateUsageRecordsCommandOutput,
81+
CostExplorerClientResolvedConfig,
82+
ServiceInputTypes,
83+
ServiceOutputTypes
84+
>()
85+
.ep({
86+
...commonParams,
87+
})
88+
.m(function (this: any, Command: any, cs: any, config: CostExplorerClientResolvedConfig, o: any) {
89+
return [
90+
getSerdePlugin(config, this.serialize, this.deserialize),
91+
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
92+
];
93+
})
94+
.s("AWSInsightsIndexService", "GetApproximateUsageRecords", {})
95+
.n("CostExplorerClient", "GetApproximateUsageRecordsCommand")
96+
.f(void 0, void 0)
97+
.ser(se_GetApproximateUsageRecordsCommand)
98+
.de(de_GetApproximateUsageRecordsCommand)
99+
.build() {}

clients/client-cost-explorer/src/commands/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from "./DescribeCostCategoryDefinitionCommand";
99
export * from "./GetAnomaliesCommand";
1010
export * from "./GetAnomalyMonitorsCommand";
1111
export * from "./GetAnomalySubscriptionsCommand";
12+
export * from "./GetApproximateUsageRecordsCommand";
1213
export * from "./GetCostAndUsageCommand";
1314
export * from "./GetCostAndUsageWithResourcesCommand";
1415
export * from "./GetCostCategoriesCommand";

clients/client-cost-explorer/src/models/models_0.ts

+106-43
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,20 @@ export interface Subscriber {
482482
Status?: SubscriberStatus;
483483
}
484484

485+
/**
486+
* @public
487+
* @enum
488+
*/
489+
export const ApproximationDimension = {
490+
RESOURCE: "RESOURCE",
491+
SERVICE: "SERVICE",
492+
} as const;
493+
494+
/**
495+
* @public
496+
*/
497+
export type ApproximationDimension = (typeof ApproximationDimension)[keyof typeof ApproximationDimension];
498+
485499
/**
486500
* @public
487501
* <p>The tag structure that contains a tag key and value. </p>
@@ -1129,28 +1143,6 @@ export interface GetAnomalySubscriptionsRequest {
11291143
MaxResults?: number;
11301144
}
11311145

1132-
/**
1133-
* @public
1134-
* <p>The requested report expired. Update the date interval and try again.</p>
1135-
*/
1136-
export class BillExpirationException extends __BaseException {
1137-
readonly name: "BillExpirationException" = "BillExpirationException";
1138-
readonly $fault: "client" = "client";
1139-
Message?: string;
1140-
/**
1141-
* @internal
1142-
*/
1143-
constructor(opts: __ExceptionOptionType<BillExpirationException, __BaseException>) {
1144-
super({
1145-
name: "BillExpirationException",
1146-
$fault: "client",
1147-
...opts,
1148-
});
1149-
Object.setPrototypeOf(this, BillExpirationException.prototype);
1150-
this.Message = opts.Message;
1151-
}
1152-
}
1153-
11541146
/**
11551147
* @public
11561148
* <p>The requested data is unavailable.</p>
@@ -1188,38 +1180,30 @@ export const Granularity = {
11881180
*/
11891181
export type Granularity = (typeof Granularity)[keyof typeof Granularity];
11901182

1191-
/**
1192-
* @public
1193-
* @enum
1194-
*/
1195-
export const GroupDefinitionType = {
1196-
COST_CATEGORY: "COST_CATEGORY",
1197-
DIMENSION: "DIMENSION",
1198-
TAG: "TAG",
1199-
} as const;
1200-
12011183
/**
12021184
* @public
12031185
*/
1204-
export type GroupDefinitionType = (typeof GroupDefinitionType)[keyof typeof GroupDefinitionType];
1186+
export interface GetApproximateUsageRecordsRequest {
1187+
/**
1188+
* @public
1189+
* <p>How granular you want the data to be. You can enable data at hourly or daily
1190+
* granularity.</p>
1191+
*/
1192+
Granularity: Granularity | undefined;
12051193

1206-
/**
1207-
* @public
1208-
* <p>Represents a group when you specify a group by criteria or in the response to a query
1209-
* with a specific grouping.</p>
1210-
*/
1211-
export interface GroupDefinition {
12121194
/**
12131195
* @public
1214-
* <p>The string that represents the type of group.</p>
1196+
* <p>The service metadata for the service or services you want to query. If not specified, all
1197+
* elements are returned.</p>
12151198
*/
1216-
Type?: GroupDefinitionType;
1199+
Services?: string[];
12171200

12181201
/**
12191202
* @public
1220-
* <p>The string that represents a key for a specified group.</p>
1203+
* <p>The service to evaluate for the usage records. You can choose resource-level data at daily
1204+
* granularity, or hourly granularity with or without resource-level data.</p>
12211205
*/
1222-
Key?: string;
1206+
ApproximationDimension: ApproximationDimension | undefined;
12231207
}
12241208

12251209
/**
@@ -1245,6 +1229,85 @@ export interface DateInterval {
12451229
End: string | undefined;
12461230
}
12471231

1232+
/**
1233+
* @public
1234+
*/
1235+
export interface GetApproximateUsageRecordsResponse {
1236+
/**
1237+
* @public
1238+
* <p>The service metadata for the service or services in the response.</p>
1239+
*/
1240+
Services?: Record<string, number>;
1241+
1242+
/**
1243+
* @public
1244+
* <p>The total number of usage records for all services in the services list.</p>
1245+
*/
1246+
TotalRecords?: number;
1247+
1248+
/**
1249+
* @public
1250+
* <p>The lookback period that's used for the estimation.</p>
1251+
*/
1252+
LookbackPeriod?: DateInterval;
1253+
}
1254+
1255+
/**
1256+
* @public
1257+
* <p>The requested report expired. Update the date interval and try again.</p>
1258+
*/
1259+
export class BillExpirationException extends __BaseException {
1260+
readonly name: "BillExpirationException" = "BillExpirationException";
1261+
readonly $fault: "client" = "client";
1262+
Message?: string;
1263+
/**
1264+
* @internal
1265+
*/
1266+
constructor(opts: __ExceptionOptionType<BillExpirationException, __BaseException>) {
1267+
super({
1268+
name: "BillExpirationException",
1269+
$fault: "client",
1270+
...opts,
1271+
});
1272+
Object.setPrototypeOf(this, BillExpirationException.prototype);
1273+
this.Message = opts.Message;
1274+
}
1275+
}
1276+
1277+
/**
1278+
* @public
1279+
* @enum
1280+
*/
1281+
export const GroupDefinitionType = {
1282+
COST_CATEGORY: "COST_CATEGORY",
1283+
DIMENSION: "DIMENSION",
1284+
TAG: "TAG",
1285+
} as const;
1286+
1287+
/**
1288+
* @public
1289+
*/
1290+
export type GroupDefinitionType = (typeof GroupDefinitionType)[keyof typeof GroupDefinitionType];
1291+
1292+
/**
1293+
* @public
1294+
* <p>Represents a group when you specify a group by criteria or in the response to a query
1295+
* with a specific grouping.</p>
1296+
*/
1297+
export interface GroupDefinition {
1298+
/**
1299+
* @public
1300+
* <p>The string that represents the type of group.</p>
1301+
*/
1302+
Type?: GroupDefinitionType;
1303+
1304+
/**
1305+
* @public
1306+
* <p>The string that represents a key for a specified group.</p>
1307+
*/
1308+
Key?: string;
1309+
}
1310+
12481311
/**
12491312
* @public
12501313
* <p>The metadata of a specific type that you can use to filter and group your results. You

0 commit comments

Comments
 (0)