diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index bfb6719791..0d193c323f 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -91830,16 +91830,42 @@ components: x-enum-varnames: - RECOMMENDATION RecommendationsFilterRequest: - description: Request body for filtering cost recommendations. + description: JSON:API request body for filtering cost recommendations. example: - filter: "@resource_table:aws_ec2_instance" - sort: - - expression: potential_daily_savings.amount - order: DESC + data: + attributes: + scope: ccm + sort: + - expression: potential_daily_savings.amount + order: DESC + id: "@resource_table:aws_ec2_instance" + type: recommendations_filter properties: - filter: - description: Filter expression applied to the recommendations. + data: + $ref: "#/components/schemas/RecommendationsFilterRequestData" + required: + - data + type: object + RecommendationsFilterRequestData: + description: |- + JSON:API resource containing the cost recommendations filter. This legacy search contract + uses the resource ID for the filter expression rather than as a persistent resource identifier. + properties: + attributes: + $ref: "#/components/schemas/RecommendationsFilterRequestDataAttributes" + id: + description: |- + Filter expression applied to the recommendations. The server treats an omitted ID as `*` + and returns all recommendations. type: string + type: + $ref: "#/components/schemas/RecommendationsFilterRequestDataType" + required: + - type + type: object + RecommendationsFilterRequestDataAttributes: + description: Attributes used to filter and sort cost recommendations. + properties: scope: $ref: "#/components/schemas/RecommendationsFilterRequestScope" sort: @@ -91851,6 +91877,15 @@ components: description: Active view name (for example, `active`, `dismissed`, `open`, `in-progress`, or `completed`). type: string type: object + RecommendationsFilterRequestDataType: + default: recommendations_filter + description: Legacy JSON:API resource type required by the cost recommendations search decoder. + enum: + - recommendations_filter + example: recommendations_filter + type: string + x-enum-varnames: + - RECOMMENDATIONS_FILTER RecommendationsFilterRequestScope: description: Recommendations scope. Defaults to `ccm`; use `experiment` for experimental recommendations or `*` for both. enum: @@ -145681,10 +145716,14 @@ paths: examples: default: value: - filter: "@resource_table:aws_ec2_instance" - sort: - - expression: potential_daily_savings.amount - order: DESC + data: + attributes: + scope: ccm + sort: + - expression: potential_daily_savings.amount + order: DESC + id: "@resource_table:aws_ec2_instance" + type: recommendations_filter schema: $ref: "#/components/schemas/RecommendationsFilterRequest" required: true diff --git a/examples/v2/cloud-cost-management/SearchCostRecommendations.py b/examples/v2/cloud-cost-management/SearchCostRecommendations.py index 2f1002b5d1..7df7d836ae 100644 --- a/examples/v2/cloud-cost-management/SearchCostRecommendations.py +++ b/examples/v2/cloud-cost-management/SearchCostRecommendations.py @@ -5,16 +5,28 @@ 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_data import RecommendationsFilterRequestData +from datadog_api_client.v2.model.recommendations_filter_request_data_attributes import ( + RecommendationsFilterRequestDataAttributes, +) +from datadog_api_client.v2.model.recommendations_filter_request_data_type import RecommendationsFilterRequestDataType +from datadog_api_client.v2.model.recommendations_filter_request_scope import RecommendationsFilterRequestScope 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", + data=RecommendationsFilterRequestData( + attributes=RecommendationsFilterRequestDataAttributes( + scope=RecommendationsFilterRequestScope.CCM, + sort=[ + RecommendationsFilterRequestSortItems( + expression="potential_daily_savings.amount", + order="DESC", + ), + ], ), - ], + id="@resource_table:aws_ec2_instance", + type=RecommendationsFilterRequestDataType.RECOMMENDATIONS_FILTER, + ), ) configuration = Configuration() diff --git a/src/datadog_api_client/v2/model/recommendations_filter_request.py b/src/datadog_api_client/v2/model/recommendations_filter_request.py index d7e3d7215a..17d8517170 100644 --- a/src/datadog_api_client/v2/model/recommendations_filter_request.py +++ b/src/datadog_api_client/v2/model/recommendations_filter_request.py @@ -3,74 +3,39 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations -from typing import List, Union, TYPE_CHECKING +from typing import 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_scope import RecommendationsFilterRequestScope - from datadog_api_client.v2.model.recommendations_filter_request_sort_items import ( - RecommendationsFilterRequestSortItems, - ) + from datadog_api_client.v2.model.recommendations_filter_request_data import RecommendationsFilterRequestData class RecommendationsFilterRequest(ModelNormal): @cached_property def openapi_types(_): - from datadog_api_client.v2.model.recommendations_filter_request_scope import RecommendationsFilterRequestScope - from datadog_api_client.v2.model.recommendations_filter_request_sort_items import ( - RecommendationsFilterRequestSortItems, - ) + from datadog_api_client.v2.model.recommendations_filter_request_data import RecommendationsFilterRequestData return { - "filter": (str,), - "scope": (RecommendationsFilterRequestScope,), - "sort": ([RecommendationsFilterRequestSortItems],), - "view": (str,), + "data": (RecommendationsFilterRequestData,), } attribute_map = { - "filter": "filter", - "scope": "scope", - "sort": "sort", - "view": "view", + "data": "data", } - def __init__( - self_, - filter: Union[str, UnsetType] = unset, - scope: Union[RecommendationsFilterRequestScope, UnsetType] = unset, - sort: Union[List[RecommendationsFilterRequestSortItems], UnsetType] = unset, - view: Union[str, UnsetType] = unset, - **kwargs, - ): + def __init__(self_, data: RecommendationsFilterRequestData, **kwargs): """ - Request body for filtering cost recommendations. + JSON:API 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: RecommendationsFilterRequestScope, 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 + :param data: JSON:API resource containing the cost recommendations filter. This legacy search contract + uses the resource ID for the filter expression rather than as a persistent resource identifier. + :type data: RecommendationsFilterRequestData """ - 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) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/recommendations_filter_request_data.py b/src/datadog_api_client/v2/model/recommendations_filter_request_data.py new file mode 100644 index 0000000000..86d70fa8b2 --- /dev/null +++ b/src/datadog_api_client/v2/model/recommendations_filter_request_data.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 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_data_attributes import ( + RecommendationsFilterRequestDataAttributes, + ) + from datadog_api_client.v2.model.recommendations_filter_request_data_type import ( + RecommendationsFilterRequestDataType, + ) + + +class RecommendationsFilterRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.recommendations_filter_request_data_attributes import ( + RecommendationsFilterRequestDataAttributes, + ) + from datadog_api_client.v2.model.recommendations_filter_request_data_type import ( + RecommendationsFilterRequestDataType, + ) + + return { + "attributes": (RecommendationsFilterRequestDataAttributes,), + "id": (str,), + "type": (RecommendationsFilterRequestDataType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + type: RecommendationsFilterRequestDataType, + attributes: Union[RecommendationsFilterRequestDataAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + JSON:API resource containing the cost recommendations filter. This legacy search contract + uses the resource ID for the filter expression rather than as a persistent resource identifier. + + :param attributes: Attributes used to filter and sort cost recommendations. + :type attributes: RecommendationsFilterRequestDataAttributes, optional + + :param id: Filter expression applied to the recommendations. The server treats an omitted ID as ``*`` + and returns all recommendations. + :type id: str, optional + + :param type: Legacy JSON:API resource type required by the cost recommendations search decoder. + :type type: RecommendationsFilterRequestDataType + """ + 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/recommendations_filter_request_data_attributes.py b/src/datadog_api_client/v2/model/recommendations_filter_request_data_attributes.py new file mode 100644 index 0000000000..b54302743b --- /dev/null +++ b/src/datadog_api_client/v2/model/recommendations_filter_request_data_attributes.py @@ -0,0 +1,68 @@ +# 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_scope import RecommendationsFilterRequestScope + from datadog_api_client.v2.model.recommendations_filter_request_sort_items import ( + RecommendationsFilterRequestSortItems, + ) + + +class RecommendationsFilterRequestDataAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.recommendations_filter_request_scope import RecommendationsFilterRequestScope + from datadog_api_client.v2.model.recommendations_filter_request_sort_items import ( + RecommendationsFilterRequestSortItems, + ) + + return { + "scope": (RecommendationsFilterRequestScope,), + "sort": ([RecommendationsFilterRequestSortItems],), + "view": (str,), + } + + attribute_map = { + "scope": "scope", + "sort": "sort", + "view": "view", + } + + def __init__( + self_, + scope: Union[RecommendationsFilterRequestScope, UnsetType] = unset, + sort: Union[List[RecommendationsFilterRequestSortItems], UnsetType] = unset, + view: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Attributes used to filter and sort cost recommendations. + + :param scope: Recommendations scope. Defaults to ``ccm`` ; use ``experiment`` for experimental recommendations or ``*`` for both. + :type scope: RecommendationsFilterRequestScope, 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 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_data_type.py b/src/datadog_api_client/v2/model/recommendations_filter_request_data_type.py new file mode 100644 index 0000000000..0d7a25a276 --- /dev/null +++ b/src/datadog_api_client/v2/model/recommendations_filter_request_data_type.py @@ -0,0 +1,37 @@ +# 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 RecommendationsFilterRequestDataType(ModelSimple): + """ + Legacy JSON:API resource type required by the cost recommendations search decoder. + + :param value: If omitted defaults to "recommendations_filter". Must be one of ["recommendations_filter"]. + :type value: str + """ + + allowed_values = { + "recommendations_filter", + } + RECOMMENDATIONS_FILTER: ClassVar["RecommendationsFilterRequestDataType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +RecommendationsFilterRequestDataType.RECOMMENDATIONS_FILTER = RecommendationsFilterRequestDataType( + "recommendations_filter" +) diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 56f43e7d2a..27ee53f7fc 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -8007,6 +8007,11 @@ 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_data import RecommendationsFilterRequestData +from datadog_api_client.v2.model.recommendations_filter_request_data_attributes import ( + RecommendationsFilterRequestDataAttributes, +) +from datadog_api_client.v2.model.recommendations_filter_request_data_type import RecommendationsFilterRequestDataType from datadog_api_client.v2.model.recommendations_filter_request_scope import RecommendationsFilterRequestScope from datadog_api_client.v2.model.recommendations_filter_request_sort_items import RecommendationsFilterRequestSortItems from datadog_api_client.v2.model.recommendations_page_meta import RecommendationsPageMeta @@ -17114,6 +17119,9 @@ "RecommendationDocument", "RecommendationType", "RecommendationsFilterRequest", + "RecommendationsFilterRequestData", + "RecommendationsFilterRequestDataAttributes", + "RecommendationsFilterRequestDataType", "RecommendationsFilterRequestScope", "RecommendationsFilterRequestSortItems", "RecommendationsPageMeta", diff --git a/tests/v2/features/cloud_cost_management.feature b/tests/v2/features/cloud_cost_management.feature index 205054b8a5..f6298e74f2 100644 --- a/tests/v2/features/cloud_cost_management.feature +++ b/tests/v2/features/cloud_cost_management.feature @@ -974,7 +974,7 @@ Feature: Cloud Cost Management Scenario: Search cost recommendations returns "OK" response Given operation "SearchCostRecommendations" enabled And new "SearchCostRecommendations" request - And body with value {"filter": "@resource_table:aws_ec2_instance", "sort": [{"expression": "potential_daily_savings.amount", "order": "DESC"}]} + And body with value {"data": {"attributes": {"scope": "ccm", "sort": [{"expression": "potential_daily_savings.amount", "order": "DESC"}]}, "id": "@resource_table:aws_ec2_instance", "type": "recommendations_filter"}} When the request is sent Then the response status is 200 OK