diff --git a/clients/client-cost-explorer/README.md b/clients/client-cost-explorer/README.md index 39b02ab2e7b02..0318f0239b94e 100644 --- a/clients/client-cost-explorer/README.md +++ b/clients/client-cost-explorer/README.md @@ -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/) + +
+ +GetApproximateUsageRecords + + +[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/) +
diff --git a/clients/client-cost-explorer/src/CostExplorer.ts b/clients/client-cost-explorer/src/CostExplorer.ts index 7915e37ec1448..454c6143e04eb 100644 --- a/clients/client-cost-explorer/src/CostExplorer.ts +++ b/clients/client-cost-explorer/src/CostExplorer.ts @@ -52,6 +52,11 @@ import { GetAnomalySubscriptionsCommandInput, GetAnomalySubscriptionsCommandOutput, } from "./commands/GetAnomalySubscriptionsCommand"; +import { + GetApproximateUsageRecordsCommand, + GetApproximateUsageRecordsCommandInput, + GetApproximateUsageRecordsCommandOutput, +} from "./commands/GetApproximateUsageRecordsCommand"; import { GetCostAndUsageCommand, GetCostAndUsageCommandInput, @@ -197,6 +202,7 @@ const commands = { GetAnomaliesCommand, GetAnomalyMonitorsCommand, GetAnomalySubscriptionsCommand, + GetApproximateUsageRecordsCommand, GetCostAndUsageCommand, GetCostAndUsageWithResourcesCommand, GetCostCategoriesCommand, @@ -392,6 +398,23 @@ export interface CostExplorer { cb: (err: any, data?: GetAnomalySubscriptionsCommandOutput) => void ): void; + /** + * @see {@link GetApproximateUsageRecordsCommand} + */ + getApproximateUsageRecords( + args: GetApproximateUsageRecordsCommandInput, + options?: __HttpHandlerOptions + ): Promise; + 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} */ diff --git a/clients/client-cost-explorer/src/CostExplorerClient.ts b/clients/client-cost-explorer/src/CostExplorerClient.ts index 478e6ac18318e..1d16458f00c76 100644 --- a/clients/client-cost-explorer/src/CostExplorerClient.ts +++ b/clients/client-cost-explorer/src/CostExplorerClient.ts @@ -87,6 +87,10 @@ import { GetAnomalySubscriptionsCommandInput, GetAnomalySubscriptionsCommandOutput, } from "./commands/GetAnomalySubscriptionsCommand"; +import { + GetApproximateUsageRecordsCommandInput, + GetApproximateUsageRecordsCommandOutput, +} from "./commands/GetApproximateUsageRecordsCommand"; import { GetCostAndUsageCommandInput, GetCostAndUsageCommandOutput } from "./commands/GetCostAndUsageCommand"; import { GetCostAndUsageWithResourcesCommandInput, @@ -200,6 +204,7 @@ export type ServiceInputTypes = | GetAnomaliesCommandInput | GetAnomalyMonitorsCommandInput | GetAnomalySubscriptionsCommandInput + | GetApproximateUsageRecordsCommandInput | GetCostAndUsageCommandInput | GetCostAndUsageWithResourcesCommandInput | GetCostCategoriesCommandInput @@ -243,6 +248,7 @@ export type ServiceOutputTypes = | GetAnomaliesCommandOutput | GetAnomalyMonitorsCommandOutput | GetAnomalySubscriptionsCommandOutput + | GetApproximateUsageRecordsCommandOutput | GetCostAndUsageCommandOutput | GetCostAndUsageWithResourcesCommandOutput | GetCostCategoriesCommandOutput diff --git a/clients/client-cost-explorer/src/commands/GetApproximateUsageRecordsCommand.ts b/clients/client-cost-explorer/src/commands/GetApproximateUsageRecordsCommand.ts new file mode 100644 index 0000000000000..6b575c964c50b --- /dev/null +++ b/clients/client-cost-explorer/src/commands/GetApproximateUsageRecordsCommand.ts @@ -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 + *

Retrieves estimated usage records for hourly granularity or resource-level data at daily + * granularity.

+ * @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 + * // "": 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) + *

The requested data is unavailable.

+ * + * @throws {@link LimitExceededException} (client fault) + *

You made too many calls in a short period of time. Try again later.

+ * + * @throws {@link CostExplorerServiceException} + *

Base exception class for all service exceptions from CostExplorer service.

+ * + */ +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() {} diff --git a/clients/client-cost-explorer/src/commands/index.ts b/clients/client-cost-explorer/src/commands/index.ts index 515381259310a..19e42ec79e8c2 100644 --- a/clients/client-cost-explorer/src/commands/index.ts +++ b/clients/client-cost-explorer/src/commands/index.ts @@ -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"; diff --git a/clients/client-cost-explorer/src/models/models_0.ts b/clients/client-cost-explorer/src/models/models_0.ts index ad38b5d5f2bb6..79d40a0f4ebc6 100644 --- a/clients/client-cost-explorer/src/models/models_0.ts +++ b/clients/client-cost-explorer/src/models/models_0.ts @@ -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 *

The tag structure that contains a tag key and value.

@@ -1129,28 +1143,6 @@ export interface GetAnomalySubscriptionsRequest { MaxResults?: number; } -/** - * @public - *

The requested report expired. Update the date interval and try again.

- */ -export class BillExpirationException extends __BaseException { - readonly name: "BillExpirationException" = "BillExpirationException"; - readonly $fault: "client" = "client"; - Message?: string; - /** - * @internal - */ - constructor(opts: __ExceptionOptionType) { - super({ - name: "BillExpirationException", - $fault: "client", - ...opts, - }); - Object.setPrototypeOf(this, BillExpirationException.prototype); - this.Message = opts.Message; - } -} - /** * @public *

The requested data is unavailable.

@@ -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 + *

How granular you want the data to be. You can enable data at hourly or daily + * granularity.

+ */ + Granularity: Granularity | undefined; -/** - * @public - *

Represents a group when you specify a group by criteria or in the response to a query - * with a specific grouping.

- */ -export interface GroupDefinition { /** * @public - *

The string that represents the type of group.

+ *

The service metadata for the service or services you want to query. If not specified, all + * elements are returned.

*/ - Type?: GroupDefinitionType; + Services?: string[]; /** * @public - *

The string that represents a key for a specified group.

+ *

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.

*/ - Key?: string; + ApproximationDimension: ApproximationDimension | undefined; } /** @@ -1245,6 +1229,85 @@ export interface DateInterval { End: string | undefined; } +/** + * @public + */ +export interface GetApproximateUsageRecordsResponse { + /** + * @public + *

The service metadata for the service or services in the response.

+ */ + Services?: Record; + + /** + * @public + *

The total number of usage records for all services in the services list.

+ */ + TotalRecords?: number; + + /** + * @public + *

The lookback period that's used for the estimation.

+ */ + LookbackPeriod?: DateInterval; +} + +/** + * @public + *

The requested report expired. Update the date interval and try again.

+ */ +export class BillExpirationException extends __BaseException { + readonly name: "BillExpirationException" = "BillExpirationException"; + readonly $fault: "client" = "client"; + Message?: string; + /** + * @internal + */ + constructor(opts: __ExceptionOptionType) { + 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 + *

Represents a group when you specify a group by criteria or in the response to a query + * with a specific grouping.

+ */ +export interface GroupDefinition { + /** + * @public + *

The string that represents the type of group.

+ */ + Type?: GroupDefinitionType; + + /** + * @public + *

The string that represents a key for a specified group.

+ */ + Key?: string; +} + /** * @public *

The metadata of a specific type that you can use to filter and group your results. You diff --git a/clients/client-cost-explorer/src/protocols/Aws_json1_1.ts b/clients/client-cost-explorer/src/protocols/Aws_json1_1.ts index 9c95c974b134c..2acf67157f34a 100644 --- a/clients/client-cost-explorer/src/protocols/Aws_json1_1.ts +++ b/clients/client-cost-explorer/src/protocols/Aws_json1_1.ts @@ -52,6 +52,10 @@ import { GetAnomalySubscriptionsCommandInput, GetAnomalySubscriptionsCommandOutput, } from "../commands/GetAnomalySubscriptionsCommand"; +import { + GetApproximateUsageRecordsCommandInput, + GetApproximateUsageRecordsCommandOutput, +} from "../commands/GetApproximateUsageRecordsCommand"; import { GetCostAndUsageCommandInput, GetCostAndUsageCommandOutput } from "../commands/GetCostAndUsageCommand"; import { GetCostAndUsageWithResourcesCommandInput, @@ -175,6 +179,7 @@ import { GetAnomalyMonitorsResponse, GetAnomalySubscriptionsRequest, GetAnomalySubscriptionsResponse, + GetApproximateUsageRecordsRequest, GetCostAndUsageRequest, GetCostAndUsageWithResourcesRequest, GetCostCategoriesRequest, @@ -355,6 +360,19 @@ export const se_GetAnomalySubscriptionsCommand = async ( return buildHttpRpcRequest(context, headers, "/", undefined, body); }; +/** + * serializeAws_json1_1GetApproximateUsageRecordsCommand + */ +export const se_GetApproximateUsageRecordsCommand = async ( + input: GetApproximateUsageRecordsCommandInput, + context: __SerdeContext +): Promise<__HttpRequest> => { + const headers: __HeaderBag = sharedHeaders("GetApproximateUsageRecords"); + let body: any; + body = JSON.stringify(_json(input)); + return buildHttpRpcRequest(context, headers, "/", undefined, body); +}; + /** * serializeAws_json1_1GetCostAndUsageCommand */ @@ -919,6 +937,26 @@ export const de_GetAnomalySubscriptionsCommand = async ( return response; }; +/** + * deserializeAws_json1_1GetApproximateUsageRecordsCommand + */ +export const de_GetApproximateUsageRecordsCommand = async ( + output: __HttpResponse, + context: __SerdeContext +): Promise => { + if (output.statusCode >= 300) { + return de_CommandError(output, context); + } + const data: any = await parseBody(output.body, context); + let contents: any = {}; + contents = _json(data); + const response: GetApproximateUsageRecordsCommandOutput = { + $metadata: deserializeMetadata(output), + ...contents, + }; + return response; +}; + /** * deserializeAws_json1_1GetCostAndUsageCommand */ @@ -1507,12 +1545,12 @@ const de_CommandError = async (output: __HttpResponse, context: __SerdeContext): case "InvalidNextTokenException": case "com.amazonaws.costexplorer#InvalidNextTokenException": throw await de_InvalidNextTokenExceptionRes(parsedOutput, context); - case "BillExpirationException": - case "com.amazonaws.costexplorer#BillExpirationException": - throw await de_BillExpirationExceptionRes(parsedOutput, context); case "DataUnavailableException": case "com.amazonaws.costexplorer#DataUnavailableException": throw await de_DataUnavailableExceptionRes(parsedOutput, context); + case "BillExpirationException": + case "com.amazonaws.costexplorer#BillExpirationException": + throw await de_BillExpirationExceptionRes(parsedOutput, context); case "RequestChangedException": case "com.amazonaws.costexplorer#RequestChangedException": throw await de_RequestChangedExceptionRes(parsedOutput, context); @@ -1902,6 +1940,8 @@ const se_GetAnomaliesRequest = (input: GetAnomaliesRequest, context: __SerdeCont // se_GetAnomalySubscriptionsRequest omitted. +// se_GetApproximateUsageRecordsRequest omitted. + /** * serializeAws_json1_1GetCostAndUsageRequest */ @@ -2239,6 +2279,8 @@ const se_UpdateCostCategoryDefinitionRequest = ( }); }; +// se_UsageServices omitted. + // se_Values omitted. /** @@ -2337,6 +2379,8 @@ const de_AnomalySubscriptions = (output: any, context: __SerdeContext): AnomalyS return retVal; }; +// de_ApproximateUsageRecordsPerService omitted. + // de_Attributes omitted. // de_BillExpirationException omitted. @@ -2546,6 +2590,8 @@ const de_GetAnomalySubscriptionsResponse = (output: any, context: __SerdeContext }) as any; }; +// de_GetApproximateUsageRecordsResponse omitted. + // de_GetCostAndUsageResponse omitted. // de_GetCostAndUsageWithResourcesResponse omitted. diff --git a/codegen/sdk-codegen/aws-models/cost-explorer.json b/codegen/sdk-codegen/aws-models/cost-explorer.json index 03d7578860645..4da77e0a8a4bb 100644 --- a/codegen/sdk-codegen/aws-models/cost-explorer.json +++ b/codegen/sdk-codegen/aws-models/cost-explorer.json @@ -63,6 +63,9 @@ { "target": "com.amazonaws.costexplorer#GetAnomalySubscriptions" }, + { + "target": "com.amazonaws.costexplorer#GetApproximateUsageRecords" + }, { "target": "com.amazonaws.costexplorer#GetCostAndUsage" }, @@ -1280,6 +1283,32 @@ "target": "com.amazonaws.costexplorer#AnomalySubscription" } }, + "com.amazonaws.costexplorer#ApproximateUsageRecordsPerService": { + "type": "map", + "key": { + "target": "com.amazonaws.costexplorer#GenericString" + }, + "value": { + "target": "com.amazonaws.costexplorer#NonNegativeLong" + } + }, + "com.amazonaws.costexplorer#ApproximationDimension": { + "type": "enum", + "members": { + "SERVICE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "SERVICE" + } + }, + "RESOURCE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "RESOURCE" + } + } + } + }, "com.amazonaws.costexplorer#Arn": { "type": "string", "traits": { @@ -3737,6 +3766,81 @@ "smithy.api#output": {} } }, + "com.amazonaws.costexplorer#GetApproximateUsageRecords": { + "type": "operation", + "input": { + "target": "com.amazonaws.costexplorer#GetApproximateUsageRecordsRequest" + }, + "output": { + "target": "com.amazonaws.costexplorer#GetApproximateUsageRecordsResponse" + }, + "errors": [ + { + "target": "com.amazonaws.costexplorer#DataUnavailableException" + }, + { + "target": "com.amazonaws.costexplorer#LimitExceededException" + } + ], + "traits": { + "smithy.api#documentation": "

Retrieves estimated usage records for hourly granularity or resource-level data at daily\n granularity.

" + } + }, + "com.amazonaws.costexplorer#GetApproximateUsageRecordsRequest": { + "type": "structure", + "members": { + "Granularity": { + "target": "com.amazonaws.costexplorer#Granularity", + "traits": { + "smithy.api#documentation": "

How granular you want the data to be. You can enable data at hourly or daily\n granularity.

", + "smithy.api#required": {} + } + }, + "Services": { + "target": "com.amazonaws.costexplorer#UsageServices", + "traits": { + "smithy.api#documentation": "

The service metadata for the service or services you want to query. If not specified, all\n elements are returned.

" + } + }, + "ApproximationDimension": { + "target": "com.amazonaws.costexplorer#ApproximationDimension", + "traits": { + "smithy.api#documentation": "

The service to evaluate for the usage records. You can choose resource-level data at daily\n granularity, or hourly granularity with or without resource-level data.

", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.costexplorer#GetApproximateUsageRecordsResponse": { + "type": "structure", + "members": { + "Services": { + "target": "com.amazonaws.costexplorer#ApproximateUsageRecordsPerService", + "traits": { + "smithy.api#documentation": "

The service metadata for the service or services in the response.

" + } + }, + "TotalRecords": { + "target": "com.amazonaws.costexplorer#NonNegativeLong", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

The total number of usage records for all services in the services list.

" + } + }, + "LookbackPeriod": { + "target": "com.amazonaws.costexplorer#DateInterval", + "traits": { + "smithy.api#documentation": "

The lookback period that's used for the estimation.

" + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, "com.amazonaws.costexplorer#GetCostAndUsage": { "type": "operation", "input": { @@ -6168,6 +6272,15 @@ } } }, + "com.amazonaws.costexplorer#NonNegativeLong": { + "type": "long", + "traits": { + "smithy.api#default": 0, + "smithy.api#range": { + "min": 0 + } + } + }, "com.amazonaws.costexplorer#NullableNonNegativeDouble": { "type": "double", "traits": { @@ -9039,6 +9152,12 @@ "smithy.api#output": {} } }, + "com.amazonaws.costexplorer#UsageServices": { + "type": "list", + "member": { + "target": "com.amazonaws.costexplorer#GenericString" + } + }, "com.amazonaws.costexplorer#UtilizationByTime": { "type": "structure", "members": {