Skip to content

Commit 16ed069

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

17 files changed

Lines changed: 898 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.

docs/datadog_api_client.v2.model.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7137,6 +7137,41 @@ datadog\_api\_client.v2.model.cost\_orchestrators\_response module
71377137
:members:
71387138
:show-inheritance:
71397139

7140+
datadog\_api\_client.v2.model.cost\_recommendation\_array module
7141+
----------------------------------------------------------------
7142+
7143+
.. automodule:: datadog_api_client.v2.model.cost_recommendation_array
7144+
:members:
7145+
:show-inheritance:
7146+
7147+
datadog\_api\_client.v2.model.cost\_recommendation\_data module
7148+
---------------------------------------------------------------
7149+
7150+
.. automodule:: datadog_api_client.v2.model.cost_recommendation_data
7151+
:members:
7152+
:show-inheritance:
7153+
7154+
datadog\_api\_client.v2.model.cost\_recommendation\_data\_attributes module
7155+
---------------------------------------------------------------------------
7156+
7157+
.. automodule:: datadog_api_client.v2.model.cost_recommendation_data_attributes
7158+
:members:
7159+
:show-inheritance:
7160+
7161+
datadog\_api\_client.v2.model.cost\_recommendation\_data\_attributes\_potential\_daily\_savings module
7162+
------------------------------------------------------------------------------------------------------
7163+
7164+
.. automodule:: datadog_api_client.v2.model.cost_recommendation_data_attributes_potential_daily_savings
7165+
:members:
7166+
:show-inheritance:
7167+
7168+
datadog\_api\_client.v2.model.cost\_recommendation\_data\_type module
7169+
---------------------------------------------------------------------
7170+
7171+
.. automodule:: datadog_api_client.v2.model.cost_recommendation_data_type
7172+
:members:
7173+
:show-inheritance:
7174+
71407175
datadog\_api\_client.v2.model.cost\_tag module
71417176
----------------------------------------------
71427177

@@ -27521,6 +27556,34 @@ datadog\_api\_client.v2.model.recommendation\_type module
2752127556
:members:
2752227557
:show-inheritance:
2752327558

27559+
datadog\_api\_client.v2.model.recommendations\_filter\_request module
27560+
---------------------------------------------------------------------
27561+
27562+
.. automodule:: datadog_api_client.v2.model.recommendations_filter_request
27563+
:members:
27564+
:show-inheritance:
27565+
27566+
datadog\_api\_client.v2.model.recommendations\_filter\_request\_sort\_items module
27567+
----------------------------------------------------------------------------------
27568+
27569+
.. automodule:: datadog_api_client.v2.model.recommendations_filter_request_sort_items
27570+
:members:
27571+
:show-inheritance:
27572+
27573+
datadog\_api\_client.v2.model.recommendations\_page\_meta module
27574+
----------------------------------------------------------------
27575+
27576+
.. automodule:: datadog_api_client.v2.model.recommendations_page_meta
27577+
:members:
27578+
:show-inheritance:
27579+
27580+
datadog\_api\_client.v2.model.recommendations\_page\_meta\_page module
27581+
----------------------------------------------------------------------
27582+
27583+
.. automodule:: datadog_api_client.v2.model.recommendations_page_meta_page
27584+
:members:
27585+
:show-inheritance:
27586+
2752427587
datadog\_api\_client.v2.model.reference\_table\_create\_source\_type module
2752527588
---------------------------------------------------------------------------
2752627589

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
Search cost recommendations returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi
7+
from datadog_api_client.v2.model.recommendations_filter_request import RecommendationsFilterRequest
8+
from datadog_api_client.v2.model.recommendations_filter_request_sort_items import RecommendationsFilterRequestSortItems
9+
10+
body = RecommendationsFilterRequest(
11+
filter="@resource_table:aws_ec2_instance",
12+
sort=[
13+
RecommendationsFilterRequestSortItems(
14+
expression="potential_daily_savings.amount",
15+
order="DESC",
16+
),
17+
],
18+
)
19+
20+
configuration = Configuration()
21+
configuration.unstable_operations["search_cost_recommendations"] = True
22+
with ApiClient(configuration) as api_client:
23+
api_instance = CloudCostManagementApi(api_client)
24+
response = api_instance.search_cost_recommendations(body=body)
25+
26+
print(response)

src/datadog_api_client/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ def __init__(
413413
"v2.list_cost_tag_metadata": False,
414414
"v2.list_cost_tag_metadata_metrics": False,
415415
"v2.list_cost_tag_metadata_orchestrators": False,
416+
"v2.search_cost_recommendations": False,
416417
"v2.create_dashboard_secure_embed": False,
417418
"v2.delete_dashboard_secure_embed": False,
418419
"v2.get_dashboard_secure_embed": False,

0 commit comments

Comments
 (0)