Skip to content

Commit

Permalink
feat(client-cost-explorer): This release introduces the new API 'GetA…
Browse files Browse the repository at this point in the history
…pproximateUsageRecords', which retrieves estimated usage records for hourly granularity or resource-level data at daily granularity.
  • Loading branch information
awstools committed Feb 28, 2024
1 parent 4528e88 commit 83885d0
Show file tree
Hide file tree
Showing 8 changed files with 411 additions and 46 deletions.
8 changes: 8 additions & 0 deletions clients/client-cost-explorer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ GetAnomalySubscriptions

[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/)

</details>
<details>
<summary>
GetApproximateUsageRecords
</summary>

[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/)

</details>
<details>
<summary>
Expand Down
23 changes: 23 additions & 0 deletions clients/client-cost-explorer/src/CostExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ import {
GetAnomalySubscriptionsCommandInput,
GetAnomalySubscriptionsCommandOutput,
} from "./commands/GetAnomalySubscriptionsCommand";
import {
GetApproximateUsageRecordsCommand,
GetApproximateUsageRecordsCommandInput,
GetApproximateUsageRecordsCommandOutput,
} from "./commands/GetApproximateUsageRecordsCommand";
import {
GetCostAndUsageCommand,
GetCostAndUsageCommandInput,
Expand Down Expand Up @@ -197,6 +202,7 @@ const commands = {
GetAnomaliesCommand,
GetAnomalyMonitorsCommand,
GetAnomalySubscriptionsCommand,
GetApproximateUsageRecordsCommand,
GetCostAndUsageCommand,
GetCostAndUsageWithResourcesCommand,
GetCostCategoriesCommand,
Expand Down Expand Up @@ -392,6 +398,23 @@ export interface CostExplorer {
cb: (err: any, data?: GetAnomalySubscriptionsCommandOutput) => void
): void;

/**
* @see {@link GetApproximateUsageRecordsCommand}
*/
getApproximateUsageRecords(
args: GetApproximateUsageRecordsCommandInput,
options?: __HttpHandlerOptions
): Promise<GetApproximateUsageRecordsCommandOutput>;
getApproximateUsageRecords(
args: GetApproximateUsageRecordsCommandInput,
cb: (err: any, data?: GetApproximateUsageRecordsCommandOutput) => void
): void;
getApproximateUsageRecords(
args: GetApproximateUsageRecordsCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: GetApproximateUsageRecordsCommandOutput) => void
): void;

/**
* @see {@link GetCostAndUsageCommand}
*/
Expand Down
6 changes: 6 additions & 0 deletions clients/client-cost-explorer/src/CostExplorerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ import {
GetAnomalySubscriptionsCommandInput,
GetAnomalySubscriptionsCommandOutput,
} from "./commands/GetAnomalySubscriptionsCommand";
import {
GetApproximateUsageRecordsCommandInput,
GetApproximateUsageRecordsCommandOutput,
} from "./commands/GetApproximateUsageRecordsCommand";
import { GetCostAndUsageCommandInput, GetCostAndUsageCommandOutput } from "./commands/GetCostAndUsageCommand";
import {
GetCostAndUsageWithResourcesCommandInput,
Expand Down Expand Up @@ -200,6 +204,7 @@ export type ServiceInputTypes =
| GetAnomaliesCommandInput
| GetAnomalyMonitorsCommandInput
| GetAnomalySubscriptionsCommandInput
| GetApproximateUsageRecordsCommandInput
| GetCostAndUsageCommandInput
| GetCostAndUsageWithResourcesCommandInput
| GetCostCategoriesCommandInput
Expand Down Expand Up @@ -243,6 +248,7 @@ export type ServiceOutputTypes =
| GetAnomaliesCommandOutput
| GetAnomalyMonitorsCommandOutput
| GetAnomalySubscriptionsCommandOutput
| GetApproximateUsageRecordsCommandOutput
| GetCostAndUsageCommandOutput
| GetCostAndUsageWithResourcesCommandOutput
| GetCostCategoriesCommandOutput
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// smithy-typescript generated code
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";

import { CostExplorerClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CostExplorerClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { GetApproximateUsageRecordsRequest, GetApproximateUsageRecordsResponse } from "../models/models_0";
import { de_GetApproximateUsageRecordsCommand, se_GetApproximateUsageRecordsCommand } from "../protocols/Aws_json1_1";

/**
* @public
*/
export { __MetadataBearer, $Command };
/**
* @public
*
* The input for {@link GetApproximateUsageRecordsCommand}.
*/
export interface GetApproximateUsageRecordsCommandInput extends GetApproximateUsageRecordsRequest {}
/**
* @public
*
* The output of {@link GetApproximateUsageRecordsCommand}.
*/
export interface GetApproximateUsageRecordsCommandOutput extends GetApproximateUsageRecordsResponse, __MetadataBearer {}

/**
* @public
* <p>Retrieves estimated usage records for hourly granularity or resource-level data at daily
* granularity.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { CostExplorerClient, GetApproximateUsageRecordsCommand } from "@aws-sdk/client-cost-explorer"; // ES Modules import
* // const { CostExplorerClient, GetApproximateUsageRecordsCommand } = require("@aws-sdk/client-cost-explorer"); // CommonJS import
* const client = new CostExplorerClient(config);
* const input = { // GetApproximateUsageRecordsRequest
* Granularity: "DAILY" || "MONTHLY" || "HOURLY", // required
* Services: [ // UsageServices
* "STRING_VALUE",
* ],
* ApproximationDimension: "SERVICE" || "RESOURCE", // required
* };
* const command = new GetApproximateUsageRecordsCommand(input);
* const response = await client.send(command);
* // { // GetApproximateUsageRecordsResponse
* // Services: { // ApproximateUsageRecordsPerService
* // "<keys>": Number("long"),
* // },
* // TotalRecords: Number("long"),
* // LookbackPeriod: { // DateInterval
* // Start: "STRING_VALUE", // required
* // End: "STRING_VALUE", // required
* // },
* // };
*
* ```
*
* @param GetApproximateUsageRecordsCommandInput - {@link GetApproximateUsageRecordsCommandInput}
* @returns {@link GetApproximateUsageRecordsCommandOutput}
* @see {@link GetApproximateUsageRecordsCommandInput} for command's `input` shape.
* @see {@link GetApproximateUsageRecordsCommandOutput} for command's `response` shape.
* @see {@link CostExplorerClientResolvedConfig | config} for CostExplorerClient's `config` shape.
*
* @throws {@link DataUnavailableException} (client fault)
* <p>The requested data is unavailable.</p>
*
* @throws {@link LimitExceededException} (client fault)
* <p>You made too many calls in a short period of time. Try again later.</p>
*
* @throws {@link CostExplorerServiceException}
* <p>Base exception class for all service exceptions from CostExplorer service.</p>
*
*/
export class GetApproximateUsageRecordsCommand extends $Command
.classBuilder<
GetApproximateUsageRecordsCommandInput,
GetApproximateUsageRecordsCommandOutput,
CostExplorerClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes
>()
.ep({
...commonParams,
})
.m(function (this: any, Command: any, cs: any, config: CostExplorerClientResolvedConfig, o: any) {
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("AWSInsightsIndexService", "GetApproximateUsageRecords", {})
.n("CostExplorerClient", "GetApproximateUsageRecordsCommand")
.f(void 0, void 0)
.ser(se_GetApproximateUsageRecordsCommand)
.de(de_GetApproximateUsageRecordsCommand)
.build() {}
1 change: 1 addition & 0 deletions clients/client-cost-explorer/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from "./DescribeCostCategoryDefinitionCommand";
export * from "./GetAnomaliesCommand";
export * from "./GetAnomalyMonitorsCommand";
export * from "./GetAnomalySubscriptionsCommand";
export * from "./GetApproximateUsageRecordsCommand";
export * from "./GetCostAndUsageCommand";
export * from "./GetCostAndUsageWithResourcesCommand";
export * from "./GetCostCategoriesCommand";
Expand Down
149 changes: 106 additions & 43 deletions clients/client-cost-explorer/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,20 @@ export interface Subscriber {
Status?: SubscriberStatus;
}

/**
* @public
* @enum
*/
export const ApproximationDimension = {
RESOURCE: "RESOURCE",
SERVICE: "SERVICE",
} as const;

/**
* @public
*/
export type ApproximationDimension = (typeof ApproximationDimension)[keyof typeof ApproximationDimension];

/**
* @public
* <p>The tag structure that contains a tag key and value. </p>
Expand Down Expand Up @@ -1129,28 +1143,6 @@ export interface GetAnomalySubscriptionsRequest {
MaxResults?: number;
}

/**
* @public
* <p>The requested report expired. Update the date interval and try again.</p>
*/
export class BillExpirationException extends __BaseException {
readonly name: "BillExpirationException" = "BillExpirationException";
readonly $fault: "client" = "client";
Message?: string;
/**
* @internal
*/
constructor(opts: __ExceptionOptionType<BillExpirationException, __BaseException>) {
super({
name: "BillExpirationException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, BillExpirationException.prototype);
this.Message = opts.Message;
}
}

/**
* @public
* <p>The requested data is unavailable.</p>
Expand Down Expand Up @@ -1188,38 +1180,30 @@ export const Granularity = {
*/
export type Granularity = (typeof Granularity)[keyof typeof Granularity];

/**
* @public
* @enum
*/
export const GroupDefinitionType = {
COST_CATEGORY: "COST_CATEGORY",
DIMENSION: "DIMENSION",
TAG: "TAG",
} as const;

/**
* @public
*/
export type GroupDefinitionType = (typeof GroupDefinitionType)[keyof typeof GroupDefinitionType];
export interface GetApproximateUsageRecordsRequest {
/**
* @public
* <p>How granular you want the data to be. You can enable data at hourly or daily
* granularity.</p>
*/
Granularity: Granularity | undefined;

/**
* @public
* <p>Represents a group when you specify a group by criteria or in the response to a query
* with a specific grouping.</p>
*/
export interface GroupDefinition {
/**
* @public
* <p>The string that represents the type of group.</p>
* <p>The service metadata for the service or services you want to query. If not specified, all
* elements are returned.</p>
*/
Type?: GroupDefinitionType;
Services?: string[];

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

/**
Expand All @@ -1245,6 +1229,85 @@ export interface DateInterval {
End: string | undefined;
}

/**
* @public
*/
export interface GetApproximateUsageRecordsResponse {
/**
* @public
* <p>The service metadata for the service or services in the response.</p>
*/
Services?: Record<string, number>;

/**
* @public
* <p>The total number of usage records for all services in the services list.</p>
*/
TotalRecords?: number;

/**
* @public
* <p>The lookback period that's used for the estimation.</p>
*/
LookbackPeriod?: DateInterval;
}

/**
* @public
* <p>The requested report expired. Update the date interval and try again.</p>
*/
export class BillExpirationException extends __BaseException {
readonly name: "BillExpirationException" = "BillExpirationException";
readonly $fault: "client" = "client";
Message?: string;
/**
* @internal
*/
constructor(opts: __ExceptionOptionType<BillExpirationException, __BaseException>) {
super({
name: "BillExpirationException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, BillExpirationException.prototype);
this.Message = opts.Message;
}
}

/**
* @public
* @enum
*/
export const GroupDefinitionType = {
COST_CATEGORY: "COST_CATEGORY",
DIMENSION: "DIMENSION",
TAG: "TAG",
} as const;

/**
* @public
*/
export type GroupDefinitionType = (typeof GroupDefinitionType)[keyof typeof GroupDefinitionType];

/**
* @public
* <p>Represents a group when you specify a group by criteria or in the response to a query
* with a specific grouping.</p>
*/
export interface GroupDefinition {
/**
* @public
* <p>The string that represents the type of group.</p>
*/
Type?: GroupDefinitionType;

/**
* @public
* <p>The string that represents a key for a specified group.</p>
*/
Key?: string;
}

/**
* @public
* <p>The metadata of a specific type that you can use to filter and group your results. You
Expand Down
Loading

0 comments on commit 83885d0

Please sign in to comment.