diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index e4c949659000..4fc8dbe37859 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -7255,6 +7255,12 @@ components: Monitor: description: Object describing a monitor. properties: + assets: + description: The list of monitor assets tied to a monitor, which represents + key links for users to take action on monitor alerts (for example, runbooks). + items: + $ref: '#/components/schemas/MonitorAsset' + type: array created: description: Timestamp of the monitor creation. format: date-time @@ -7338,6 +7344,52 @@ components: - type - query type: object + MonitorAsset: + description: 'Represents key links tied to a monitor to help users take action + on alerts. + + This feature is in Preview and only available to users with the feature enabled.' + properties: + category: + $ref: '#/components/schemas/MonitorAssetCategory' + name: + description: Name for the monitor asset + example: Monitor Runbook + type: string + resource_key: + description: Represents the identifier of the internal Datadog resource + that this asset represents. IDs in this field should be passed in as strings. + example: '12345' + type: string + resource_type: + $ref: '#/components/schemas/MonitorAssetResourceType' + url: + description: URL link for the asset. For links with an internal resource + type set, this should be the relative path to where the Datadog domain + is appended internally. For external links, this should be the full URL + path. + example: /notebooks/12345 + type: string + required: + - name + - url + - category + type: object + MonitorAssetCategory: + description: Indicates the type of asset this entity represents on a monitor. + enum: + - runbook + example: runbook + type: string + x-enum-varnames: + - RUNBOOK + MonitorAssetResourceType: + description: Type of internal Datadog resource associated with a monitor asset. + enum: + - notebook + type: string + x-enum-varnames: + - NOTEBOOK MonitorDeviceID: description: ID of the device the Synthetics monitor is running on. Same as `SyntheticsDeviceID`. @@ -8452,6 +8504,13 @@ components: MonitorUpdateRequest: description: Object describing a monitor update request. properties: + assets: + description: The list of monitor assets tied to a monitor, which represents + key links for users to take action on monitor alerts (for example, runbooks). + items: + $ref: '#/components/schemas/MonitorAsset' + nullable: true + type: array created: description: Timestamp of the monitor creation. format: date-time @@ -31584,6 +31643,13 @@ paths: required: false schema: type: boolean + - description: If this argument is set to `true`, the returned data includes + all assets tied to this monitor. + in: query + name: with_assets + required: false + schema: + type: boolean responses: '200': content: diff --git a/cassettes/features/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.frozen b/cassettes/features/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.frozen index 2dbbd94e2877..9dda83bd1cf5 100644 --- a/cassettes/features/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.frozen +++ b/cassettes/features/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.frozen @@ -1 +1 @@ -2024-10-10T16:41:03.364Z \ No newline at end of file +2025-11-21T18:03:25.715Z \ No newline at end of file diff --git a/cassettes/features/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.yml b/cassettes/features/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.yml index 97803eec7eda..088bffbea0ad 100644 --- a/cassettes/features/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.yml +++ b/cassettes/features/v1/monitors/Check-if-a-monitor-can-be-deleted-returns-OK-response.yml @@ -1,12 +1,12 @@ http_interactions: -- recorded_at: Thu, 10 Oct 2024 16:41:03 GMT +- recorded_at: Fri, 21 Nov 2025 18:03:25 GMT request: body: encoding: UTF-8 - string: '{"message":"some message Notify: @hipchat-channel","name":"Test-Check_if_a_monitor_can_be_deleted_returns_OK_response-1728578463","options":{"enable_logs_sample":true,"escalation_message":"the + string: '{"message":"some message Notify: @hipchat-channel","name":"Test-Check_if_a_monitor_can_be_deleted_returns_OK_response-1763748205","options":{"enable_logs_sample":true,"escalation_message":"the situation has escalated","evaluation_delay":700,"include_tags":true,"locked":false,"new_host_delay":600,"no_data_timeframe":null,"notification_preset_name":"hide_handles","notify_audit":false,"notify_no_data":false,"on_missing_data":"show_and_notify_no_data","renotify_interval":60,"require_full_window":true,"thresholds":{"critical":2,"warning":1},"timeout_h":24},"priority":3,"query":"logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\") - > 2","tags":["test:testcheckifamonitorcanbedeletedreturnsokresponse1728578463","env:ci"],"type":"log + > 2","tags":["test:testcheckifamonitorcanbedeletedreturnsokresponse1763748205","env:ci"],"type":"log alert"}' headers: Accept: @@ -18,12 +18,12 @@ http_interactions: response: body: encoding: UTF-8 - string: '{"id":155845287,"org_id":321813,"type":"log alert","name":"Test-Check_if_a_monitor_can_be_deleted_returns_OK_response-1728578463","message":"some - message Notify: @hipchat-channel","tags":["test:testcheckifamonitorcanbedeletedreturnsokresponse1728578463","env:ci"],"query":"logs(\"service:foo + string: '{"id":238669218,"org_id":197728,"type":"log alert","name":"Test-Check_if_a_monitor_can_be_deleted_returns_OK_response-1763748205","message":"some + message Notify: @hipchat-channel","tags":["test:testcheckifamonitorcanbedeletedreturnsokresponse1763748205","env:ci"],"query":"logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\") > 2","options":{"enable_logs_sample":true,"escalation_message":"the situation - has escalated","evaluation_delay":700,"include_tags":true,"locked":false,"new_host_delay":600,"no_data_timeframe":null,"notification_preset_name":"hide_handles","notify_audit":false,"notify_no_data":false,"on_missing_data":"show_and_notify_no_data","renotify_interval":60,"require_full_window":true,"thresholds":{"critical":2.0,"warning":1.0},"timeout_h":24,"groupby_simple_monitor":false,"silenced":{}},"multi":true,"created_at":1728578463000,"created":"2024-10-10T16:41:03.666877+00:00","modified":"2024-10-10T16:41:03.666877+00:00","deleted":null,"restricted_roles":null,"priority":3,"restriction_policy":null,"overall_state_modified":null,"overall_state":"No - Data","creator":{"name":null,"handle":"frog@datadoghq.com","email":"frog@datadoghq.com","id":1445416}} + has escalated","evaluation_delay":700,"include_tags":true,"locked":false,"new_host_delay":600,"no_data_timeframe":null,"notification_preset_name":"hide_handles","notify_audit":false,"notify_no_data":false,"on_missing_data":"show_and_notify_no_data","renotify_interval":60,"require_full_window":true,"thresholds":{"critical":2.0,"warning":1.0},"timeout_h":24,"groupby_simple_monitor":false,"silenced":{}},"multi":true,"created_at":1763748206000,"created":"2025-11-21T18:03:26.123200+00:00","modified":"2025-11-21T18:03:26.123200+00:00","deleted":null,"priority":3,"restricted_roles":null,"restriction_policy":null,"draft_status":"published","assets":[],"overall_state_modified":null,"overall_state":"No + Data","creator":{"name":"Kevin Pombo","handle":"kevin.pombo@datadoghq.com","email":"kevin.pombo@datadoghq.com","id":25712273}} ' headers: @@ -32,18 +32,18 @@ http_interactions: status: code: 200 message: OK -- recorded_at: Thu, 10 Oct 2024 16:41:03 GMT +- recorded_at: Fri, 21 Nov 2025 18:03:25 GMT request: body: null headers: Accept: - application/json method: GET - uri: https://api.datadoghq.com/api/v1/monitor/can_delete?monitor_ids=155845287 + uri: https://api.datadoghq.com/api/v1/monitor/can_delete?monitor_ids=238669218 response: body: encoding: UTF-8 - string: '{"data":{"ok":[155845287]},"errors":null} + string: '{"data":{"ok":[238669218]},"errors":null} ' headers: @@ -52,18 +52,18 @@ http_interactions: status: code: 200 message: OK -- recorded_at: Thu, 10 Oct 2024 16:41:03 GMT +- recorded_at: Fri, 21 Nov 2025 18:03:25 GMT request: body: null headers: Accept: - application/json method: DELETE - uri: https://api.datadoghq.com/api/v1/monitor/155845287 + uri: https://api.datadoghq.com/api/v1/monitor/238669218 response: body: encoding: UTF-8 - string: '{"deleted_monitor_id":155845287} + string: '{"deleted_monitor_id":238669218} ' headers: diff --git a/cassettes/features/v1/monitors/Create-a-monitor-with-assets-returns-OK-response.frozen b/cassettes/features/v1/monitors/Create-a-monitor-with-assets-returns-OK-response.frozen new file mode 100644 index 000000000000..12b1e5fed0c7 --- /dev/null +++ b/cassettes/features/v1/monitors/Create-a-monitor-with-assets-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-21T19:04:55.769Z \ No newline at end of file diff --git a/cassettes/features/v1/monitors/Create-a-monitor-with-assets-returns-OK-response.yml b/cassettes/features/v1/monitors/Create-a-monitor-with-assets-returns-OK-response.yml new file mode 100644 index 000000000000..fb72d83ab9e9 --- /dev/null +++ b/cassettes/features/v1/monitors/Create-a-monitor-with-assets-returns-OK-response.yml @@ -0,0 +1,52 @@ +http_interactions: +- recorded_at: Fri, 21 Nov 2025 19:04:55 GMT + request: + body: + encoding: UTF-8 + string: '{"assets":[{"category":"runbook","name":"Monitor Runbook","resource_key":"12345","resource_type":"notebook","url":"/notebooks/12345"}],"message":"some + message Notify: @hipchat-channel","name":"Test-Create_a_monitor_with_assets_returns_OK_response-1763751895","options":{"scheduling_options":{"evaluation_window":{"day_starts":"04:00","month_starts":1}},"thresholds":{"critical":0.5}},"query":"avg(current_1mo):avg:system.load.5{*} + > 0.5","type":"metric alert"}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/monitor + response: + body: + encoding: UTF-8 + string: '{"id":238681257,"org_id":321813,"type":"query alert","name":"Test-Create_a_monitor_with_assets_returns_OK_response-1763751895","message":"some + message Notify: @hipchat-channel","tags":[],"query":"avg(current_1mo):avg:system.load.5{*} + > 0.5","options":{"scheduling_options":{"evaluation_window":{"day_starts":"04:00","month_starts":1}},"thresholds":{"critical":0.5},"notify_no_data":false,"notify_audit":false,"new_host_delay":300,"include_tags":true,"silenced":{}},"multi":false,"created_at":1763751896000,"created":"2025-11-21T19:04:56.060346+00:00","modified":"2025-11-21T19:04:56.060346+00:00","deleted":null,"priority":null,"restricted_roles":null,"restriction_policy":null,"draft_status":"published","assets":[{"monitor_id":238681257,"name":"Monitor + Runbook","category":"runbook","url":"/notebooks/12345","template_variables":{},"options":{},"resource_key":"12345","resource_type":"notebook"}],"overall_state_modified":null,"overall_state":"No + Data","creator":{"name":"CI Account","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","email":"team-intg-tools-libs-spam@datadoghq.com","id":2320499}} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Fri, 21 Nov 2025 19:04:55 GMT + request: + body: null + headers: + Accept: + - application/json + method: DELETE + uri: https://api.datadoghq.com/api/v1/monitor/238681257 + response: + body: + encoding: UTF-8 + string: '{"deleted_monitor_id":238681257} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v1/monitors/CreateMonitor_3541766733.rb b/examples/v1/monitors/CreateMonitor_3541766733.rb new file mode 100644 index 000000000000..c7ea5f06b0e3 --- /dev/null +++ b/examples/v1/monitors/CreateMonitor_3541766733.rb @@ -0,0 +1,32 @@ +# Create a monitor with assets returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::MonitorsAPI.new + +body = DatadogAPIClient::V1::Monitor.new({ + assets: [ + DatadogAPIClient::V1::MonitorAsset.new({ + category: DatadogAPIClient::V1::MonitorAssetCategory::RUNBOOK, + name: "Monitor Runbook", + resource_key: "12345", + resource_type: DatadogAPIClient::V1::MonitorAssetResourceType::NOTEBOOK, + url: "/notebooks/12345", + }), + ], + name: "Example-Monitor", + type: DatadogAPIClient::V1::MonitorType::METRIC_ALERT, + query: "avg(current_1mo):avg:system.load.5{*} > 0.5", + message: "some message Notify: @hipchat-channel", + options: DatadogAPIClient::V1::MonitorOptions.new({ + thresholds: DatadogAPIClient::V1::MonitorThresholds.new({ + critical: 0.5, + }), + scheduling_options: DatadogAPIClient::V1::MonitorOptionsSchedulingOptions.new({ + evaluation_window: DatadogAPIClient::V1::MonitorOptionsSchedulingOptionsEvaluationWindow.new({ + day_starts: "04:00", + month_starts: 1, + }), + }), + }), +}) +p api_instance.create_monitor(body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 15e1897d6c51..3401b2ec9a97 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -565,6 +565,7 @@ "monitor_id" => "Integer", "group_states" => "String", "with_downtimes" => "Boolean", + "with_assets" => "Boolean", }, "v1.UpdateMonitor" => { "monitor_id" => "Integer", diff --git a/features/v1/monitors.feature b/features/v1/monitors.feature index 64e72f698b4d..75a681927b95 100644 --- a/features/v1/monitors.feature +++ b/features/v1/monitors.feature @@ -131,6 +131,18 @@ Feature: Monitors And the response "type" is equal to "log alert" And the response "query" is equal to "logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\") > 2" + @team:DataDog/monitor-app + Scenario: Create a monitor with assets returns "OK" response + Given new "CreateMonitor" request + And body with value {"assets": [{"category": "runbook", "name": "Monitor Runbook", "resource_key": "12345", "resource_type": "notebook", "url": "/notebooks/12345"}], "name": "{{ unique }}", "type": "metric alert", "query": "avg(current_1mo):avg:system.load.5{*} > 0.5", "message": "some message Notify: @hipchat-channel", "options":{"thresholds":{"critical":0.5}, "scheduling_options":{"evaluation_window":{"day_starts":"04:00", "month_starts":1}}}} + When the request is sent + Then the response status is 200 OK + And the response "assets[0].category" is equal to "runbook" + And the response "assets[0].name" is equal to "Monitor Runbook" + And the response "assets[0].resource_key" is equal to "12345" + And the response "assets[0].resource_type" is equal to "notebook" + And the response "assets[0].url" is equal to "/notebooks/12345" + @team:DataDog/monitor-app Scenario: Create an Error Tracking monitor returns "OK" response Given new "CreateMonitor" request @@ -169,7 +181,7 @@ Feature: Monitors Scenario: Edit a monitor returns "Bad Request" response Given new "UpdateMonitor" request And request contains "monitor_id" parameter from "REPLACE.ME" - And body with value {"draft_status": "published", "options": {"evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1, "timezone": "Europe/Paris"}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "priority": null, "restricted_roles": [], "tags": [], "type": "query alert"} + And body with value {"assets": [{"category": "runbook", "name": "Monitor Runbook", "resource_key": "12345", "resource_type": "notebook", "url": "/notebooks/12345"}], "draft_status": "published", "options": {"evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1, "timezone": "Europe/Paris"}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "priority": null, "restricted_roles": [], "tags": [], "type": "query alert"} When the request is sent Then the response status is 400 Bad Request diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 427fdcf8659c..a3d0e141db66 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -321,6 +321,9 @@ def overrides "v1.metrics_query_response" => "MetricsQueryResponse", "v1.metrics_query_unit" => "MetricsQueryUnit", "v1.monitor" => "Monitor", + "v1.monitor_asset" => "MonitorAsset", + "v1.monitor_asset_category" => "MonitorAssetCategory", + "v1.monitor_asset_resource_type" => "MonitorAssetResourceType", "v1.monitor_device_id" => "MonitorDeviceID", "v1.monitor_draft_status" => "MonitorDraftStatus", "v1.monitor_formula_and_function_cost_aggregator" => "MonitorFormulaAndFunctionCostAggregator", diff --git a/lib/datadog_api_client/v1/api/monitors_api.rb b/lib/datadog_api_client/v1/api/monitors_api.rb index 4a46a009ecbf..24041dcf2bd5 100644 --- a/lib/datadog_api_client/v1/api/monitors_api.rb +++ b/lib/datadog_api_client/v1/api/monitors_api.rb @@ -456,6 +456,7 @@ def get_monitor(monitor_id, opts = {}) # @param opts [Hash] the optional parameters # @option opts [String] :group_states When specified, shows additional information about the group states. Choose one or more from `all`, `alert`, `warn`, and `no data`. # @option opts [Boolean] :with_downtimes If this argument is set to true, then the returned data includes all current active downtimes for the monitor. + # @option opts [Boolean] :with_assets If this argument is set to `true`, the returned data includes all assets tied to this monitor. # @return [Array<(Monitor, Integer, Hash)>] Monitor data, response status code and response headers def get_monitor_with_http_info(monitor_id, opts = {}) @@ -473,6 +474,7 @@ def get_monitor_with_http_info(monitor_id, opts = {}) query_params = opts[:query_params] || {} query_params[:'group_states'] = opts[:'group_states'] if !opts[:'group_states'].nil? query_params[:'with_downtimes'] = opts[:'with_downtimes'] if !opts[:'with_downtimes'].nil? + query_params[:'with_assets'] = opts[:'with_assets'] if !opts[:'with_assets'].nil? # header parameters header_params = opts[:header_params] || {} diff --git a/lib/datadog_api_client/v1/models/monitor.rb b/lib/datadog_api_client/v1/models/monitor.rb index 5d67b95e73f7..2f9350f46080 100644 --- a/lib/datadog_api_client/v1/models/monitor.rb +++ b/lib/datadog_api_client/v1/models/monitor.rb @@ -21,6 +21,9 @@ module DatadogAPIClient::V1 class Monitor include BaseGenericModel + # The list of monitor assets tied to a monitor, which represents key links for users to take action on monitor alerts (for example, runbooks). + attr_accessor :assets + # Timestamp of the monitor creation. attr_accessor :created @@ -86,6 +89,7 @@ class Monitor # @!visibility private def self.attribute_map { + :'assets' => :'assets', :'created' => :'created', :'creator' => :'creator', :'deleted' => :'deleted', @@ -111,6 +115,7 @@ def self.attribute_map # @!visibility private def self.openapi_types { + :'assets' => :'Array', :'created' => :'Time', :'creator' => :'Creator', :'deleted' => :'Time', @@ -160,6 +165,12 @@ def initialize(attributes = {}) end } + if attributes.key?(:'assets') + if (value = attributes[:'assets']).is_a?(Array) + self.assets = value + end + end + if attributes.key?(:'created') self.created = attributes[:'created'] end @@ -294,6 +305,7 @@ def to_hash def ==(o) return true if self.equal?(o) self.class == o.class && + assets == o.assets && created == o.created && creator == o.creator && deleted == o.deleted && @@ -319,7 +331,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [created, creator, deleted, draft_status, id, matching_downtimes, message, modified, multi, name, options, overall_state, priority, query, restricted_roles, state, tags, type, additional_properties].hash + [assets, created, creator, deleted, draft_status, id, matching_downtimes, message, modified, multi, name, options, overall_state, priority, query, restricted_roles, state, tags, type, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v1/models/monitor_asset.rb b/lib/datadog_api_client/v1/models/monitor_asset.rb new file mode 100644 index 000000000000..94ddf22e817e --- /dev/null +++ b/lib/datadog_api_client/v1/models/monitor_asset.rb @@ -0,0 +1,186 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # Represents key links tied to a monitor to help users take action on alerts. + # This feature is in Preview and only available to users with the feature enabled. + class MonitorAsset + include BaseGenericModel + + # Indicates the type of asset this entity represents on a monitor. + attr_reader :category + + # Name for the monitor asset + attr_reader :name + + # Represents the identifier of the internal Datadog resource that this asset represents. IDs in this field should be passed in as strings. + attr_accessor :resource_key + + # Type of internal Datadog resource associated with a monitor asset. + attr_accessor :resource_type + + # URL link for the asset. For links with an internal resource type set, this should be the relative path to where the Datadog domain is appended internally. For external links, this should be the full URL path. + attr_reader :url + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'category' => :'category', + :'name' => :'name', + :'resource_key' => :'resource_key', + :'resource_type' => :'resource_type', + :'url' => :'url' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'category' => :'MonitorAssetCategory', + :'name' => :'String', + :'resource_key' => :'String', + :'resource_type' => :'MonitorAssetResourceType', + :'url' => :'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::V1::MonitorAsset` 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?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'resource_key') + self.resource_key = attributes[:'resource_key'] + end + + if attributes.key?(:'resource_type') + self.resource_type = attributes[:'resource_type'] + end + + if attributes.key?(:'url') + self.url = attributes[:'url'] + 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 @category.nil? + return false if @name.nil? + return false if @url.nil? + true + end + + # Custom attribute writer method with validation + # @param category [Object] Object to be assigned + # @!visibility private + def category=(category) + if category.nil? + fail ArgumentError, 'invalid value for "category", category cannot be nil.' + end + @category = category + 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 + + # Custom attribute writer method with validation + # @param url [Object] Object to be assigned + # @!visibility private + def url=(url) + if url.nil? + fail ArgumentError, 'invalid value for "url", url cannot be nil.' + end + @url = url + 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 && + category == o.category && + name == o.name && + resource_key == o.resource_key && + resource_type == o.resource_type && + url == o.url && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [category, name, resource_key, resource_type, url, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/monitor_asset_category.rb b/lib/datadog_api_client/v1/models/monitor_asset_category.rb new file mode 100644 index 000000000000..d397ca00303d --- /dev/null +++ b/lib/datadog_api_client/v1/models/monitor_asset_category.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # Indicates the type of asset this entity represents on a monitor. + class MonitorAssetCategory + include BaseEnumModel + + RUNBOOK = "runbook".freeze + end +end diff --git a/lib/datadog_api_client/v1/models/monitor_asset_resource_type.rb b/lib/datadog_api_client/v1/models/monitor_asset_resource_type.rb new file mode 100644 index 000000000000..76dceddcdc21 --- /dev/null +++ b/lib/datadog_api_client/v1/models/monitor_asset_resource_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # Type of internal Datadog resource associated with a monitor asset. + class MonitorAssetResourceType + include BaseEnumModel + + NOTEBOOK = "notebook".freeze + end +end diff --git a/lib/datadog_api_client/v1/models/monitor_update_request.rb b/lib/datadog_api_client/v1/models/monitor_update_request.rb index 1fdbabef8128..8b96cfbf19b4 100644 --- a/lib/datadog_api_client/v1/models/monitor_update_request.rb +++ b/lib/datadog_api_client/v1/models/monitor_update_request.rb @@ -21,6 +21,9 @@ module DatadogAPIClient::V1 class MonitorUpdateRequest include BaseGenericModel + # The list of monitor assets tied to a monitor, which represents key links for users to take action on monitor alerts (for example, runbooks). + attr_accessor :assets + # Timestamp of the monitor creation. attr_accessor :created @@ -83,6 +86,7 @@ class MonitorUpdateRequest # @!visibility private def self.attribute_map { + :'assets' => :'assets', :'created' => :'created', :'creator' => :'creator', :'deleted' => :'deleted', @@ -107,6 +111,7 @@ def self.attribute_map # @!visibility private def self.openapi_types { + :'assets' => :'Array', :'created' => :'Time', :'creator' => :'Creator', :'deleted' => :'Time', @@ -131,6 +136,7 @@ def self.openapi_types # @!visibility private def self.openapi_nullable Set.new([ + :'assets', :'deleted', :'priority', :'restricted_roles', @@ -155,6 +161,12 @@ def initialize(attributes = {}) end } + if attributes.key?(:'assets') + if (value = attributes[:'assets']).is_a?(Array) + self.assets = value + end + end + if attributes.key?(:'created') self.created = attributes[:'created'] end @@ -254,6 +266,7 @@ def to_hash def ==(o) return true if self.equal?(o) self.class == o.class && + assets == o.assets && created == o.created && creator == o.creator && deleted == o.deleted && @@ -278,7 +291,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [created, creator, deleted, draft_status, id, message, modified, multi, name, options, overall_state, priority, query, restricted_roles, state, tags, type, additional_properties].hash + [assets, created, creator, deleted, draft_status, id, message, modified, multi, name, options, overall_state, priority, query, restricted_roles, state, tags, type, additional_properties].hash end end end