From d1b97f4746d3e518897c7941ad18121801077521 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 19 Jan 2026 09:06:04 +0000 Subject: [PATCH] Regenerate client from commit cf2b609 of spec repo --- .generator/schemas/v2/openapi.yaml | 172 +++++++++++++++ .../service-level-objectives/GetSloStatus.rb | 8 + features/scenarios_model_mapping.rb | 6 + features/v2/service_level_objectives.feature | 30 +++ features/v2/undo.json | 6 + lib/datadog_api_client/configuration.rb | 1 + lib/datadog_api_client/inflector.rb | 5 + .../v2/api/service_level_objectives_api.rb | 87 ++++++++ .../v2/models/raw_error_budget_remaining.rb | 144 ++++++++++++ .../v2/models/slo_status_data.rb | 165 ++++++++++++++ .../v2/models/slo_status_data_attributes.rb | 207 ++++++++++++++++++ .../v2/models/slo_status_response.rb | 123 +++++++++++ .../v2/models/slo_status_type.rb | 26 +++ 13 files changed, 980 insertions(+) create mode 100644 examples/v2/service-level-objectives/GetSloStatus.rb create mode 100644 lib/datadog_api_client/v2/models/raw_error_budget_remaining.rb create mode 100644 lib/datadog_api_client/v2/models/slo_status_data.rb create mode 100644 lib/datadog_api_client/v2/models/slo_status_data_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/slo_status_response.rb create mode 100644 lib/datadog_api_client/v2/models/slo_status_type.rb diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index f11972d91d04..23ff00337aa4 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -338,6 +338,16 @@ components: required: true schema: type: string + DisableCorrections: + description: Whether to exclude correction windows from the SLO status calculation. + Defaults to false. + in: query + name: disable_corrections + required: false + schema: + default: false + example: false + type: boolean EntityID: description: UUID or Entity Ref. in: path @@ -449,6 +459,15 @@ components: required: false schema: $ref: '#/components/schemas/RelationType' + FromTimestamp: + description: The starting timestamp for the SLO status query in epoch seconds. + in: query + name: from_ts + required: true + schema: + example: 1690901870 + format: int64 + type: integer GCPSTSServiceAccountID: description: Your GCP STS enabled service account's unique ID. in: path @@ -1088,6 +1107,14 @@ components: required: false schema: type: boolean + SloID: + description: The ID of the SLO. + in: path + name: slo_id + required: true + schema: + example: 00000000-0000-0000-0000-000000000000 + type: string SpansMetricIDParameter: description: The name of the span-based metric. in: path @@ -1109,6 +1136,15 @@ components: required: true schema: type: string + ToTimestamp: + description: The ending timestamp for the SLO status query in epoch seconds. + in: query + name: to_ts + required: true + schema: + example: 1706803070 + format: int64 + type: integer UserID: description: The ID of the user. in: path @@ -43787,6 +43823,22 @@ components: from the other indexes type: string type: object + RawErrorBudgetRemaining: + description: The raw error budget remaining for the SLO. + properties: + unit: + description: The unit of the error budget (e.g., seconds, requests). + example: seconds + type: string + value: + description: The numeric value of the remaining error budget. + example: 86400.5 + format: double + type: number + required: + - value + - unit + type: object ReadinessGate: description: Used to merge multiple branches into a single branch. properties: @@ -53911,6 +53963,69 @@ components: required: - attributes type: object + SloStatusData: + description: The data portion of the SLO status response. + properties: + attributes: + $ref: '#/components/schemas/SloStatusDataAttributes' + id: + description: The ID of the SLO. + example: 00000000-0000-0000-0000-000000000000 + type: string + type: + $ref: '#/components/schemas/SloStatusType' + required: + - id + - type + - attributes + type: object + SloStatusDataAttributes: + description: The attributes of the SLO status. + properties: + error_budget_remaining: + description: The percentage of error budget remaining. + example: 99.5 + format: double + type: number + raw_error_budget_remaining: + $ref: '#/components/schemas/RawErrorBudgetRemaining' + sli: + description: The current Service Level Indicator (SLI) value as a percentage. + example: 99.95 + format: double + type: number + span_precision: + description: The precision of the time span in seconds. + example: 2 + format: int64 + type: integer + state: + description: The current state of the SLO (e.g., breached, warning, ok). + example: ok + type: string + required: + - sli + - error_budget_remaining + - raw_error_budget_remaining + - state + - span_precision + type: object + SloStatusResponse: + description: The SLO status response. + properties: + data: + $ref: '#/components/schemas/SloStatusData' + required: + - data + type: object + SloStatusType: + description: The type of the SLO status resource. + enum: + - slo_status + example: slo_status + type: string + x-enum-varnames: + - SLO_STATUS SoftwareCatalogTriggerWrapper: description: Schema for a Software Catalog-based trigger. properties: @@ -88060,6 +88175,63 @@ paths: x-unstable: '**Note**: This feature is in private beta. To request access, use the request access form in the [Service Level Objectives](https://docs.datadoghq.com/service_management/service_level_objectives/#slo-csv-export) docs.' + /api/v2/slo/{slo_id}/status: + get: + description: 'Get the status of a Service Level Objective (SLO) for a given + time period. + + + This endpoint returns the current SLI value, error budget remaining, and other + status information for the specified SLO.' + operationId: GetSloStatus + parameters: + - $ref: '#/components/parameters/SloID' + - $ref: '#/components/parameters/FromTimestamp' + - $ref: '#/components/parameters/ToTimestamp' + - $ref: '#/components/parameters/DisableCorrections' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SloStatusResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - slos_read + summary: Get SLO status + tags: + - Service Level Objectives + x-permission: + operator: OR + permissions: + - slos_read + x-unstable: '**Note**: This endpoint is in public beta and it''s subject to + change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/spa/recommendations/{service}: get: description: This endpoint is currently experimental and restricted to Datadog diff --git a/examples/v2/service-level-objectives/GetSloStatus.rb b/examples/v2/service-level-objectives/GetSloStatus.rb new file mode 100644 index 000000000000..8b0e7fbd32c5 --- /dev/null +++ b/examples/v2/service-level-objectives/GetSloStatus.rb @@ -0,0 +1,8 @@ +# Get SLO status returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_slo_status".to_sym] = true +end +api_instance = DatadogAPIClient::V2::ServiceLevelObjectivesAPI.new +p api_instance.get_slo_status("00000000-0000-0000-0000-000000000000", 1690901870, 1706803070) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 909e6202543f..a4ef6fb5f9ac 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3230,6 +3230,12 @@ "v2.GetSLOReportJobStatus" => { "report_id" => "String", }, + "v2.GetSloStatus" => { + "slo_id" => "String", + "from_ts" => "Integer", + "to_ts" => "Integer", + "disable_corrections" => "Boolean", + }, "v2.GetSPARecommendations" => { "bypass_cache" => "String", "service" => "String", diff --git a/features/v2/service_level_objectives.feature b/features/v2/service_level_objectives.feature index a415d16ccec9..4dc11df9e57d 100644 --- a/features/v2/service_level_objectives.feature +++ b/features/v2/service_level_objectives.feature @@ -79,3 +79,33 @@ Feature: Service Level Objectives When the request is sent Then the response status is 200 OK And the response "data.type" is equal to "report_id" + + @generated @skip @team:DataDog/slo-app + Scenario: Get SLO status returns "Bad Request" response + Given operation "GetSloStatus" enabled + And new "GetSloStatus" request + And request contains "slo_id" parameter from "REPLACE.ME" + And request contains "from_ts" parameter from "REPLACE.ME" + And request contains "to_ts" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/slo-app + Scenario: Get SLO status returns "Not Found" response + Given operation "GetSloStatus" enabled + And new "GetSloStatus" request + And request contains "slo_id" parameter from "REPLACE.ME" + And request contains "from_ts" parameter from "REPLACE.ME" + And request contains "to_ts" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/slo-app + Scenario: Get SLO status returns "OK" response + Given operation "GetSloStatus" enabled + And new "GetSloStatus" request + And request contains "slo_id" parameter from "REPLACE.ME" + And request contains "from_ts" parameter from "REPLACE.ME" + And request contains "to_ts" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK diff --git a/features/v2/undo.json b/features/v2/undo.json index 421fd8933730..f36e099fb10c 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -4521,6 +4521,12 @@ "type": "safe" } }, + "GetSloStatus": { + "tag": "Service Level Objectives", + "undo": { + "type": "safe" + } + }, "GetSPARecommendations": { "tag": "Spa", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index cdd2bdf2c018..0e3cfd8ec59a 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -333,6 +333,7 @@ def initialize "v2.create_slo_report_job": false, "v2.get_slo_report": false, "v2.get_slo_report_job_status": false, + "v2.get_slo_status": false, "v2.get_spa_recommendations": false, "v2.get_spa_recommendations_with_shard": false, "v2.create_sca_resolve_vulnerable_symbols": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 5cfdf83ee17c..a3c4be4b2cbb 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -3633,6 +3633,7 @@ def overrides "v2.query_users_request_data_attributes" => "QueryUsersRequestDataAttributes", "v2.query_users_request_data_attributes_sort" => "QueryUsersRequestDataAttributesSort", "v2.query_users_request_data_type" => "QueryUsersRequestDataType", + "v2.raw_error_budget_remaining" => "RawErrorBudgetRemaining", "v2.readiness_gate" => "ReadinessGate", "v2.readiness_gate_threshold_type" => "ReadinessGateThresholdType", "v2.recommendation_attributes" => "RecommendationAttributes", @@ -4331,6 +4332,10 @@ def overrides "v2.slo_report_status_get_response" => "SLOReportStatusGetResponse", "v2.slo_report_status_get_response_attributes" => "SLOReportStatusGetResponseAttributes", "v2.slo_report_status_get_response_data" => "SLOReportStatusGetResponseData", + "v2.slo_status_data" => "SloStatusData", + "v2.slo_status_data_attributes" => "SloStatusDataAttributes", + "v2.slo_status_response" => "SloStatusResponse", + "v2.slo_status_type" => "SloStatusType", "v2.software_catalog_trigger_wrapper" => "SoftwareCatalogTriggerWrapper", "v2.sort_direction" => "SortDirection", "v2.span" => "Span", diff --git a/lib/datadog_api_client/v2/api/service_level_objectives_api.rb b/lib/datadog_api_client/v2/api/service_level_objectives_api.rb index 9131dd3ccb73..8fd5b67ce46e 100644 --- a/lib/datadog_api_client/v2/api/service_level_objectives_api.rb +++ b/lib/datadog_api_client/v2/api/service_level_objectives_api.rb @@ -241,5 +241,92 @@ def get_slo_report_job_status_with_http_info(report_id, opts = {}) end return data, status_code, headers end + + # Get SLO status. + # + # @see #get_slo_status_with_http_info + def get_slo_status(slo_id, from_ts, to_ts, opts = {}) + data, _status_code, _headers = get_slo_status_with_http_info(slo_id, from_ts, to_ts, opts) + data + end + + # Get SLO status. + # + # Get the status of a Service Level Objective (SLO) for a given time period. + # + # This endpoint returns the current SLI value, error budget remaining, and other status information for the specified SLO. + # + # @param slo_id [String] The ID of the SLO. + # @param from_ts [Integer] The starting timestamp for the SLO status query in epoch seconds. + # @param to_ts [Integer] The ending timestamp for the SLO status query in epoch seconds. + # @param opts [Hash] the optional parameters + # @option opts [Boolean] :disable_corrections Whether to exclude correction windows from the SLO status calculation. Defaults to false. + # @return [Array<(SloStatusResponse, Integer, Hash)>] SloStatusResponse data, response status code and response headers + def get_slo_status_with_http_info(slo_id, from_ts, to_ts, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_slo_status".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_slo_status") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_slo_status")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ServiceLevelObjectivesAPI.get_slo_status ...' + end + # verify the required parameter 'slo_id' is set + if @api_client.config.client_side_validation && slo_id.nil? + fail ArgumentError, "Missing the required parameter 'slo_id' when calling ServiceLevelObjectivesAPI.get_slo_status" + end + # verify the required parameter 'from_ts' is set + if @api_client.config.client_side_validation && from_ts.nil? + fail ArgumentError, "Missing the required parameter 'from_ts' when calling ServiceLevelObjectivesAPI.get_slo_status" + end + # verify the required parameter 'to_ts' is set + if @api_client.config.client_side_validation && to_ts.nil? + fail ArgumentError, "Missing the required parameter 'to_ts' when calling ServiceLevelObjectivesAPI.get_slo_status" + end + # resource path + local_var_path = '/api/v2/slo/{slo_id}/status'.sub('{slo_id}', CGI.escape(slo_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'from_ts'] = from_ts + query_params[:'to_ts'] = to_ts + query_params[:'disable_corrections'] = opts[:'disable_corrections'] if !opts[:'disable_corrections'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'SloStatusResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_slo_status, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ServiceLevelObjectivesAPI#get_slo_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/datadog_api_client/v2/models/raw_error_budget_remaining.rb b/lib/datadog_api_client/v2/models/raw_error_budget_remaining.rb new file mode 100644 index 000000000000..a72e261752c6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/raw_error_budget_remaining.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 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::V2 + # The raw error budget remaining for the SLO. + class RawErrorBudgetRemaining + include BaseGenericModel + + # The unit of the error budget (e.g., seconds, requests). + attr_reader :unit + + # The numeric value of the remaining error budget. + attr_reader :value + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'unit' => :'unit', + :'value' => :'value' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'unit' => :'String', + :'value' => :'Float' + } + 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::V2::RawErrorBudgetRemaining` 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?(:'unit') + self.unit = attributes[:'unit'] + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + 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 @unit.nil? + return false if @value.nil? + true + end + + # Custom attribute writer method with validation + # @param unit [Object] Object to be assigned + # @!visibility private + def unit=(unit) + if unit.nil? + fail ArgumentError, 'invalid value for "unit", unit cannot be nil.' + end + @unit = unit + end + + # Custom attribute writer method with validation + # @param value [Object] Object to be assigned + # @!visibility private + def value=(value) + if value.nil? + fail ArgumentError, 'invalid value for "value", value cannot be nil.' + end + @value = value + 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 && + unit == o.unit && + value == o.value && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [unit, value, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/slo_status_data.rb b/lib/datadog_api_client/v2/models/slo_status_data.rb new file mode 100644 index 000000000000..518f4b70e72d --- /dev/null +++ b/lib/datadog_api_client/v2/models/slo_status_data.rb @@ -0,0 +1,165 @@ +=begin +#Datadog API V2 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::V2 + # The data portion of the SLO status response. + class SloStatusData + include BaseGenericModel + + # The attributes of the SLO status. + attr_reader :attributes + + # The ID of the SLO. + attr_reader :id + + # The type of the SLO status resource. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'SloStatusDataAttributes', + :'id' => :'String', + :'type' => :'SloStatusType' + } + 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::V2::SloStatusData` 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?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + 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 @attributes.nil? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + 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 && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/slo_status_data_attributes.rb b/lib/datadog_api_client/v2/models/slo_status_data_attributes.rb new file mode 100644 index 000000000000..fb5412dc8b12 --- /dev/null +++ b/lib/datadog_api_client/v2/models/slo_status_data_attributes.rb @@ -0,0 +1,207 @@ +=begin +#Datadog API V2 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::V2 + # The attributes of the SLO status. + class SloStatusDataAttributes + include BaseGenericModel + + # The percentage of error budget remaining. + attr_reader :error_budget_remaining + + # The raw error budget remaining for the SLO. + attr_reader :raw_error_budget_remaining + + # The current Service Level Indicator (SLI) value as a percentage. + attr_reader :sli + + # The precision of the time span in seconds. + attr_reader :span_precision + + # The current state of the SLO (e.g., breached, warning, ok). + attr_reader :state + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'error_budget_remaining' => :'error_budget_remaining', + :'raw_error_budget_remaining' => :'raw_error_budget_remaining', + :'sli' => :'sli', + :'span_precision' => :'span_precision', + :'state' => :'state' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'error_budget_remaining' => :'Float', + :'raw_error_budget_remaining' => :'RawErrorBudgetRemaining', + :'sli' => :'Float', + :'span_precision' => :'Integer', + :'state' => :'String' + } + 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::V2::SloStatusDataAttributes` 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?(:'error_budget_remaining') + self.error_budget_remaining = attributes[:'error_budget_remaining'] + end + + if attributes.key?(:'raw_error_budget_remaining') + self.raw_error_budget_remaining = attributes[:'raw_error_budget_remaining'] + end + + if attributes.key?(:'sli') + self.sli = attributes[:'sli'] + end + + if attributes.key?(:'span_precision') + self.span_precision = attributes[:'span_precision'] + end + + if attributes.key?(:'state') + self.state = attributes[:'state'] + 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 @error_budget_remaining.nil? + return false if @raw_error_budget_remaining.nil? + return false if @sli.nil? + return false if @span_precision.nil? + return false if @state.nil? + true + end + + # Custom attribute writer method with validation + # @param error_budget_remaining [Object] Object to be assigned + # @!visibility private + def error_budget_remaining=(error_budget_remaining) + if error_budget_remaining.nil? + fail ArgumentError, 'invalid value for "error_budget_remaining", error_budget_remaining cannot be nil.' + end + @error_budget_remaining = error_budget_remaining + end + + # Custom attribute writer method with validation + # @param raw_error_budget_remaining [Object] Object to be assigned + # @!visibility private + def raw_error_budget_remaining=(raw_error_budget_remaining) + if raw_error_budget_remaining.nil? + fail ArgumentError, 'invalid value for "raw_error_budget_remaining", raw_error_budget_remaining cannot be nil.' + end + @raw_error_budget_remaining = raw_error_budget_remaining + end + + # Custom attribute writer method with validation + # @param sli [Object] Object to be assigned + # @!visibility private + def sli=(sli) + if sli.nil? + fail ArgumentError, 'invalid value for "sli", sli cannot be nil.' + end + @sli = sli + end + + # Custom attribute writer method with validation + # @param span_precision [Object] Object to be assigned + # @!visibility private + def span_precision=(span_precision) + if span_precision.nil? + fail ArgumentError, 'invalid value for "span_precision", span_precision cannot be nil.' + end + @span_precision = span_precision + end + + # Custom attribute writer method with validation + # @param state [Object] Object to be assigned + # @!visibility private + def state=(state) + if state.nil? + fail ArgumentError, 'invalid value for "state", state cannot be nil.' + end + @state = state + 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 && + error_budget_remaining == o.error_budget_remaining && + raw_error_budget_remaining == o.raw_error_budget_remaining && + sli == o.sli && + span_precision == o.span_precision && + state == o.state && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [error_budget_remaining, raw_error_budget_remaining, sli, span_precision, state, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/slo_status_response.rb b/lib/datadog_api_client/v2/models/slo_status_response.rb new file mode 100644 index 000000000000..22fae4612d3c --- /dev/null +++ b/lib/datadog_api_client/v2/models/slo_status_response.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 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::V2 + # The SLO status response. + class SloStatusResponse + include BaseGenericModel + + # The data portion of the SLO status response. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'SloStatusData' + } + 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::V2::SloStatusResponse` 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?(:'data') + self.data = attributes[:'data'] + 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 @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + 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 && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/slo_status_type.rb b/lib/datadog_api_client/v2/models/slo_status_type.rb new file mode 100644 index 000000000000..7a23ab097e2a --- /dev/null +++ b/lib/datadog_api_client/v2/models/slo_status_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 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::V2 + # The type of the SLO status resource. + class SloStatusType + include BaseEnumModel + + SLO_STATUS = "slo_status".freeze + end +end