Skip to content

Commit

Permalink
feat(client-cost-explorer): Added two new APIs to support cost alloca…
Browse files Browse the repository at this point in the history
…tion tags operations: ListCostAllocationTags, UpdateCostAllocationTagsStatus.
  • Loading branch information
awstools committed Jun 7, 2022
1 parent 9754a55 commit 25dcf34
Show file tree
Hide file tree
Showing 19 changed files with 1,568 additions and 409 deletions.
152 changes: 123 additions & 29 deletions clients/client-cost-explorer/src/CostExplorer.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions clients/client-cost-explorer/src/CostExplorerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ import {
} from "./commands/GetSavingsPlansUtilizationDetailsCommand";
import { GetTagsCommandInput, GetTagsCommandOutput } from "./commands/GetTagsCommand";
import { GetUsageForecastCommandInput, GetUsageForecastCommandOutput } from "./commands/GetUsageForecastCommand";
import {
ListCostAllocationTagsCommandInput,
ListCostAllocationTagsCommandOutput,
} from "./commands/ListCostAllocationTagsCommand";
import {
ListCostCategoryDefinitionsCommandInput,
ListCostCategoryDefinitionsCommandOutput,
Expand All @@ -151,6 +155,10 @@ import {
UpdateAnomalySubscriptionCommandInput,
UpdateAnomalySubscriptionCommandOutput,
} from "./commands/UpdateAnomalySubscriptionCommand";
import {
UpdateCostAllocationTagsStatusCommandInput,
UpdateCostAllocationTagsStatusCommandOutput,
} from "./commands/UpdateCostAllocationTagsStatusCommand";
import {
UpdateCostCategoryDefinitionCommandInput,
UpdateCostCategoryDefinitionCommandOutput,
Expand Down Expand Up @@ -183,13 +191,15 @@ export type ServiceInputTypes =
| GetSavingsPlansUtilizationDetailsCommandInput
| GetTagsCommandInput
| GetUsageForecastCommandInput
| ListCostAllocationTagsCommandInput
| ListCostCategoryDefinitionsCommandInput
| ListTagsForResourceCommandInput
| ProvideAnomalyFeedbackCommandInput
| TagResourceCommandInput
| UntagResourceCommandInput
| UpdateAnomalyMonitorCommandInput
| UpdateAnomalySubscriptionCommandInput
| UpdateCostAllocationTagsStatusCommandInput
| UpdateCostCategoryDefinitionCommandInput;

export type ServiceOutputTypes =
Expand Down Expand Up @@ -218,13 +228,15 @@ export type ServiceOutputTypes =
| GetSavingsPlansUtilizationDetailsCommandOutput
| GetTagsCommandOutput
| GetUsageForecastCommandOutput
| ListCostAllocationTagsCommandOutput
| ListCostCategoryDefinitionsCommandOutput
| ListTagsForResourceCommandOutput
| ProvideAnomalyFeedbackCommandOutput
| TagResourceCommandOutput
| UntagResourceCommandOutput
| UpdateAnomalyMonitorCommandOutput
| UpdateAnomalySubscriptionCommandOutput
| UpdateCostAllocationTagsStatusCommandOutput
| UpdateCostCategoryDefinitionCommandOutput;

export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__HttpHandlerOptions>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ export interface DescribeCostCategoryDefinitionCommandOutput
__MetadataBearer {}

/**
* <p>Returns the name, ARN, rules, definition, and effective dates of a Cost Category that's defined in the account.</p>
* <p>You have the option to use <code>EffectiveOn</code> to return a Cost Category that is active on a specific date. If there is no <code>EffectiveOn</code> specified, you’ll see a Cost Category that is effective on the current date. If Cost Category is still effective, <code>EffectiveEnd</code> is omitted in the response. </p>
* <p>Returns the name, Amazon Resource Name (ARN), rules, definition, and effective dates of a
* Cost Category that's defined in the account.</p>
* <p>You have the option to use <code>EffectiveOn</code> to return a Cost Category that's
* active on a specific date. If there's no <code>EffectiveOn</code> specified, you see a Cost
* Category that's effective on the current date. If Cost Category is still effective,
* <code>EffectiveEnd</code> is omitted in the response. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export interface GetCostAndUsageWithResourcesCommandOutput
* such as <code>SERVICE</code> or <code>AZ</code>, in a specific time range. For a complete list
* of valid dimensions, see the <a href="https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetDimensionValues.html">GetDimensionValues</a> operation. Management account in an organization in Organizations have access to all member accounts. This API is currently available for the Amazon Elastic Compute Cloud – Compute service only.</p>
* <note>
* <p>This is an opt-in only feature. You can enable this feature from the Cost Explorer Settings page. For information on how to access the Settings page, see <a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/ce-access.html">Controlling Access for Cost Explorer</a> in the <i>Billing and Cost Management User Guide</i>.</p>
* <p>This is an opt-in only feature. You can enable this feature from the Cost Explorer Settings
* page. For information about how to access the Settings page, see <a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/ce-access.html">Controlling Access for Cost
* Explorer</a> in the <i>Billing and Cost Management User Guide</i>.</p>
* </note>
* @example
* Use a bare-bones client and the command you need to make an API call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ export interface GetReservationCoverageCommandInput extends GetReservationCovera
export interface GetReservationCoverageCommandOutput extends GetReservationCoverageResponse, __MetadataBearer {}

/**
* <p>Retrieves the reservation coverage for your account. This enables you to see how much of your Amazon Elastic Compute Cloud, Amazon ElastiCache, Amazon Relational Database Service, or
* Amazon Redshift usage is covered by a reservation. An organization's management account can see the coverage of the associated member accounts. This supports dimensions, Cost Categories, and nested expressions.
* For any time period, you can filter data about reservation usage by the following dimensions:</p>
* <p>Retrieves the reservation coverage for your account, which you can use to see how much of
* your Amazon Elastic Compute Cloud, Amazon ElastiCache, Amazon Relational Database Service, or
* Amazon Redshift usage is covered by a reservation. An organization's management account can
* see the coverage of the associated member accounts. This supports dimensions, Cost Categories,
* and nested expressions. For any time period, you can filter data about reservation usage by
* the following dimensions:</p>
* <ul>
* <li>
* <p>AZ</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,22 @@ export interface GetReservationPurchaseRecommendationCommandOutput
__MetadataBearer {}

/**
* <p>Gets recommendations for which reservations to purchase. These recommendations could help you reduce your costs.
* Reservations provide a discounted hourly rate (up to 75%) compared to On-Demand pricing.</p>
* <p>Amazon Web Services generates your recommendations by identifying your On-Demand usage during a specific time period and collecting your usage
* into categories that are eligible for a reservation. After Amazon Web Services has these categories, it simulates every combination of reservations
* in each category of usage to identify the best number of each type of RI to purchase to maximize your estimated savings. </p>
* <p>For example, Amazon Web Services automatically aggregates your Amazon EC2 Linux, shared tenancy, and c4 family usage in the US West (Oregon) Region
* and recommends that you buy size-flexible regional reservations to apply to the c4 family usage. Amazon Web Services recommends the smallest size instance
* in an instance family. This makes it easier to purchase a size-flexible RI. Amazon Web Services also shows the equal number of normalized units
* so that you can purchase any instance size that you want. For this example, your RI recommendation would be for <code>c4.large</code>
* because that is the smallest size instance in the c4 instance family.</p>
* <p>Gets recommendations for reservation purchases. These recommendations might help you to
* reduce your costs. Reservations provide a discounted hourly rate (up to 75%) compared to
* On-Demand pricing.</p>
* <p>Amazon Web Services generates your recommendations by identifying your On-Demand usage
* during a specific time period and collecting your usage into categories that are eligible for
* a reservation. After Amazon Web Services has these categories, it simulates every combination
* of reservations in each category of usage to identify the best number of each type of Reserved
* Instance (RI) to purchase to maximize your estimated savings. </p>
* <p>For example, Amazon Web Services automatically aggregates your Amazon EC2 Linux, shared
* tenancy, and c4 family usage in the US West (Oregon) Region and recommends that you buy
* size-flexible regional reservations to apply to the c4 family usage. Amazon Web Services
* recommends the smallest size instance in an instance family. This makes it easier to purchase
* a size-flexible Reserved Instance (RI). Amazon Web Services also shows the equal number of
* normalized units. This way, you can purchase any instance size that you want. For this
* example, your RI recommendation is for <code>c4.large</code> because that is the smallest size
* instance in the c4 instance family.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ export interface GetRightsizingRecommendationCommandOutput
* help you save cost
* by identifying idle and underutilized Amazon EC2 instances.</p>
* <p>Recommendations are generated to either downsize or terminate instances, along with
* providing savings detail and metrics. For details on calculation and function, see
* <a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/ce-rightsizing.html">Optimizing
* Your Cost with Rightsizing
* Recommendations</a>
* in the <i>Billing and Cost Management User
* Guide</i>.</p>
* providing savings detail and metrics. For more information about calculation and function, see
* <a href="https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/ce-rightsizing.html">Optimizing Your Cost with Rightsizing Recommendations</a> in the <i>Billing and Cost Management User Guide</i>.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface GetSavingsPlansUtilizationCommandOutput extends GetSavingsPlans
/**
* <p>Retrieves the Savings Plans utilization for your account across date ranges with daily or monthly granularity. Management account in an organization have access to member accounts. You can use <code>GetDimensionValues</code> in <code>SAVINGS_PLANS</code> to determine the possible dimension values.</p>
* <note>
* <p>You cannot group by any dimension values for <code>GetSavingsPlansUtilization</code>.</p>
* <p>You can't group by any dimension values for <code>GetSavingsPlansUtilization</code>.</p>
* </note>
* @example
* Use a bare-bones client and the command you need to make an API call.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// smithy-typescript generated code
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import { CostExplorerClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CostExplorerClient";
import { ListCostAllocationTagsRequest, ListCostAllocationTagsResponse } from "../models/models_0";
import {
deserializeAws_json1_1ListCostAllocationTagsCommand,
serializeAws_json1_1ListCostAllocationTagsCommand,
} from "../protocols/Aws_json1_1";

export interface ListCostAllocationTagsCommandInput extends ListCostAllocationTagsRequest {}
export interface ListCostAllocationTagsCommandOutput extends ListCostAllocationTagsResponse, __MetadataBearer {}

/**
* <p>Get a list of cost allocation tags. All inputs in the API are optional and serve as
* filters. By default, all cost allocation tags are returned. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { CostExplorerClient, ListCostAllocationTagsCommand } from "@aws-sdk/client-cost-explorer"; // ES Modules import
* // const { CostExplorerClient, ListCostAllocationTagsCommand } = require("@aws-sdk/client-cost-explorer"); // CommonJS import
* const client = new CostExplorerClient(config);
* const command = new ListCostAllocationTagsCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link ListCostAllocationTagsCommandInput} for command's `input` shape.
* @see {@link ListCostAllocationTagsCommandOutput} for command's `response` shape.
* @see {@link CostExplorerClientResolvedConfig | config} for CostExplorerClient's `config` shape.
*
*/
export class ListCostAllocationTagsCommand extends $Command<
ListCostAllocationTagsCommandInput,
ListCostAllocationTagsCommandOutput,
CostExplorerClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: ListCostAllocationTagsCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: CostExplorerClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<ListCostAllocationTagsCommandInput, ListCostAllocationTagsCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "CostExplorerClient";
const commandName = "ListCostAllocationTagsCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: ListCostAllocationTagsRequest.filterSensitiveLog,
outputFilterSensitiveLog: ListCostAllocationTagsResponse.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: ListCostAllocationTagsCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_json1_1ListCostAllocationTagsCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<ListCostAllocationTagsCommandOutput> {
return deserializeAws_json1_1ListCostAllocationTagsCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ export interface ListCostCategoryDefinitionsCommandOutput
__MetadataBearer {}

/**
* <p>Returns the name, ARN, <code>NumberOfRules</code> and effective dates of all Cost Categories defined in the account. You have the option to use <code>EffectiveOn</code> to return a list of Cost Categories that were active on a specific date. If there is no <code>EffectiveOn</code> specified, you’ll see Cost Categories that are effective on the current date. If Cost Category is still effective, <code>EffectiveEnd</code> is omitted in the response. <code>ListCostCategoryDefinitions</code> supports pagination. The request can have a <code>MaxResults</code> range up to 100.</p>
* <p>Returns the name, Amazon Resource Name (ARN), <code>NumberOfRules</code> and effective
* dates of all Cost Categories defined in the account. You have the option to use
* <code>EffectiveOn</code> to return a list of Cost Categories that were active on a specific
* date. If there is no <code>EffectiveOn</code> specified, you’ll see Cost Categories that are
* effective on the current date. If Cost Category is still effective, <code>EffectiveEnd</code>
* is omitted in the response. <code>ListCostCategoryDefinitions</code> supports pagination. The
* request can have a <code>MaxResults</code> range up to 100.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export interface TagResourceCommandOutput extends TagResourceResponse, __Metadat
/**
* <p>An API operation for adding one or more tags (key-value pairs) to a resource.</p>
* <p>You can use the <code>TagResource</code> operation with a resource that already has tags. If you specify a new tag key for the resource, this tag is appended to the list of tags associated with the resource. If you specify a tag key that is already associated with the resource, the new tag value you specify replaces the previous value for that tag.</p>
* <p>
* Although the maximum number of array members is 200, user-tag maximum is 50. The remaining are reserved for Amazon Web Services use.</p>
* <p>Although the maximum number of array members is 200, user-tag maximum is 50. The remaining
* are reserved for Amazon Web Services use.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ export interface UntagResourceCommandInput extends UntagResourceRequest {}
export interface UntagResourceCommandOutput extends UntagResourceResponse, __MetadataBearer {}

/**
* <p>
* Removes one or more tags from a resource. Specify only tag key(s) in your request. Do not specify the value.
* </p>
* <p>Removes one or more tags from a resource. Specify only tag keys in your request. Don't
* specify the value. </p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
Expand Down
Loading

0 comments on commit 25dcf34

Please sign in to comment.