diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index afb32a4a89a..f640568bf28 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -11481,6 +11481,60 @@ components: example: UTC type: string type: object + SLOCountCondition: + description: 'A metric 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.hits{*} by {env}.as_count() + - data_source: metrics + name: query2 + query: sum:trace.servlet.request.errors{*} by {env}.as_count() + total_events_formula: query1 + 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 metric SLI specification. + example: + count: + good_events_formula: query1 - query2 + queries: + - data_source: metrics + name: query1 + query: sum:trace.servlet.request.hits{*} by {env}.as_count() + - data_source: metrics + name: query2 + query: sum:trace.servlet.request.errors{*} by {env}.as_count() + total_events_formula: query1 + properties: + count: + $ref: '#/components/schemas/SLOCountCondition' + required: + - count + type: object SLOCreator: description: The creator of the SLO nullable: true @@ -12328,8 +12382,16 @@ components: type: string query: $ref: '#/components/schemas/ServiceLevelObjectiveQuery' + description: 'The metric query of good / total events. This is not allowed + if the `sli_specification` field + + is used in the same request.' sli_specification: $ref: '#/components/schemas/SLOSliSpec' + description: 'A generic SLI specification. This is currently used for time-slice + and metric SLOs only. + + This is not allowed if the `query` field is used in the same request.' tags: description: 'A list of tags associated with this service level objective. @@ -12386,9 +12448,10 @@ components: type: object SLOSliSpec: description: A generic SLI specification. This is currently used for time-slice - SLOs only. + and metric SLOs only. oneOf: - $ref: '#/components/schemas/SLOTimeSliceSpec' + - $ref: '#/components/schemas/SLOCountSpec' SLOState: description: State of the SLO. enum: @@ -13479,8 +13542,16 @@ components: type: string query: $ref: '#/components/schemas/ServiceLevelObjectiveQuery' + description: 'The metric query of good / total events. This is not allowed + if the `sli_specification` field + + is used in the same request.' sli_specification: $ref: '#/components/schemas/SLOSliSpec' + description: 'A generic SLI specification. This is currently used for time-slice + and metric SLOs only. + + This is not allowed if the `query` field is used in the same request.' tags: description: 'A list of tags associated with this service level objective. @@ -13540,8 +13611,8 @@ 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 now deprecated metric 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 @@ -13610,8 +13681,16 @@ components: type: string query: $ref: '#/components/schemas/ServiceLevelObjectiveQuery' + description: 'The metric query of good / total events. This is not allowed + if the `sli_specification` field + + is used in the same request.' sli_specification: $ref: '#/components/schemas/SLOSliSpec' + description: 'A generic SLI specification. This is currently used for time-slice + and metric SLOs only. + + This is not allowed if the `query` field is used in the same request.' tags: description: 'A list of tags associated with this service level objective. diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 9a311d18bec..579b4c3d42c 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -522,6 +522,8 @@ def overrides "v1.slo_correction_update_data" => "SLOCorrectionUpdateData", "v1.slo_correction_update_request" => "SLOCorrectionUpdateRequest", "v1.slo_correction_update_request_attributes" => "SLOCorrectionUpdateRequestAttributes", + "v1.slo_count_condition" => "SLOCountCondition", + "v1.slo_count_spec" => "SLOCountSpec", "v1.slo_creator" => "SLOCreator", "v1.slo_data_source_query_definition" => "SLODataSourceQueryDefinition", "v1.slo_delete_response" => "SLODeleteResponse", diff --git a/lib/datadog_api_client/v1/models/service_level_objective.rb b/lib/datadog_api_client/v1/models/service_level_objective.rb index bf18b9ab7e4..46998f3d73f 100644 --- a/lib/datadog_api_client/v1/models/service_level_objective.rb +++ b/lib/datadog_api_client/v1/models/service_level_objective.rb @@ -68,12 +68,12 @@ class ServiceLevelObjective # The name of the service level objective object. attr_reader :name - # A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator + # A now deprecated metric 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. attr_accessor :query - # 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 metric SLOs only. attr_accessor :sli_specification # A list of tags associated with this service level objective. diff --git a/lib/datadog_api_client/v1/models/service_level_objective_query.rb b/lib/datadog_api_client/v1/models/service_level_objective_query.rb index 354cf44c603..f88ec63ad79 100644 --- a/lib/datadog_api_client/v1/models/service_level_objective_query.rb +++ b/lib/datadog_api_client/v1/models/service_level_objective_query.rb @@ -17,7 +17,7 @@ require 'time' module DatadogAPIClient::V1 - # A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator + # A now deprecated metric 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. class ServiceLevelObjectiveQuery diff --git a/lib/datadog_api_client/v1/models/service_level_objective_request.rb b/lib/datadog_api_client/v1/models/service_level_objective_request.rb index c2415da8bd3..d37c67497de 100644 --- a/lib/datadog_api_client/v1/models/service_level_objective_request.rb +++ b/lib/datadog_api_client/v1/models/service_level_objective_request.rb @@ -42,12 +42,12 @@ class ServiceLevelObjectiveRequest # The name of the service level objective object. attr_reader :name - # A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator + # A now deprecated metric 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. attr_accessor :query - # 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 metric SLOs only. attr_accessor :sli_specification # A list of tags associated with this service level objective. diff --git a/lib/datadog_api_client/v1/models/slo_count_condition.rb b/lib/datadog_api_client/v1/models/slo_count_condition.rb new file mode 100644 index 00000000000..25597b492e0 --- /dev/null +++ b/lib/datadog_api_client/v1/models/slo_count_condition.rb @@ -0,0 +1,172 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # A metric SLI specification, composed of three parts: the good events formula, the total events formula, + # and the involved queries. + class SLOCountCondition + include BaseGenericModel + + # A formula that specifies how to combine the results of multiple queries. + attr_reader :good_events_formula + + # + attr_reader :queries + + # A formula that specifies how to combine the results of multiple queries. + attr_reader :total_events_formula + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'good_events_formula' => :'good_events_formula', + :'queries' => :'queries', + :'total_events_formula' => :'total_events_formula' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'good_events_formula' => :'SLOFormula', + :'queries' => :'Array', + :'total_events_formula' => :'SLOFormula' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::SLOCountCondition` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'good_events_formula') + self.good_events_formula = attributes[:'good_events_formula'] + end + + if attributes.key?(:'queries') + if (value = attributes[:'queries']).is_a?(Array) + self.queries = value + end + end + + if attributes.key?(:'total_events_formula') + self.total_events_formula = attributes[:'total_events_formula'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @good_events_formula.nil? + return false if @queries.nil? + return false if @queries.length < 1 + return false if @total_events_formula.nil? + true + end + + # Custom attribute writer method with validation + # @param good_events_formula [Object] Object to be assigned + # @!visibility private + def good_events_formula=(good_events_formula) + if good_events_formula.nil? + fail ArgumentError, 'invalid value for "good_events_formula", good_events_formula cannot be nil.' + end + @good_events_formula = good_events_formula + end + + # Custom attribute writer method with validation + # @param queries [Object] Object to be assigned + # @!visibility private + def queries=(queries) + if queries.nil? + fail ArgumentError, 'invalid value for "queries", queries cannot be nil.' + end + if queries.length < 1 + fail ArgumentError, 'invalid value for "queries", number of items must be greater than or equal to 1.' + end + @queries = queries + end + + # Custom attribute writer method with validation + # @param total_events_formula [Object] Object to be assigned + # @!visibility private + def total_events_formula=(total_events_formula) + if total_events_formula.nil? + fail ArgumentError, 'invalid value for "total_events_formula", total_events_formula cannot be nil.' + end + @total_events_formula = total_events_formula + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + good_events_formula == o.good_events_formula && + queries == o.queries && + total_events_formula == o.total_events_formula && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [good_events_formula, queries, total_events_formula, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/slo_count_spec.rb b/lib/datadog_api_client/v1/models/slo_count_spec.rb new file mode 100644 index 00000000000..1d60eaca12d --- /dev/null +++ b/lib/datadog_api_client/v1/models/slo_count_spec.rb @@ -0,0 +1,99 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # A metric SLI specification. + class SLOCountSpec + include BaseGenericModel + + # A metric SLI specification, composed of three parts: the good events formula, the total events formula, + # and the involved queries. + attr_reader :count + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'count' => :'count' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'count' => :'SLOCountCondition' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::SLOCountSpec` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::SLOCountSpec`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'count') + self.count = attributes[:'count'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @count.nil? + true + end + + # Custom attribute writer method with validation + # @param count [Object] Object to be assigned + # @!visibility private + def count=(count) + if count.nil? + fail ArgumentError, 'invalid value for "count", count cannot be nil.' + end + @count = count + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + count == o.count + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [count].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/slo_response_data.rb b/lib/datadog_api_client/v1/models/slo_response_data.rb index 5b010d33bbe..32366fa00a8 100644 --- a/lib/datadog_api_client/v1/models/slo_response_data.rb +++ b/lib/datadog_api_client/v1/models/slo_response_data.rb @@ -71,12 +71,12 @@ class SLOResponseData # The name of the service level objective object. attr_accessor :name - # A metric-based SLO. **Required if type is `metric`**. Note that Datadog only allows the sum by aggregator + # A now deprecated metric 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. attr_accessor :query - # 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 metric SLOs only. attr_accessor :sli_specification # A list of tags associated with this service level objective. diff --git a/lib/datadog_api_client/v1/models/slo_sli_spec.rb b/lib/datadog_api_client/v1/models/slo_sli_spec.rb index 4c15c69a6de..4b161d1bb06 100644 --- a/lib/datadog_api_client/v1/models/slo_sli_spec.rb +++ b/lib/datadog_api_client/v1/models/slo_sli_spec.rb @@ -17,7 +17,7 @@ require 'time' module DatadogAPIClient::V1 - # 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 metric SLOs only. module SLOSliSpec class << self include BaseOneOfModel @@ -26,7 +26,8 @@ class << self # List of class defined in oneOf (OpenAPI v3) def openapi_one_of [ - :'SLOTimeSliceSpec' + :'SLOTimeSliceSpec', + :'SLOCountSpec' ] end # Builds the object