diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 809d974e933b..18e45727600d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -76024,6 +76024,45 @@ components: required: - data type: object + IssueSnoozeRequest: + description: Snooze issue request payload. + properties: + data: + $ref: "#/components/schemas/IssueSnoozeRequestData" + required: + - data + type: object + IssueSnoozeRequestData: + description: Snooze issue request. + properties: + attributes: + $ref: "#/components/schemas/IssueSnoozeRequestDataAttributes" + id: + description: Issue identifier. + example: "c1726a66-1f64-11ee-b338-da7ad0900002" + type: string + type: + $ref: "#/components/schemas/IssueSnoozeRequestDataType" + required: + - id + - type + - attributes + type: object + IssueSnoozeRequestDataAttributes: + description: Object describing an issue snooze request. + properties: + condition: + $ref: "#/components/schemas/IssueWatchCondition" + required: + - condition + type: object + IssueSnoozeRequestDataType: + description: Type of the object. + enum: ["error_tracking_issue"] + example: "error_tracking_issue" + type: string + x-enum-varnames: + - ERROR_TRACKING_ISSUE IssueState: description: State of the issue enum: @@ -76288,18 +76327,29 @@ components: `ELAPSED_TIME` uses `duration`, and `ANY` and `ALL` use `operands`. properties: duration: - description: Time that must elapse before the condition is met, as a Go duration string. + description: |- + Time that must elapse from when the watch started, as a Go duration string, such as `24h`, or `168h` for a + week. example: "168h0m0s" type: string kind: $ref: "#/components/schemas/IssueWatchConditionKind" operands: description: Nested conditions combined by `ANY` or `ALL`. + example: + - duration: 168h + kind: ELAPSED_TIME + - kind: OCCURRENCES + threshold: 100 items: $ref: "#/components/schemas/IssueWatchCondition" type: array projection: - description: Attributes whose distinct values are counted for `CARDINALITY`. + description: |- + Attributes whose distinct values `CARDINALITY` counts, in search syntax: `@` for attributes, such as + `@usr.id` or `@account.id`, and no prefix for tags and reserved fields, such as `org_id` or `service`. + Only use attributes that the issue's errors carry: a condition on an attribute they don't carry is never + met. example: ["@usr.id"] items: description: Attribute path. @@ -76307,7 +76357,9 @@ components: type: string type: array threshold: - description: Number of occurrences, or of distinct values for `CARDINALITY`, that triggers the condition. + description: |- + Number of new occurrences, or of distinct values for `CARDINALITY`, that meets the condition, counted from + when the watch started. example: 100 format: int64 type: integer @@ -182656,6 +182708,112 @@ paths: - Error Tracking x-unstable: |- **Note**: This endpoint is in preview and is subject to change. + /api/v2/error-tracking/issues/{issue_id}/snooze: + post: + description: |- + Snooze an issue by `issue_id`: move it to `IGNORED` until a condition is met, then back to `OPEN`. + The condition can be a number of occurrences, a number of distinct values of an attribute such as `@usr.id`, + an elapsed time, or any or all of several conditions. + Snoozing an issue that is already snoozed replaces its snooze. Updating the state of the issue with + `UpdateIssueState` cancels the snooze. + The response includes the watch that reopens the issue. + operationId: SnoozeIssue + parameters: + - $ref: "#/components/parameters/IssueIDPathParameter" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + condition: + kind: ANY + operands: + - duration: 168h + kind: ELAPSED_TIME + - kind: OCCURRENCES + threshold: 100 + id: c1726a66-1f64-11ee-b338-da7ad0900002 + type: error_tracking_issue + schema: + $ref: "#/components/schemas/IssueSnoozeRequest" + description: Snooze issue request payload. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + error_message: "object of type 'NoneType' has no len()" + error_type: builtins.TypeError + service: test-service + state: IGNORED + id: c1726a66-1f64-11ee-b338-da7ad0900002 + relationships: + watches: + data: + - id: e7a1c3b5-2d4f-4a6b-8c9d-0e1f2a3b4c5d + type: error_tracking_issue_watch + type: issue + included: + - attributes: + action: + from: IGNORED + kind: CHANGE_ISSUE_STATE + to: OPEN + condition: + kind: ANY + operands: + - duration: 168h0m0s + kind: ELAPSED_TIME + - kind: OCCURRENCES + threshold: 100 + started_at: "2025-01-01T00:00:00Z" + status: ACTIVE + id: e7a1c3b5-2d4f-4a6b-8c9d-0e1f2a3b4c5d + type: error_tracking_issue_watch + schema: + $ref: "#/components/schemas/IssueResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + $ref: "#/components/responses/UnauthorizedResponse" + "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: + - error_tracking_read + - error_tracking_write + summary: Snooze an issue + tags: + - Error Tracking + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. /api/v2/error-tracking/issues/{issue_id}/state: put: description: Update the state of an issue by `issue_id`. Use this endpoint to move an issue between states such as `OPEN`, `RESOLVED`, or `IGNORED`. diff --git a/examples/v2/error-tracking/SnoozeIssue.rb b/examples/v2/error-tracking/SnoozeIssue.rb new file mode 100644 index 000000000000..eb364738f700 --- /dev/null +++ b/examples/v2/error-tracking/SnoozeIssue.rb @@ -0,0 +1,25 @@ +# Snooze an issue returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.snooze_issue".to_sym] = true +end +api_instance = DatadogAPIClient::V2::ErrorTrackingAPI.new + +# there is a valid "issue" in the system +ISSUE_ID = ENV["ISSUE_ID"] + +body = DatadogAPIClient::V2::IssueSnoozeRequest.new({ + data: DatadogAPIClient::V2::IssueSnoozeRequestData.new({ + attributes: DatadogAPIClient::V2::IssueSnoozeRequestDataAttributes.new({ + condition: DatadogAPIClient::V2::IssueWatchCondition.new({ + kind: DatadogAPIClient::V2::IssueWatchConditionKind::ELAPSED_TIME, + duration: "168h", + }), + }), + id: ISSUE_ID, + type: DatadogAPIClient::V2::IssueSnoozeRequestDataType::ERROR_TRACKING_ISSUE, + }), +}) +p api_instance.snooze_issue(ISSUE_ID, body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 44f677f00d7f..07274057c608 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3821,6 +3821,10 @@ "filter_from" => "Integer", "filter_to" => "Integer", }, + "v2.SnoozeIssue" => { + "issue_id" => "String", + "body" => "IssueSnoozeRequest", + }, "v2.UpdateIssueState" => { "issue_id" => "String", "body" => "IssueUpdateStateRequest", diff --git a/features/v2/error_tracking.feature b/features/v2/error_tracking.feature index 468c9b4d8e22..7722f8e84c28 100644 --- a/features/v2/error_tracking.feature +++ b/features/v2/error_tracking.feature @@ -124,6 +124,38 @@ Feature: Error Tracking When the request is sent Then the response status is 200 OK + @skip @team:ddoghq/error-tracking + Scenario: Snooze an issue returns "Bad Request" response + Given operation "SnoozeIssue" enabled + And new "SnoozeIssue" request + And there is a valid "issue" in the system + And request contains "issue_id" parameter from "issue.id" + And body with value {"data": {"attributes": {"condition": {"kind": "OCCURRENCES"}}, "id": "{{ issue.id }}", "type": "error_tracking_issue"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:ddoghq/error-tracking + Scenario: Snooze an issue returns "Not Found" response + Given operation "SnoozeIssue" enabled + And new "SnoozeIssue" request + And request contains "issue_id" parameter with value "67d80aa3-36ff-44b9-a694-c501a7591737" + And body with value {"data": {"attributes": {"condition": {"kind": "ELAPSED_TIME", "duration": "168h"}}, "id": "67d80aa3-36ff-44b9-a694-c501a7591737", "type": "error_tracking_issue"}} + When the request is sent + Then the response status is 404 Not Found + + @skip @team:ddoghq/error-tracking + Scenario: Snooze an issue returns "OK" response + Given operation "SnoozeIssue" enabled + And new "SnoozeIssue" request + And there is a valid "issue" in the system + And request contains "issue_id" parameter from "issue.id" + And body with value {"data": {"attributes": {"condition": {"kind": "ELAPSED_TIME", "duration": "168h"}}, "id": "{{ issue.id }}", "type": "error_tracking_issue"}} + When the request is sent + Then the response status is 200 OK + And the response "data.id" is equal to "{{ issue.id }}" + And the response "data.attributes.state" is equal to "IGNORED" + And the response "data.relationships" has field "watches" + @team:ddoghq/error-tracking Scenario: Update the assignee of an issue returns "Bad Request" response Given new "UpdateIssueAssignee" request diff --git a/features/v2/undo.json b/features/v2/undo.json index 735b21bfccae..0d9b33aa46f6 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -2789,6 +2789,23 @@ "type": "safe" } }, + "SnoozeIssue": { + "tag": "Error Tracking", + "undo": { + "operationId": "UpdateIssueState", + "parameters": [ + { + "name": "issue_id", + "source": "data.id" + }, + { + "name": "body", + "template": "{\"data\": {\"type\": \"error_tracking_issue\", \"id\": \"{{ data.id }}\", \"attributes\": {\"state\": \"OPEN\"}}}" + } + ], + "type": "unsafe" + } + }, "UpdateIssueState": { "tag": "Error Tracking", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index a481a0527d31..f3c25b0e12e0 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -547,6 +547,7 @@ def initialize "v2.update_deployment_gate": false, "v2.update_deployment_rule": false, "v2.get_issue_impact": false, + "v2.snooze_issue": false, "v2.get_eudm_device": false, "v2.get_eudm_devices": false, "v2.clone_form": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index fe09c8ecd669..01c6d5579703 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -5410,6 +5410,10 @@ def overrides "v2.issue_samples_relationship" => "IssueSamplesRelationship", "v2.issue_sample_stack_frame" => "IssueSampleStackFrame", "v2.issue_sample_type" => "IssueSampleType", + "v2.issue_snooze_request" => "IssueSnoozeRequest", + "v2.issue_snooze_request_data" => "IssueSnoozeRequestData", + "v2.issue_snooze_request_data_attributes" => "IssueSnoozeRequestDataAttributes", + "v2.issue_snooze_request_data_type" => "IssueSnoozeRequestDataType", "v2.issues_search_request" => "IssuesSearchRequest", "v2.issues_search_request_data" => "IssuesSearchRequestData", "v2.issues_search_request_data_attributes" => "IssuesSearchRequestDataAttributes", diff --git a/lib/datadog_api_client/v2/api/error_tracking_api.rb b/lib/datadog_api_client/v2/api/error_tracking_api.rb index 7419cf72abf0..83c9542e2b39 100644 --- a/lib/datadog_api_client/v2/api/error_tracking_api.rb +++ b/lib/datadog_api_client/v2/api/error_tracking_api.rb @@ -314,6 +314,89 @@ def search_issues_with_http_info(body, opts = {}) return data, status_code, headers end + # Snooze an issue. + # + # @see #snooze_issue_with_http_info + def snooze_issue(issue_id, body, opts = {}) + data, _status_code, _headers = snooze_issue_with_http_info(issue_id, body, opts) + data + end + + # Snooze an issue. + # + # Snooze an issue by `issue_id`: move it to `IGNORED` until a condition is met, then back to `OPEN`. + # The condition can be a number of occurrences, a number of distinct values of an attribute such as `@usr.id`, + # an elapsed time, or any or all of several conditions. + # Snoozing an issue that is already snoozed replaces its snooze. Updating the state of the issue with + # `UpdateIssueState` cancels the snooze. + # The response includes the watch that reopens the issue. + # + # @param issue_id [String] The identifier of the issue. + # @param body [IssueSnoozeRequest] Snooze issue request payload. + # @param opts [Hash] the optional parameters + # @return [Array<(IssueResponse, Integer, Hash)>] IssueResponse data, response status code and response headers + def snooze_issue_with_http_info(issue_id, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.snooze_issue".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.snooze_issue") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.snooze_issue")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ErrorTrackingAPI.snooze_issue ...' + end + # verify the required parameter 'issue_id' is set + if @api_client.config.client_side_validation && issue_id.nil? + fail ArgumentError, "Missing the required parameter 'issue_id' when calling ErrorTrackingAPI.snooze_issue" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling ErrorTrackingAPI.snooze_issue" + end + # resource path + local_var_path = '/api/v2/error-tracking/issues/{issue_id}/snooze'.sub('{issue_id}', CGI.escape(issue_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'IssueResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :snooze_issue, + :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::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ErrorTrackingAPI#snooze_issue\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Update the assignee of an issue. # # @see #update_issue_assignee_with_http_info diff --git a/lib/datadog_api_client/v2/models/issue_snooze_request.rb b/lib/datadog_api_client/v2/models/issue_snooze_request.rb new file mode 100644 index 000000000000..98b6156a061c --- /dev/null +++ b/lib/datadog_api_client/v2/models/issue_snooze_request.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 + # Snooze issue request payload. + class IssueSnoozeRequest + include BaseGenericModel + + # Snooze issue request. + 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' => :'IssueSnoozeRequestData' + } + 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::IssueSnoozeRequest` 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/issue_snooze_request_data.rb b/lib/datadog_api_client/v2/models/issue_snooze_request_data.rb new file mode 100644 index 000000000000..0e76fa1afee7 --- /dev/null +++ b/lib/datadog_api_client/v2/models/issue_snooze_request_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 + # Snooze issue request. + class IssueSnoozeRequestData + include BaseGenericModel + + # Object describing an issue snooze request. + attr_reader :attributes + + # Issue identifier. + attr_reader :id + + # Type of the object. + 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' => :'IssueSnoozeRequestDataAttributes', + :'id' => :'String', + :'type' => :'IssueSnoozeRequestDataType' + } + 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::IssueSnoozeRequestData` 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/issue_snooze_request_data_attributes.rb b/lib/datadog_api_client/v2/models/issue_snooze_request_data_attributes.rb new file mode 100644 index 000000000000..e111fdd9b3f2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/issue_snooze_request_data_attributes.rb @@ -0,0 +1,125 @@ +=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 + # Object describing an issue snooze request. + class IssueSnoozeRequestDataAttributes + include BaseGenericModel + + # Condition that triggers the watch action. The fields that are set depend on `kind`: + # `OCCURRENCES` uses `threshold`, `CARDINALITY` uses `threshold` and `projection`, + # `ELAPSED_TIME` uses `duration`, and `ANY` and `ALL` use `operands`. + attr_reader :condition + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'condition' => :'condition' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'condition' => :'IssueWatchCondition' + } + 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::IssueSnoozeRequestDataAttributes` 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?(:'condition') + self.condition = attributes[:'condition'] + 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 @condition.nil? + true + end + + # Custom attribute writer method with validation + # @param condition [Object] Object to be assigned + # @!visibility private + def condition=(condition) + if condition.nil? + fail ArgumentError, 'invalid value for "condition", condition cannot be nil.' + end + @condition = condition + 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 && + condition == o.condition && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [condition, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/issue_snooze_request_data_type.rb b/lib/datadog_api_client/v2/models/issue_snooze_request_data_type.rb new file mode 100644 index 000000000000..7db641739d71 --- /dev/null +++ b/lib/datadog_api_client/v2/models/issue_snooze_request_data_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 + # Type of the object. + class IssueSnoozeRequestDataType + include BaseEnumModel + + ERROR_TRACKING_ISSUE = "error_tracking_issue".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/issue_watch_condition.rb b/lib/datadog_api_client/v2/models/issue_watch_condition.rb index 79943e7f56db..a36cb5cc5c24 100644 --- a/lib/datadog_api_client/v2/models/issue_watch_condition.rb +++ b/lib/datadog_api_client/v2/models/issue_watch_condition.rb @@ -23,7 +23,8 @@ module DatadogAPIClient::V2 class IssueWatchCondition include BaseGenericModel - # Time that must elapse before the condition is met, as a Go duration string. + # Time that must elapse from when the watch started, as a Go duration string, such as `24h`, or `168h` for a + # week. attr_accessor :duration # Kind of watch condition. @@ -32,10 +33,14 @@ class IssueWatchCondition # Nested conditions combined by `ANY` or `ALL`. attr_accessor :operands - # Attributes whose distinct values are counted for `CARDINALITY`. + # Attributes whose distinct values `CARDINALITY` counts, in search syntax: `@` for attributes, such as + # `@usr.id` or `@account.id`, and no prefix for tags and reserved fields, such as `org_id` or `service`. + # Only use attributes that the issue's errors carry: a condition on an attribute they don't carry is never + # met. attr_accessor :projection - # Number of occurrences, or of distinct values for `CARDINALITY`, that triggers the condition. + # Number of new occurrences, or of distinct values for `CARDINALITY`, that meets the condition, counted from + # when the watch started. attr_accessor :threshold attr_accessor :additional_properties