diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 050e782eb9c3..888611645f22 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -11287,6 +11287,12 @@ components: type: string status: $ref: "#/components/schemas/NotebookStatus" + template_variables: + description: List of template variables for this notebook. + items: + $ref: "#/components/schemas/NotebookTemplateVariable" + nullable: true + type: array time: $ref: "#/components/schemas/NotebookGlobalTime" required: @@ -11506,6 +11512,12 @@ components: type: string status: $ref: "#/components/schemas/NotebookStatus" + template_variables: + description: List of template variables for this notebook. + items: + $ref: "#/components/schemas/NotebookTemplateVariable" + nullable: true + type: array time: $ref: "#/components/schemas/NotebookGlobalTime" required: @@ -11548,6 +11560,128 @@ components: type: string x-enum-varnames: - PUBLISHED + NotebookTemplateVariable: + additionalProperties: false + description: Notebook template variable. + properties: + available_values: + description: The list of values that the template variable drop-down is limited to. + example: ["my-host", "host1", "host2"] + items: + description: Template variable value. + minLength: 1 + type: string + nullable: true + type: array + uniqueItems: true + available_values_query: + $ref: "#/components/schemas/NotebookTemplateVariableAvailableValuesQuery" + data_source_mappings: + additionalProperties: + description: The value for the given data source. + type: string + description: Mapping of data source names to template variable values. + type: object + default: + deprecated: true + description: |- + (deprecated) The default value for the template variable on notebook load. + Cannot be used in conjunction with `defaults`. + example: my-host + nullable: true + type: string + defaults: + description: One or many default values for the template variable. Cannot be used in conjunction with `default`. + example: ["my-host-1", "my-host-2"] + items: + description: A default value for the template variable. + minLength: 1 + type: string + type: array + uniqueItems: true + name: + description: The name of the variable. + example: host1 + type: string + placement: + description: The placement of the template variable in the notebook. + example: global + type: string + prefix: + description: The tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down. + example: host + nullable: true + type: string + type: + description: The type of the template variable. + example: tag + type: string + required: + - name + type: object + NotebookTemplateVariableAvailableValuesQuery: + description: Query used to dynamically populate the list of available values for the template variable. + oneOf: + - $ref: "#/components/schemas/NotebookTemplateVariableAvailableValuesQueryLogRumSpans" + - $ref: "#/components/schemas/NotebookTemplateVariableAvailableValuesQueryMetrics" + NotebookTemplateVariableAvailableValuesQueryGroupBy: + additionalProperties: false + description: A group-by facet for an available values query. + properties: + facet: + description: The facet name to group by. + example: host + type: string + required: + - facet + type: object + NotebookTemplateVariableAvailableValuesQueryLogRumSpans: + additionalProperties: false + description: Available values query for logs, RUM, or spans data sources. + properties: + data_source: + description: The data source for the query. Must be one of `logs`, `rum`, or `spans`. + example: logs + type: string + group_by: + description: Group-by fields for the query. + items: + $ref: "#/components/schemas/NotebookTemplateVariableAvailableValuesQueryGroupBy" + type: array + search: + $ref: "#/components/schemas/NotebookTemplateVariableAvailableValuesQuerySearch" + required: + - data_source + - search + - group_by + type: object + NotebookTemplateVariableAvailableValuesQueryMetrics: + additionalProperties: false + description: Available values query for the metrics data source. + properties: + data_source: + description: The data source for the query. Must be `metrics`. + example: metrics + type: string + query: + description: The metrics query string. + example: "avg:system.cpu.user{*} by {host}" + type: string + required: + - data_source + - query + type: object + NotebookTemplateVariableAvailableValuesQuerySearch: + additionalProperties: false + description: Search parameters for an available values query. + properties: + query: + description: The search query string. + example: "service:web" + type: string + required: + - query + type: object NotebookTimeseriesCellAttributes: description: The attributes of a notebook `timeseries` cell. properties: @@ -11613,6 +11747,12 @@ components: type: string status: $ref: "#/components/schemas/NotebookStatus" + template_variables: + description: List of template variables for this notebook. + items: + $ref: "#/components/schemas/NotebookTemplateVariable" + nullable: true + type: array time: $ref: "#/components/schemas/NotebookGlobalTime" required: @@ -11689,6 +11829,12 @@ components: type: string status: $ref: "#/components/schemas/NotebookStatus" + template_variables: + description: List of template variables for this notebook. + items: + $ref: "#/components/schemas/NotebookTemplateVariable" + nullable: true + type: array time: $ref: "#/components/schemas/NotebookGlobalTime" required: diff --git a/features/v1/notebooks.feature b/features/v1/notebooks.feature index 3ff8343c9b19..1a7dcacb6b8f 100644 --- a/features/v1/notebooks.feature +++ b/features/v1/notebooks.feature @@ -13,7 +13,7 @@ Feature: Notebooks @generated @skip @team:DataDog/notebooks Scenario: Create a notebook returns "Bad Request" response Given new "CreateNotebook" request - And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "time": {"live_span": "1h"}}, "type": "notebooks"}} + And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "template_variables": [{"available_values": ["my-host", "host1", "host2"], "available_values_query": {"data_source": "logs", "group_by": [{"facet": "host"}], "search": {"query": "service:web"}}, "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "placement": "global", "prefix": "host", "type": "tag"}], "time": {"live_span": "1h"}}, "type": "notebooks"}} When the request is sent Then the response status is 400 Bad Request @@ -98,7 +98,7 @@ Feature: Notebooks Scenario: Update a notebook returns "Bad Request" response Given new "UpdateNotebook" request And request contains "notebook_id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "time": {"live_span": "1h"}}, "type": "notebooks"}} + And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "template_variables": [{"available_values": ["my-host", "host1", "host2"], "available_values_query": {"data_source": "logs", "group_by": [{"facet": "host"}], "search": {"query": "service:web"}}, "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "placement": "global", "prefix": "host", "type": "tag"}], "time": {"live_span": "1h"}}, "type": "notebooks"}} When the request is sent Then the response status is 400 Bad Request @@ -106,7 +106,7 @@ Feature: Notebooks Scenario: Update a notebook returns "Conflict" response Given new "UpdateNotebook" request And request contains "notebook_id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "time": {"live_span": "1h"}}, "type": "notebooks"}} + And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "template_variables": [{"available_values": ["my-host", "host1", "host2"], "available_values_query": {"data_source": "logs", "group_by": [{"facet": "host"}], "search": {"query": "service:web"}}, "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "placement": "global", "prefix": "host", "type": "tag"}], "time": {"live_span": "1h"}}, "type": "notebooks"}} When the request is sent Then the response status is 409 Conflict @@ -114,7 +114,7 @@ Feature: Notebooks Scenario: Update a notebook returns "Not Found" response Given new "UpdateNotebook" request And request contains "notebook_id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "time": {"live_span": "1h"}}, "type": "notebooks"}} + And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "template_variables": [{"available_values": ["my-host", "host1", "host2"], "available_values_query": {"data_source": "logs", "group_by": [{"facet": "host"}], "search": {"query": "service:web"}}, "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "placement": "global", "prefix": "host", "type": "tag"}], "time": {"live_span": "1h"}}, "type": "notebooks"}} When the request is sent Then the response status is 404 Not Found diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index b5448a033d8c..4f9a8a582838 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -487,6 +487,12 @@ def overrides "v1.notebooks_response_meta" => "NotebooksResponseMeta", "v1.notebooks_response_page" => "NotebooksResponsePage", "v1.notebook_status" => "NotebookStatus", + "v1.notebook_template_variable" => "NotebookTemplateVariable", + "v1.notebook_template_variable_available_values_query" => "NotebookTemplateVariableAvailableValuesQuery", + "v1.notebook_template_variable_available_values_query_group_by" => "NotebookTemplateVariableAvailableValuesQueryGroupBy", + "v1.notebook_template_variable_available_values_query_log_rum_spans" => "NotebookTemplateVariableAvailableValuesQueryLogRumSpans", + "v1.notebook_template_variable_available_values_query_metrics" => "NotebookTemplateVariableAvailableValuesQueryMetrics", + "v1.notebook_template_variable_available_values_query_search" => "NotebookTemplateVariableAvailableValuesQuerySearch", "v1.notebook_timeseries_cell_attributes" => "NotebookTimeseriesCellAttributes", "v1.notebook_toplist_cell_attributes" => "NotebookToplistCellAttributes", "v1.notebook_update_cell" => "NotebookUpdateCell", diff --git a/lib/datadog_api_client/v1/models/notebook_create_data_attributes.rb b/lib/datadog_api_client/v1/models/notebook_create_data_attributes.rb index c542cd2793fd..14e116115ba4 100644 --- a/lib/datadog_api_client/v1/models/notebook_create_data_attributes.rb +++ b/lib/datadog_api_client/v1/models/notebook_create_data_attributes.rb @@ -33,6 +33,9 @@ class NotebookCreateDataAttributes # Publication status of the notebook. For now, always "published". attr_accessor :status + # List of template variables for this notebook. + attr_accessor :template_variables + # Notebook global timeframe. attr_reader :time @@ -46,6 +49,7 @@ def self.attribute_map :'metadata' => :'metadata', :'name' => :'name', :'status' => :'status', + :'template_variables' => :'template_variables', :'time' => :'time' } end @@ -58,10 +62,19 @@ def self.openapi_types :'metadata' => :'NotebookMetadata', :'name' => :'String', :'status' => :'NotebookStatus', + :'template_variables' => :'Array', :'time' => :'NotebookGlobalTime' } end + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'template_variables', + ]) + end + # Initializes the object # @param attributes [Hash] Model attributes in the form of hash # @!visibility private @@ -98,6 +111,12 @@ def initialize(attributes = {}) self.status = attributes[:'status'] end + if attributes.key?(:'template_variables') + if (value = attributes[:'template_variables']).is_a?(Array) + self.template_variables = value + end + end + if attributes.key?(:'time') self.time = attributes[:'time'] end @@ -181,6 +200,7 @@ def ==(o) metadata == o.metadata && name == o.name && status == o.status && + template_variables == o.template_variables && time == o.time && additional_properties == o.additional_properties end @@ -189,7 +209,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [cells, metadata, name, status, time, additional_properties].hash + [cells, metadata, name, status, template_variables, time, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v1/models/notebook_response_data_attributes.rb b/lib/datadog_api_client/v1/models/notebook_response_data_attributes.rb index a41a4948721e..3a67c924b4d4 100644 --- a/lib/datadog_api_client/v1/models/notebook_response_data_attributes.rb +++ b/lib/datadog_api_client/v1/models/notebook_response_data_attributes.rb @@ -42,6 +42,9 @@ class NotebookResponseDataAttributes # Publication status of the notebook. For now, always "published". attr_accessor :status + # List of template variables for this notebook. + attr_accessor :template_variables + # Notebook global timeframe. attr_reader :time @@ -58,6 +61,7 @@ def self.attribute_map :'modified' => :'modified', :'name' => :'name', :'status' => :'status', + :'template_variables' => :'template_variables', :'time' => :'time' } end @@ -73,10 +77,19 @@ def self.openapi_types :'modified' => :'Time', :'name' => :'String', :'status' => :'NotebookStatus', + :'template_variables' => :'Array', :'time' => :'NotebookGlobalTime' } end + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'template_variables', + ]) + end + # Initializes the object # @param attributes [Hash] Model attributes in the form of hash # @!visibility private @@ -125,6 +138,12 @@ def initialize(attributes = {}) self.status = attributes[:'status'] end + if attributes.key?(:'template_variables') + if (value = attributes[:'template_variables']).is_a?(Array) + self.template_variables = value + end + end + if attributes.key?(:'time') self.time = attributes[:'time'] end @@ -211,6 +230,7 @@ def ==(o) modified == o.modified && name == o.name && status == o.status && + template_variables == o.template_variables && time == o.time && additional_properties == o.additional_properties end @@ -219,7 +239,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [author, cells, created, metadata, modified, name, status, time, additional_properties].hash + [author, cells, created, metadata, modified, name, status, template_variables, time, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v1/models/notebook_template_variable.rb b/lib/datadog_api_client/v1/models/notebook_template_variable.rb new file mode 100644 index 000000000000..5d7db4a01d9e --- /dev/null +++ b/lib/datadog_api_client/v1/models/notebook_template_variable.rb @@ -0,0 +1,193 @@ +=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 + # Notebook template variable. + class NotebookTemplateVariable + include BaseGenericModel + + # The list of values that the template variable drop-down is limited to. + attr_accessor :available_values + + # Query used to dynamically populate the list of available values for the template variable. + attr_accessor :available_values_query + + # Mapping of data source names to template variable values. + attr_accessor :data_source_mappings + + # (deprecated) The default value for the template variable on notebook load. + # Cannot be used in conjunction with `defaults`. + attr_accessor :default + + # One or many default values for the template variable. Cannot be used in conjunction with `default`. + attr_accessor :defaults + + # The name of the variable. + attr_reader :name + + # The placement of the template variable in the notebook. + attr_accessor :placement + + # The tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down. + attr_accessor :prefix + + # The type of the template variable. + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'available_values' => :'available_values', + :'available_values_query' => :'available_values_query', + :'data_source_mappings' => :'data_source_mappings', + :'default' => :'default', + :'defaults' => :'defaults', + :'name' => :'name', + :'placement' => :'placement', + :'prefix' => :'prefix', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'available_values' => :'Array', + :'available_values_query' => :'NotebookTemplateVariableAvailableValuesQuery', + :'data_source_mappings' => :'Hash', + :'default' => :'String', + :'defaults' => :'Array', + :'name' => :'String', + :'placement' => :'String', + :'prefix' => :'String', + :'type' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'available_values', + :'default', + :'prefix', + ]) + 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::NotebookTemplateVariable` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::NotebookTemplateVariable`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'available_values') + if (value = attributes[:'available_values']).is_a?(Array) + self.available_values = value + end + end + + if attributes.key?(:'available_values_query') + self.available_values_query = attributes[:'available_values_query'] + end + + if attributes.key?(:'data_source_mappings') + self.data_source_mappings = attributes[:'data_source_mappings'] + end + + if attributes.key?(:'default') + self.default = attributes[:'default'] + end + + if attributes.key?(:'defaults') + if (value = attributes[:'defaults']).is_a?(Array) + self.defaults = value + end + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'placement') + self.placement = attributes[:'placement'] + end + + if attributes.key?(:'prefix') + self.prefix = attributes[:'prefix'] + 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 @name.nil? + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # 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 && + available_values == o.available_values && + available_values_query == o.available_values_query && + data_source_mappings == o.data_source_mappings && + default == o.default && + defaults == o.defaults && + name == o.name && + placement == o.placement && + prefix == o.prefix && + type == o.type + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [available_values, available_values_query, data_source_mappings, default, defaults, name, placement, prefix, type].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query.rb b/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query.rb new file mode 100644 index 000000000000..d8851b2d030e --- /dev/null +++ b/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query.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 + # Query used to dynamically populate the list of available values for the template variable. + module NotebookTemplateVariableAvailableValuesQuery + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'NotebookTemplateVariableAvailableValuesQueryLogRumSpans', + :'NotebookTemplateVariableAvailableValuesQueryMetrics' + ] + 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/notebook_template_variable_available_values_query_group_by.rb b/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_group_by.rb new file mode 100644 index 000000000000..9f7a8ee8d807 --- /dev/null +++ b/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_group_by.rb @@ -0,0 +1,98 @@ +=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 group-by facet for an available values query. + class NotebookTemplateVariableAvailableValuesQueryGroupBy + include BaseGenericModel + + # The facet name to group by. + attr_reader :facet + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'facet' => :'facet' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'facet' => :'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::NotebookTemplateVariableAvailableValuesQueryGroupBy` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::NotebookTemplateVariableAvailableValuesQueryGroupBy`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'facet') + self.facet = attributes[:'facet'] + 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 @facet.nil? + true + end + + # Custom attribute writer method with validation + # @param facet [Object] Object to be assigned + # @!visibility private + def facet=(facet) + if facet.nil? + fail ArgumentError, 'invalid value for "facet", facet cannot be nil.' + end + @facet = facet + 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 && + facet == o.facet + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [facet].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_log_rum_spans.rb b/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_log_rum_spans.rb new file mode 100644 index 000000000000..7390d6b44622 --- /dev/null +++ b/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_log_rum_spans.rb @@ -0,0 +1,142 @@ +=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 + # Available values query for logs, RUM, or spans data sources. + class NotebookTemplateVariableAvailableValuesQueryLogRumSpans + include BaseGenericModel + + # The data source for the query. Must be one of `logs`, `rum`, or `spans`. + attr_reader :data_source + + # Group-by fields for the query. + attr_reader :group_by + + # Search parameters for an available values query. + attr_reader :search + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data_source' => :'data_source', + :'group_by' => :'group_by', + :'search' => :'search' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data_source' => :'String', + :'group_by' => :'Array', + :'search' => :'NotebookTemplateVariableAvailableValuesQuerySearch' + } + 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::NotebookTemplateVariableAvailableValuesQueryLogRumSpans` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::NotebookTemplateVariableAvailableValuesQueryLogRumSpans`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data_source') + self.data_source = attributes[:'data_source'] + end + + if attributes.key?(:'group_by') + if (value = attributes[:'group_by']).is_a?(Array) + self.group_by = value + end + end + + if attributes.key?(:'search') + self.search = attributes[:'search'] + 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_source.nil? + return false if @group_by.nil? + return false if @search.nil? + true + end + + # Custom attribute writer method with validation + # @param data_source [Object] Object to be assigned + # @!visibility private + def data_source=(data_source) + if data_source.nil? + fail ArgumentError, 'invalid value for "data_source", data_source cannot be nil.' + end + @data_source = data_source + end + + # Custom attribute writer method with validation + # @param group_by [Object] Object to be assigned + # @!visibility private + def group_by=(group_by) + if group_by.nil? + fail ArgumentError, 'invalid value for "group_by", group_by cannot be nil.' + end + @group_by = group_by + end + + # Custom attribute writer method with validation + # @param search [Object] Object to be assigned + # @!visibility private + def search=(search) + if search.nil? + fail ArgumentError, 'invalid value for "search", search cannot be nil.' + end + @search = search + 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_source == o.data_source && + group_by == o.group_by && + search == o.search + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data_source, group_by, search].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_metrics.rb b/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_metrics.rb new file mode 100644 index 000000000000..154ae32fb431 --- /dev/null +++ b/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_metrics.rb @@ -0,0 +1,119 @@ +=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 + # Available values query for the metrics data source. + class NotebookTemplateVariableAvailableValuesQueryMetrics + include BaseGenericModel + + # The data source for the query. Must be `metrics`. + attr_reader :data_source + + # The metrics query string. + attr_reader :query + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data_source' => :'data_source', + :'query' => :'query' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data_source' => :'String', + :'query' => :'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::NotebookTemplateVariableAvailableValuesQueryMetrics` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::NotebookTemplateVariableAvailableValuesQueryMetrics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data_source') + self.data_source = attributes[:'data_source'] + end + + if attributes.key?(:'query') + self.query = attributes[:'query'] + 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_source.nil? + return false if @query.nil? + true + end + + # Custom attribute writer method with validation + # @param data_source [Object] Object to be assigned + # @!visibility private + def data_source=(data_source) + if data_source.nil? + fail ArgumentError, 'invalid value for "data_source", data_source cannot be nil.' + end + @data_source = data_source + end + + # Custom attribute writer method with validation + # @param query [Object] Object to be assigned + # @!visibility private + def query=(query) + if query.nil? + fail ArgumentError, 'invalid value for "query", query cannot be nil.' + end + @query = query + 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_source == o.data_source && + query == o.query + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data_source, query].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_search.rb b/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_search.rb new file mode 100644 index 000000000000..879880b0c00e --- /dev/null +++ b/lib/datadog_api_client/v1/models/notebook_template_variable_available_values_query_search.rb @@ -0,0 +1,98 @@ +=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 + # Search parameters for an available values query. + class NotebookTemplateVariableAvailableValuesQuerySearch + include BaseGenericModel + + # The search query string. + attr_reader :query + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'query' => :'query' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'query' => :'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::NotebookTemplateVariableAvailableValuesQuerySearch` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::NotebookTemplateVariableAvailableValuesQuerySearch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'query') + self.query = attributes[:'query'] + 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 @query.nil? + true + end + + # Custom attribute writer method with validation + # @param query [Object] Object to be assigned + # @!visibility private + def query=(query) + if query.nil? + fail ArgumentError, 'invalid value for "query", query cannot be nil.' + end + @query = query + 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 && + query == o.query + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [query].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/notebook_update_data_attributes.rb b/lib/datadog_api_client/v1/models/notebook_update_data_attributes.rb index 179cbdabf070..b4a6c1a68543 100644 --- a/lib/datadog_api_client/v1/models/notebook_update_data_attributes.rb +++ b/lib/datadog_api_client/v1/models/notebook_update_data_attributes.rb @@ -33,6 +33,9 @@ class NotebookUpdateDataAttributes # Publication status of the notebook. For now, always "published". attr_accessor :status + # List of template variables for this notebook. + attr_accessor :template_variables + # Notebook global timeframe. attr_reader :time @@ -46,6 +49,7 @@ def self.attribute_map :'metadata' => :'metadata', :'name' => :'name', :'status' => :'status', + :'template_variables' => :'template_variables', :'time' => :'time' } end @@ -58,10 +62,19 @@ def self.openapi_types :'metadata' => :'NotebookMetadata', :'name' => :'String', :'status' => :'NotebookStatus', + :'template_variables' => :'Array', :'time' => :'NotebookGlobalTime' } end + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'template_variables', + ]) + end + # Initializes the object # @param attributes [Hash] Model attributes in the form of hash # @!visibility private @@ -98,6 +111,12 @@ def initialize(attributes = {}) self.status = attributes[:'status'] end + if attributes.key?(:'template_variables') + if (value = attributes[:'template_variables']).is_a?(Array) + self.template_variables = value + end + end + if attributes.key?(:'time') self.time = attributes[:'time'] end @@ -181,6 +200,7 @@ def ==(o) metadata == o.metadata && name == o.name && status == o.status && + template_variables == o.template_variables && time == o.time && additional_properties == o.additional_properties end @@ -189,7 +209,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [cells, metadata, name, status, time, additional_properties].hash + [cells, metadata, name, status, template_variables, time, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v1/models/notebooks_response_data_attributes.rb b/lib/datadog_api_client/v1/models/notebooks_response_data_attributes.rb index 8e361561671e..d3c944dda756 100644 --- a/lib/datadog_api_client/v1/models/notebooks_response_data_attributes.rb +++ b/lib/datadog_api_client/v1/models/notebooks_response_data_attributes.rb @@ -42,6 +42,9 @@ class NotebooksResponseDataAttributes # Publication status of the notebook. For now, always "published". attr_accessor :status + # List of template variables for this notebook. + attr_accessor :template_variables + # Notebook global timeframe. attr_accessor :time @@ -58,6 +61,7 @@ def self.attribute_map :'modified' => :'modified', :'name' => :'name', :'status' => :'status', + :'template_variables' => :'template_variables', :'time' => :'time' } end @@ -73,10 +77,19 @@ def self.openapi_types :'modified' => :'Time', :'name' => :'String', :'status' => :'NotebookStatus', + :'template_variables' => :'Array', :'time' => :'NotebookGlobalTime' } end + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'template_variables', + ]) + end + # Initializes the object # @param attributes [Hash] Model attributes in the form of hash # @!visibility private @@ -125,6 +138,12 @@ def initialize(attributes = {}) self.status = attributes[:'status'] end + if attributes.key?(:'template_variables') + if (value = attributes[:'template_variables']).is_a?(Array) + self.template_variables = value + end + end + if attributes.key?(:'time') self.time = attributes[:'time'] end @@ -189,6 +208,7 @@ def ==(o) modified == o.modified && name == o.name && status == o.status && + template_variables == o.template_variables && time == o.time && additional_properties == o.additional_properties end @@ -197,7 +217,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [author, cells, created, metadata, modified, name, status, time, additional_properties].hash + [author, cells, created, metadata, modified, name, status, template_variables, time, additional_properties].hash end end end