diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index b0ee5756e1..c4420ead84 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -16658,6 +16658,76 @@ components: type: string x-enum-varnames: - COST_BY_ORG + CostRecommendationArray: + description: A page of cost recommendations with pagination metadata. + properties: + data: + description: The list of cost recommendations on this page. + items: + $ref: "#/components/schemas/CostRecommendationData" + type: array + meta: + $ref: "#/components/schemas/RecommendationsPageMeta" + required: + - data + type: object + CostRecommendationData: + description: A single cost recommendation entry in JSON:API form. + properties: + attributes: + $ref: "#/components/schemas/CostRecommendationDataAttributes" + id: + description: Unique identifier for the recommendation. + type: string + type: + $ref: "#/components/schemas/CostRecommendationDataType" + required: + - type + type: object + CostRecommendationDataAttributes: + description: Attributes describing a single cost recommendation. + properties: + dd_resource_key: + description: Datadog resource key identifying the recommended resource. + type: string + potential_daily_savings: + $ref: "#/components/schemas/CostRecommendationDataAttributesPotentialDailySavings" + recommendation_type: + description: The kind of recommendation (for example, `terminate` or `rightsize`). + type: string + resource_id: + description: Cloud provider identifier of the resource. + type: string + resource_type: + description: Resource type (for example, `aws_ec2_instance`). + type: string + tags: + description: Tags attached to the recommended resource. + items: + description: A single resource tag. + type: string + type: array + type: object + CostRecommendationDataAttributesPotentialDailySavings: + description: Estimated daily savings if the recommendation is applied. + properties: + amount: + description: Numeric amount of the potential daily savings. + format: double + type: number + currency: + description: ISO 4217 currency code for the savings amount. + type: string + type: object + CostRecommendationDataType: + default: recommendation + description: Recommendation resource type. + enum: + - recommendation + example: recommendation + type: string + x-enum-varnames: + - RECOMMENDATION CostTag: description: A Cloud Cost Management tag. properties: @@ -59600,6 +59670,64 @@ components: type: string x-enum-varnames: - RECOMMENDATION + RecommendationsFilterRequest: + description: Request body for filtering cost recommendations. + example: + filter: "@resource_table:aws_ec2_instance" + sort: + - expression: potential_daily_savings.amount + order: DESC + properties: + filter: + description: Filter expression applied to the recommendations. + type: string + scope: + description: Recommendations scope. Defaults to `ccm`; use `experiment` for experimental recommendations or `*` for both. + type: string + sort: + description: Ordered list of sort clauses applied to the result set. + items: + $ref: "#/components/schemas/RecommendationsFilterRequestSortItems" + type: array + view: + description: Active view name (for example, `active`, `dismissed`, `open`, `in-progress`, or `completed`). + type: string + type: object + RecommendationsFilterRequestSortItems: + description: A single sort clause applied to the cost recommendations result set. + properties: + expression: + description: Field to sort by (for example, `potential_daily_savings.amount`). + type: string + order: + description: Sort direction, either `ASC` or `DESC`. + type: string + type: object + RecommendationsPageMeta: + description: Top-level JSON:API meta object for paginated cost recommendation responses. + properties: + page: + $ref: "#/components/schemas/RecommendationsPageMetaPage" + type: object + RecommendationsPageMetaPage: + description: Pagination metadata for a page of cost recommendations. + properties: + filter: + description: The filter expression that was applied to produce this page. + type: string + next_page_token: + description: Opaque token used to fetch the next page; absent on the last page. + type: string + page_size: + description: Number of items returned in this page (1–10000). + format: int32 + maximum: 10000 + minimum: 1 + type: integer + page_token: + description: Pagination token echoed back from the request. + type: string + type: object ReferenceTableCreateSourceType: description: The source type for creating reference table data. Only these source types can be created through this API. enum: @@ -100097,6 +100225,76 @@ paths: operator: OR permissions: - cloud_cost_management_read + /api/v2/cost/recommendations: + post: + description: List cost recommendations matching a filter, with pagination and sorting. + operationId: GetRecommendationsByFilter + parameters: + - description: Number of results per page (1–10000). + in: query + name: page[size] + schema: + type: string + - description: Pagination token from a previous response. + in: query + name: page[token] + schema: + type: string + requestBody: + content: + application/json: + examples: + default: + value: + filter: "@resource_table:aws_ec2_instance" + sort: + - expression: potential_daily_savings.amount + order: DESC + schema: + $ref: "#/components/schemas/RecommendationsFilterRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + dd_resource_key: "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0" + potential_daily_savings: + amount: 1.23 + currency: USD + recommendation_type: terminate + resource_id: i-1234567890abcdef0 + resource_type: aws_ec2_instance + tags: + - "env:prod" + - "team:ccm" + id: encoded-event-id-1 + type: recommendation + meta: + page: + filter: "@resource_table:aws_ec2_instance" + next_page_token: "" + page_size: 100 + schema: + $ref: "#/components/schemas/CostRecommendationArray" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: Get recommendations by filter + tags: + - Cloud Cost Management + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/cost/tag_descriptions: get: 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. diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 019a1a618c..f5a5812c45 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -6535,6 +6535,41 @@ datadog\_api\_client.v2.model.cost\_by\_org\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.cost\_recommendation\_array module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.cost_recommendation_array + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.cost\_recommendation\_data module +--------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.cost_recommendation_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.cost\_recommendation\_data\_attributes module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.cost_recommendation_data_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.cost\_recommendation\_data\_attributes\_potential\_daily\_savings module +------------------------------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.cost_recommendation_data_attributes_potential_daily_savings + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.cost\_recommendation\_data\_type module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.cost_recommendation_data_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.cost\_tag module ---------------------------------------------- @@ -25680,6 +25715,34 @@ datadog\_api\_client.v2.model.recommendation\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.recommendations\_filter\_request module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.recommendations_filter_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.recommendations\_filter\_request\_sort\_items module +---------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.recommendations_filter_request_sort_items + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.recommendations\_page\_meta module +---------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.recommendations_page_meta + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.recommendations\_page\_meta\_page module +---------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.recommendations_page_meta_page + :members: + :show-inheritance: + datadog\_api\_client.v2.model.reference\_table\_create\_source\_type module --------------------------------------------------------------------------- diff --git a/examples/v2/cloud-cost-management/GetRecommendationsByFilter.py b/examples/v2/cloud-cost-management/GetRecommendationsByFilter.py new file mode 100644 index 0000000000..f82529869d --- /dev/null +++ b/examples/v2/cloud-cost-management/GetRecommendationsByFilter.py @@ -0,0 +1,26 @@ +""" +Get recommendations by filter returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi +from datadog_api_client.v2.model.recommendations_filter_request import RecommendationsFilterRequest +from datadog_api_client.v2.model.recommendations_filter_request_sort_items import RecommendationsFilterRequestSortItems + +body = RecommendationsFilterRequest( + filter="@resource_table:aws_ec2_instance", + sort=[ + RecommendationsFilterRequestSortItems( + expression="potential_daily_savings.amount", + order="DESC", + ), + ], +) + +configuration = Configuration() +configuration.unstable_operations["get_recommendations_by_filter"] = True +with ApiClient(configuration) as api_client: + api_instance = CloudCostManagementApi(api_client) + response = api_instance.get_recommendations_by_filter(body=body) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 9d77d4720c..46b767864e 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -361,6 +361,7 @@ def __init__( "v2.get_commitments_utilization_scalar": False, "v2.get_commitments_utilization_timeseries": False, "v2.get_cost_anomaly": False, + "v2.get_recommendations_by_filter": False, "v2.list_cost_anomalies": False, "v2.create_dashboard_secure_embed": False, "v2.delete_dashboard_secure_embed": False, diff --git a/src/datadog_api_client/v2/api/cloud_cost_management_api.py b/src/datadog_api_client/v2/api/cloud_cost_management_api.py index 48b133f336..1013c07001 100644 --- a/src/datadog_api_client/v2/api/cloud_cost_management_api.py +++ b/src/datadog_api_client/v2/api/cloud_cost_management_api.py @@ -56,6 +56,8 @@ from datadog_api_client.v2.model.gcp_uc_config_response import GcpUcConfigResponse from datadog_api_client.v2.model.gcp_usage_cost_config_patch_request import GCPUsageCostConfigPatchRequest from datadog_api_client.v2.model.oci_configs_response import OCIConfigsResponse +from datadog_api_client.v2.model.cost_recommendation_array import CostRecommendationArray +from datadog_api_client.v2.model.recommendations_filter_request import RecommendationsFilterRequest from datadog_api_client.v2.model.cost_tag_descriptions_response import CostTagDescriptionsResponse from datadog_api_client.v2.model.cost_tag_keys_response import CostTagKeysResponse from datadog_api_client.v2.model.cost_tag_key_response import CostTagKeyResponse @@ -921,6 +923,36 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._get_recommendations_by_filter_endpoint = _Endpoint( + settings={ + "response_type": (CostRecommendationArray,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/cost/recommendations", + "operation_id": "get_recommendations_by_filter", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "page_size": { + "openapi_types": (str,), + "attribute": "page[size]", + "location": "query", + }, + "page_token": { + "openapi_types": (str,), + "attribute": "page[token]", + "location": "query", + }, + "body": { + "required": True, + "openapi_types": (RecommendationsFilterRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + self._get_tag_pipelines_ruleset_endpoint = _Endpoint( settings={ "response_type": (RulesetResp,), @@ -2265,6 +2297,35 @@ def get_custom_costs_file( return self._get_custom_costs_file_endpoint.call_with_http_info(**kwargs) + def get_recommendations_by_filter( + self, + body: RecommendationsFilterRequest, + *, + page_size: Union[str, UnsetType] = unset, + page_token: Union[str, UnsetType] = unset, + ) -> CostRecommendationArray: + """Get recommendations by filter. + + List cost recommendations matching a filter, with pagination and sorting. + + :type body: RecommendationsFilterRequest + :param page_size: Number of results per page (1–10000). + :type page_size: str, optional + :param page_token: Pagination token from a previous response. + :type page_token: str, optional + :rtype: CostRecommendationArray + """ + kwargs: Dict[str, Any] = {} + if page_size is not unset: + kwargs["page_size"] = page_size + + if page_token is not unset: + kwargs["page_token"] = page_token + + kwargs["body"] = body + + return self._get_recommendations_by_filter_endpoint.call_with_http_info(**kwargs) + def get_tag_pipelines_ruleset( self, ruleset_id: str, diff --git a/src/datadog_api_client/v2/model/cost_recommendation_array.py b/src/datadog_api_client/v2/model/cost_recommendation_array.py new file mode 100644 index 0000000000..9605a420f8 --- /dev/null +++ b/src/datadog_api_client/v2/model/cost_recommendation_array.py @@ -0,0 +1,53 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.cost_recommendation_data import CostRecommendationData + from datadog_api_client.v2.model.recommendations_page_meta import RecommendationsPageMeta + + +class CostRecommendationArray(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.cost_recommendation_data import CostRecommendationData + from datadog_api_client.v2.model.recommendations_page_meta import RecommendationsPageMeta + + return { + "data": ([CostRecommendationData],), + "meta": (RecommendationsPageMeta,), + } + + attribute_map = { + "data": "data", + "meta": "meta", + } + + def __init__( + self_, data: List[CostRecommendationData], meta: Union[RecommendationsPageMeta, UnsetType] = unset, **kwargs + ): + """ + A page of cost recommendations with pagination metadata. + + :param data: The list of cost recommendations on this page. + :type data: [CostRecommendationData] + + :param meta: Top-level JSON:API meta object for paginated cost recommendation responses. + :type meta: RecommendationsPageMeta, optional + """ + if meta is not unset: + kwargs["meta"] = meta + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/cost_recommendation_data.py b/src/datadog_api_client/v2/model/cost_recommendation_data.py new file mode 100644 index 0000000000..91544eb2aa --- /dev/null +++ b/src/datadog_api_client/v2/model/cost_recommendation_data.py @@ -0,0 +1,64 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.cost_recommendation_data_attributes import CostRecommendationDataAttributes + from datadog_api_client.v2.model.cost_recommendation_data_type import CostRecommendationDataType + + +class CostRecommendationData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.cost_recommendation_data_attributes import CostRecommendationDataAttributes + from datadog_api_client.v2.model.cost_recommendation_data_type import CostRecommendationDataType + + return { + "attributes": (CostRecommendationDataAttributes,), + "id": (str,), + "type": (CostRecommendationDataType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + type: CostRecommendationDataType, + attributes: Union[CostRecommendationDataAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + A single cost recommendation entry in JSON:API form. + + :param attributes: Attributes describing a single cost recommendation. + :type attributes: CostRecommendationDataAttributes, optional + + :param id: Unique identifier for the recommendation. + :type id: str, optional + + :param type: Recommendation resource type. + :type type: CostRecommendationDataType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + super().__init__(kwargs) + + self_.type = type diff --git a/src/datadog_api_client/v2/model/cost_recommendation_data_attributes.py b/src/datadog_api_client/v2/model/cost_recommendation_data_attributes.py new file mode 100644 index 0000000000..e7e6bd6382 --- /dev/null +++ b/src/datadog_api_client/v2/model/cost_recommendation_data_attributes.py @@ -0,0 +1,90 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.cost_recommendation_data_attributes_potential_daily_savings import ( + CostRecommendationDataAttributesPotentialDailySavings, + ) + + +class CostRecommendationDataAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.cost_recommendation_data_attributes_potential_daily_savings import ( + CostRecommendationDataAttributesPotentialDailySavings, + ) + + return { + "dd_resource_key": (str,), + "potential_daily_savings": (CostRecommendationDataAttributesPotentialDailySavings,), + "recommendation_type": (str,), + "resource_id": (str,), + "resource_type": (str,), + "tags": ([str],), + } + + attribute_map = { + "dd_resource_key": "dd_resource_key", + "potential_daily_savings": "potential_daily_savings", + "recommendation_type": "recommendation_type", + "resource_id": "resource_id", + "resource_type": "resource_type", + "tags": "tags", + } + + def __init__( + self_, + dd_resource_key: Union[str, UnsetType] = unset, + potential_daily_savings: Union[CostRecommendationDataAttributesPotentialDailySavings, UnsetType] = unset, + recommendation_type: Union[str, UnsetType] = unset, + resource_id: Union[str, UnsetType] = unset, + resource_type: Union[str, UnsetType] = unset, + tags: Union[List[str], UnsetType] = unset, + **kwargs, + ): + """ + Attributes describing a single cost recommendation. + + :param dd_resource_key: Datadog resource key identifying the recommended resource. + :type dd_resource_key: str, optional + + :param potential_daily_savings: Estimated daily savings if the recommendation is applied. + :type potential_daily_savings: CostRecommendationDataAttributesPotentialDailySavings, optional + + :param recommendation_type: The kind of recommendation (for example, ``terminate`` or ``rightsize`` ). + :type recommendation_type: str, optional + + :param resource_id: Cloud provider identifier of the resource. + :type resource_id: str, optional + + :param resource_type: Resource type (for example, ``aws_ec2_instance`` ). + :type resource_type: str, optional + + :param tags: Tags attached to the recommended resource. + :type tags: [str], optional + """ + if dd_resource_key is not unset: + kwargs["dd_resource_key"] = dd_resource_key + if potential_daily_savings is not unset: + kwargs["potential_daily_savings"] = potential_daily_savings + if recommendation_type is not unset: + kwargs["recommendation_type"] = recommendation_type + if resource_id is not unset: + kwargs["resource_id"] = resource_id + if resource_type is not unset: + kwargs["resource_type"] = resource_type + if tags is not unset: + kwargs["tags"] = tags + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/cost_recommendation_data_attributes_potential_daily_savings.py b/src/datadog_api_client/v2/model/cost_recommendation_data_attributes_potential_daily_savings.py new file mode 100644 index 0000000000..41cd677b44 --- /dev/null +++ b/src/datadog_api_client/v2/model/cost_recommendation_data_attributes_potential_daily_savings.py @@ -0,0 +1,43 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class CostRecommendationDataAttributesPotentialDailySavings(ModelNormal): + @cached_property + def openapi_types(_): + return { + "amount": (float,), + "currency": (str,), + } + + attribute_map = { + "amount": "amount", + "currency": "currency", + } + + def __init__(self_, amount: Union[float, UnsetType] = unset, currency: Union[str, UnsetType] = unset, **kwargs): + """ + Estimated daily savings if the recommendation is applied. + + :param amount: Numeric amount of the potential daily savings. + :type amount: float, optional + + :param currency: ISO 4217 currency code for the savings amount. + :type currency: str, optional + """ + if amount is not unset: + kwargs["amount"] = amount + if currency is not unset: + kwargs["currency"] = currency + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/cost_recommendation_data_type.py b/src/datadog_api_client/v2/model/cost_recommendation_data_type.py new file mode 100644 index 0000000000..771067a2cd --- /dev/null +++ b/src/datadog_api_client/v2/model/cost_recommendation_data_type.py @@ -0,0 +1,35 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class CostRecommendationDataType(ModelSimple): + """ + Recommendation resource type. + + :param value: If omitted defaults to "recommendation". Must be one of ["recommendation"]. + :type value: str + """ + + allowed_values = { + "recommendation", + } + RECOMMENDATION: ClassVar["CostRecommendationDataType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +CostRecommendationDataType.RECOMMENDATION = CostRecommendationDataType("recommendation") diff --git a/src/datadog_api_client/v2/model/recommendations_filter_request.py b/src/datadog_api_client/v2/model/recommendations_filter_request.py new file mode 100644 index 0000000000..ec7d1545f0 --- /dev/null +++ b/src/datadog_api_client/v2/model/recommendations_filter_request.py @@ -0,0 +1,74 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.recommendations_filter_request_sort_items import ( + RecommendationsFilterRequestSortItems, + ) + + +class RecommendationsFilterRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.recommendations_filter_request_sort_items import ( + RecommendationsFilterRequestSortItems, + ) + + return { + "filter": (str,), + "scope": (str,), + "sort": ([RecommendationsFilterRequestSortItems],), + "view": (str,), + } + + attribute_map = { + "filter": "filter", + "scope": "scope", + "sort": "sort", + "view": "view", + } + + def __init__( + self_, + filter: Union[str, UnsetType] = unset, + scope: Union[str, UnsetType] = unset, + sort: Union[List[RecommendationsFilterRequestSortItems], UnsetType] = unset, + view: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Request body for filtering cost recommendations. + + :param filter: Filter expression applied to the recommendations. + :type filter: str, optional + + :param scope: Recommendations scope. Defaults to ``ccm`` ; use ``experiment`` for experimental recommendations or ``*`` for both. + :type scope: str, optional + + :param sort: Ordered list of sort clauses applied to the result set. + :type sort: [RecommendationsFilterRequestSortItems], optional + + :param view: Active view name (for example, ``active`` , ``dismissed`` , ``open`` , ``in-progress`` , or ``completed`` ). + :type view: str, optional + """ + if filter is not unset: + kwargs["filter"] = filter + if scope is not unset: + kwargs["scope"] = scope + if sort is not unset: + kwargs["sort"] = sort + if view is not unset: + kwargs["view"] = view + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/recommendations_filter_request_sort_items.py b/src/datadog_api_client/v2/model/recommendations_filter_request_sort_items.py new file mode 100644 index 0000000000..3b10e874f0 --- /dev/null +++ b/src/datadog_api_client/v2/model/recommendations_filter_request_sort_items.py @@ -0,0 +1,43 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class RecommendationsFilterRequestSortItems(ModelNormal): + @cached_property + def openapi_types(_): + return { + "expression": (str,), + "order": (str,), + } + + attribute_map = { + "expression": "expression", + "order": "order", + } + + def __init__(self_, expression: Union[str, UnsetType] = unset, order: Union[str, UnsetType] = unset, **kwargs): + """ + A single sort clause applied to the cost recommendations result set. + + :param expression: Field to sort by (for example, ``potential_daily_savings.amount`` ). + :type expression: str, optional + + :param order: Sort direction, either ``ASC`` or ``DESC``. + :type order: str, optional + """ + if expression is not unset: + kwargs["expression"] = expression + if order is not unset: + kwargs["order"] = order + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/recommendations_page_meta.py b/src/datadog_api_client/v2/model/recommendations_page_meta.py new file mode 100644 index 0000000000..9941c1effc --- /dev/null +++ b/src/datadog_api_client/v2/model/recommendations_page_meta.py @@ -0,0 +1,42 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.recommendations_page_meta_page import RecommendationsPageMetaPage + + +class RecommendationsPageMeta(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.recommendations_page_meta_page import RecommendationsPageMetaPage + + return { + "page": (RecommendationsPageMetaPage,), + } + + attribute_map = { + "page": "page", + } + + def __init__(self_, page: Union[RecommendationsPageMetaPage, UnsetType] = unset, **kwargs): + """ + Top-level JSON:API meta object for paginated cost recommendation responses. + + :param page: Pagination metadata for a page of cost recommendations. + :type page: RecommendationsPageMetaPage, optional + """ + if page is not unset: + kwargs["page"] = page + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/recommendations_page_meta_page.py b/src/datadog_api_client/v2/model/recommendations_page_meta_page.py new file mode 100644 index 0000000000..ce36bbe4e1 --- /dev/null +++ b/src/datadog_api_client/v2/model/recommendations_page_meta_page.py @@ -0,0 +1,71 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class RecommendationsPageMetaPage(ModelNormal): + validations = { + "page_size": { + "inclusive_maximum": 10000, + "inclusive_minimum": 1, + }, + } + + @cached_property + def openapi_types(_): + return { + "filter": (str,), + "next_page_token": (str,), + "page_size": (int,), + "page_token": (str,), + } + + attribute_map = { + "filter": "filter", + "next_page_token": "next_page_token", + "page_size": "page_size", + "page_token": "page_token", + } + + def __init__( + self_, + filter: Union[str, UnsetType] = unset, + next_page_token: Union[str, UnsetType] = unset, + page_size: Union[int, UnsetType] = unset, + page_token: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Pagination metadata for a page of cost recommendations. + + :param filter: The filter expression that was applied to produce this page. + :type filter: str, optional + + :param next_page_token: Opaque token used to fetch the next page; absent on the last page. + :type next_page_token: str, optional + + :param page_size: Number of items returned in this page (1–10000). + :type page_size: int, optional + + :param page_token: Pagination token echoed back from the request. + :type page_token: str, optional + """ + if filter is not unset: + kwargs["filter"] = filter + if next_page_token is not unset: + kwargs["next_page_token"] = next_page_token + if page_size is not unset: + kwargs["page_size"] = page_size + if page_token is not unset: + kwargs["page_token"] = page_token + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index e1ca9fac28..77a69f7161 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -1223,6 +1223,13 @@ from datadog_api_client.v2.model.cost_by_org_attributes import CostByOrgAttributes from datadog_api_client.v2.model.cost_by_org_response import CostByOrgResponse from datadog_api_client.v2.model.cost_by_org_type import CostByOrgType +from datadog_api_client.v2.model.cost_recommendation_array import CostRecommendationArray +from datadog_api_client.v2.model.cost_recommendation_data import CostRecommendationData +from datadog_api_client.v2.model.cost_recommendation_data_attributes import CostRecommendationDataAttributes +from datadog_api_client.v2.model.cost_recommendation_data_attributes_potential_daily_savings import ( + CostRecommendationDataAttributesPotentialDailySavings, +) +from datadog_api_client.v2.model.cost_recommendation_data_type import CostRecommendationDataType from datadog_api_client.v2.model.cost_tag import CostTag from datadog_api_client.v2.model.cost_tag_attributes import CostTagAttributes from datadog_api_client.v2.model.cost_tag_description import CostTagDescription @@ -5293,6 +5300,10 @@ from datadog_api_client.v2.model.recommendation_data import RecommendationData from datadog_api_client.v2.model.recommendation_document import RecommendationDocument from datadog_api_client.v2.model.recommendation_type import RecommendationType +from datadog_api_client.v2.model.recommendations_filter_request import RecommendationsFilterRequest +from datadog_api_client.v2.model.recommendations_filter_request_sort_items import RecommendationsFilterRequestSortItems +from datadog_api_client.v2.model.recommendations_page_meta import RecommendationsPageMeta +from datadog_api_client.v2.model.recommendations_page_meta_page import RecommendationsPageMetaPage from datadog_api_client.v2.model.reference_table_create_source_type import ReferenceTableCreateSourceType from datadog_api_client.v2.model.reference_table_schema_field_type import ReferenceTableSchemaFieldType from datadog_api_client.v2.model.reference_table_sort_type import ReferenceTableSortType @@ -8620,6 +8631,11 @@ "CostByOrgAttributes", "CostByOrgResponse", "CostByOrgType", + "CostRecommendationArray", + "CostRecommendationData", + "CostRecommendationDataAttributes", + "CostRecommendationDataAttributesPotentialDailySavings", + "CostRecommendationDataType", "CostTag", "CostTagAttributes", "CostTagDescription", @@ -11408,6 +11424,10 @@ "RecommendationData", "RecommendationDocument", "RecommendationType", + "RecommendationsFilterRequest", + "RecommendationsFilterRequestSortItems", + "RecommendationsPageMeta", + "RecommendationsPageMetaPage", "ReferenceTableCreateSourceType", "ReferenceTableSchemaFieldType", "ReferenceTableSortType", diff --git a/tests/v2/features/cloud_cost_management.feature b/tests/v2/features/cloud_cost_management.feature index 76cb7c1d63..5b2a277d1a 100644 --- a/tests/v2/features/cloud_cost_management.feature +++ b/tests/v2/features/cloud_cost_management.feature @@ -520,6 +520,14 @@ Feature: Cloud Cost Management When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/ccm-optimize + Scenario: Get recommendations by filter returns "OK" response + Given operation "GetRecommendationsByFilter" enabled + And new "GetRecommendationsByFilter" request + And body with value {"filter": "@resource_table:aws_ec2_instance", "sort": [{"expression": "potential_daily_savings.amount", "order": "DESC"}]} + When the request is sent + Then the response status is 200 OK + @replay-only @team:DataDog/cloud-cost-management Scenario: List Cloud Cost Management AWS CUR configs returns "OK" response Given new "ListCostAWSCURConfigs" request diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 7a5941a2c0..8b5b1ac253 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -1591,6 +1591,12 @@ "type": "safe" } }, + "GetRecommendationsByFilter": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, "ListCostTagDescriptions": { "tag": "Cloud Cost Management", "undo": {