From b42979a27be4a3880bda7fbd165fa658ef9619dc Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 13 Mar 2026 03:51:49 +0000 Subject: [PATCH] Regenerate client from commit 53a6366 of spec repo --- .generator/schemas/v1/openapi.yaml | 64 ++++-- ...-events-formula-returns-OK-response.frozen | 1 + ...bad-events-formula-returns-OK-response.yml | 52 +++++ .../CreateSLO_512760759.rb | 2 +- .../CreateSLO_707861409.rb | 49 +++++ features/v1/service_level_objectives.feature | 15 +- lib/datadog_api_client/inflector.rb | 2 + .../v1/models/slo_count_definition.rb | 183 ++++-------------- ...ount_definition_with_bad_events_formula.rb | 146 ++++++++++++++ ...nt_definition_with_total_events_formula.rb | 146 ++++++++++++++ .../v1/models/slo_count_spec.rb | 5 +- 11 files changed, 504 insertions(+), 161 deletions(-) create mode 100644 cassettes/features/v1/service_level_objectives/Create-a-new-metric-SLO-object-using-bad-events-formula-returns-OK-response.frozen create mode 100644 cassettes/features/v1/service_level_objectives/Create-a-new-metric-SLO-object-using-bad-events-formula-returns-OK-response.yml create mode 100644 examples/v1/service-level-objectives/CreateSLO_707861409.rb create mode 100644 lib/datadog_api_client/v1/models/slo_count_definition_with_bad_events_formula.rb create mode 100644 lib/datadog_api_client/v1/models/slo_count_definition_with_total_events_formula.rb diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index daa9d89fc342..ea9665ada3d0 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -12338,33 +12338,73 @@ components: type: object SLOCountDefinition: description: 'A count-based (metric) SLI specification, composed of three parts: - the good events formula, the total events formula, + the good events formula, - and the underlying queries.' + the bad or total events formula, and the underlying queries. + + Exactly one of `total_events_formula` or `bad_events_formula` must be provided.' example: - good_events_formula: query1 - query2 + bad_events_formula: query2 + good_events_formula: query1 queries: - data_source: metrics name: query1 - query: sum:trace.servlet.request.hits{*} by {env}.as_count() + query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count() - data_source: metrics name: query2 - query: sum:trace.servlet.request.errors{*} by {env}.as_count() - total_events_formula: query1 + query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count() + oneOf: + - $ref: '#/components/schemas/SLOCountDefinitionWithTotalEventsFormula' + - $ref: '#/components/schemas/SLOCountDefinitionWithBadEventsFormula' + SLOCountDefinitionWithBadEventsFormula: + additionalProperties: false properties: + bad_events_formula: + $ref: '#/components/schemas/SLOFormula' + description: The bad events formula (recommended). Total events queries + can be defined using the `total_events_formula` field as an alternative. + Only one of `total_events_formula` or `bad_events_formula` must be provided. good_events_formula: $ref: '#/components/schemas/SLOFormula' queries: example: - data_source: metrics name: query1 - query: sum:trace.servlet.request.hits{*} by {env}.as_count() + query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count() + - data_source: metrics + name: query2 + query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count() + items: + $ref: '#/components/schemas/SLODataSourceQueryDefinition' + minItems: 1 + type: array + required: + - good_events_formula + - bad_events_formula + - queries + type: object + SLOCountDefinitionWithTotalEventsFormula: + additionalProperties: false + properties: + good_events_formula: + $ref: '#/components/schemas/SLOFormula' + queries: + example: + - data_source: metrics + name: query1 + query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count() + - data_source: metrics + name: query2 + query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count() items: $ref: '#/components/schemas/SLODataSourceQueryDefinition' minItems: 1 type: array total_events_formula: $ref: '#/components/schemas/SLOFormula' + description: The total events formula. Bad events queries can be defined + using the `bad_events_formula` field as an alternative. Only one of `total_events_formula` + or `bad_events_formula` must be provided. required: - good_events_formula - total_events_formula @@ -12375,15 +12415,15 @@ components: description: A metric SLI specification. example: count: - good_events_formula: query1 - query2 + bad_events_formula: query2 + good_events_formula: query1 queries: - data_source: metrics name: query1 - query: sum:trace.servlet.request.hits{*} by {env}.as_count() + query: sum:trace.servlet.request.hits{!http.status_code:500} by {env}.as_count() - data_source: metrics name: query2 - query: sum:trace.servlet.request.errors{*} by {env}.as_count() - total_events_formula: query1 + query: sum:trace.servlet.request.hits{http.status_code:500} by {env}.as_count() properties: count: $ref: '#/components/schemas/SLOCountDefinition' @@ -13519,7 +13559,7 @@ components: name: query1 query: sum:trace.servlet.request.hits{*} by {env}.as_count() - data_source: metrics - name: query1 + name: query2 query: sum:trace.servlet.request.errors{*} by {env}.as_count() threshold: 5 properties: diff --git a/cassettes/features/v1/service_level_objectives/Create-a-new-metric-SLO-object-using-bad-events-formula-returns-OK-response.frozen b/cassettes/features/v1/service_level_objectives/Create-a-new-metric-SLO-object-using-bad-events-formula-returns-OK-response.frozen new file mode 100644 index 000000000000..b1ab9b09452b --- /dev/null +++ b/cassettes/features/v1/service_level_objectives/Create-a-new-metric-SLO-object-using-bad-events-formula-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-02-25T17:45:38.518Z \ No newline at end of file diff --git a/cassettes/features/v1/service_level_objectives/Create-a-new-metric-SLO-object-using-bad-events-formula-returns-OK-response.yml b/cassettes/features/v1/service_level_objectives/Create-a-new-metric-SLO-object-using-bad-events-formula-returns-OK-response.yml new file mode 100644 index 000000000000..64627909ff97 --- /dev/null +++ b/cassettes/features/v1/service_level_objectives/Create-a-new-metric-SLO-object-using-bad-events-formula-returns-OK-response.yml @@ -0,0 +1,52 @@ +http_interactions: +- recorded_at: Wed, 25 Feb 2026 17:45:38 GMT + request: + body: + encoding: UTF-8 + string: '{"description":"Metric SLO using sli_specification","name":"Test-Create_a_new_metric_SLO_object_using_bad_events_formula_returns_OK_response-1772041538","sli_specification":{"count":{"bad_events_formula":{"formula":"query2"},"good_events_formula":{"formula":"query1 + - query2"},"queries":[{"data_source":"metrics","name":"query1","query":"sum:httpservice.hits{*}.as_count()"},{"data_source":"metrics","name":"query2","query":"sum:httpservice.errors{*}.as_count()"}]}},"tags":["env:prod","type:count"],"target_threshold":99,"thresholds":[{"target":99,"target_display":"99.0","timeframe":"7d","warning":99.5,"warning_display":"99.5"}],"timeframe":"7d","type":"metric","warning_threshold":99.5}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/slo + response: + body: + encoding: UTF-8 + string: '{"data":[{"id":"7309ff3752fd519f80f65a2ed3247dbb","name":"Test-Create_a_new_metric_SLO_object_using_bad_events_formula_returns_OK_response-1772041538","tags":["env:prod","type:count"],"monitor_tags":[],"thresholds":[{"timeframe":"7d","target":99.0,"target_display":"99.","warning":99.5,"warning_display":"99.5"}],"type":"metric","type_id":1,"description":"Metric + SLO using sli_specification","timeframe":"7d","warning_threshold":99.5,"target_threshold":99,"query":{"numerator":"sum:httpservice.hits{*}.as_count() + - sum:httpservice.errors{*}.as_count()","denominator":"(sum:httpservice.hits{*}.as_count() + - sum:httpservice.errors{*}.as_count()) + (sum:httpservice.errors{*}.as_count())"},"creator":{"name":"CI + Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","email":"team-intg-tools-libs-spam@datadoghq.com"},"created_at":1772041538,"modified_at":1772041538,"sli_specification":{"count":{"bad_events_formula":{"formula":"query2"},"good_events_formula":{"formula":"query1 + - query2"},"queries":[{"data_source":"metrics","name":"query1","query":"sum:httpservice.hits{*}.as_count()"},{"data_source":"metrics","name":"query2","query":"sum:httpservice.errors{*}.as_count()"}]}}}],"error":null} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Wed, 25 Feb 2026 17:45:38 GMT + request: + body: null + headers: + Accept: + - application/json + method: DELETE + uri: https://api.datadoghq.com/api/v1/slo/7309ff3752fd519f80f65a2ed3247dbb + response: + body: + encoding: UTF-8 + string: '{"data":["7309ff3752fd519f80f65a2ed3247dbb"],"error":null} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v1/service-level-objectives/CreateSLO_512760759.rb b/examples/v1/service-level-objectives/CreateSLO_512760759.rb index 7a441ecb5a1e..7482f95d30eb 100644 --- a/examples/v1/service-level-objectives/CreateSLO_512760759.rb +++ b/examples/v1/service-level-objectives/CreateSLO_512760759.rb @@ -8,7 +8,7 @@ description: "Metric SLO using sli_specification", name: "Example-Service-Level-Objective", sli_specification: DatadogAPIClient::V1::SLOCountSpec.new({ - count: DatadogAPIClient::V1::SLOCountDefinition.new({ + count: DatadogAPIClient::V1::SLOCountDefinitionWithTotalEventsFormula.new({ good_events_formula: DatadogAPIClient::V1::SLOFormula.new({ formula: "query1 - query2", }), diff --git a/examples/v1/service-level-objectives/CreateSLO_707861409.rb b/examples/v1/service-level-objectives/CreateSLO_707861409.rb new file mode 100644 index 000000000000..4e153268cab7 --- /dev/null +++ b/examples/v1/service-level-objectives/CreateSLO_707861409.rb @@ -0,0 +1,49 @@ +# Create a new metric SLO object using bad events formula returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::ServiceLevelObjectivesAPI.new + +body = DatadogAPIClient::V1::ServiceLevelObjectiveRequest.new({ + type: DatadogAPIClient::V1::SLOType::METRIC, + description: "Metric SLO using sli_specification", + name: "Example-Service-Level-Objective", + sli_specification: DatadogAPIClient::V1::SLOCountSpec.new({ + count: DatadogAPIClient::V1::SLOCountDefinitionWithBadEventsFormula.new({ + good_events_formula: DatadogAPIClient::V1::SLOFormula.new({ + formula: "query1 - query2", + }), + bad_events_formula: DatadogAPIClient::V1::SLOFormula.new({ + formula: "query2", + }), + queries: [ + DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({ + data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS, + name: "query1", + query: "sum:httpservice.hits{*}.as_count()", + }), + DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({ + data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS, + name: "query2", + query: "sum:httpservice.errors{*}.as_count()", + }), + ], + }), + }), + tags: [ + "env:prod", + "type:count", + ], + thresholds: [ + DatadogAPIClient::V1::SLOThreshold.new({ + target: 99.0, + target_display: "99.0", + timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS, + warning: 99.5, + warning_display: "99.5", + }), + ], + timeframe: DatadogAPIClient::V1::SLOTimeframe::SEVEN_DAYS, + target_threshold: 99.0, + warning_threshold: 99.5, +}) +p api_instance.create_slo(body) diff --git a/features/v1/service_level_objectives.feature b/features/v1/service_level_objectives.feature index 22c9d6cd3f91..6e756c5a54e3 100644 --- a/features/v1/service_level_objectives.feature +++ b/features/v1/service_level_objectives.feature @@ -48,6 +48,19 @@ Feature: Service Level Objectives When the request is sent Then the response status is 200 OK + @team:DataDog/slo-app + Scenario: Create a new metric SLO object using bad events formula returns "OK" response + Given new "CreateSLO" request + And body with value {"type":"metric","description":"Metric SLO using sli_specification","name":"{{ unique }}","sli_specification":{"count":{"good_events_formula":{"formula":"query1 - query2"},"bad_events_formula":{"formula":"query2"},"queries":[{"data_source":"metrics","name":"query1","query":"sum:httpservice.hits{*}.as_count()"},{"data_source":"metrics","name":"query2","query":"sum:httpservice.errors{*}.as_count()"}]}},"tags":["env:prod","type:count"],"thresholds":[{"target":99.0,"target_display":"99.0","timeframe":"7d","warning":99.5,"warning_display":"99.5"}],"timeframe":"7d","target_threshold":99.0,"warning_threshold":99.5} + When the request is sent + Then the response status is 200 OK + And the response "data[0]" has field "sli_specification" + And the response "data[0].sli_specification" has field "count" + And the response "data[0].sli_specification.count" has field "good_events_formula" + And the response "data[0].sli_specification.count" has field "bad_events_formula" + And the response "data[0].sli_specification.count" has field "queries" + And the response "data[0].sli_specification.count.queries" has length 2 + @team:DataDog/slo-app Scenario: Create a new metric SLO object using sli_specification returns "OK" response Given new "CreateSLO" request @@ -247,7 +260,7 @@ Feature: Service Level Objectives Scenario: Update an SLO returns "Not Found" response Given new "UpdateSLO" request And request contains "slo_id" parameter from "REPLACE.ME" - And body with value {"description": null, "groups": ["env:prod", "role:mysql"], "monitor_ids": [], "monitor_tags": [], "name": "Custom Metric SLO", "query": {"denominator": "sum:my.custom.metric{*}.as_count()", "numerator": "sum:my.custom.metric{type:good}.as_count()"}, "sli_specification": {"time_slice": {"comparator": "<", "query": {"formulas": [{"formula": "query2/query1"}], "queries": [{"data_source": "metrics", "name": "query1", "query": "sum:trace.servlet.request.hits{*} by {env}.as_count()"}, {"data_source": "metrics", "name": "query1", "query": "sum:trace.servlet.request.errors{*} by {env}.as_count()"}]}, "threshold": 5}}, "tags": ["env:prod", "app:core"], "target_threshold": 99.9, "thresholds": [{"target": 95, "timeframe": "7d"}, {"target": 95, "timeframe": "30d", "warning": 97}], "timeframe": "30d", "type": "metric", "warning_threshold": 99.95} + And body with value {"description": null, "groups": ["env:prod", "role:mysql"], "monitor_ids": [], "monitor_tags": [], "name": "Custom Metric SLO", "query": {"denominator": "sum:my.custom.metric{*}.as_count()", "numerator": "sum:my.custom.metric{type:good}.as_count()"}, "sli_specification": {"time_slice": {"comparator": "<", "query": {"formulas": [{"formula": "query2/query1"}], "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()"}]}, "threshold": 5}}, "tags": ["env:prod", "app:core"], "target_threshold": 99.9, "thresholds": [{"target": 95, "timeframe": "7d"}, {"target": 95, "timeframe": "30d", "warning": 97}], "timeframe": "30d", "type": "metric", "warning_threshold": 99.95} When the request is sent Then the response status is 404 Not Found diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index d50fa5f2e08f..c43d8f7768a8 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -557,6 +557,8 @@ def overrides "v1.slo_correction_update_request" => "SLOCorrectionUpdateRequest", "v1.slo_correction_update_request_attributes" => "SLOCorrectionUpdateRequestAttributes", "v1.slo_count_definition" => "SLOCountDefinition", + "v1.slo_count_definition_with_bad_events_formula" => "SLOCountDefinitionWithBadEventsFormula", + "v1.slo_count_definition_with_total_events_formula" => "SLOCountDefinitionWithTotalEventsFormula", "v1.slo_count_spec" => "SLOCountSpec", "v1.slo_creator" => "SLOCreator", "v1.slo_data_source_query_definition" => "SLODataSourceQueryDefinition", diff --git a/lib/datadog_api_client/v1/models/slo_count_definition.rb b/lib/datadog_api_client/v1/models/slo_count_definition.rb index ae35b276d728..16e00a06c8c2 100644 --- a/lib/datadog_api_client/v1/models/slo_count_definition.rb +++ b/lib/datadog_api_client/v1/models/slo_count_definition.rb @@ -17,156 +17,49 @@ require 'time' module DatadogAPIClient::V1 - # A count-based (metric) SLI specification, composed of three parts: the good events formula, the total events formula, - # and the underlying queries. - class SLOCountDefinition - 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::SLOCountDefinition` initialize method" + # A count-based (metric) SLI specification, composed of three parts: the good events formula, + # the bad or total events formula, and the underlying queries. + # Exactly one of `total_events_formula` or `bad_events_formula` must be provided. + module SLOCountDefinition + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'SLOCountDefinitionWithTotalEventsFormula', + :'SLOCountDefinitionWithBadEventsFormula' + ] 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 + # Builds the object + # @param data [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end 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}")) + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) 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_definition_with_bad_events_formula.rb b/lib/datadog_api_client/v1/models/slo_count_definition_with_bad_events_formula.rb new file mode 100644 index 000000000000..4edd168b210d --- /dev/null +++ b/lib/datadog_api_client/v1/models/slo_count_definition_with_bad_events_formula.rb @@ -0,0 +1,146 @@ +=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 + # + class SLOCountDefinitionWithBadEventsFormula + include BaseGenericModel + + # A formula that specifies how to combine the results of multiple queries. + attr_reader :bad_events_formula + + # A formula that specifies how to combine the results of multiple queries. + attr_reader :good_events_formula + + # + attr_reader :queries + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'bad_events_formula' => :'bad_events_formula', + :'good_events_formula' => :'good_events_formula', + :'queries' => :'queries' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'bad_events_formula' => :'SLOFormula', + :'good_events_formula' => :'SLOFormula', + :'queries' => :'Array' + } + 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::SLOCountDefinitionWithBadEventsFormula` 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::SLOCountDefinitionWithBadEventsFormula`. 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?(:'bad_events_formula') + self.bad_events_formula = attributes[:'bad_events_formula'] + 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 + 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 @bad_events_formula.nil? + return false if @good_events_formula.nil? + return false if @queries.nil? + return false if @queries.length < 1 + true + end + + # Custom attribute writer method with validation + # @param bad_events_formula [Object] Object to be assigned + # @!visibility private + def bad_events_formula=(bad_events_formula) + if bad_events_formula.nil? + fail ArgumentError, 'invalid value for "bad_events_formula", bad_events_formula cannot be nil.' + end + @bad_events_formula = bad_events_formula + 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 + + # 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 && + bad_events_formula == o.bad_events_formula && + good_events_formula == o.good_events_formula && + queries == o.queries + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [bad_events_formula, good_events_formula, queries].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/slo_count_definition_with_total_events_formula.rb b/lib/datadog_api_client/v1/models/slo_count_definition_with_total_events_formula.rb new file mode 100644 index 000000000000..25e3054dc1fb --- /dev/null +++ b/lib/datadog_api_client/v1/models/slo_count_definition_with_total_events_formula.rb @@ -0,0 +1,146 @@ +=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 + # + class SLOCountDefinitionWithTotalEventsFormula + 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 + + # 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::SLOCountDefinitionWithTotalEventsFormula` 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::SLOCountDefinitionWithTotalEventsFormula`. 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?(:'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 + + # 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 + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [good_events_formula, queries, total_events_formula].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 index 09986104d714..623ff622a4bf 100644 --- a/lib/datadog_api_client/v1/models/slo_count_spec.rb +++ b/lib/datadog_api_client/v1/models/slo_count_spec.rb @@ -21,8 +21,9 @@ module DatadogAPIClient::V1 class SLOCountSpec include BaseGenericModel - # A count-based (metric) SLI specification, composed of three parts: the good events formula, the total events formula, - # and the underlying queries. + # A count-based (metric) SLI specification, composed of three parts: the good events formula, + # the bad or total events formula, and the underlying queries. + # Exactly one of `total_events_formula` or `bad_events_formula` must be provided. attr_reader :count # Attribute mapping from ruby-style variable name to JSON key.