diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 70523726660..74bf0b38616 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -29120,6 +29120,92 @@ components: user_defined_fields: $ref: '#/components/schemas/RelationshipToIncidentUserDefinedFields' type: object + IncidentRuleAttributesRequest: + properties: + name: + description: The name of the rule + example: High Severity Rule + type: string + required: + - name + type: object + IncidentRuleAttributesResponse: + properties: + createdAt: + description: When the rule was created + example: '2026-01-13T17:15:53.208340Z' + format: date-time + type: string + modifiedAt: + description: When the rule was last modified + example: '2026-01-13T17:15:53.208340Z' + format: date-time + type: string + name: + description: The name of the rule + example: High Severity Rule + type: string + required: + - name + - createdAt + - modifiedAt + type: object + IncidentRuleDataRequest: + properties: + attributes: + $ref: '#/components/schemas/IncidentRuleAttributesRequest' + type: + $ref: '#/components/schemas/IncidentRuleType' + required: + - type + - attributes + type: object + IncidentRuleDataResponse: + properties: + attributes: + $ref: '#/components/schemas/IncidentRuleAttributesResponse' + id: + description: The ID of the rule + example: 612e0c88-9137-4bd2-8de4-9356867d4c6a + type: string + type: + $ref: '#/components/schemas/IncidentRuleType' + required: + - id + - type + - attributes + type: object + IncidentRuleRequest: + properties: + data: + $ref: '#/components/schemas/IncidentRuleDataRequest' + required: + - data + type: object + IncidentRuleResponse: + properties: + data: + $ref: '#/components/schemas/IncidentRuleDataResponse' + required: + - data + type: object + IncidentRuleType: + description: Incident rule resource type + enum: + - incident_rule + example: incident_rule + type: string + x-enum-varnames: + - INCIDENT_RULE + IncidentRulesResponse: + properties: + data: + items: + $ref: '#/components/schemas/IncidentRuleDataResponse' + type: array + required: + - data + type: object IncidentSearchResponse: description: Response with incidents and facets. properties: @@ -75865,6 +75951,178 @@ paths: - incident_notification_settings_write x-unstable: '**Note**: This endpoint is in Preview. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/incidents/config/rules: + get: + description: Retrieve a list of all incident rules for the organization. + operationId: ListIncidentConfigRules + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRulesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List incident rules + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create a new incident rule for the organization. + operationId: CreateIncidentConfigRule + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRuleRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRuleResponse' + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create incident rule + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/incidents/config/rules/{rule_id}: + delete: + description: Delete an incident rule. + operationId: DeleteIncidentConfigRule + parameters: + - description: The ID of the incident rule + in: path + name: rule_id + required: true + schema: + example: 612e0c88-9137-4bd2-8de4-9356867d4c6a + type: string + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete incident rule + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Retrieve details of a specific incident rule. + operationId: GetIncidentConfigRule + parameters: + - description: The ID of the incident rule + in: path + name: rule_id + required: true + schema: + example: 612e0c88-9137-4bd2-8de4-9356867d4c6a + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRuleResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get incident rule + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: Update an existing incident rule. + operationId: UpdateIncidentConfigRule + parameters: + - description: The ID of the incident rule + in: path + name: rule_id + required: true + schema: + example: 612e0c88-9137-4bd2-8de4-9356867d4c6a + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRuleRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRuleResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update incident rule + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/incidents/config/types: get: diff --git a/examples/v2/incidents/CreateIncidentConfigRule.rb b/examples/v2/incidents/CreateIncidentConfigRule.rb new file mode 100644 index 00000000000..f45d749188d --- /dev/null +++ b/examples/v2/incidents/CreateIncidentConfigRule.rb @@ -0,0 +1,17 @@ +# Create incident rule returns "Created" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.create_incident_config_rule".to_sym] = true +end +api_instance = DatadogAPIClient::V2::IncidentsAPI.new + +body = DatadogAPIClient::V2::IncidentRuleRequest.new({ + data: DatadogAPIClient::V2::IncidentRuleDataRequest.new({ + attributes: DatadogAPIClient::V2::IncidentRuleAttributesRequest.new({ + name: "High Severity Rule", + }), + type: DatadogAPIClient::V2::IncidentRuleType::INCIDENT_RULE, + }), +}) +p api_instance.create_incident_config_rule(body) diff --git a/examples/v2/incidents/DeleteIncidentConfigRule.rb b/examples/v2/incidents/DeleteIncidentConfigRule.rb new file mode 100644 index 00000000000..79807183d77 --- /dev/null +++ b/examples/v2/incidents/DeleteIncidentConfigRule.rb @@ -0,0 +1,8 @@ +# Delete incident rule returns "No Content" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.delete_incident_config_rule".to_sym] = true +end +api_instance = DatadogAPIClient::V2::IncidentsAPI.new +api_instance.delete_incident_config_rule("612e0c88-9137-4bd2-8de4-9356867d4c6a") diff --git a/examples/v2/incidents/GetIncidentConfigRule.rb b/examples/v2/incidents/GetIncidentConfigRule.rb new file mode 100644 index 00000000000..f3723195cd3 --- /dev/null +++ b/examples/v2/incidents/GetIncidentConfigRule.rb @@ -0,0 +1,8 @@ +# Get incident rule returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_incident_config_rule".to_sym] = true +end +api_instance = DatadogAPIClient::V2::IncidentsAPI.new +p api_instance.get_incident_config_rule("612e0c88-9137-4bd2-8de4-9356867d4c6a") diff --git a/examples/v2/incidents/ListIncidentConfigRules.rb b/examples/v2/incidents/ListIncidentConfigRules.rb new file mode 100644 index 00000000000..1d5574fcf42 --- /dev/null +++ b/examples/v2/incidents/ListIncidentConfigRules.rb @@ -0,0 +1,8 @@ +# List incident rules returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.list_incident_config_rules".to_sym] = true +end +api_instance = DatadogAPIClient::V2::IncidentsAPI.new +p api_instance.list_incident_config_rules() diff --git a/examples/v2/incidents/UpdateIncidentConfigRule.rb b/examples/v2/incidents/UpdateIncidentConfigRule.rb new file mode 100644 index 00000000000..39bd8b39a25 --- /dev/null +++ b/examples/v2/incidents/UpdateIncidentConfigRule.rb @@ -0,0 +1,17 @@ +# Update incident rule returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.update_incident_config_rule".to_sym] = true +end +api_instance = DatadogAPIClient::V2::IncidentsAPI.new + +body = DatadogAPIClient::V2::IncidentRuleRequest.new({ + data: DatadogAPIClient::V2::IncidentRuleDataRequest.new({ + attributes: DatadogAPIClient::V2::IncidentRuleAttributesRequest.new({ + name: "High Severity Rule", + }), + type: DatadogAPIClient::V2::IncidentRuleType::INCIDENT_RULE, + }), +}) +p api_instance.update_incident_config_rule("612e0c88-9137-4bd2-8de4-9356867d4c6a", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 6674c3b1a04..d0fd0a948df 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2121,6 +2121,19 @@ "include" => "String", "body" => "PatchIncidentNotificationTemplateRequest", }, + "v2.CreateIncidentConfigRule" => { + "body" => "IncidentRuleRequest", + }, + "v2.DeleteIncidentConfigRule" => { + "rule_id" => "String", + }, + "v2.GetIncidentConfigRule" => { + "rule_id" => "String", + }, + "v2.UpdateIncidentConfigRule" => { + "rule_id" => "String", + "body" => "IncidentRuleRequest", + }, "v2.ListIncidentTypes" => { "include_deleted" => "Boolean", }, diff --git a/features/v2/incidents.feature b/features/v2/incidents.feature index db706355841..64c59703a9a 100644 --- a/features/v2/incidents.feature +++ b/features/v2/incidents.feature @@ -272,6 +272,22 @@ Feature: Incidents When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app + Scenario: Create incident rule returns "Bad Request" response + Given operation "CreateIncidentConfigRule" enabled + And new "CreateIncidentConfigRule" request + And body with value {"data": {"attributes": {"name": "High Severity Rule"}, "type": "incident_rule"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Create incident rule returns "Created" response + Given operation "CreateIncidentConfigRule" enabled + And new "CreateIncidentConfigRule" request + And body with value {"data": {"attributes": {"name": "High Severity Rule"}, "type": "incident_rule"}} + When the request is sent + Then the response status is 201 Created + @generated @skip @team:DataDog/incident-app Scenario: Create postmortem attachment returns "Bad Request" response Given operation "CreateIncidentPostmortemAttachment" enabled @@ -537,6 +553,30 @@ Feature: Incidents When the request is sent Then the response status is 204 No Content + @generated @skip @team:DataDog/incident-app + Scenario: Delete incident rule returns "Bad Request" response + Given operation "DeleteIncidentConfigRule" enabled + And new "DeleteIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Delete incident rule returns "No Content" response + Given operation "DeleteIncidentConfigRule" enabled + And new "DeleteIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/incident-app + Scenario: Delete incident rule returns "Not Found" response + Given operation "DeleteIncidentConfigRule" enabled + And new "DeleteIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app Scenario: Get a list of an incident's integration metadata returns "Bad Request" response Given operation "ListIncidentIntegrations" enabled @@ -756,6 +796,30 @@ Feature: Incidents And the response "data" has field "attributes" And the response "data" has field "relationships" + @generated @skip @team:DataDog/incident-app + Scenario: Get incident rule returns "Bad Request" response + Given operation "GetIncidentConfigRule" enabled + And new "GetIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Get incident rule returns "Not Found" response + Given operation "GetIncidentConfigRule" enabled + And new "GetIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/incident-app + Scenario: Get incident rule returns "OK" response + Given operation "GetIncidentConfigRule" enabled + And new "GetIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:Datadog/incident-app Scenario: Get incident todo details returns "Bad Request" response Given operation "GetIncidentTodo" enabled @@ -940,6 +1004,20 @@ Feature: Incidents Then the response status is 200 OK And the response "data" has length 0 + @generated @skip @team:DataDog/incident-app + Scenario: List incident rules returns "Bad Request" response + Given operation "ListIncidentConfigRules" enabled + And new "ListIncidentConfigRules" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: List incident rules returns "OK" response + Given operation "ListIncidentConfigRules" enabled + And new "ListIncidentConfigRules" request + When the request is sent + Then the response status is 200 OK + @team:DataDog/incident-app Scenario: Remove commander from an incident returns "OK" response Given operation "UpdateIncident" enabled @@ -1270,3 +1348,30 @@ Feature: Incidents And the response "data.id" has the same value as "notification_template.data.id" And the response "data.attributes.name" has the same value as "unique" And the response "data.attributes.category" is equal to "update" + + @generated @skip @team:DataDog/incident-app + Scenario: Update incident rule returns "Bad Request" response + Given operation "UpdateIncidentConfigRule" enabled + And new "UpdateIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "High Severity Rule"}, "type": "incident_rule"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Update incident rule returns "Not Found" response + Given operation "UpdateIncidentConfigRule" enabled + And new "UpdateIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "High Severity Rule"}, "type": "incident_rule"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/incident-app + Scenario: Update incident rule returns "OK" response + Given operation "UpdateIncidentConfigRule" enabled + And new "UpdateIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "High Severity Rule"}, "type": "incident_rule"}} + 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 5a347bddf11..bae2754c7e8 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -1714,6 +1714,43 @@ "type": "idempotent" } }, + "ListIncidentConfigRules": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "CreateIncidentConfigRule": { + "tag": "Incidents", + "undo": { + "operationId": "DeleteIncidentConfigRule", + "parameters": [ + { + "name": "rule_id", + "source": "" + } + ], + "type": "unsafe" + } + }, + "DeleteIncidentConfigRule": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "GetIncidentConfigRule": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "UpdateIncidentConfigRule": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, "ListIncidentTypes": { "tag": "Incidents", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index 7085b0efde5..a043f2706b3 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -249,6 +249,7 @@ def initialize "v2.create_global_incident_handle": false, "v2.create_incident": false, "v2.create_incident_attachment": false, + "v2.create_incident_config_rule": false, "v2.create_incident_integration": false, "v2.create_incident_notification_rule": false, "v2.create_incident_notification_template": false, @@ -258,6 +259,7 @@ def initialize "v2.delete_global_incident_handle": false, "v2.delete_incident": false, "v2.delete_incident_attachment": false, + "v2.delete_incident_config_rule": false, "v2.delete_incident_integration": false, "v2.delete_incident_notification_rule": false, "v2.delete_incident_notification_template": false, @@ -265,6 +267,7 @@ def initialize "v2.delete_incident_type": false, "v2.get_global_incident_settings": false, "v2.get_incident": false, + "v2.get_incident_config_rule": false, "v2.get_incident_integration": false, "v2.get_incident_notification_rule": false, "v2.get_incident_notification_template": false, @@ -272,6 +275,7 @@ def initialize "v2.get_incident_type": false, "v2.list_global_incident_handles": false, "v2.list_incident_attachments": false, + "v2.list_incident_config_rules": false, "v2.list_incident_integrations": false, "v2.list_incident_notification_rules": false, "v2.list_incident_notification_templates": false, @@ -283,6 +287,7 @@ def initialize "v2.update_global_incident_settings": false, "v2.update_incident": false, "v2.update_incident_attachment": false, + "v2.update_incident_config_rule": false, "v2.update_incident_integration": false, "v2.update_incident_notification_rule": false, "v2.update_incident_notification_template": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index b3cd03dc3ae..d9f60f92cf6 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -2727,6 +2727,14 @@ def overrides "v2.incident_response_meta" => "IncidentResponseMeta", "v2.incident_response_meta_pagination" => "IncidentResponseMetaPagination", "v2.incident_response_relationships" => "IncidentResponseRelationships", + "v2.incident_rule_attributes_request" => "IncidentRuleAttributesRequest", + "v2.incident_rule_attributes_response" => "IncidentRuleAttributesResponse", + "v2.incident_rule_data_request" => "IncidentRuleDataRequest", + "v2.incident_rule_data_response" => "IncidentRuleDataResponse", + "v2.incident_rule_request" => "IncidentRuleRequest", + "v2.incident_rule_response" => "IncidentRuleResponse", + "v2.incident_rules_response" => "IncidentRulesResponse", + "v2.incident_rule_type" => "IncidentRuleType", "v2.incident_search_response" => "IncidentSearchResponse", "v2.incident_search_response_attributes" => "IncidentSearchResponseAttributes", "v2.incident_search_response_data" => "IncidentSearchResponseData", diff --git a/lib/datadog_api_client/v2/api/incidents_api.rb b/lib/datadog_api_client/v2/api/incidents_api.rb index 8d70192d255..8a48a46e10c 100644 --- a/lib/datadog_api_client/v2/api/incidents_api.rb +++ b/lib/datadog_api_client/v2/api/incidents_api.rb @@ -251,6 +251,79 @@ def create_incident_attachment_with_http_info(incident_id, body, opts = {}) return data, status_code, headers end + # Create incident rule. + # + # @see #create_incident_config_rule_with_http_info + def create_incident_config_rule(body, opts = {}) + data, _status_code, _headers = create_incident_config_rule_with_http_info(body, opts) + data + end + + # Create incident rule. + # + # Create a new incident rule for the organization. + # + # @param body [IncidentRuleRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(IncidentRuleResponse, Integer, Hash)>] IncidentRuleResponse data, response status code and response headers + def create_incident_config_rule_with_http_info(body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.create_incident_config_rule".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.create_incident_config_rule") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.create_incident_config_rule")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: IncidentsAPI.create_incident_config_rule ...' + 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 IncidentsAPI.create_incident_config_rule" + end + # resource path + local_var_path = '/api/v2/incidents/config/rules' + + # 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] || 'IncidentRuleResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_incident_config_rule, + :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: IncidentsAPI#create_incident_config_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Create an incident impact. # # @see #create_incident_impact_with_http_info @@ -988,6 +1061,77 @@ def delete_incident_attachment_with_http_info(incident_id, attachment_id, opts = return data, status_code, headers end + # Delete incident rule. + # + # @see #delete_incident_config_rule_with_http_info + def delete_incident_config_rule(rule_id, opts = {}) + delete_incident_config_rule_with_http_info(rule_id, opts) + nil + end + + # Delete incident rule. + # + # Delete an incident rule. + # + # @param rule_id [String] The ID of the incident rule + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_incident_config_rule_with_http_info(rule_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.delete_incident_config_rule".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.delete_incident_config_rule") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.delete_incident_config_rule")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: IncidentsAPI.delete_incident_config_rule ...' + end + # verify the required parameter 'rule_id' is set + if @api_client.config.client_side_validation && rule_id.nil? + fail ArgumentError, "Missing the required parameter 'rule_id' when calling IncidentsAPI.delete_incident_config_rule" + end + # resource path + local_var_path = '/api/v2/incidents/config/rules/{rule_id}'.sub('{rule_id}', CGI.escape(rule_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(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :delete_incident_config_rule, + :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::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: IncidentsAPI#delete_incident_config_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete an incident impact. # # @see #delete_incident_impact_with_http_info @@ -1566,6 +1710,77 @@ def get_incident_with_http_info(incident_id, opts = {}) return data, status_code, headers end + # Get incident rule. + # + # @see #get_incident_config_rule_with_http_info + def get_incident_config_rule(rule_id, opts = {}) + data, _status_code, _headers = get_incident_config_rule_with_http_info(rule_id, opts) + data + end + + # Get incident rule. + # + # Retrieve details of a specific incident rule. + # + # @param rule_id [String] The ID of the incident rule + # @param opts [Hash] the optional parameters + # @return [Array<(IncidentRuleResponse, Integer, Hash)>] IncidentRuleResponse data, response status code and response headers + def get_incident_config_rule_with_http_info(rule_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_incident_config_rule".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_incident_config_rule") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_incident_config_rule")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: IncidentsAPI.get_incident_config_rule ...' + end + # verify the required parameter 'rule_id' is set + if @api_client.config.client_side_validation && rule_id.nil? + fail ArgumentError, "Missing the required parameter 'rule_id' when calling IncidentsAPI.get_incident_config_rule" + end + # resource path + local_var_path = '/api/v2/incidents/config/rules/{rule_id}'.sub('{rule_id}', CGI.escape(rule_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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'IncidentRuleResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :get_incident_config_rule, + :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: IncidentsAPI#get_incident_config_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get incident integration metadata details. # # @see #get_incident_integration_with_http_info @@ -2078,6 +2293,72 @@ def list_incident_attachments_with_http_info(incident_id, opts = {}) return data, status_code, headers end + # List incident rules. + # + # @see #list_incident_config_rules_with_http_info + def list_incident_config_rules(opts = {}) + data, _status_code, _headers = list_incident_config_rules_with_http_info(opts) + data + end + + # List incident rules. + # + # Retrieve a list of all incident rules for the organization. + # + # @param opts [Hash] the optional parameters + # @return [Array<(IncidentRulesResponse, Integer, Hash)>] IncidentRulesResponse data, response status code and response headers + def list_incident_config_rules_with_http_info(opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.list_incident_config_rules".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_incident_config_rules") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_incident_config_rules")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: IncidentsAPI.list_incident_config_rules ...' + end + # resource path + local_var_path = '/api/v2/incidents/config/rules' + + # 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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'IncidentRulesResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :list_incident_config_rules, + :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: IncidentsAPI#list_incident_config_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List an incident's impacts. # # @see #list_incident_impacts_with_http_info @@ -3005,6 +3286,84 @@ def update_incident_attachment_with_http_info(incident_id, attachment_id, body, return data, status_code, headers end + # Update incident rule. + # + # @see #update_incident_config_rule_with_http_info + def update_incident_config_rule(rule_id, body, opts = {}) + data, _status_code, _headers = update_incident_config_rule_with_http_info(rule_id, body, opts) + data + end + + # Update incident rule. + # + # Update an existing incident rule. + # + # @param rule_id [String] The ID of the incident rule + # @param body [IncidentRuleRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(IncidentRuleResponse, Integer, Hash)>] IncidentRuleResponse data, response status code and response headers + def update_incident_config_rule_with_http_info(rule_id, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.update_incident_config_rule".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.update_incident_config_rule") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.update_incident_config_rule")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: IncidentsAPI.update_incident_config_rule ...' + end + # verify the required parameter 'rule_id' is set + if @api_client.config.client_side_validation && rule_id.nil? + fail ArgumentError, "Missing the required parameter 'rule_id' when calling IncidentsAPI.update_incident_config_rule" + 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 IncidentsAPI.update_incident_config_rule" + end + # resource path + local_var_path = '/api/v2/incidents/config/rules/{rule_id}'.sub('{rule_id}', CGI.escape(rule_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] || 'IncidentRuleResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :update_incident_config_rule, + :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::Patch, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: IncidentsAPI#update_incident_config_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Update an existing incident integration metadata. # # @see #update_incident_integration_with_http_info diff --git a/lib/datadog_api_client/v2/models/incident_rule_attributes_request.rb b/lib/datadog_api_client/v2/models/incident_rule_attributes_request.rb new file mode 100644 index 00000000000..3bd2342d137 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_rule_attributes_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 + # + class IncidentRuleAttributesRequest + include BaseGenericModel + + # The name of the rule + attr_reader :name + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'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::IncidentRuleAttributesRequest` 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?(:'name') + self.name = attributes[:'name'] + 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 @name.nil? + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + 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 && + name == o.name && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_rule_attributes_response.rb b/lib/datadog_api_client/v2/models/incident_rule_attributes_response.rb new file mode 100644 index 00000000000..ff596446b2d --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_rule_attributes_response.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 + # + class IncidentRuleAttributesResponse + include BaseGenericModel + + # When the rule was created + attr_reader :created_at + + # When the rule was last modified + attr_reader :modified_at + + # The name of the rule + attr_reader :name + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'created_at' => :'createdAt', + :'modified_at' => :'modifiedAt', + :'name' => :'name' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'created_at' => :'Time', + :'modified_at' => :'Time', + :'name' => :'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::IncidentRuleAttributesResponse` 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?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'modified_at') + self.modified_at = attributes[:'modified_at'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + 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 @created_at.nil? + return false if @modified_at.nil? + return false if @name.nil? + true + end + + # Custom attribute writer method with validation + # @param created_at [Object] Object to be assigned + # @!visibility private + def created_at=(created_at) + if created_at.nil? + fail ArgumentError, 'invalid value for "created_at", created_at cannot be nil.' + end + @created_at = created_at + end + + # Custom attribute writer method with validation + # @param modified_at [Object] Object to be assigned + # @!visibility private + def modified_at=(modified_at) + if modified_at.nil? + fail ArgumentError, 'invalid value for "modified_at", modified_at cannot be nil.' + end + @modified_at = modified_at + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + 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 && + created_at == o.created_at && + modified_at == o.modified_at && + name == o.name && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [created_at, modified_at, name, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_rule_data_request.rb b/lib/datadog_api_client/v2/models/incident_rule_data_request.rb new file mode 100644 index 00000000000..f847d0cf8fd --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_rule_data_request.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 + # + class IncidentRuleDataRequest + include BaseGenericModel + + # + attr_reader :attributes + + # Incident rule resource type + 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', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'IncidentRuleAttributesRequest', + :'type' => :'IncidentRuleType' + } + 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::IncidentRuleDataRequest` 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?(:'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 @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 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 && + 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, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/incident_rule_data_response.rb b/lib/datadog_api_client/v2/models/incident_rule_data_response.rb new file mode 100644 index 00000000000..90c5aa1c206 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_rule_data_response.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 + # + class IncidentRuleDataResponse + include BaseGenericModel + + # + attr_reader :attributes + + # The ID of the rule + attr_reader :id + + # Incident rule resource type + 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' => :'IncidentRuleAttributesResponse', + :'id' => :'String', + :'type' => :'IncidentRuleType' + } + 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::IncidentRuleDataResponse` 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/incident_rule_request.rb b/lib/datadog_api_client/v2/models/incident_rule_request.rb new file mode 100644 index 00000000000..3d4dd713eb5 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_rule_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 + # + class IncidentRuleRequest + include BaseGenericModel + + # + 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' => :'IncidentRuleDataRequest' + } + 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::IncidentRuleRequest` 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/incident_rule_response.rb b/lib/datadog_api_client/v2/models/incident_rule_response.rb new file mode 100644 index 00000000000..673196aeeb1 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_rule_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 + # + class IncidentRuleResponse + include BaseGenericModel + + # + 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' => :'IncidentRuleDataResponse' + } + 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::IncidentRuleResponse` 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/incident_rule_type.rb b/lib/datadog_api_client/v2/models/incident_rule_type.rb new file mode 100644 index 00000000000..45ff89d8209 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_rule_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 + # Incident rule resource type + class IncidentRuleType + include BaseEnumModel + + INCIDENT_RULE = "incident_rule".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/incident_rules_response.rb b/lib/datadog_api_client/v2/models/incident_rules_response.rb new file mode 100644 index 00000000000..1d879e9a7e3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/incident_rules_response.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 + # + class IncidentRulesResponse + include BaseGenericModel + + # + 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' => :'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::V2::IncidentRulesResponse` 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') + if (value = attributes[:'data']).is_a?(Array) + self.data = 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 @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