Skip to content

Commit e142659

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

15 files changed

Lines changed: 2155 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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Search cost recommendations returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v2.api.CloudCostManagementApi;
6+
import com.datadog.api.client.v2.model.CostRecommendationArray;
7+
import com.datadog.api.client.v2.model.RecommendationsFilterRequest;
8+
import com.datadog.api.client.v2.model.RecommendationsFilterRequestSortItems;
9+
import java.util.Collections;
10+
11+
public class Example {
12+
public static void main(String[] args) {
13+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
14+
defaultClient.setUnstableOperationEnabled("v2.searchCostRecommendations", true);
15+
CloudCostManagementApi apiInstance = new CloudCostManagementApi(defaultClient);
16+
17+
RecommendationsFilterRequest body =
18+
new RecommendationsFilterRequest()
19+
.filter("@resource_table:aws_ec2_instance")
20+
.sort(
21+
Collections.singletonList(
22+
new RecommendationsFilterRequestSortItems()
23+
.expression("potential_daily_savings.amount")
24+
.order("DESC")));
25+
26+
try {
27+
CostRecommendationArray result = apiInstance.searchCostRecommendations(body);
28+
System.out.println(result);
29+
} catch (ApiException e) {
30+
System.err.println("Exception when calling CloudCostManagementApi#searchCostRecommendations");
31+
System.err.println("Status code: " + e.getCode());
32+
System.err.println("Reason: " + e.getResponseBody());
33+
System.err.println("Response headers: " + e.getResponseHeaders());
34+
e.printStackTrace();
35+
}
36+
}
37+
}

‎src/main/java/com/datadog/api/client/ApiClient.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ public class ApiClient {
921921
put("v2.listCostTagMetadata", false);
922922
put("v2.listCostTagMetadataMetrics", false);
923923
put("v2.listCostTagMetadataOrchestrators", false);
924+
put("v2.searchCostRecommendations", false);
924925
put("v2.createDashboardSecureEmbed", false);
925926
put("v2.deleteDashboardSecureEmbed", false);
926927
put("v2.getDashboardSecureEmbed", false);

0 commit comments

Comments
 (0)