diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 2ba4dbf6d68b..729000cd1e6c 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -1443,6 +1443,10 @@ components: format: date-time readOnly: true type: string + default_timeframe: + $ref: "#/components/schemas/DashboardDefaultTimeframeSetting" + description: The default timeframe applied when opening the dashboard. Set to `null` to clear. + nullable: true description: description: Description of the dashboard. nullable: true @@ -1557,6 +1561,11 @@ components: required: - data type: object + DashboardDefaultTimeframeSetting: + description: The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe. + oneOf: + - $ref: "#/components/schemas/DashboardLiveTimeframe" + - $ref: "#/components/schemas/DashboardFixedTimeframe" DashboardDeleteResponse: description: Response from the delete dashboard call. properties: @@ -1564,6 +1573,36 @@ components: description: ID of the deleted dashboard. type: string type: object + DashboardFixedTimeframe: + description: A fixed dashboard timeframe. + properties: + from: + description: Start time in milliseconds since epoch. + example: 1712080128000 + format: int64 + minimum: 0 + type: integer + to: + description: End time in milliseconds since epoch. + example: 1712083128000 + format: int64 + minimum: 0 + type: integer + type: + $ref: "#/components/schemas/DashboardFixedTimeframeType" + required: + - type + - from + - to + type: object + DashboardFixedTimeframeType: + description: Type of fixed timeframe. + enum: + - fixed + example: fixed + type: string + x-enum-varnames: + - FIXED DashboardGlobalTime: description: Object containing the live span selection for the dashboard. properties: @@ -1672,6 +1711,32 @@ components: $ref: "#/components/schemas/DashboardList" type: array type: object + DashboardLiveTimeframe: + description: A live dashboard timeframe. + properties: + type: + $ref: "#/components/schemas/DashboardLiveTimeframeType" + unit: + $ref: "#/components/schemas/WidgetLiveSpanUnit" + value: + description: Value of the live timeframe span. + example: 4 + format: int64 + minimum: 1 + type: integer + required: + - type + - value + - unit + type: object + DashboardLiveTimeframeType: + description: Type of live timeframe. + enum: + - live + example: live + type: string + x-enum-varnames: + - LIVE DashboardReflowType: description: |- Reflow type for a **new dashboard layout** dashboard. Set this only when layout type is 'ordered'. diff --git a/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-live-default-timeframe-returns-OK-response.frozen b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-live-default-timeframe-returns-OK-response.frozen new file mode 100644 index 000000000000..cd5f7343babc --- /dev/null +++ b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-live-default-timeframe-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-22T17:48:02.651Z \ No newline at end of file diff --git a/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-live-default-timeframe-returns-OK-response.yml b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-live-default-timeframe-returns-OK-response.yml new file mode 100644 index 000000000000..2b8231711e83 --- /dev/null +++ b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-live-default-timeframe-returns-OK-response.yml @@ -0,0 +1,43 @@ +http_interactions: +- recorded_at: Mon, 22 Jun 2026 17:48:02 GMT + request: + body: + encoding: UTF-8 + string: '{"default_timeframe":{"type":"live","unit":"hour","value":4},"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_a_live_default_timeframe_returns_OK_response-1782150482","widgets":[{"definition":{"background_color":"white","content":"test","font_size":"14","show_tick":false,"text_align":"left","tick_edge":"left","tick_pos":"50%","type":"note"}}]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/dashboard + response: + body: + encoding: UTF-8 + string: '{"id":"3v2-z74-apr","title":"Test-Create_a_new_dashboard_with_a_live_default_timeframe_returns_OK_response-1782150482","description":null,"author_handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","author_name":"CI + Account","layout_type":"ordered","url":"/dashboard/3v2-z74-apr/test-createanewdashboardwithalivedefaulttimeframereturnsokresponse-1782150482","template_variables":null,"widgets":[{"definition":{"background_color":"white","content":"test","font_size":"14","show_tick":false,"text_align":"left","tick_edge":"left","tick_pos":"50%","type":"note"},"id":2716227217953845}],"notify_list":null,"created_at":"2026-06-22T17:48:02.860491+00:00","modified_at":"2026-06-22T17:48:02.860491+00:00","default_timeframe":{"type":"live","unit":"hour","value":4},"restricted_roles":[]}' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Mon, 22 Jun 2026 17:48:02 GMT + request: + body: null + headers: + Accept: + - application/json + method: DELETE + uri: https://api.datadoghq.com/api/v1/dashboard/3v2-z74-apr + response: + body: + encoding: UTF-8 + string: '{"deleted_dashboard_id":"3v2-z74-apr"}' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v1/dashboards/CreateDashboard_4032568083.rb b/examples/v1/dashboards/CreateDashboard_4032568083.rb new file mode 100644 index 000000000000..b604bc2cfbd2 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_4032568083.rb @@ -0,0 +1,29 @@ +# Create a new dashboard with a live default_timeframe returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::DashboardsAPI.new + +body = DatadogAPIClient::V1::Dashboard.new({ + title: "Example-Dashboard", + layout_type: DatadogAPIClient::V1::DashboardLayoutType::ORDERED, + widgets: [ + DatadogAPIClient::V1::Widget.new({ + definition: DatadogAPIClient::V1::NoteWidgetDefinition.new({ + type: DatadogAPIClient::V1::NoteWidgetDefinitionType::NOTE, + content: "test", + background_color: "white", + font_size: "14", + text_align: DatadogAPIClient::V1::WidgetTextAlign::LEFT, + show_tick: false, + tick_pos: "50%", + tick_edge: DatadogAPIClient::V1::WidgetTickEdge::LEFT, + }), + }), + ], + default_timeframe: DatadogAPIClient::V1::DashboardLiveTimeframe.new({ + type: DatadogAPIClient::V1::DashboardLiveTimeframeType::LIVE, + unit: DatadogAPIClient::V1::WidgetLiveSpanUnit::HOUR, + value: 4, + }), +}) +p api_instance.create_dashboard(body) diff --git a/features/v1/dashboards.feature b/features/v1/dashboards.feature index 932dc22b0b39..fcdfaf309db5 100644 --- a/features/v1/dashboards.feature +++ b/features/v1/dashboards.feature @@ -90,7 +90,7 @@ Feature: Dashboards @generated @skip @team:DataDog/dashboards-backend Scenario: Create a new dashboard returns "Bad Request" response Given new "CreateDashboard" request - And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} When the request is sent Then the response status is 400 Bad Request @@ -171,6 +171,16 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "hour_before(query1)" And the response "widgets[0].definition.requests[0].formulas[1].formula" is equal to "query1" + @team:DataDog/dashboards-backend + Scenario: Create a new dashboard with a live default_timeframe returns "OK" response + Given new "CreateDashboard" request + And body with value {"title": "{{ unique }}", "layout_type": "ordered", "widgets": [{"definition": {"type": "note", "content": "test", "background_color": "white", "font_size": "14", "text_align": "left", "show_tick": false, "tick_pos": "50%", "tick_edge": "left"}}], "default_timeframe": {"type": "live", "unit": "hour", "value": 4}} + When the request is sent + Then the response status is 200 OK + And the response "default_timeframe.type" is equal to "live" + And the response "default_timeframe.unit" is equal to "hour" + And the response "default_timeframe.value" is equal to 4 + @team:DataDog/dashboards-backend Scenario: Create a new dashboard with a query value widget using the percentile aggregator Given new "CreateDashboard" request @@ -1463,7 +1473,7 @@ Feature: Dashboards Scenario: Update a dashboard returns "Bad Request" response Given new "UpdateDashboard" request And request contains "dashboard_id" parameter from "REPLACE.ME" - And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} When the request is sent Then the response status is 400 Bad Request @@ -1471,7 +1481,7 @@ Feature: Dashboards Scenario: Update a dashboard returns "Item Not Found" response Given new "UpdateDashboard" request And request contains "dashboard_id" parameter from "REPLACE.ME" - And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} When the request is sent Then the response status is 404 Item Not Found diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 1912c3a1f419..42676a0d5737 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -87,7 +87,10 @@ def overrides "v1.dashboard" => "Dashboard", "v1.dashboard_bulk_action_data" => "DashboardBulkActionData", "v1.dashboard_bulk_delete_request" => "DashboardBulkDeleteRequest", + "v1.dashboard_default_timeframe_setting" => "DashboardDefaultTimeframeSetting", "v1.dashboard_delete_response" => "DashboardDeleteResponse", + "v1.dashboard_fixed_timeframe" => "DashboardFixedTimeframe", + "v1.dashboard_fixed_timeframe_type" => "DashboardFixedTimeframeType", "v1.dashboard_global_time" => "DashboardGlobalTime", "v1.dashboard_global_time_live_span" => "DashboardGlobalTimeLiveSpan", "v1.dashboard_invite_type" => "DashboardInviteType", @@ -95,6 +98,8 @@ def overrides "v1.dashboard_list" => "DashboardList", "v1.dashboard_list_delete_response" => "DashboardListDeleteResponse", "v1.dashboard_list_list_response" => "DashboardListListResponse", + "v1.dashboard_live_timeframe" => "DashboardLiveTimeframe", + "v1.dashboard_live_timeframe_type" => "DashboardLiveTimeframeType", "v1.dashboard_reflow_type" => "DashboardReflowType", "v1.dashboard_resource_type" => "DashboardResourceType", "v1.dashboard_restore_request" => "DashboardRestoreRequest", diff --git a/lib/datadog_api_client/v1/models/dashboard.rb b/lib/datadog_api_client/v1/models/dashboard.rb index b6d8a58748ba..799d7bc77f14 100644 --- a/lib/datadog_api_client/v1/models/dashboard.rb +++ b/lib/datadog_api_client/v1/models/dashboard.rb @@ -31,6 +31,9 @@ class Dashboard # Creation date of the dashboard. attr_accessor :created_at + # The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe. + attr_accessor :default_timeframe + # Description of the dashboard. attr_accessor :description @@ -89,6 +92,7 @@ def self.attribute_map :'author_handle' => :'author_handle', :'author_name' => :'author_name', :'created_at' => :'created_at', + :'default_timeframe' => :'default_timeframe', :'description' => :'description', :'id' => :'id', :'is_read_only' => :'is_read_only', @@ -114,6 +118,7 @@ def self.openapi_types :'author_handle' => :'String', :'author_name' => :'String', :'created_at' => :'Time', + :'default_timeframe' => :'DashboardDefaultTimeframeSetting', :'description' => :'String', :'id' => :'String', :'is_read_only' => :'Boolean', @@ -176,6 +181,10 @@ def initialize(attributes = {}) self.created_at = attributes[:'created_at'] end + if attributes.key?(:'default_timeframe') + self.default_timeframe = attributes[:'default_timeframe'] + end + if attributes.key?(:'description') self.description = attributes[:'description'] end @@ -342,6 +351,7 @@ def ==(o) author_handle == o.author_handle && author_name == o.author_name && created_at == o.created_at && + default_timeframe == o.default_timeframe && description == o.description && id == o.id && is_read_only == o.is_read_only && @@ -364,7 +374,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [author_handle, author_name, created_at, description, id, is_read_only, layout_type, modified_at, notify_list, reflow_type, restricted_roles, tabs, tags, template_variable_presets, template_variables, title, url, widgets, additional_properties].hash + [author_handle, author_name, created_at, default_timeframe, description, id, is_read_only, layout_type, modified_at, notify_list, reflow_type, restricted_roles, tabs, tags, template_variable_presets, template_variables, title, url, widgets, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v1/models/dashboard_default_timeframe_setting.rb b/lib/datadog_api_client/v1/models/dashboard_default_timeframe_setting.rb new file mode 100644 index 000000000000..90c8cb6cdc02 --- /dev/null +++ b/lib/datadog_api_client/v1/models/dashboard_default_timeframe_setting.rb @@ -0,0 +1,63 @@ +=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 + # The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe. + module DashboardDefaultTimeframeSetting + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'DashboardLiveTimeframe', + :'DashboardFixedTimeframe' + ] + end + # Builds the object + # @param data [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end diff --git a/lib/datadog_api_client/v1/models/dashboard_fixed_timeframe.rb b/lib/datadog_api_client/v1/models/dashboard_fixed_timeframe.rb new file mode 100644 index 000000000000..90b3639ac30d --- /dev/null +++ b/lib/datadog_api_client/v1/models/dashboard_fixed_timeframe.rb @@ -0,0 +1,173 @@ +=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 + # A fixed dashboard timeframe. + class DashboardFixedTimeframe + include BaseGenericModel + + # Start time in milliseconds since epoch. + attr_reader :from + + # End time in milliseconds since epoch. + attr_reader :to + + # Type of fixed timeframe. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'from' => :'from', + :'to' => :'to', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'from' => :'Integer', + :'to' => :'Integer', + :'type' => :'DashboardFixedTimeframeType' + } + 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::DashboardFixedTimeframe` 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?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + 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 @from.nil? + return false if @from < 0 + return false if @to.nil? + return false if @to < 0 + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param from [Object] Object to be assigned + # @!visibility private + def from=(from) + if from.nil? + fail ArgumentError, 'invalid value for "from", from cannot be nil.' + end + if from < 0 + fail ArgumentError, 'invalid value for "from", must be greater than or equal to 0.' + end + @from = from + end + + # Custom attribute writer method with validation + # @param to [Object] Object to be assigned + # @!visibility private + def to=(to) + if to.nil? + fail ArgumentError, 'invalid value for "to", to cannot be nil.' + end + if to < 0 + fail ArgumentError, 'invalid value for "to", must be greater than or equal to 0.' + end + @to = to + 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 && + from == o.from && + to == o.to && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [from, to, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/dashboard_fixed_timeframe_type.rb b/lib/datadog_api_client/v1/models/dashboard_fixed_timeframe_type.rb new file mode 100644 index 000000000000..64fc58c58abb --- /dev/null +++ b/lib/datadog_api_client/v1/models/dashboard_fixed_timeframe_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 fixed timeframe. + class DashboardFixedTimeframeType + include BaseEnumModel + + FIXED = "fixed".freeze + end +end diff --git a/lib/datadog_api_client/v1/models/dashboard_live_timeframe.rb b/lib/datadog_api_client/v1/models/dashboard_live_timeframe.rb new file mode 100644 index 000000000000..9d7e11b0a407 --- /dev/null +++ b/lib/datadog_api_client/v1/models/dashboard_live_timeframe.rb @@ -0,0 +1,169 @@ +=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 + # A live dashboard timeframe. + class DashboardLiveTimeframe + include BaseGenericModel + + # Type of live timeframe. + attr_reader :type + + # Unit of the time span. + attr_reader :unit + + # Value of the live timeframe span. + attr_reader :value + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'type' => :'type', + :'unit' => :'unit', + :'value' => :'value' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'type' => :'DashboardLiveTimeframeType', + :'unit' => :'WidgetLiveSpanUnit', + :'value' => :'Integer' + } + 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::DashboardLiveTimeframe` 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?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'unit') + self.unit = attributes[:'unit'] + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + 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 @type.nil? + return false if @unit.nil? + return false if @value.nil? + return false if @value < 1 + true + 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 + + # Custom attribute writer method with validation + # @param unit [Object] Object to be assigned + # @!visibility private + def unit=(unit) + if unit.nil? + fail ArgumentError, 'invalid value for "unit", unit cannot be nil.' + end + @unit = unit + end + + # Custom attribute writer method with validation + # @param value [Object] Object to be assigned + # @!visibility private + def value=(value) + if value.nil? + fail ArgumentError, 'invalid value for "value", value cannot be nil.' + end + if value < 1 + fail ArgumentError, 'invalid value for "value", must be greater than or equal to 1.' + end + @value = value + 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 && + type == o.type && + unit == o.unit && + value == o.value && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [type, unit, value, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/dashboard_live_timeframe_type.rb b/lib/datadog_api_client/v1/models/dashboard_live_timeframe_type.rb new file mode 100644 index 000000000000..807365b9e8b0 --- /dev/null +++ b/lib/datadog_api_client/v1/models/dashboard_live_timeframe_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 live timeframe. + class DashboardLiveTimeframeType + include BaseEnumModel + + LIVE = "live".freeze + end +end