Skip to content

Commit 6addcfc

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Revert "Remove duplicate MonitorFormulaAndFunctionCostDataSource schema" (#3859)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent c166546 commit 6addcfc

4 files changed

Lines changed: 93 additions & 13 deletions

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7524,13 +7524,25 @@ components:
75247524
- L2NORM
75257525
- PERCENTILE
75267526
- STDDEV
7527+
MonitorFormulaAndFunctionCostDataSource:
7528+
description: Data source for cost queries.
7529+
enum:
7530+
- metrics
7531+
- cloud_cost
7532+
- datadog_usage
7533+
example: "cloud_cost"
7534+
type: string
7535+
x-enum-varnames:
7536+
- METRICS
7537+
- CLOUD_COST
7538+
- DATADOG_USAGE
75277539
MonitorFormulaAndFunctionCostQueryDefinition:
75287540
description: A formula and functions cost query.
75297541
properties:
75307542
aggregator:
75317543
$ref: "#/components/schemas/MonitorFormulaAndFunctionCostAggregator"
75327544
data_source:
7533-
$ref: "#/components/schemas/MonitorFormulaAndFunctionMetricsDataSource"
7545+
$ref: "#/components/schemas/MonitorFormulaAndFunctionCostDataSource"
75347546
name:
75357547
description: Name of the query for use in formulas.
75367548
example: "query1"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV1
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// MonitorFormulaAndFunctionCostDataSource Data source for cost queries.
14+
type MonitorFormulaAndFunctionCostDataSource string
15+
16+
// List of MonitorFormulaAndFunctionCostDataSource.
17+
const (
18+
MONITORFORMULAANDFUNCTIONCOSTDATASOURCE_METRICS MonitorFormulaAndFunctionCostDataSource = "metrics"
19+
MONITORFORMULAANDFUNCTIONCOSTDATASOURCE_CLOUD_COST MonitorFormulaAndFunctionCostDataSource = "cloud_cost"
20+
MONITORFORMULAANDFUNCTIONCOSTDATASOURCE_DATADOG_USAGE MonitorFormulaAndFunctionCostDataSource = "datadog_usage"
21+
)
22+
23+
var allowedMonitorFormulaAndFunctionCostDataSourceEnumValues = []MonitorFormulaAndFunctionCostDataSource{
24+
MONITORFORMULAANDFUNCTIONCOSTDATASOURCE_METRICS,
25+
MONITORFORMULAANDFUNCTIONCOSTDATASOURCE_CLOUD_COST,
26+
MONITORFORMULAANDFUNCTIONCOSTDATASOURCE_DATADOG_USAGE,
27+
}
28+
29+
// GetAllowedValues reeturns the list of possible values.
30+
func (v *MonitorFormulaAndFunctionCostDataSource) GetAllowedValues() []MonitorFormulaAndFunctionCostDataSource {
31+
return allowedMonitorFormulaAndFunctionCostDataSourceEnumValues
32+
}
33+
34+
// UnmarshalJSON deserializes the given payload.
35+
func (v *MonitorFormulaAndFunctionCostDataSource) UnmarshalJSON(src []byte) error {
36+
var value string
37+
err := datadog.Unmarshal(src, &value)
38+
if err != nil {
39+
return err
40+
}
41+
*v = MonitorFormulaAndFunctionCostDataSource(value)
42+
return nil
43+
}
44+
45+
// NewMonitorFormulaAndFunctionCostDataSourceFromValue returns a pointer to a valid MonitorFormulaAndFunctionCostDataSource
46+
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
47+
func NewMonitorFormulaAndFunctionCostDataSourceFromValue(v string) (*MonitorFormulaAndFunctionCostDataSource, error) {
48+
ev := MonitorFormulaAndFunctionCostDataSource(v)
49+
if ev.IsValid() {
50+
return &ev, nil
51+
}
52+
return nil, fmt.Errorf("invalid value '%v' for MonitorFormulaAndFunctionCostDataSource: valid values are %v", v, allowedMonitorFormulaAndFunctionCostDataSourceEnumValues)
53+
}
54+
55+
// IsValid return true if the value is valid for the enum, false otherwise.
56+
func (v MonitorFormulaAndFunctionCostDataSource) IsValid() bool {
57+
for _, existing := range allowedMonitorFormulaAndFunctionCostDataSourceEnumValues {
58+
if existing == v {
59+
return true
60+
}
61+
}
62+
return false
63+
}
64+
65+
// Ptr returns reference to MonitorFormulaAndFunctionCostDataSource value.
66+
func (v MonitorFormulaAndFunctionCostDataSource) Ptr() *MonitorFormulaAndFunctionCostDataSource {
67+
return &v
68+
}

api/datadogV1/model_monitor_formula_and_function_cost_query_definition.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
type MonitorFormulaAndFunctionCostQueryDefinition struct {
1515
// Aggregation methods for metric queries.
1616
Aggregator *MonitorFormulaAndFunctionCostAggregator `json:"aggregator,omitempty"`
17-
// Data source for metrics queries.
18-
DataSource MonitorFormulaAndFunctionMetricsDataSource `json:"data_source"`
17+
// Data source for cost queries.
18+
DataSource MonitorFormulaAndFunctionCostDataSource `json:"data_source"`
1919
// Name of the query for use in formulas.
2020
Name string `json:"name"`
2121
// The monitor query.
@@ -29,7 +29,7 @@ type MonitorFormulaAndFunctionCostQueryDefinition struct {
2929
// This constructor will assign default values to properties that have it defined,
3030
// and makes sure properties required by API are set, but the set of arguments
3131
// will change when the set of required properties is changed.
32-
func NewMonitorFormulaAndFunctionCostQueryDefinition(dataSource MonitorFormulaAndFunctionMetricsDataSource, name string, query string) *MonitorFormulaAndFunctionCostQueryDefinition {
32+
func NewMonitorFormulaAndFunctionCostQueryDefinition(dataSource MonitorFormulaAndFunctionCostDataSource, name string, query string) *MonitorFormulaAndFunctionCostQueryDefinition {
3333
this := MonitorFormulaAndFunctionCostQueryDefinition{}
3434
this.DataSource = dataSource
3535
this.Name = name
@@ -74,25 +74,25 @@ func (o *MonitorFormulaAndFunctionCostQueryDefinition) SetAggregator(v MonitorFo
7474
}
7575

7676
// GetDataSource returns the DataSource field value.
77-
func (o *MonitorFormulaAndFunctionCostQueryDefinition) GetDataSource() MonitorFormulaAndFunctionMetricsDataSource {
77+
func (o *MonitorFormulaAndFunctionCostQueryDefinition) GetDataSource() MonitorFormulaAndFunctionCostDataSource {
7878
if o == nil {
79-
var ret MonitorFormulaAndFunctionMetricsDataSource
79+
var ret MonitorFormulaAndFunctionCostDataSource
8080
return ret
8181
}
8282
return o.DataSource
8383
}
8484

8585
// GetDataSourceOk returns a tuple with the DataSource field value
8686
// and a boolean to check if the value has been set.
87-
func (o *MonitorFormulaAndFunctionCostQueryDefinition) GetDataSourceOk() (*MonitorFormulaAndFunctionMetricsDataSource, bool) {
87+
func (o *MonitorFormulaAndFunctionCostQueryDefinition) GetDataSourceOk() (*MonitorFormulaAndFunctionCostDataSource, bool) {
8888
if o == nil {
8989
return nil, false
9090
}
9191
return &o.DataSource, true
9292
}
9393

9494
// SetDataSource sets field value.
95-
func (o *MonitorFormulaAndFunctionCostQueryDefinition) SetDataSource(v MonitorFormulaAndFunctionMetricsDataSource) {
95+
func (o *MonitorFormulaAndFunctionCostQueryDefinition) SetDataSource(v MonitorFormulaAndFunctionCostDataSource) {
9696
o.DataSource = v
9797
}
9898

@@ -164,10 +164,10 @@ func (o MonitorFormulaAndFunctionCostQueryDefinition) MarshalJSON() ([]byte, err
164164
// UnmarshalJSON deserializes the given payload.
165165
func (o *MonitorFormulaAndFunctionCostQueryDefinition) UnmarshalJSON(bytes []byte) (err error) {
166166
all := struct {
167-
Aggregator *MonitorFormulaAndFunctionCostAggregator `json:"aggregator,omitempty"`
168-
DataSource *MonitorFormulaAndFunctionMetricsDataSource `json:"data_source"`
169-
Name *string `json:"name"`
170-
Query *string `json:"query"`
167+
Aggregator *MonitorFormulaAndFunctionCostAggregator `json:"aggregator,omitempty"`
168+
DataSource *MonitorFormulaAndFunctionCostDataSource `json:"data_source"`
169+
Name *string `json:"name"`
170+
Query *string `json:"query"`
171171
}{}
172172
if err = datadog.Unmarshal(bytes, &all); err != nil {
173173
return datadog.Unmarshal(bytes, &o.UnparsedObject)

examples/v1/monitors/CreateMonitor_1303514967.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func main() {
3131
Variables: []datadogV1.MonitorFormulaAndFunctionQueryDefinition{
3232
datadogV1.MonitorFormulaAndFunctionQueryDefinition{
3333
MonitorFormulaAndFunctionCostQueryDefinition: &datadogV1.MonitorFormulaAndFunctionCostQueryDefinition{
34-
DataSource: datadogV1.MONITORFORMULAANDFUNCTIONMETRICSDATASOURCE_CLOUD_COST,
34+
DataSource: datadogV1.MONITORFORMULAANDFUNCTIONCOSTDATASOURCE_CLOUD_COST,
3535
Query: "sum:aws.cost.net.amortized.shared.resources.allocated{aws_product IN (amplify ,athena, backup, bedrock ) } by {aws_product}.rollup(sum, 86400)",
3636
Name: "query1",
3737
Aggregator: datadogV1.MONITORFORMULAANDFUNCTIONCOSTAGGREGATOR_SUM.Ptr(),

0 commit comments

Comments
 (0)