diff --git a/.apigentools-info b/.apigentools-info index 7a4426c2b601..491a8c5784bd 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.5.1.dev2", - "regenerated": "2021-09-15 13:20:32.964477", - "spec_repo_commit": "0ded40f" + "regenerated": "2021-09-20 06:56:25.513055", + "spec_repo_commit": "363bae4" }, "v2": { "apigentools_version": "1.5.1.dev2", - "regenerated": "2021-09-15 13:21:11.612963", - "spec_repo_commit": "0ded40f" + "regenerated": "2021-09-20 06:57:08.873788", + "spec_repo_commit": "363bae4" } } } \ No newline at end of file diff --git a/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-formulas-and-functions-scatterplot-widget.yml b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-formulas-and-functions-scatterplot-widget.yml new file mode 100644 index 000000000000..532ea7340fd2 --- /dev/null +++ b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-formulas-and-functions-scatterplot-widget.yml @@ -0,0 +1,74 @@ +http_interactions: +- recorded_at: Fri, 17 Sep 2021 10:08:55 GMT + request: + body: + encoding: UTF-8 + string: '{"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_formulas_and_functions_scatterplot_widget-1631873335","widgets":[{"definition":{"requests":{"table":{"formulas":[{"alias":"my-query1","dimension":"x","formula":"query1"},{"alias":"my-query2","dimension":"y","formula":"query2"}],"queries":[{"aggregator":"avg","data_source":"metrics","name":"query1","query":"avg:system.cpu.user{*} + by {service}"},{"aggregator":"avg","data_source":"metrics","name":"query2","query":"avg:system.mem.used{*} + by {service}"}],"response_format":"scalar"}},"title":"","title_align":"left","title_size":"16","type":"scatterplot"},"id":5346764334358972,"layout":{"height":2,"width":4,"x":0,"y":0}}]}' + headers: + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '1077' + Content-Security-Policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + Content-Type: + - application/json + Date: + - Fri, 17 Sep 2021 10:08:56 GMT + Pragma: + - no-cache + Vary: + - Accept-Encoding + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + method: POST + uri: https://api.datadoghq.com/api/v1/dashboard + response: + body: + encoding: UTF-8 + string: '{"notify_list":null,"description":null,"restricted_roles":[],"author_name":null,"template_variables":null,"is_read_only":false,"id":"psg-3ga-96v","title":"Test-Create_a_new_dashboard_with_formulas_and_functions_scatterplot_widget-1631873335","url":"/dashboard/psg-3ga-96v/test-createanewdashboardwithformulasandfunctionsscatterplotwidget-1631873335","created_at":"2021-09-17T10:08:56.289100+00:00","modified_at":"2021-09-17T10:08:56.289100+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"type":"scatterplot","requests":{"table":{"formulas":[{"alias":"my-query1","dimension":"x","formula":"query1"},{"alias":"my-query2","dimension":"y","formula":"query2"}],"response_format":"scalar","queries":[{"aggregator":"avg","data_source":"metrics","name":"query1","query":"avg:system.cpu.user{*} + by {service}"},{"aggregator":"avg","data_source":"metrics","name":"query2","query":"avg:system.mem.used{*} + by {service}"}]}},"title_align":"left","title_size":"16","title":""},"layout":{"y":0,"width":4,"x":0,"height":2},"id":5346764334358972}],"layout_type":"ordered"}' + status: + code: 200 + message: OK +- recorded_at: Fri, 17 Sep 2021 10:08:55 GMT + request: + body: null + headers: + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '38' + Content-Security-Policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + Content-Type: + - application/json + Date: + - Fri, 17 Sep 2021 10:08:56 GMT + Pragma: + - no-cache + Vary: + - Accept-Encoding + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + method: DELETE + uri: https://api.datadoghq.com/api/v1/dashboard/psg-3ga-96v + response: + body: + encoding: UTF-8 + string: '{"deleted_dashboard_id":"psg-3ga-96v"}' + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/data/v1/openapi.yaml b/data/v1/openapi.yaml index 0f035005f8e4..6f7db5dc3ffc 100644 --- a/data/v1/openapi.yaml +++ b/data/v1/openapi.yaml @@ -8295,13 +8295,12 @@ components: y: q: system.mem.used properties: + table: + $ref: '#/components/schemas/ScatterplotTableRequest' x: $ref: '#/components/schemas/ScatterPlotRequest' y: $ref: '#/components/schemas/ScatterPlotRequest' - required: - - x - - y type: object time: $ref: '#/components/schemas/WidgetTime' @@ -8332,6 +8331,38 @@ components: type: string x-enum-varnames: - SCATTERPLOT + ScatterplotDimension: + description: Dimension of the Scatterplot. + enum: + - x + - y + - radius + - color + example: radius + type: string + x-enum-varnames: + - X + - Y + - RADIUS + - COLOR + ScatterplotTableRequest: + description: Scatterplot request containing formulas and functions. + properties: + formulas: + description: List of Scatterplot formulas that operate on queries. **This + feature is currently in beta.** + items: + $ref: '#/components/schemas/ScatterplotWidgetFormula' + type: array + queries: + description: List of queries that can be returned directly or used in formulas. + **This feature is currently in beta.** + items: + $ref: '#/components/schemas/FormulaAndFunctionQueryDefinition' + type: array + response_format: + $ref: '#/components/schemas/FormulaAndFunctionResponseFormat' + type: object ScatterplotWidgetAggregator: description: Aggregator used for the request. enum: @@ -8347,6 +8378,23 @@ components: - MAXIMUM - MINIMUM - SUM + ScatterplotWidgetFormula: + description: Formula to be used in a Scatterplot widget query. + properties: + alias: + description: Expression alias. + example: my-query + type: string + dimension: + $ref: '#/components/schemas/ScatterplotDimension' + formula: + description: String expression built from queries, formulas, and functions. + example: func(a) + b + type: string + required: + - formula + - dimension + type: object Series: description: 'A metric to submit to Datadog. diff --git a/docs/v1/README.md b/docs/v1/README.md index bcb4f1f145a6..107f637325c3 100644 --- a/docs/v1/README.md +++ b/docs/v1/README.md @@ -590,7 +590,10 @@ Class | Method | HTTP request | Description - [DatadogAPIClient::V1::ScatterPlotWidgetDefinition](ScatterPlotWidgetDefinition.md) - [DatadogAPIClient::V1::ScatterPlotWidgetDefinitionRequests](ScatterPlotWidgetDefinitionRequests.md) - [DatadogAPIClient::V1::ScatterPlotWidgetDefinitionType](ScatterPlotWidgetDefinitionType.md) + - [DatadogAPIClient::V1::ScatterplotDimension](ScatterplotDimension.md) + - [DatadogAPIClient::V1::ScatterplotTableRequest](ScatterplotTableRequest.md) - [DatadogAPIClient::V1::ScatterplotWidgetAggregator](ScatterplotWidgetAggregator.md) + - [DatadogAPIClient::V1::ScatterplotWidgetFormula](ScatterplotWidgetFormula.md) - [DatadogAPIClient::V1::Series](Series.md) - [DatadogAPIClient::V1::ServiceCheck](ServiceCheck.md) - [DatadogAPIClient::V1::ServiceCheckStatus](ServiceCheckStatus.md) diff --git a/docs/v1/ScatterPlotWidgetDefinitionRequests.md b/docs/v1/ScatterPlotWidgetDefinitionRequests.md index 02bb2ea8a397..72ada84eb85f 100644 --- a/docs/v1/ScatterPlotWidgetDefinitionRequests.md +++ b/docs/v1/ScatterPlotWidgetDefinitionRequests.md @@ -4,8 +4,9 @@ | Name | Type | Description | Notes | | ---- | ---- | ----------- | ----- | -| **x** | [**ScatterPlotRequest**](ScatterPlotRequest.md) | | | -| **y** | [**ScatterPlotRequest**](ScatterPlotRequest.md) | | | +| **table** | [**ScatterplotTableRequest**](ScatterplotTableRequest.md) | | [optional] | +| **x** | [**ScatterPlotRequest**](ScatterPlotRequest.md) | | [optional] | +| **y** | [**ScatterPlotRequest**](ScatterPlotRequest.md) | | [optional] | ## Example @@ -13,6 +14,7 @@ require 'datadog_api_client/v1' instance = DatadogAPIClient::V1::ScatterPlotWidgetDefinitionRequests.new( + table: null, x: null, y: null ) diff --git a/docs/v1/ScatterplotDimension.md b/docs/v1/ScatterplotDimension.md new file mode 100644 index 000000000000..241b9172dda5 --- /dev/null +++ b/docs/v1/ScatterplotDimension.md @@ -0,0 +1,15 @@ +# DatadogAPIClient::V1::ScatterplotDimension + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'datadog_api_client/v1' + +instance = DatadogAPIClient::V1::ScatterplotDimension.new() +``` + diff --git a/docs/v1/ScatterplotTableRequest.md b/docs/v1/ScatterplotTableRequest.md new file mode 100644 index 000000000000..3ee341a6fa27 --- /dev/null +++ b/docs/v1/ScatterplotTableRequest.md @@ -0,0 +1,22 @@ +# DatadogAPIClient::V1::ScatterplotTableRequest + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **formulas** | [**Array<ScatterplotWidgetFormula>**](ScatterplotWidgetFormula.md) | List of Scatterplot formulas that operate on queries. **This feature is currently in beta.** | [optional] | +| **queries** | [**Array<FormulaAndFunctionQueryDefinition>**](FormulaAndFunctionQueryDefinition.md) | List of queries that can be returned directly or used in formulas. **This feature is currently in beta.** | [optional] | +| **response_format** | [**FormulaAndFunctionResponseFormat**](FormulaAndFunctionResponseFormat.md) | | [optional] | + +## Example + +```ruby +require 'datadog_api_client/v1' + +instance = DatadogAPIClient::V1::ScatterplotTableRequest.new( + formulas: null, + queries: null, + response_format: null +) +``` + diff --git a/docs/v1/ScatterplotWidgetFormula.md b/docs/v1/ScatterplotWidgetFormula.md new file mode 100644 index 000000000000..d70989995c5d --- /dev/null +++ b/docs/v1/ScatterplotWidgetFormula.md @@ -0,0 +1,22 @@ +# DatadogAPIClient::V1::ScatterplotWidgetFormula + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **_alias** | **String** | Expression alias. | [optional] | +| **dimension** | [**ScatterplotDimension**](ScatterplotDimension.md) | | | +| **formula** | **String** | String expression built from queries, formulas, and functions. | | + +## Example + +```ruby +require 'datadog_api_client/v1' + +instance = DatadogAPIClient::V1::ScatterplotWidgetFormula.new( + _alias: my-query, + dimension: null, + formula: func(a) + b +) +``` + diff --git a/features/v1/dashboards.feature b/features/v1/dashboards.feature index 0d5b8fcbc834..f821d2b8215c 100644 --- a/features/v1/dashboards.feature +++ b/features/v1/dashboards.feature @@ -73,6 +73,27 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].queries[0].primary_tag_name" is equal to "datacenter" And the response "widgets[0].definition.requests[0].queries[0].operation_name" is equal to "cassandra.query" + Scenario: Create a new dashboard with formulas and functions scatterplot widget + Given new "CreateDashboard" request + And body with value { "title": "{{ unique }}", "widgets": [ { "id": 5346764334358972, "definition": { "title": "", "title_size": "16", "title_align": "left", "type": "scatterplot", "requests": { "table": { "formulas": [ { "formula": "query1", "dimension": "x", "alias": "my-query1" }, { "formula": "query2", "dimension": "y", "alias": "my-query2" } ], "queries": [ { "data_source": "metrics", "name": "query1", "query": "avg:system.cpu.user{*} by {service}", "aggregator": "avg" }, { "data_source": "metrics", "name": "query2", "query": "avg:system.mem.used{*} by {service}", "aggregator": "avg" } ], "response_format": "scalar" } } }, "layout": { "x": 0, "y": 0, "width": 4, "height": 2 } } ], "layout_type": "ordered" } + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.requests.table.formulas[0].formula" is equal to "query1" + And the response "widgets[0].definition.requests.table.formulas[0].dimension" is equal to "x" + And the response "widgets[0].definition.requests.table.formulas[0].alias" is equal to "my-query1" + And the response "widgets[0].definition.requests.table.formulas[1].formula" is equal to "query2" + And the response "widgets[0].definition.requests.table.formulas[1].dimension" is equal to "y" + And the response "widgets[0].definition.requests.table.formulas[1].alias" is equal to "my-query2" + And the response "widgets[0].definition.requests.table.queries[0].data_source" is equal to "metrics" + And the response "widgets[0].definition.requests.table.queries[0].name" is equal to "query1" + And the response "widgets[0].definition.requests.table.queries[0].query" is equal to "avg:system.cpu.user{*} by {service}" + And the response "widgets[0].definition.requests.table.queries[0].aggregator" is equal to "avg" + And the response "widgets[0].definition.requests.table.queries[1].data_source" is equal to "metrics" + And the response "widgets[0].definition.requests.table.queries[1].name" is equal to "query2" + And the response "widgets[0].definition.requests.table.queries[1].query" is equal to "avg:system.mem.used{*} by {service}" + And the response "widgets[0].definition.requests.table.queries[1].aggregator" is equal to "avg" + And the response "widgets[0].definition.requests.table.response_format" is equal to "scalar" + Scenario: Create a new dashboard with list_stream widget Given new "CreateDashboard" request And body with value {"layout_type": "ordered", "title": "{{ unique }} with list_stream widget","widgets": [{"definition": {"type": "list_stream","requests": [{"columns":[{"width":"auto","field":"timestamp"}],"query":{"data_source":"issue_stream","query_string":""},"response_format":"event_list"}]}}]} diff --git a/lib/datadog_api_client/v1.rb b/lib/datadog_api_client/v1.rb index 588c9f3121f1..876ec7784c48 100644 --- a/lib/datadog_api_client/v1.rb +++ b/lib/datadog_api_client/v1.rb @@ -373,7 +373,10 @@ require 'datadog_api_client/v1/models/scatter_plot_widget_definition' require 'datadog_api_client/v1/models/scatter_plot_widget_definition_requests' require 'datadog_api_client/v1/models/scatter_plot_widget_definition_type' +require 'datadog_api_client/v1/models/scatterplot_dimension' +require 'datadog_api_client/v1/models/scatterplot_table_request' require 'datadog_api_client/v1/models/scatterplot_widget_aggregator' +require 'datadog_api_client/v1/models/scatterplot_widget_formula' require 'datadog_api_client/v1/models/series' require 'datadog_api_client/v1/models/service_check' require 'datadog_api_client/v1/models/service_check_status' diff --git a/lib/datadog_api_client/v1/models/scatter_plot_widget_definition_requests.rb b/lib/datadog_api_client/v1/models/scatter_plot_widget_definition_requests.rb index 353e70090dcd..cf3d18de52cb 100644 --- a/lib/datadog_api_client/v1/models/scatter_plot_widget_definition_requests.rb +++ b/lib/datadog_api_client/v1/models/scatter_plot_widget_definition_requests.rb @@ -22,6 +22,8 @@ class ScatterPlotWidgetDefinitionRequests # whether the object has unparsed attributes attr_accessor :_unparsed + attr_accessor :table + attr_accessor :x attr_accessor :y @@ -29,6 +31,7 @@ class ScatterPlotWidgetDefinitionRequests # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'table' => :'table', :'x' => :'x', :'y' => :'y' } @@ -42,6 +45,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'table' => :'ScatterplotTableRequest', :'x' => :'ScatterPlotRequest', :'y' => :'ScatterPlotRequest' } @@ -68,6 +72,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'table') + self.table = attributes[:'table'] + end + if attributes.key?(:'x') self.x = attributes[:'x'] end @@ -81,22 +89,12 @@ def initialize(attributes = {}) # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new - if @x.nil? - invalid_properties.push('invalid value for "x", x cannot be nil.') - end - - if @y.nil? - invalid_properties.push('invalid value for "y", y cannot be nil.') - end - invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - return false if @x.nil? - return false if @y.nil? true end @@ -105,6 +103,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + table == o.table && x == o.x && y == o.y end @@ -118,7 +117,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [x, y].hash + [table, x, y].hash end # Builds the object from hash diff --git a/lib/datadog_api_client/v1/models/scatterplot_dimension.rb b/lib/datadog_api_client/v1/models/scatterplot_dimension.rb new file mode 100644 index 000000000000..168569eb14e4 --- /dev/null +++ b/lib/datadog_api_client/v1/models/scatterplot_dimension.rb @@ -0,0 +1,41 @@ +=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://openapi-generator.tech + + 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 + class ScatterplotDimension + X = "x".freeze + Y = "y".freeze + RADIUS = "radius".freeze + COLOR = "color".freeze + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + constantValues = ScatterplotDimension.constants.select { |c| ScatterplotDimension::const_get(c) == value } + constantValues.empty? ? DatadogAPIClient::V1::UnparsedObject.new(value) : value + end + end +end diff --git a/lib/datadog_api_client/v1/models/scatterplot_table_request.rb b/lib/datadog_api_client/v1/models/scatterplot_table_request.rb new file mode 100644 index 000000000000..c9defee8c522 --- /dev/null +++ b/lib/datadog_api_client/v1/models/scatterplot_table_request.rb @@ -0,0 +1,256 @@ +=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://openapi-generator.tech + + 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 + # Scatterplot request containing formulas and functions. + class ScatterplotTableRequest + # whether the object has unparsed attributes + attr_accessor :_unparsed + + # List of Scatterplot formulas that operate on queries. **This feature is currently in beta.** + attr_accessor :formulas + + # List of queries that can be returned directly or used in formulas. **This feature is currently in beta.** + attr_accessor :queries + + attr_accessor :response_format + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'formulas' => :'formulas', + :'queries' => :'queries', + :'response_format' => :'response_format' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'formulas' => :'Array', + :'queries' => :'Array', + :'response_format' => :'FormulaAndFunctionResponseFormat' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::ScatterplotTableRequest` 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::ScatterplotTableRequest`. 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?(:'formulas') + if (value = attributes[:'formulas']).is_a?(Array) + self.formulas = value + end + end + + if attributes.key?(:'queries') + if (value = attributes[:'queries']).is_a?(Array) + self.queries = value + end + end + + if attributes.key?(:'response_format') + self.response_format = attributes[:'response_format'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + formulas == o.formulas && + queries == o.queries && + response_format == o.response_format + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [formulas, queries, response_format].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when :Array + # generic array, return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = DatadogAPIClient::V1.const_get(type) + res = klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + if res.instance_of? DatadogAPIClient::V1::UnparsedObject + self._unparsed = true + end + res + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + 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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/lib/datadog_api_client/v1/models/scatterplot_widget_formula.rb b/lib/datadog_api_client/v1/models/scatterplot_widget_formula.rb new file mode 100644 index 000000000000..201215cef270 --- /dev/null +++ b/lib/datadog_api_client/v1/models/scatterplot_widget_formula.rb @@ -0,0 +1,262 @@ +=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://openapi-generator.tech + + 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 + # Formula to be used in a Scatterplot widget query. + class ScatterplotWidgetFormula + # whether the object has unparsed attributes + attr_accessor :_unparsed + + # Expression alias. + attr_accessor :_alias + + attr_accessor :dimension + + # String expression built from queries, formulas, and functions. + attr_accessor :formula + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'_alias' => :'alias', + :'dimension' => :'dimension', + :'formula' => :'formula' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'_alias' => :'String', + :'dimension' => :'ScatterplotDimension', + :'formula' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::ScatterplotWidgetFormula` 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::ScatterplotWidgetFormula`. 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?(:'_alias') + self._alias = attributes[:'_alias'] + end + + if attributes.key?(:'dimension') + self.dimension = attributes[:'dimension'] + end + + if attributes.key?(:'formula') + self.formula = attributes[:'formula'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @dimension.nil? + invalid_properties.push('invalid value for "dimension", dimension cannot be nil.') + end + + if @formula.nil? + invalid_properties.push('invalid value for "formula", formula cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @dimension.nil? + return false if @formula.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + _alias == o._alias && + dimension == o.dimension && + formula == o.formula + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [_alias, dimension, formula].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when :Array + # generic array, return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = DatadogAPIClient::V1.const_get(type) + res = klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + if res.instance_of? DatadogAPIClient::V1::UnparsedObject + self._unparsed = true + end + res + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + 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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/spec/v1/models/scatterplot_dimension_spec.rb b/spec/v1/models/scatterplot_dimension_spec.rb new file mode 100644 index 000000000000..263bf3e63d57 --- /dev/null +++ b/spec/v1/models/scatterplot_dimension_spec.rb @@ -0,0 +1,31 @@ +=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://openapi-generator.tech + + 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 'spec_helper' +require 'json' +require 'date' + +# Unit tests for DatadogAPIClient::V1::ScatterplotDimension +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe DatadogAPIClient::V1::ScatterplotDimension do + let(:instance) { DatadogAPIClient::V1::ScatterplotDimension.new } + + describe 'test an instance of ScatterplotDimension' do + it 'should create an instance of ScatterplotDimension' do + expect(instance).to be_instance_of(DatadogAPIClient::V1::ScatterplotDimension) + end + end +end diff --git a/spec/v1/models/scatterplot_table_request_spec.rb b/spec/v1/models/scatterplot_table_request_spec.rb new file mode 100644 index 000000000000..187914543901 --- /dev/null +++ b/spec/v1/models/scatterplot_table_request_spec.rb @@ -0,0 +1,49 @@ +=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://openapi-generator.tech + + 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 'spec_helper' +require 'json' +require 'date' + +# Unit tests for DatadogAPIClient::V1::ScatterplotTableRequest +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe DatadogAPIClient::V1::ScatterplotTableRequest do + let(:instance) { DatadogAPIClient::V1::ScatterplotTableRequest.new } + + describe 'test an instance of ScatterplotTableRequest' do + it 'should create an instance of ScatterplotTableRequest' do + expect(instance).to be_instance_of(DatadogAPIClient::V1::ScatterplotTableRequest) + end + end + describe 'test attribute "formulas"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "queries"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "response_format"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/spec/v1/models/scatterplot_widget_formula_spec.rb b/spec/v1/models/scatterplot_widget_formula_spec.rb new file mode 100644 index 000000000000..a8024d0707ab --- /dev/null +++ b/spec/v1/models/scatterplot_widget_formula_spec.rb @@ -0,0 +1,49 @@ +=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://openapi-generator.tech + + 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 'spec_helper' +require 'json' +require 'date' + +# Unit tests for DatadogAPIClient::V1::ScatterplotWidgetFormula +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe DatadogAPIClient::V1::ScatterplotWidgetFormula do + let(:instance) { DatadogAPIClient::V1::ScatterplotWidgetFormula.new } + + describe 'test an instance of ScatterplotWidgetFormula' do + it 'should create an instance of ScatterplotWidgetFormula' do + expect(instance).to be_instance_of(DatadogAPIClient::V1::ScatterplotWidgetFormula) + end + end + describe 'test attribute "_alias"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "dimension"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "formula"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end