Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,6 @@ components:
schema:
$ref: "#/components/schemas/APIErrorResponse"
description: Too many requests
headers:
X-RateLimit-Limit:
description: Number of requests allowed in the rate-limit period.
schema:
format: int64
type: integer
X-RateLimit-Period:
description: Length of the rate-limit period in seconds.
schema:
format: int64
type: integer
X-RateLimit-Remaining:
description: Number of requests remaining in the current rate-limit period.
schema:
format: int64
type: integer
X-RateLimit-Reset:
description: Number of seconds until the current rate-limit period resets.
schema:
format: int64
type: integer
schemas:
APIErrorResponse:
description: Error response object.
Expand Down
61 changes: 40 additions & 21 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3142,27 +3142,6 @@ components:
schema:
$ref: "#/components/schemas/APIErrorResponse"
description: Too many requests
headers:
X-RateLimit-Limit:
description: Number of requests allowed in the rate-limit period.
schema:
format: int64
type: integer
X-RateLimit-Period:
description: Length of the rate-limit period in seconds.
schema:
format: int64
type: integer
X-RateLimit-Remaining:
description: Number of requests remaining in the current rate-limit period.
schema:
format: int64
type: integer
X-RateLimit-Reset:
description: Number of seconds until the current rate-limit period resets.
schema:
format: int64
type: integer
UnauthorizedResponse:
content:
application/json:
Expand Down Expand Up @@ -31732,6 +31711,11 @@ components:
dd_resource_key:
description: Datadog resource key identifying the recommended resource.
type: string
extra_fields:
description: Selected recommendation fields. Omitted when no requested fields match.
items:
$ref: "#/components/schemas/CostRecommendationExtraField"
type: array
potential_daily_savings:
$ref: "#/components/schemas/CostRecommendationDataAttributesPotentialDailySavings"
recommendation_type:
Expand Down Expand Up @@ -31775,6 +31759,20 @@ components:
type: string
x-enum-varnames:
- RECOMMENDATION
CostRecommendationExtraField:
description: A recommendation field selected by the request's `extra_fields` patterns.
properties:
path:
description: Dotted path of the matched field in the recommendation event's custom attributes.
example: tags.env
type: string
value:
description: Matched JSON value. Paths through arrays return the matched values as an array.
example: prod
required:
- path
- value
type: object
CostTag:
description: A Cloud Cost Management tag.
properties:
Expand Down Expand Up @@ -118145,6 +118143,8 @@ components:
example:
data:
attributes:
extra_fields:
- tags.env
scope: ccm
sort:
- expression: "@potential_daily_savings"
Expand Down Expand Up @@ -118179,6 +118179,20 @@ components:
RecommendationsFilterRequestDataAttributes:
description: Attributes used to filter and sort cost recommendations.
properties:
extra_fields:
description: |-
Additional fields to return from the recommendation event's custom attributes, selected
by dotted paths such as `tags.env` or wildcard patterns such as `*target*`.
Arrays are traversed without indexes. Matched objects and arrays are returned whole.
A maximum of 256 selectors can be requested. Selectors that match nothing return no field.
example:
- tags.env
- "*target*"
items:
description: A dotted field path or wildcard pattern.
type: string
maxItems: 256
type: array
filter:
description: |-
Filter expression applied to the recommendations. When supplied, this attribute overrides
Expand Down Expand Up @@ -179232,6 +179246,8 @@ paths:
value:
data:
attributes:
extra_fields:
- tags.env
scope: ccm
sort:
- expression: "@potential_daily_savings"
Expand All @@ -179251,6 +179267,9 @@ paths:
data:
- attributes:
dd_resource_key: "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0"
extra_fields:
- path: tags.env
value: prod
potential_daily_savings:
amount: 1.23
currency: USD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
body = RecommendationsFilterRequest(
data=RecommendationsFilterRequestData(
attributes=RecommendationsFilterRequestDataAttributes(
extra_fields=[
"tags.env",
],
scope=RecommendationsFilterRequestScope.CCM,
sort=[
RecommendationsFilterRequestSortItems(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


if TYPE_CHECKING:
from datadog_api_client.v2.model.cost_recommendation_extra_field import CostRecommendationExtraField
from datadog_api_client.v2.model.cost_recommendation_data_attributes_potential_daily_savings import (
CostRecommendationDataAttributesPotentialDailySavings,
)
Expand All @@ -22,12 +23,14 @@
class CostRecommendationDataAttributes(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.cost_recommendation_extra_field import CostRecommendationExtraField
from datadog_api_client.v2.model.cost_recommendation_data_attributes_potential_daily_savings import (
CostRecommendationDataAttributesPotentialDailySavings,
)

return {
"dd_resource_key": (str,),
"extra_fields": ([CostRecommendationExtraField],),
"potential_daily_savings": (CostRecommendationDataAttributesPotentialDailySavings,),
"recommendation_type": (str,),
"recommender_id": (str,),
Expand All @@ -38,6 +41,7 @@ def openapi_types(_):

attribute_map = {
"dd_resource_key": "dd_resource_key",
"extra_fields": "extra_fields",
"potential_daily_savings": "potential_daily_savings",
"recommendation_type": "recommendation_type",
"recommender_id": "recommender_id",
Expand All @@ -49,6 +53,7 @@ def openapi_types(_):
def __init__(
self_,
dd_resource_key: Union[str, UnsetType] = unset,
extra_fields: Union[List[CostRecommendationExtraField], UnsetType] = unset,
potential_daily_savings: Union[CostRecommendationDataAttributesPotentialDailySavings, UnsetType] = unset,
recommendation_type: Union[str, UnsetType] = unset,
recommender_id: Union[str, UnsetType] = unset,
Expand All @@ -63,6 +68,9 @@ def __init__(
:param dd_resource_key: Datadog resource key identifying the recommended resource.
:type dd_resource_key: str, optional

:param extra_fields: Selected recommendation fields. Omitted when no requested fields match.
:type extra_fields: [CostRecommendationExtraField], optional

:param potential_daily_savings: Estimated daily savings if the recommendation is applied.
:type potential_daily_savings: CostRecommendationDataAttributesPotentialDailySavings, optional

Expand All @@ -84,6 +92,8 @@ def __init__(
"""
if dd_resource_key is not unset:
kwargs["dd_resource_key"] = dd_resource_key
if extra_fields is not unset:
kwargs["extra_fields"] = extra_fields
if potential_daily_savings is not unset:
kwargs["potential_daily_savings"] = potential_daily_savings
if recommendation_type is not unset:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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 Any

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
date,
datetime,
none_type,
UUID,
)


class CostRecommendationExtraField(ModelNormal):
@cached_property
def openapi_types(_):
return {
"path": (str,),
"value": (
bool,
date,
datetime,
dict,
float,
int,
list,
str,
UUID,
none_type,
),
}

attribute_map = {
"path": "path",
"value": "value",
}

def __init__(self_, path: str, value: Any, **kwargs):
"""
A recommendation field selected by the request's ``extra_fields`` patterns.

:param path: Dotted path of the matched field in the recommendation event's custom attributes.
:type path: str

:param value: Matched JSON value. Paths through arrays return the matched values as an array.
:type value: bool, date, datetime, dict, float, int, list, str, UUID, none_type
"""
super().__init__(kwargs)

self_.path = path
self_.value = value
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@


class RecommendationsFilterRequestDataAttributes(ModelNormal):
validations = {
"extra_fields": {
"max_items": 256,
},
}

@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.recommendations_filter_request_scope import RecommendationsFilterRequestScope
Expand All @@ -29,13 +35,15 @@ def openapi_types(_):
)

return {
"extra_fields": ([str],),
"filter": (str,),
"scope": (RecommendationsFilterRequestScope,),
"sort": ([RecommendationsFilterRequestSortItems],),
"view": (str,),
}

attribute_map = {
"extra_fields": "extra_fields",
"filter": "filter",
"scope": "scope",
"sort": "sort",
Expand All @@ -44,6 +52,7 @@ def openapi_types(_):

def __init__(
self_,
extra_fields: Union[List[str], UnsetType] = unset,
filter: Union[str, UnsetType] = unset,
scope: Union[RecommendationsFilterRequestScope, UnsetType] = unset,
sort: Union[List[RecommendationsFilterRequestSortItems], UnsetType] = unset,
Expand All @@ -53,6 +62,12 @@ def __init__(
"""
Attributes used to filter and sort cost recommendations.

:param extra_fields: Additional fields to return from the recommendation event's custom attributes, selected
by dotted paths such as ``tags.env`` or wildcard patterns such as ``*target*``.
Arrays are traversed without indexes. Matched objects and arrays are returned whole.
A maximum of 256 selectors can be requested. Selectors that match nothing return no field.
:type extra_fields: [str], optional

:param filter: Filter expression applied to the recommendations. When supplied, this attribute overrides
``data.id`` , including when empty. When omitted, ``data.id`` is used. If the resulting filter
is empty, it defaults to ``*``. Scope, view, and pagination still apply.
Expand All @@ -69,6 +84,8 @@ def __init__(
or ``completed``. Defaults to ``all`` , which returns recommendations in every status.
:type view: str, optional
"""
if extra_fields is not unset:
kwargs["extra_fields"] = extra_fields
if filter is not unset:
kwargs["filter"] = filter
if scope is not unset:
Expand Down
2 changes: 2 additions & 0 deletions src/datadog_api_client/v2/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,7 @@
CostRecommendationDataAttributesPotentialDailySavings,
)
from datadog_api_client.v2.model.cost_recommendation_data_type import CostRecommendationDataType
from datadog_api_client.v2.model.cost_recommendation_extra_field import CostRecommendationExtraField
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
Expand Down Expand Up @@ -16294,6 +16295,7 @@
"CostRecommendationDataAttributes",
"CostRecommendationDataAttributesPotentialDailySavings",
"CostRecommendationDataType",
"CostRecommendationExtraField",
"CostTag",
"CostTagAttributes",
"CostTagDescription",
Expand Down
4 changes: 2 additions & 2 deletions tests/v2/features/cloud_cost_management.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1028,15 +1028,15 @@ Feature: Cloud Cost Management
Scenario: Search cost recommendations returns "Bad Request" response
Given operation "SearchCostRecommendations" enabled
And new "SearchCostRecommendations" request
And body with value {"data": {"attributes": {"scope": "ccm", "sort": [{"expression": "@potential_daily_savings", "order": "DESC"}]}, "id": "@resource_table:aws_ec2_instance", "type": "recommendations_filter"}}
And body with value {"data": {"attributes": {"extra_fields": ["tags.env"], "scope": "ccm", "sort": [{"expression": "@potential_daily_savings", "order": "DESC"}]}, "id": "@resource_table:aws_ec2_instance", "type": "recommendations_filter"}}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:ddoghq/ccm-optimize
Scenario: Search cost recommendations returns "OK" response
Given operation "SearchCostRecommendations" enabled
And new "SearchCostRecommendations" request
And body with value {"data": {"attributes": {"scope": "ccm", "sort": [{"expression": "@potential_daily_savings", "order": "DESC"}]}, "id": "@resource_table:aws_ec2_instance", "type": "recommendations_filter"}}
And body with value {"data": {"attributes": {"extra_fields": ["tags.env"], "scope": "ccm", "sort": [{"expression": "@potential_daily_savings", "order": "DESC"}]}, "id": "@resource_table:aws_ec2_instance", "type": "recommendations_filter"}}
When the request is sent
Then the response status is 200 OK

Expand Down
Loading