diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 615b42d5e76d..4f7435f733ce 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -79405,6 +79405,67 @@ components: type: string x-enum-varnames: - MONITOR_ALERT_TRIGGER + MonitorAutomationAttributes: + description: Automatic investigation settings for a monitor. + properties: + enabled: + description: Whether Bits automatically investigates alerts from this monitor. + example: true + type: boolean + required: + - enabled + type: object + MonitorAutomationData: + description: Automatic investigation configuration identified by monitor ID. + properties: + attributes: + $ref: "#/components/schemas/MonitorAutomationAttributes" + id: + description: The monitor ID. + example: "12345678" + type: string + type: + $ref: "#/components/schemas/MonitorAutomationType" + required: + - id + - type + - attributes + type: object + MonitorAutomationRequest: + description: Set whether Bits automatically investigates alerts from a monitor. + properties: + data: + $ref: "#/components/schemas/MonitorAutomationRequestData" + required: + - data + type: object + MonitorAutomationRequestData: + description: The automatic investigation settings to apply. + properties: + attributes: + $ref: "#/components/schemas/MonitorAutomationAttributes" + type: + $ref: "#/components/schemas/MonitorAutomationType" + required: + - type + - attributes + type: object + MonitorAutomationResponse: + description: Automatic investigation settings for a monitor. + properties: + data: + $ref: "#/components/schemas/MonitorAutomationData" + required: + - data + type: object + MonitorAutomationType: + description: The resource type for monitor automation settings. + enum: + - monitor_automation + example: monitor_automation + type: string + x-enum-varnames: + - MONITOR_AUTOMATION MonitorConfigPolicyAttributeCreateRequest: description: Policy and policy type for a monitor configuration policy. properties: @@ -145227,6 +145288,158 @@ paths: x-unstable: |- **Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/bits-ai/monitors/{monitor_id}/automation: + get: + description: Manage the Bits automatic investigation setting independently of the monitor definition. Requires access to the monitor and the specified permissions. A newly created monitor and updated settings can take time to appear in reads. + operationId: GetMonitorAutomation + parameters: + - description: The monitor ID. + in: path + name: monitor_id + required: true + schema: + format: int64 + minimum: 1 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + enabled: true + id: "12345678" + type: monitor_automation + schema: + $ref: "#/components/schemas/MonitorAutomationResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Invalid request or unsupported monitor type. + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Missing permission or automatic investigation API access is not enabled. + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Monitor not found or not visible to the caller. + "412": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: The monitor setting could not be updated. + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitors_read + - bits_investigations_read + summary: Get automatic investigation settings for a monitor + tags: + - Bits AI + x-permission: + operator: AND + permissions: + - monitors_read + - bits_investigations_read + x-unstable: This endpoint is in preview and is subject to change. + put: + description: Manage the Bits automatic investigation setting independently of the monitor definition. Requires access to the monitor and the specified permissions. A newly created monitor and updated settings can take time to appear in reads. The enabled attribute is required; false disables automatic investigations. Repeated requests set the same desired state. This operation does not create or delete the monitor. + operationId: UpdateMonitorAutomation + parameters: + - description: The monitor ID. + in: path + name: monitor_id + required: true + schema: + format: int64 + minimum: 1 + type: integer + requestBody: + content: + application/json: + example: + data: + attributes: + enabled: true + type: monitor_automation + schema: + $ref: "#/components/schemas/MonitorAutomationRequest" + description: Automatic investigation settings to apply. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + enabled: true + id: "12345678" + type: monitor_automation + schema: + $ref: "#/components/schemas/MonitorAutomationResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Invalid request or unsupported monitor type. + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Missing permission or automatic investigation API access is not enabled. + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Monitor not found or not visible to the caller. + "412": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: The monitor setting could not be updated. + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - monitors_read + - monitors_write + - bits_investigations_write + summary: Update monitor automatic investigation settings + tags: + - Bits AI + x-codegen-request-body-name: body + x-permission: + operator: AND + permissions: + - monitors_read + - monitors_write + - bits_investigations_write + x-unstable: This endpoint is in preview and is subject to change. /api/v2/cases: get: description: >- diff --git a/examples/v2/bits-ai/GetMonitorAutomation.rb b/examples/v2/bits-ai/GetMonitorAutomation.rb new file mode 100644 index 000000000000..7239c9bd8e35 --- /dev/null +++ b/examples/v2/bits-ai/GetMonitorAutomation.rb @@ -0,0 +1,9 @@ +# Get automatic investigation settings for a monitor returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.get_monitor_automation".to_sym] = true +end +api_instance = DatadogAPIClient::V2::BitsAIAPI.new +p api_instance.get_monitor_automation(9223372036854775807) diff --git a/examples/v2/bits-ai/GetMonitorAutomation_1312691475.rb b/examples/v2/bits-ai/GetMonitorAutomation_1312691475.rb new file mode 100644 index 000000000000..faeec96f934d --- /dev/null +++ b/examples/v2/bits-ai/GetMonitorAutomation_1312691475.rb @@ -0,0 +1,12 @@ +# Read automatic investigation settings for a new monitor + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.get_monitor_automation".to_sym] = true +end +api_instance = DatadogAPIClient::V2::BitsAIAPI.new + +# there is a valid "monitor" in the system +MONITOR_ID = ENV["MONITOR_ID"] +p api_instance.get_monitor_automation(MONITOR_ID.to_i) diff --git a/examples/v2/bits-ai/UpdateMonitorAutomation.rb b/examples/v2/bits-ai/UpdateMonitorAutomation.rb new file mode 100644 index 000000000000..94a738c4adf4 --- /dev/null +++ b/examples/v2/bits-ai/UpdateMonitorAutomation.rb @@ -0,0 +1,18 @@ +# Update monitor automatic investigation settings returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.update_monitor_automation".to_sym] = true +end +api_instance = DatadogAPIClient::V2::BitsAIAPI.new + +body = DatadogAPIClient::V2::MonitorAutomationRequest.new({ + data: DatadogAPIClient::V2::MonitorAutomationRequestData.new({ + attributes: DatadogAPIClient::V2::MonitorAutomationAttributes.new({ + enabled: true, + }), + type: DatadogAPIClient::V2::MonitorAutomationType::MONITOR_AUTOMATION, + }), +}) +p api_instance.update_monitor_automation(9223372036854775807, body) diff --git a/examples/v2/bits-ai/UpdateMonitorAutomation_2360742230.rb b/examples/v2/bits-ai/UpdateMonitorAutomation_2360742230.rb new file mode 100644 index 000000000000..5127e3b54842 --- /dev/null +++ b/examples/v2/bits-ai/UpdateMonitorAutomation_2360742230.rb @@ -0,0 +1,21 @@ +# Enable automatic investigations for a monitor + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.update_monitor_automation".to_sym] = true +end +api_instance = DatadogAPIClient::V2::BitsAIAPI.new + +# there is a valid "monitor" in the system +MONITOR_ID = ENV["MONITOR_ID"] + +body = DatadogAPIClient::V2::MonitorAutomationRequest.new({ + data: DatadogAPIClient::V2::MonitorAutomationRequestData.new({ + type: DatadogAPIClient::V2::MonitorAutomationType::MONITOR_AUTOMATION, + attributes: DatadogAPIClient::V2::MonitorAutomationAttributes.new({ + enabled: true, + }), + }), +}) +p api_instance.update_monitor_automation(MONITOR_ID.to_i, body) diff --git a/examples/v2/bits-ai/UpdateMonitorAutomation_2686390723.rb b/examples/v2/bits-ai/UpdateMonitorAutomation_2686390723.rb new file mode 100644 index 000000000000..c644f11119f4 --- /dev/null +++ b/examples/v2/bits-ai/UpdateMonitorAutomation_2686390723.rb @@ -0,0 +1,21 @@ +# Disable automatic investigations for a monitor + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] + config.unstable_operations["v2.update_monitor_automation".to_sym] = true +end +api_instance = DatadogAPIClient::V2::BitsAIAPI.new + +# there is a valid "monitor" in the system +MONITOR_ID = ENV["MONITOR_ID"] + +body = DatadogAPIClient::V2::MonitorAutomationRequest.new({ + data: DatadogAPIClient::V2::MonitorAutomationRequestData.new({ + type: DatadogAPIClient::V2::MonitorAutomationType::MONITOR_AUTOMATION, + attributes: DatadogAPIClient::V2::MonitorAutomationAttributes.new({ + enabled: false, + }), + }), +}) +p api_instance.update_monitor_automation(MONITOR_ID.to_i, body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 0fe9b59c75c5..048f4b0babce 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -1674,6 +1674,13 @@ "v2.GetInvestigation" => { "id" => "String", }, + "v2.GetMonitorAutomation" => { + "monitor_id" => "Integer", + }, + "v2.UpdateMonitorAutomation" => { + "monitor_id" => "Integer", + "body" => "MonitorAutomationRequest", + }, "v2.SearchCases" => { "page_size" => "Integer", "page_number" => "Integer", diff --git a/features/v2/bits_ai.feature b/features/v2/bits_ai.feature index 52c8a9b56fbe..c6c54b6901d2 100644 --- a/features/v2/bits_ai.feature +++ b/features/v2/bits_ai.feature @@ -7,6 +7,28 @@ Feature: Bits AI And a valid "appKeyAuth" key in the system And an instance of "BitsAI" API + @skip @team:ddoghq/bits-ai + Scenario: Disable automatic investigations for a monitor + Given operation "UpdateMonitorAutomation" enabled + And there is a valid "monitor" in the system + And new "UpdateMonitorAutomation" request + And request contains "monitor_id" parameter from "monitor.id" + And body with value {"data":{"type":"monitor_automation","attributes":{"enabled":false}}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.enabled" is false + + @skip @team:ddoghq/bits-ai + Scenario: Enable automatic investigations for a monitor + Given operation "UpdateMonitorAutomation" enabled + And there is a valid "monitor" in the system + And new "UpdateMonitorAutomation" request + And request contains "monitor_id" parameter from "monitor.id" + And body with value {"data":{"type":"monitor_automation","attributes":{"enabled":true}}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.enabled" is true + @generated @skip @team:ddoghq/bits-ai Scenario: Get a Bits AI investigation returns "Bad Request" response Given operation "GetInvestigation" enabled @@ -31,6 +53,38 @@ Feature: Bits AI When the request is sent Then the response status is 200 OK + @generated @skip @team:ddoghq/bits-ai + Scenario: Get automatic investigation settings for a monitor returns "Invalid request or unsupported monitor type." response + Given operation "GetMonitorAutomation" enabled + And new "GetMonitorAutomation" request + And request contains "monitor_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Invalid request or unsupported monitor type. + + @generated @skip @team:ddoghq/bits-ai + Scenario: Get automatic investigation settings for a monitor returns "Monitor not found or not visible to the caller." response + Given operation "GetMonitorAutomation" enabled + And new "GetMonitorAutomation" request + And request contains "monitor_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Monitor not found or not visible to the caller. + + @generated @skip @team:ddoghq/bits-ai + Scenario: Get automatic investigation settings for a monitor returns "OK" response + Given operation "GetMonitorAutomation" enabled + And new "GetMonitorAutomation" request + And request contains "monitor_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:ddoghq/bits-ai + Scenario: Get automatic investigation settings for a monitor returns "The monitor setting could not be updated." response + Given operation "GetMonitorAutomation" enabled + And new "GetMonitorAutomation" request + And request contains "monitor_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 412 The monitor setting could not be updated. + @generated @skip @team:ddoghq/bits-ai Scenario: List Bits AI investigations returns "Bad Request" response Given operation "ListInvestigations" enabled @@ -52,6 +106,16 @@ Feature: Bits AI When the request with pagination is sent Then the response status is 200 OK + @skip @team:ddoghq/bits-ai + Scenario: Read automatic investigation settings for a new monitor + Given operation "GetMonitorAutomation" enabled + And there is a valid "monitor" in the system + And new "GetMonitorAutomation" request + And request contains "monitor_id" parameter from "monitor.id" + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.enabled" is false + @generated @skip @team:ddoghq/bits-ai Scenario: Trigger a Bits AI investigation returns "Bad Request" response Given operation "TriggerInvestigation" enabled @@ -67,3 +131,39 @@ Feature: Bits AI And body with value {"data": {"attributes": {"trigger": {"monitor_alert_trigger": {"event_id": "1234567890123456789", "event_ts": 1700000000000, "monitor_id": 12345678}, "type": "monitor_alert_trigger"}}, "type": "trigger_investigation_request"}} When the request is sent Then the response status is 200 OK + + @generated @skip @team:ddoghq/bits-ai + Scenario: Update monitor automatic investigation settings returns "Invalid request or unsupported monitor type." response + Given operation "UpdateMonitorAutomation" enabled + And new "UpdateMonitorAutomation" request + And request contains "monitor_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"enabled": true}, "type": "monitor_automation"}} + When the request is sent + Then the response status is 400 Invalid request or unsupported monitor type. + + @generated @skip @team:ddoghq/bits-ai + Scenario: Update monitor automatic investigation settings returns "Monitor not found or not visible to the caller." response + Given operation "UpdateMonitorAutomation" enabled + And new "UpdateMonitorAutomation" request + And request contains "monitor_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"enabled": true}, "type": "monitor_automation"}} + When the request is sent + Then the response status is 404 Monitor not found or not visible to the caller. + + @generated @skip @team:ddoghq/bits-ai + Scenario: Update monitor automatic investigation settings returns "OK" response + Given operation "UpdateMonitorAutomation" enabled + And new "UpdateMonitorAutomation" request + And request contains "monitor_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"enabled": true}, "type": "monitor_automation"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:ddoghq/bits-ai + Scenario: Update monitor automatic investigation settings returns "The monitor setting could not be updated." response + Given operation "UpdateMonitorAutomation" enabled + And new "UpdateMonitorAutomation" request + And request contains "monitor_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"enabled": true}, "type": "monitor_automation"}} + When the request is sent + Then the response status is 412 The monitor setting could not be updated. diff --git a/features/v2/undo.json b/features/v2/undo.json index 6b0fafaa067a..f38dfb909bc2 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -802,6 +802,18 @@ "type": "safe" } }, + "GetMonitorAutomation": { + "tag": "Bits AI", + "undo": { + "type": "safe" + } + }, + "UpdateMonitorAutomation": { + "tag": "Bits AI", + "undo": { + "type": "idempotent" + } + }, "SearchCases": { "tag": "Case Management", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index d5e8470922a9..ee122dcfae4a 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -294,8 +294,10 @@ def initialize "v2.list_apis": false, "v2.update_open_api": false, "v2.get_investigation": false, + "v2.get_monitor_automation": false, "v2.list_investigations": false, "v2.trigger_investigation": false, + "v2.update_monitor_automation": false, "v2.create_change_request": false, "v2.create_change_request_branch": false, "v2.delete_change_request_decision": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index d77f26ec0dac..2e0817210a1f 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -5683,6 +5683,12 @@ def overrides "v2.monitor_alert_trigger" => "MonitorAlertTrigger", "v2.monitor_alert_trigger_attributes" => "MonitorAlertTriggerAttributes", "v2.monitor_alert_trigger_type" => "MonitorAlertTriggerType", + "v2.monitor_automation_attributes" => "MonitorAutomationAttributes", + "v2.monitor_automation_data" => "MonitorAutomationData", + "v2.monitor_automation_request" => "MonitorAutomationRequest", + "v2.monitor_automation_request_data" => "MonitorAutomationRequestData", + "v2.monitor_automation_response" => "MonitorAutomationResponse", + "v2.monitor_automation_type" => "MonitorAutomationType", "v2.monitor_config_policy_attribute_create_request" => "MonitorConfigPolicyAttributeCreateRequest", "v2.monitor_config_policy_attribute_edit_request" => "MonitorConfigPolicyAttributeEditRequest", "v2.monitor_config_policy_attribute_response" => "MonitorConfigPolicyAttributeResponse", diff --git a/lib/datadog_api_client/v2/api/bits_ai_api.rb b/lib/datadog_api_client/v2/api/bits_ai_api.rb index 65657e8bd760..1044619892d7 100644 --- a/lib/datadog_api_client/v2/api/bits_ai_api.rb +++ b/lib/datadog_api_client/v2/api/bits_ai_api.rb @@ -94,6 +94,80 @@ def get_investigation_with_http_info(id, opts = {}) return data, status_code, headers end + # Get automatic investigation settings for a monitor. + # + # @see #get_monitor_automation_with_http_info + def get_monitor_automation(monitor_id, opts = {}) + data, _status_code, _headers = get_monitor_automation_with_http_info(monitor_id, opts) + data + end + + # Get automatic investigation settings for a monitor. + # + # Manage the Bits automatic investigation setting independently of the monitor definition. Requires access to the monitor and the specified permissions. A newly created monitor and updated settings can take time to appear in reads. + # + # @param monitor_id [Integer] The monitor ID. + # @param opts [Hash] the optional parameters + # @return [Array<(MonitorAutomationResponse, Integer, Hash)>] MonitorAutomationResponse data, response status code and response headers + def get_monitor_automation_with_http_info(monitor_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_monitor_automation".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_monitor_automation") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_monitor_automation")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: BitsAIAPI.get_monitor_automation ...' + end + # verify the required parameter 'monitor_id' is set + if @api_client.config.client_side_validation && monitor_id.nil? + fail ArgumentError, "Missing the required parameter 'monitor_id' when calling BitsAIAPI.get_monitor_automation" + end + if @api_client.config.client_side_validation && monitor_id < 1 + fail ArgumentError, 'invalid value for "monitor_id" when calling BitsAIAPI.get_monitor_automation, must be greater than or equal to 1.' + end + # resource path + local_var_path = '/api/v2/bits-ai/monitors/{monitor_id}/automation'.sub('{monitor_id}', CGI.escape(monitor_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] || 'MonitorAutomationResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_monitor_automation, + :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: BitsAIAPI#get_monitor_automation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List Bits AI investigations. # # @see #list_investigations_with_http_info @@ -263,5 +337,86 @@ def trigger_investigation_with_http_info(body, opts = {}) end return data, status_code, headers end + + # Update monitor automatic investigation settings. + # + # @see #update_monitor_automation_with_http_info + def update_monitor_automation(monitor_id, body, opts = {}) + data, _status_code, _headers = update_monitor_automation_with_http_info(monitor_id, body, opts) + data + end + + # Update monitor automatic investigation settings. + # + # Manage the Bits automatic investigation setting independently of the monitor definition. Requires access to the monitor and the specified permissions. A newly created monitor and updated settings can take time to appear in reads. The enabled attribute is required; false disables automatic investigations. Repeated requests set the same desired state. This operation does not create or delete the monitor. + # + # @param monitor_id [Integer] The monitor ID. + # @param body [MonitorAutomationRequest] Automatic investigation settings to apply. + # @param opts [Hash] the optional parameters + # @return [Array<(MonitorAutomationResponse, Integer, Hash)>] MonitorAutomationResponse data, response status code and response headers + def update_monitor_automation_with_http_info(monitor_id, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.update_monitor_automation".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.update_monitor_automation") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.update_monitor_automation")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: BitsAIAPI.update_monitor_automation ...' + end + # verify the required parameter 'monitor_id' is set + if @api_client.config.client_side_validation && monitor_id.nil? + fail ArgumentError, "Missing the required parameter 'monitor_id' when calling BitsAIAPI.update_monitor_automation" + end + if @api_client.config.client_side_validation && monitor_id < 1 + fail ArgumentError, 'invalid value for "monitor_id" when calling BitsAIAPI.update_monitor_automation, must be greater than or equal to 1.' + 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 BitsAIAPI.update_monitor_automation" + end + # resource path + local_var_path = '/api/v2/bits-ai/monitors/{monitor_id}/automation'.sub('{monitor_id}', CGI.escape(monitor_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] || 'MonitorAutomationResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :update_monitor_automation, + :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::Put, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: BitsAIAPI#update_monitor_automation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/datadog_api_client/v2/models/monitor_automation_attributes.rb b/lib/datadog_api_client/v2/models/monitor_automation_attributes.rb new file mode 100644 index 000000000000..8dcf94d91bae --- /dev/null +++ b/lib/datadog_api_client/v2/models/monitor_automation_attributes.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 + # Automatic investigation settings for a monitor. + class MonitorAutomationAttributes + include BaseGenericModel + + # Whether Bits automatically investigates alerts from this monitor. + attr_reader :enabled + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'enabled' => :'enabled' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'enabled' => :'Boolean' + } + 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::MonitorAutomationAttributes` 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?(:'enabled') + self.enabled = attributes[:'enabled'] + 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 @enabled.nil? + true + end + + # Custom attribute writer method with validation + # @param enabled [Object] Object to be assigned + # @!visibility private + def enabled=(enabled) + if enabled.nil? + fail ArgumentError, 'invalid value for "enabled", enabled cannot be nil.' + end + @enabled = enabled + 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 && + enabled == o.enabled && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [enabled, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/monitor_automation_data.rb b/lib/datadog_api_client/v2/models/monitor_automation_data.rb new file mode 100644 index 000000000000..baa19cc5b0c0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/monitor_automation_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 + # Automatic investigation configuration identified by monitor ID. + class MonitorAutomationData + include BaseGenericModel + + # Automatic investigation settings for a monitor. + attr_reader :attributes + + # The monitor ID. + attr_reader :id + + # The resource type for monitor automation settings. + 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' => :'MonitorAutomationAttributes', + :'id' => :'String', + :'type' => :'MonitorAutomationType' + } + 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::MonitorAutomationData` 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/monitor_automation_request.rb b/lib/datadog_api_client/v2/models/monitor_automation_request.rb new file mode 100644 index 000000000000..08bc0f313083 --- /dev/null +++ b/lib/datadog_api_client/v2/models/monitor_automation_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 + # Set whether Bits automatically investigates alerts from a monitor. + class MonitorAutomationRequest + include BaseGenericModel + + # The automatic investigation settings to apply. + 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' => :'MonitorAutomationRequestData' + } + 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::MonitorAutomationRequest` 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/monitor_automation_request_data.rb b/lib/datadog_api_client/v2/models/monitor_automation_request_data.rb new file mode 100644 index 000000000000..7b79683f67fe --- /dev/null +++ b/lib/datadog_api_client/v2/models/monitor_automation_request_data.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The automatic investigation settings to apply. + class MonitorAutomationRequestData + include BaseGenericModel + + # Automatic investigation settings for a monitor. + attr_reader :attributes + + # The resource type for monitor automation settings. + 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' => :'MonitorAutomationAttributes', + :'type' => :'MonitorAutomationType' + } + 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::MonitorAutomationRequestData` 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/monitor_automation_response.rb b/lib/datadog_api_client/v2/models/monitor_automation_response.rb new file mode 100644 index 000000000000..c6a37df2c597 --- /dev/null +++ b/lib/datadog_api_client/v2/models/monitor_automation_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 + # Automatic investigation settings for a monitor. + class MonitorAutomationResponse + include BaseGenericModel + + # Automatic investigation configuration identified by monitor ID. + 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' => :'MonitorAutomationData' + } + 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::MonitorAutomationResponse` 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/monitor_automation_type.rb b/lib/datadog_api_client/v2/models/monitor_automation_type.rb new file mode 100644 index 000000000000..4845a88a9cfc --- /dev/null +++ b/lib/datadog_api_client/v2/models/monitor_automation_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The resource type for monitor automation settings. + class MonitorAutomationType + include BaseEnumModel + + MONITOR_AUTOMATION = "monitor_automation".freeze + end +end