Skip to content
Merged
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
18 changes: 13 additions & 5 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93243,7 +93243,7 @@ components:
attributes:
scope: ccm
sort:
- expression: potential_daily_savings.amount
- expression: "@potential_daily_savings"
order: DESC
id: "@resource_table:aws_ec2_instance"
type: recommendations_filter
Expand All @@ -93262,8 +93262,9 @@ components:
$ref: "#/components/schemas/RecommendationsFilterRequestDataAttributes"
id:
description: |-
Filter expression applied to the recommendations. The server treats an omitted ID as `*`
and returns all recommendations.
Filter expression applied to the recommendations when `attributes.filter` is omitted.
When supplied, `attributes.filter` overrides this value, including when empty. If the
resulting filter is empty, it defaults to `*`. Scope, view, and pagination still apply.
type: string
type:
$ref: "#/components/schemas/RecommendationsFilterRequestDataType"
Expand All @@ -93273,6 +93274,13 @@ components:
RecommendationsFilterRequestDataAttributes:
description: Attributes used to filter and sort cost recommendations.
properties:
filter:
description: |-
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.
example: "@resource_table:aws_ec2_instance"
type: string
scope:
$ref: "#/components/schemas/RecommendationsFilterRequestScope"
sort:
Expand Down Expand Up @@ -93308,7 +93316,7 @@ components:
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`).
description: Field to sort by (for example, `@potential_daily_savings`).
type: string
order:
description: Sort direction, either `ASC` or `DESC`.
Expand Down Expand Up @@ -148137,7 +148145,7 @@ paths:
attributes:
scope: ccm
sort:
- expression: potential_daily_savings.amount
- expression: "@potential_daily_savings"
order: DESC
id: "@resource_table:aws_ec2_instance"
type: recommendations_filter
Expand Down
5 changes: 3 additions & 2 deletions api/datadogV2/model_recommendations_filter_request_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import (
type RecommendationsFilterRequestData struct {
// Attributes used to filter and sort cost recommendations.
Attributes *RecommendationsFilterRequestDataAttributes `json:"attributes,omitempty"`
// Filter expression applied to the recommendations. The server treats an omitted ID as `*`
// and returns all recommendations.
// Filter expression applied to the recommendations when `attributes.filter` is omitted.
// When supplied, `attributes.filter` overrides this value, including when empty. If the
// resulting filter is empty, it defaults to `*`. Scope, view, and pagination still apply.
Id *string `json:"id,omitempty"`
// Legacy JSON:API resource type required by the cost recommendations search decoder.
Type RecommendationsFilterRequestDataType `json:"type"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (

// RecommendationsFilterRequestDataAttributes Attributes used to filter and sort cost recommendations.
type RecommendationsFilterRequestDataAttributes struct {
// 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.
Filter *string `json:"filter,omitempty"`
// Recommendations scope. Defaults to `ccm`; use `experiment` for experimental recommendations or `*` for both.
Scope *RecommendationsFilterRequestScope `json:"scope,omitempty"`
// Ordered list of sort clauses applied to the result set.
Expand Down Expand Up @@ -38,6 +42,34 @@ func NewRecommendationsFilterRequestDataAttributesWithDefaults() *Recommendation
return &this
}

// GetFilter returns the Filter field value if set, zero value otherwise.
func (o *RecommendationsFilterRequestDataAttributes) GetFilter() string {
if o == nil || o.Filter == nil {
var ret string
return ret
}
return *o.Filter
}

// GetFilterOk returns a tuple with the Filter field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *RecommendationsFilterRequestDataAttributes) GetFilterOk() (*string, bool) {
if o == nil || o.Filter == nil {
return nil, false
}
return o.Filter, true
}

// HasFilter returns a boolean if a field has been set.
func (o *RecommendationsFilterRequestDataAttributes) HasFilter() bool {
return o != nil && o.Filter != nil
}

// SetFilter gets a reference to the given string and assigns it to the Filter field.
func (o *RecommendationsFilterRequestDataAttributes) SetFilter(v string) {
o.Filter = &v
}

// GetScope returns the Scope field value if set, zero value otherwise.
func (o *RecommendationsFilterRequestDataAttributes) GetScope() RecommendationsFilterRequestScope {
if o == nil || o.Scope == nil {
Expand Down Expand Up @@ -128,6 +160,9 @@ func (o RecommendationsFilterRequestDataAttributes) MarshalJSON() ([]byte, error
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
if o.Filter != nil {
toSerialize["filter"] = o.Filter
}
if o.Scope != nil {
toSerialize["scope"] = o.Scope
}
Expand All @@ -147,21 +182,23 @@ func (o RecommendationsFilterRequestDataAttributes) MarshalJSON() ([]byte, error
// UnmarshalJSON deserializes the given payload.
func (o *RecommendationsFilterRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Scope *RecommendationsFilterRequestScope `json:"scope,omitempty"`
Sort []RecommendationsFilterRequestSortItems `json:"sort,omitempty"`
View *string `json:"view,omitempty"`
Filter *string `json:"filter,omitempty"`
Scope *RecommendationsFilterRequestScope `json:"scope,omitempty"`
Sort []RecommendationsFilterRequestSortItems `json:"sort,omitempty"`
View *string `json:"view,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
additionalProperties := make(map[string]interface{})
if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"scope", "sort", "view"})
datadog.DeleteKeys(additionalProperties, &[]string{"filter", "scope", "sort", "view"})
} else {
return err
}

hasInvalidField := false
o.Filter = all.Filter
if all.Scope != nil && !all.Scope.IsValid() {
hasInvalidField = true
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// RecommendationsFilterRequestSortItems A single sort clause applied to the cost recommendations result set.
type RecommendationsFilterRequestSortItems struct {
// Field to sort by (for example, `potential_daily_savings.amount`).
// Field to sort by (for example, `@potential_daily_savings`).
Expression *string `json:"expression,omitempty"`
// Sort direction, either `ASC` or `DESC`.
Order *string `json:"order,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {
Scope: datadogV2.RECOMMENDATIONSFILTERREQUESTSCOPE_CCM.Ptr(),
Sort: []datadogV2.RecommendationsFilterRequestSortItems{
{
Expression: datadog.PtrString("potential_daily_savings.amount"),
Expression: datadog.PtrString("@potential_daily_savings"),
Order: datadog.PtrString("DESC"),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {"data": {"attributes": {"scope": "ccm", "sort": [{"expression": "potential_daily_savings.amount", "order": "DESC"}]}, "id": "@resource_table:aws_ec2_instance", "type": "recommendations_filter"}}
And body with value {"data": {"attributes": {"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