=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 # List of options associated with your monitor. class MonitorOptions include BaseGenericModel # Type of aggregation performed in the monitor query. attr_accessor :aggregation # IDs of the device the Synthetics monitor is running on. attr_accessor :device_ids # Whether or not to send a log sample when the log monitor triggers. attr_accessor :enable_logs_sample # Whether or not to send a list of samples when the monitor triggers. This is only used by CI Test and Pipeline monitors. attr_accessor :enable_samples # We recommend using the [is_renotify](https://docs.datadoghq.com/monitors/notify/?tab=is_alert#renotify), # block in the original message instead. # A message to include with a re-notification. Supports the `@username` notification we allow elsewhere. # Not applicable if `renotify_interval` is `None`. attr_accessor :escalation_message # Time (in seconds) to delay evaluation, as a non-negative integer. For example, if the value is set to `300` (5min), # the timeframe is set to `last_5m` and the time is 7:00, the monitor evaluates data from 6:50 to 6:55. # This is useful for AWS CloudWatch and other backfilled metrics to ensure the monitor always has data during evaluation. attr_accessor :evaluation_delay # The time span after which groups with missing data are dropped from the monitor state. # The minimum value is one hour, and the maximum value is 72 hours. # Example values are: "60m", "1h", and "2d". # This option is only available for APM Trace Analytics, Audit Trail, CI, Error Tracking, Event, Logs, and RUM monitors. attr_accessor :group_retention_duration # Whether the log alert monitor triggers a single alert or multiple alerts when any group breaches a threshold. Use `notify_by` instead. attr_accessor :groupby_simple_monitor # A Boolean indicating whether notifications from this monitor automatically inserts its triggering tags into the title. # # **Examples** # - If `True`, `[Triggered on {host:h1}] Monitor Title` # - If `False`, `[Triggered] Monitor Title` attr_accessor :include_tags # Whether or not the monitor is locked (only editable by creator and admins). Use `restricted_roles` instead. attr_accessor :locked # How long the test should be in failure before alerting (integer, number of seconds, max 7200). attr_reader :min_failure_duration # The minimum number of locations in failure at the same time during # at least one moment in the `min_failure_duration` period (`min_location_failed` and `min_failure_duration` # are part of the advanced alerting rules - integer, >= 1). attr_accessor :min_location_failed # Time (in seconds) to skip evaluations for new groups. # # For example, this option can be used to skip evaluations for new hosts while they initialize. # # Must be a non negative integer. attr_accessor :new_group_delay # Time (in seconds) to allow a host to boot and applications # to fully start before starting the evaluation of monitor results. # Should be a non negative integer. # # Use new_group_delay instead. attr_accessor :new_host_delay # The number of minutes before a monitor notifies after data stops reporting. # Datadog recommends at least 2x the monitor timeframe for query alerts or 2 minutes for service checks. # If omitted, 2x the evaluation timeframe is used for query alerts, and 24 hours is used for service checks. attr_accessor :no_data_timeframe # Toggles the display of additional content sent in the monitor notification. attr_accessor :notification_preset_name # A Boolean indicating whether tagged users is notified on changes to this monitor. attr_accessor :notify_audit # Controls what granularity a monitor alerts on. Only available for monitors with groupings. # For instance, a monitor grouped by `cluster`, `namespace`, and `pod` can be configured to only notify on each # new `cluster` violating the alert conditions by setting `notify_by` to `["cluster"]`. Tags mentioned # in `notify_by` must be a subset of the grouping tags in the query. # For example, a query grouped by `cluster` and `namespace` cannot notify on `region`. # Setting `notify_by` to `[*]` configures the monitor to notify as a simple-alert. attr_accessor :notify_by # A Boolean indicating whether this monitor notifies when data stops reporting. Defaults to `false`. attr_accessor :notify_no_data # Controls how groups or monitors are treated if an evaluation does not return any data points. # The default option results in different behavior depending on the monitor query type. # For monitors using Count queries, an empty monitor evaluation is treated as 0 and is compared to the threshold conditions. # For monitors using any query type other than Count, for example Gauge, Measure, or Rate, the monitor shows the last known status. # This option is only available for APM Trace Analytics, Audit Trail, CI, Error Tracking, Event, Logs, and RUM monitors. attr_accessor :on_missing_data # The number of minutes after the last notification before a monitor re-notifies on the current status. # It only re-notifies if it’s not resolved. attr_accessor :renotify_interval # The number of times re-notification messages should be sent on the current status at the provided re-notification interval. attr_accessor :renotify_occurrences # The types of monitor statuses for which re-notification messages are sent. # Default: **null** if `renotify_interval` is **null**. # If `renotify_interval` is set, defaults to renotify on `Alert` and `No Data`. attr_accessor :renotify_statuses # A Boolean indicating whether this monitor needs a full window of data before it’s evaluated. # We highly recommend you set this to `false` for sparse metrics, # otherwise some evaluations are skipped. Default is false. This setting only applies to # metric monitors. attr_accessor :require_full_window # Configuration options for scheduling. attr_accessor :scheduling_options # Information about the downtime applied to the monitor. Only shows v1 downtimes. attr_accessor :silenced # ID of the corresponding Synthetic check. attr_accessor :synthetics_check_id # Alerting time window options. attr_accessor :threshold_windows # List of the different monitor threshold available. attr_accessor :thresholds # The number of hours of the monitor not reporting data before it automatically resolves from a triggered state. The minimum allowed value is 0 hours. The maximum allowed value is 24 hours. attr_accessor :timeout_h # List of requests that can be used in the monitor query. **This feature is currently in beta.** attr_accessor :variables attr_accessor :additional_properties # Attribute mapping from ruby-style variable name to JSON key. # @!visibility private def self.attribute_map { :'aggregation' => :'aggregation', :'device_ids' => :'device_ids', :'enable_logs_sample' => :'enable_logs_sample', :'enable_samples' => :'enable_samples', :'escalation_message' => :'escalation_message', :'evaluation_delay' => :'evaluation_delay', :'group_retention_duration' => :'group_retention_duration', :'groupby_simple_monitor' => :'groupby_simple_monitor', :'include_tags' => :'include_tags', :'locked' => :'locked', :'min_failure_duration' => :'min_failure_duration', :'min_location_failed' => :'min_location_failed', :'new_group_delay' => :'new_group_delay', :'new_host_delay' => :'new_host_delay', :'no_data_timeframe' => :'no_data_timeframe', :'notification_preset_name' => :'notification_preset_name', :'notify_audit' => :'notify_audit', :'notify_by' => :'notify_by', :'notify_no_data' => :'notify_no_data', :'on_missing_data' => :'on_missing_data', :'renotify_interval' => :'renotify_interval', :'renotify_occurrences' => :'renotify_occurrences', :'renotify_statuses' => :'renotify_statuses', :'require_full_window' => :'require_full_window', :'scheduling_options' => :'scheduling_options', :'silenced' => :'silenced', :'synthetics_check_id' => :'synthetics_check_id', :'threshold_windows' => :'threshold_windows', :'thresholds' => :'thresholds', :'timeout_h' => :'timeout_h', :'variables' => :'variables' } end # Attribute type mapping. # @!visibility private def self.openapi_types { :'aggregation' => :'MonitorOptionsAggregation', :'device_ids' => :'Array', :'enable_logs_sample' => :'Boolean', :'enable_samples' => :'Boolean', :'escalation_message' => :'String', :'evaluation_delay' => :'Integer', :'group_retention_duration' => :'String', :'groupby_simple_monitor' => :'Boolean', :'include_tags' => :'Boolean', :'locked' => :'Boolean', :'min_failure_duration' => :'Integer', :'min_location_failed' => :'Integer', :'new_group_delay' => :'Integer', :'new_host_delay' => :'Integer', :'no_data_timeframe' => :'Integer', :'notification_preset_name' => :'MonitorOptionsNotificationPresets', :'notify_audit' => :'Boolean', :'notify_by' => :'Array', :'notify_no_data' => :'Boolean', :'on_missing_data' => :'OnMissingDataOption', :'renotify_interval' => :'Integer', :'renotify_occurrences' => :'Integer', :'renotify_statuses' => :'Array', :'require_full_window' => :'Boolean', :'scheduling_options' => :'MonitorOptionsSchedulingOptions', :'silenced' => :'Hash', :'synthetics_check_id' => :'String', :'threshold_windows' => :'MonitorThresholdWindowOptions', :'thresholds' => :'MonitorThresholds', :'timeout_h' => :'Integer', :'variables' => :'Array' } end # List of attributes with nullable: true # @!visibility private def self.openapi_nullable Set.new([ :'evaluation_delay', :'min_failure_duration', :'min_location_failed', :'new_group_delay', :'new_host_delay', :'no_data_timeframe', :'renotify_interval', :'renotify_occurrences', :'renotify_statuses', :'synthetics_check_id', :'timeout_h', ]) 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::MonitorOptions` 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?(:'aggregation') self.aggregation = attributes[:'aggregation'] end if attributes.key?(:'device_ids') if (value = attributes[:'device_ids']).is_a?(Array) self.device_ids = value end end if attributes.key?(:'enable_logs_sample') self.enable_logs_sample = attributes[:'enable_logs_sample'] end if attributes.key?(:'enable_samples') self.enable_samples = attributes[:'enable_samples'] end if attributes.key?(:'escalation_message') self.escalation_message = attributes[:'escalation_message'] end if attributes.key?(:'evaluation_delay') self.evaluation_delay = attributes[:'evaluation_delay'] end if attributes.key?(:'group_retention_duration') self.group_retention_duration = attributes[:'group_retention_duration'] end if attributes.key?(:'groupby_simple_monitor') self.groupby_simple_monitor = attributes[:'groupby_simple_monitor'] end if attributes.key?(:'include_tags') self.include_tags = attributes[:'include_tags'] end if attributes.key?(:'locked') self.locked = attributes[:'locked'] end if attributes.key?(:'min_failure_duration') self.min_failure_duration = attributes[:'min_failure_duration'] end if attributes.key?(:'min_location_failed') self.min_location_failed = attributes[:'min_location_failed'] end if attributes.key?(:'new_group_delay') self.new_group_delay = attributes[:'new_group_delay'] end if attributes.key?(:'new_host_delay') self.new_host_delay = attributes[:'new_host_delay'] end if attributes.key?(:'no_data_timeframe') self.no_data_timeframe = attributes[:'no_data_timeframe'] end if attributes.key?(:'notification_preset_name') self.notification_preset_name = attributes[:'notification_preset_name'] end if attributes.key?(:'notify_audit') self.notify_audit = attributes[:'notify_audit'] end if attributes.key?(:'notify_by') if (value = attributes[:'notify_by']).is_a?(Array) self.notify_by = value end end if attributes.key?(:'notify_no_data') self.notify_no_data = attributes[:'notify_no_data'] end if attributes.key?(:'on_missing_data') self.on_missing_data = attributes[:'on_missing_data'] end if attributes.key?(:'renotify_interval') self.renotify_interval = attributes[:'renotify_interval'] end if attributes.key?(:'renotify_occurrences') self.renotify_occurrences = attributes[:'renotify_occurrences'] end if attributes.key?(:'renotify_statuses') if (value = attributes[:'renotify_statuses']).is_a?(Array) self.renotify_statuses = value end end if attributes.key?(:'require_full_window') self.require_full_window = attributes[:'require_full_window'] end if attributes.key?(:'scheduling_options') self.scheduling_options = attributes[:'scheduling_options'] end if attributes.key?(:'silenced') self.silenced = attributes[:'silenced'] end if attributes.key?(:'synthetics_check_id') self.synthetics_check_id = attributes[:'synthetics_check_id'] end if attributes.key?(:'threshold_windows') self.threshold_windows = attributes[:'threshold_windows'] end if attributes.key?(:'thresholds') self.thresholds = attributes[:'thresholds'] end if attributes.key?(:'timeout_h') self.timeout_h = attributes[:'timeout_h'] end if attributes.key?(:'variables') if (value = attributes[:'variables']).is_a?(Array) self.variables = 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 !@min_failure_duration.nil? && @min_failure_duration > 7200 return false if !@min_failure_duration.nil? && @min_failure_duration < 0 true end # Custom attribute writer method with validation # @param min_failure_duration [Object] Object to be assigned # @!visibility private def min_failure_duration=(min_failure_duration) if !min_failure_duration.nil? && min_failure_duration > 7200 fail ArgumentError, 'invalid value for "min_failure_duration", must be smaller than or equal to 7200.' end if !min_failure_duration.nil? && min_failure_duration < 0 fail ArgumentError, 'invalid value for "min_failure_duration", must be greater than or equal to 0.' end @min_failure_duration = min_failure_duration 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 && aggregation == o.aggregation && device_ids == o.device_ids && enable_logs_sample == o.enable_logs_sample && enable_samples == o.enable_samples && escalation_message == o.escalation_message && evaluation_delay == o.evaluation_delay && group_retention_duration == o.group_retention_duration && groupby_simple_monitor == o.groupby_simple_monitor && include_tags == o.include_tags && locked == o.locked && min_failure_duration == o.min_failure_duration && min_location_failed == o.min_location_failed && new_group_delay == o.new_group_delay && new_host_delay == o.new_host_delay && no_data_timeframe == o.no_data_timeframe && notification_preset_name == o.notification_preset_name && notify_audit == o.notify_audit && notify_by == o.notify_by && notify_no_data == o.notify_no_data && on_missing_data == o.on_missing_data && renotify_interval == o.renotify_interval && renotify_occurrences == o.renotify_occurrences && renotify_statuses == o.renotify_statuses && require_full_window == o.require_full_window && scheduling_options == o.scheduling_options && silenced == o.silenced && synthetics_check_id == o.synthetics_check_id && threshold_windows == o.threshold_windows && thresholds == o.thresholds && timeout_h == o.timeout_h && variables == o.variables additional_properties == o.additional_properties end # Calculates hash code according to all attributes. # @return [Integer] Hash code # @!visibility private def hash [aggregation, device_ids, enable_logs_sample, enable_samples, escalation_message, evaluation_delay, group_retention_duration, groupby_simple_monitor, include_tags, locked, min_failure_duration, min_location_failed, new_group_delay, new_host_delay, no_data_timeframe, notification_preset_name, notify_audit, notify_by, notify_no_data, on_missing_data, renotify_interval, renotify_occurrences, renotify_statuses, require_full_window, scheduling_options, silenced, synthetics_check_id, threshold_windows, thresholds, timeout_h, variables].hash end end end