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
62 changes: 57 additions & 5 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11409,6 +11409,60 @@ components:
example: UTC
type: string
type: object
SLOCountCondition:
description: 'A count-based SLI specification, composed of three parts: the
good events formula, the total events formula,

and the involved queries.'
example:
good_events_formula: query1 - query2
queries:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.success{*} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
total_events_formula: query2
properties:
good_events_formula:
$ref: '#/components/schemas/SLOFormula'
queries:
example:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
items:
$ref: '#/components/schemas/SLODataSourceQueryDefinition'
minItems: 1
type: array
total_events_formula:
$ref: '#/components/schemas/SLOFormula'
required:
- good_events_formula
- total_events_formula
- queries
type: object
SLOCountSpec:
additionalProperties: false
description: A count-based SLI specification.
example:
count:
good_events_formula: query1 - query2
queries:
- data_source: metrics
name: query1
query: sum:trace.servlet.request.success{*} by {env}.as_count()
- data_source: metrics
name: query2
query: sum:trace.servlet.request.hits{*} by {env}.as_count()
total_events_formula: query2
properties:
count:
$ref: '#/components/schemas/SLOCountCondition'
required:
- count
type: object
SLOCreator:
description: The creator of the SLO
nullable: true
Expand Down Expand Up @@ -12295,8 +12349,6 @@ components:
type: array
timeframe:
$ref: '#/components/schemas/SLOTimeframe'
type:
$ref: '#/components/schemas/SLOType'
warning_threshold:
description: 'The optional warning threshold such that when the service
level indicator is
Expand All @@ -12314,9 +12366,10 @@ components:
type: object
SLOSliSpec:
description: A generic SLI specification. This is currently used for time-slice
SLOs only.
and count-based SLOs only.
oneOf:
- $ref: '#/components/schemas/SLOTimeSliceSpec'
- $ref: '#/components/schemas/SLOCountSpec'
SLOState:
description: State of the SLO.
enum:
Expand Down Expand Up @@ -13468,8 +13521,7 @@ components:
- type
type: object
ServiceLevelObjectiveQuery:
description: 'A metric-based SLO. **Required if type is `metric`**. Note that
Datadog only allows the sum by aggregator
description: 'A metric-based SLO. Note that Datadog only allows the sum by aggregator

to be used because this will sum up all request counts instead of averaging
them, or taking the max or
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV1/model_service_level_objective.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ type ServiceLevelObjective struct {
MonitorTags []string `json:"monitor_tags,omitempty"`
// The name of the service level objective object.
Name string `json:"name"`
// A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator
// A metric-based SLO. Note that Datadog only allows the sum by aggregator
// to be used because this will sum up all request counts instead of averaging them, or taking the max or
// min of all of those requests.
Query *ServiceLevelObjectiveQuery `json:"query,omitempty"`
// A generic SLI specification. This is currently used for time-slice SLOs only.
// A generic SLI specification. This is currently used for time-slice and count-based SLOs only.
SliSpecification *SLOSliSpec `json:"sli_specification,omitempty"`
// A list of tags associated with this service level objective.
// Always included in service level objective responses (but may be empty).
Expand Down
2 changes: 1 addition & 1 deletion api/datadogV1/model_service_level_objective_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// ServiceLevelObjectiveQuery A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator
// ServiceLevelObjectiveQuery A metric-based SLO. Note that Datadog only allows the sum by aggregator
// to be used because this will sum up all request counts instead of averaging them, or taking the max or
// min of all of those requests.
type ServiceLevelObjectiveQuery struct {
Expand Down
4 changes: 2 additions & 2 deletions api/datadogV1/model_service_level_objective_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ type ServiceLevelObjectiveRequest struct {
MonitorIds []int64 `json:"monitor_ids,omitempty"`
// The name of the service level objective object.
Name string `json:"name"`
// A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator
// A metric-based SLO. Note that Datadog only allows the sum by aggregator
// to be used because this will sum up all request counts instead of averaging them, or taking the max or
// min of all of those requests.
Query *ServiceLevelObjectiveQuery `json:"query,omitempty"`
// A generic SLI specification. This is currently used for time-slice SLOs only.
// A generic SLI specification. This is currently used for time-slice and count-based SLOs only.
SliSpecification *SLOSliSpec `json:"sli_specification,omitempty"`
// A list of tags associated with this service level objective.
// Always included in service level objective responses (but may be empty).
Expand Down
178 changes: 178 additions & 0 deletions api/datadogV1/model_slo_count_condition.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// 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.

package datadogV1

import (
"fmt"

"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// SLOCountCondition A count-based SLI specification, composed of three parts: the good events formula, the total events formula,
// and the involved queries.
type SLOCountCondition struct {
// A formula that specifies how to combine the results of multiple queries.
GoodEventsFormula SLOFormula `json:"good_events_formula"`
//
Queries []SLODataSourceQueryDefinition `json:"queries"`
// A formula that specifies how to combine the results of multiple queries.
TotalEventsFormula SLOFormula `json:"total_events_formula"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:"-"`
AdditionalProperties map[string]interface{} `json:"-"`
}

// NewSLOCountCondition instantiates a new SLOCountCondition object.
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed.
func NewSLOCountCondition(goodEventsFormula SLOFormula, queries []SLODataSourceQueryDefinition, totalEventsFormula SLOFormula) *SLOCountCondition {
this := SLOCountCondition{}
this.GoodEventsFormula = goodEventsFormula
this.Queries = queries
this.TotalEventsFormula = totalEventsFormula
return &this
}

// NewSLOCountConditionWithDefaults instantiates a new SLOCountCondition object.
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set.
func NewSLOCountConditionWithDefaults() *SLOCountCondition {
this := SLOCountCondition{}
return &this
}

// GetGoodEventsFormula returns the GoodEventsFormula field value.
func (o *SLOCountCondition) GetGoodEventsFormula() SLOFormula {
if o == nil {
var ret SLOFormula
return ret
}
return o.GoodEventsFormula
}

// GetGoodEventsFormulaOk returns a tuple with the GoodEventsFormula field value
// and a boolean to check if the value has been set.
func (o *SLOCountCondition) GetGoodEventsFormulaOk() (*SLOFormula, bool) {
if o == nil {
return nil, false
}
return &o.GoodEventsFormula, true
}

// SetGoodEventsFormula sets field value.
func (o *SLOCountCondition) SetGoodEventsFormula(v SLOFormula) {
o.GoodEventsFormula = v
}

// GetQueries returns the Queries field value.
func (o *SLOCountCondition) GetQueries() []SLODataSourceQueryDefinition {
if o == nil {
var ret []SLODataSourceQueryDefinition
return ret
}
return o.Queries
}

// GetQueriesOk returns a tuple with the Queries field value
// and a boolean to check if the value has been set.
func (o *SLOCountCondition) GetQueriesOk() (*[]SLODataSourceQueryDefinition, bool) {
if o == nil {
return nil, false
}
return &o.Queries, true
}

// SetQueries sets field value.
func (o *SLOCountCondition) SetQueries(v []SLODataSourceQueryDefinition) {
o.Queries = v
}

// GetTotalEventsFormula returns the TotalEventsFormula field value.
func (o *SLOCountCondition) GetTotalEventsFormula() SLOFormula {
if o == nil {
var ret SLOFormula
return ret
}
return o.TotalEventsFormula
}

// GetTotalEventsFormulaOk returns a tuple with the TotalEventsFormula field value
// and a boolean to check if the value has been set.
func (o *SLOCountCondition) GetTotalEventsFormulaOk() (*SLOFormula, bool) {
if o == nil {
return nil, false
}
return &o.TotalEventsFormula, true
}

// SetTotalEventsFormula sets field value.
func (o *SLOCountCondition) SetTotalEventsFormula(v SLOFormula) {
o.TotalEventsFormula = v
}

// MarshalJSON serializes the struct using spec logic.
func (o SLOCountCondition) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
toSerialize["good_events_formula"] = o.GoodEventsFormula
toSerialize["queries"] = o.Queries
toSerialize["total_events_formula"] = o.TotalEventsFormula

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return datadog.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *SLOCountCondition) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
GoodEventsFormula *SLOFormula `json:"good_events_formula"`
Queries *[]SLODataSourceQueryDefinition `json:"queries"`
TotalEventsFormula *SLOFormula `json:"total_events_formula"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
if all.GoodEventsFormula == nil {
return fmt.Errorf("required field good_events_formula missing")
}
if all.Queries == nil {
return fmt.Errorf("required field queries missing")
}
if all.TotalEventsFormula == nil {
return fmt.Errorf("required field total_events_formula missing")
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"good_events_formula", "queries", "total_events_formula"})
} else {
return err
}

hasInvalidField := false
if all.GoodEventsFormula.UnparsedObject != nil && o.UnparsedObject == nil {
hasInvalidField = true
}
o.GoodEventsFormula = *all.GoodEventsFormula
o.Queries = *all.Queries
if all.TotalEventsFormula.UnparsedObject != nil && o.UnparsedObject == nil {
hasInvalidField = true
}
o.TotalEventsFormula = *all.TotalEventsFormula

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
}

if hasInvalidField {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}

return nil
}
Loading
Loading