Skip to content

Commit 1c562b7

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Cloud Cost Recommendations Search API (#4156)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent d54c058 commit 1c562b7

18 files changed

Lines changed: 1024 additions & 0 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17847,6 +17847,76 @@ components:
1784717847
required:
1784817848
- data
1784917849
type: object
17850+
CostRecommendationArray:
17851+
description: A page of cost recommendations with pagination metadata.
17852+
properties:
17853+
data:
17854+
description: The list of cost recommendations on this page.
17855+
items:
17856+
$ref: "#/components/schemas/CostRecommendationData"
17857+
type: array
17858+
meta:
17859+
$ref: "#/components/schemas/RecommendationsPageMeta"
17860+
required:
17861+
- data
17862+
type: object
17863+
CostRecommendationData:
17864+
description: A single cost recommendation entry in JSON:API form.
17865+
properties:
17866+
attributes:
17867+
$ref: "#/components/schemas/CostRecommendationDataAttributes"
17868+
id:
17869+
description: Unique identifier for the recommendation.
17870+
type: string
17871+
type:
17872+
$ref: "#/components/schemas/CostRecommendationDataType"
17873+
required:
17874+
- type
17875+
type: object
17876+
CostRecommendationDataAttributes:
17877+
description: Attributes describing a single cost recommendation.
17878+
properties:
17879+
dd_resource_key:
17880+
description: Datadog resource key identifying the recommended resource.
17881+
type: string
17882+
potential_daily_savings:
17883+
$ref: "#/components/schemas/CostRecommendationDataAttributesPotentialDailySavings"
17884+
recommendation_type:
17885+
description: The kind of recommendation (for example, `terminate` or `rightsize`).
17886+
type: string
17887+
resource_id:
17888+
description: Cloud provider identifier of the resource.
17889+
type: string
17890+
resource_type:
17891+
description: Resource type (for example, `aws_ec2_instance`).
17892+
type: string
17893+
tags:
17894+
description: Tags attached to the recommended resource.
17895+
items:
17896+
description: A single resource tag.
17897+
type: string
17898+
type: array
17899+
type: object
17900+
CostRecommendationDataAttributesPotentialDailySavings:
17901+
description: Estimated daily savings if the recommendation is applied.
17902+
properties:
17903+
amount:
17904+
description: Numeric amount of the potential daily savings.
17905+
format: double
17906+
type: number
17907+
currency:
17908+
description: ISO 4217 currency code for the savings amount.
17909+
type: string
17910+
type: object
17911+
CostRecommendationDataType:
17912+
default: recommendation
17913+
description: Recommendation resource type.
17914+
enum:
17915+
- recommendation
17916+
example: recommendation
17917+
type: string
17918+
x-enum-varnames:
17919+
- RECOMMENDATION
1785017920
CostTag:
1785117921
description: A Cloud Cost Management tag.
1785217922
properties:
@@ -64113,6 +64183,64 @@ components:
6411364183
type: string
6411464184
x-enum-varnames:
6411564185
- RECOMMENDATION
64186+
RecommendationsFilterRequest:
64187+
description: Request body for filtering cost recommendations.
64188+
example:
64189+
filter: "@resource_table:aws_ec2_instance"
64190+
sort:
64191+
- expression: potential_daily_savings.amount
64192+
order: DESC
64193+
properties:
64194+
filter:
64195+
description: Filter expression applied to the recommendations.
64196+
type: string
64197+
scope:
64198+
description: Recommendations scope. Defaults to `ccm`; use `experiment` for experimental recommendations or `*` for both.
64199+
type: string
64200+
sort:
64201+
description: Ordered list of sort clauses applied to the result set.
64202+
items:
64203+
$ref: "#/components/schemas/RecommendationsFilterRequestSortItems"
64204+
type: array
64205+
view:
64206+
description: Active view name (for example, `active`, `dismissed`, `open`, `in-progress`, or `completed`).
64207+
type: string
64208+
type: object
64209+
RecommendationsFilterRequestSortItems:
64210+
description: A single sort clause applied to the cost recommendations result set.
64211+
properties:
64212+
expression:
64213+
description: Field to sort by (for example, `potential_daily_savings.amount`).
64214+
type: string
64215+
order:
64216+
description: Sort direction, either `ASC` or `DESC`.
64217+
type: string
64218+
type: object
64219+
RecommendationsPageMeta:
64220+
description: Top-level JSON:API meta object for paginated cost recommendation responses.
64221+
properties:
64222+
page:
64223+
$ref: "#/components/schemas/RecommendationsPageMetaPage"
64224+
type: object
64225+
RecommendationsPageMetaPage:
64226+
description: Pagination metadata for a page of cost recommendations.
64227+
properties:
64228+
filter:
64229+
description: The filter expression that was applied to produce this page.
64230+
type: string
64231+
next_page_token:
64232+
description: Opaque token used to fetch the next page; absent on the last page.
64233+
type: string
64234+
page_size:
64235+
description: Number of items returned in this page (1–10000).
64236+
format: int32
64237+
maximum: 10000
64238+
minimum: 1
64239+
type: integer
64240+
page_token:
64241+
description: Pagination token echoed back from the request.
64242+
type: string
64243+
type: object
6411664244
ReferenceTableCreateSourceType:
6411764245
description: The source type for creating reference table data. Only these source types can be created through this API.
6411864246
enum:
@@ -106527,6 +106655,76 @@ paths:
106527106655
operator: OR
106528106656
permissions:
106529106657
- cloud_cost_management_read
106658+
/api/v2/cost/recommendations:
106659+
post:
106660+
description: List cost recommendations matching a filter, with pagination and sorting.
106661+
operationId: SearchCostRecommendations
106662+
parameters:
106663+
- description: Number of results per page (1–10000).
106664+
in: query
106665+
name: page[size]
106666+
schema:
106667+
type: string
106668+
- description: Pagination token from a previous response.
106669+
in: query
106670+
name: page[token]
106671+
schema:
106672+
type: string
106673+
requestBody:
106674+
content:
106675+
application/json:
106676+
examples:
106677+
default:
106678+
value:
106679+
filter: "@resource_table:aws_ec2_instance"
106680+
sort:
106681+
- expression: potential_daily_savings.amount
106682+
order: DESC
106683+
schema:
106684+
$ref: "#/components/schemas/RecommendationsFilterRequest"
106685+
required: true
106686+
responses:
106687+
"200":
106688+
content:
106689+
application/json:
106690+
examples:
106691+
default:
106692+
value:
106693+
data:
106694+
- attributes:
106695+
dd_resource_key: "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0"
106696+
potential_daily_savings:
106697+
amount: 1.23
106698+
currency: USD
106699+
recommendation_type: terminate
106700+
resource_id: i-1234567890abcdef0
106701+
resource_type: aws_ec2_instance
106702+
tags:
106703+
- "env:prod"
106704+
- "team:ccm"
106705+
id: encoded-event-id-1
106706+
type: recommendation
106707+
meta:
106708+
page:
106709+
filter: "@resource_table:aws_ec2_instance"
106710+
next_page_token: ""
106711+
page_size: 100
106712+
schema:
106713+
$ref: "#/components/schemas/CostRecommendationArray"
106714+
description: OK
106715+
"429":
106716+
$ref: "#/components/responses/TooManyRequestsResponse"
106717+
security:
106718+
- apiKeyAuth: []
106719+
appKeyAuth: []
106720+
- AuthZ:
106721+
- cloud_cost_management_read
106722+
summary: Search cost recommendations
106723+
tags:
106724+
- Cloud Cost Management
106725+
x-unstable: |-
106726+
**Note**: This endpoint is in preview and is subject to change.
106727+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
106530106728
/api/v2/cost/tag_descriptions:
106531106729
get:
106532106730
description: List Cloud Cost Management tag key descriptions for the organization. Use `filter[cloud]` to scope the result to a single cloud provider; when omitted, both cross-cloud defaults and cloud-specific descriptions are returned.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Search cost recommendations returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
configuration.unstableOperations["v2.searchCostRecommendations"] = true;
9+
const apiInstance = new v2.CloudCostManagementApi(configuration);
10+
11+
const params: v2.CloudCostManagementApiSearchCostRecommendationsRequest = {
12+
body: {
13+
filter: "@resource_table:aws_ec2_instance",
14+
sort: [
15+
{
16+
expression: "potential_daily_savings.amount",
17+
order: "DESC",
18+
},
19+
],
20+
},
21+
};
22+
23+
apiInstance
24+
.searchCostRecommendations(params)
25+
.then((data: v2.CostRecommendationArray) => {
26+
console.log(
27+
"API called successfully. Returned data: " + JSON.stringify(data)
28+
);
29+
})
30+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7049,6 +7049,21 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
70497049
"v2.ListCostOCIConfigs": {
70507050
"operationResponseType": "OCIConfigsResponse",
70517051
},
7052+
"v2.SearchCostRecommendations": {
7053+
"pageSize": {
7054+
"type": "string",
7055+
"format": "",
7056+
},
7057+
"pageToken": {
7058+
"type": "string",
7059+
"format": "",
7060+
},
7061+
"body": {
7062+
"type": "RecommendationsFilterRequest",
7063+
"format": "",
7064+
},
7065+
"operationResponseType": "CostRecommendationArray",
7066+
},
70527067
"v2.ListCostTagDescriptions": {
70537068
"filterCloud": {
70547069
"type": "string",

features/v2/cloud_cost_management.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,14 @@ Feature: Cloud Cost Management
736736
When the request is sent
737737
Then the response status is 204 Successfully reordered rulesets
738738

739+
@generated @skip @team:DataDog/ccm-optimize
740+
Scenario: Search cost recommendations returns "OK" response
741+
Given operation "SearchCostRecommendations" enabled
742+
And new "SearchCostRecommendations" request
743+
And body with value {"filter": "@resource_table:aws_ec2_instance", "sort": [{"expression": "potential_daily_savings.amount", "order": "DESC"}]}
744+
When the request is sent
745+
Then the response status is 200 OK
746+
739747
@team:DataDog/cloud-cost-management
740748
Scenario: Update Cloud Cost Management AWS CUR config returns "Not Found" response
741749
Given new "UpdateCostAWSCURConfig" request

features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,12 @@
18261826
"type": "safe"
18271827
}
18281828
},
1829+
"SearchCostRecommendations": {
1830+
"tag": "Cloud Cost Management",
1831+
"undo": {
1832+
"type": "safe"
1833+
}
1834+
},
18291835
"ListCostTagDescriptions": {
18301836
"tag": "Cloud Cost Management",
18311837
"undo": {

packages/datadog-api-client-common/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ export function createConfiguration(
388388
"v2.listCostTagMetadata": false,
389389
"v2.listCostTagMetadataMetrics": false,
390390
"v2.listCostTagMetadataOrchestrators": false,
391+
"v2.searchCostRecommendations": false,
391392
"v2.createDashboardSecureEmbed": false,
392393
"v2.deleteDashboardSecureEmbed": false,
393394
"v2.getDashboardSecureEmbed": false,

0 commit comments

Comments
 (0)