From 6def6414d2467fb26559ffd2bbc020664d287f0a Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 28 Aug 2026 13:31:33 +0000 Subject: [PATCH] Regenerate client from commit 1df4332 of spec repo --- .generator/schemas/v1/openapi.yaml | 115 ++++++- features/scenarios_model_mapping.rb | 6 + lib/datadog_api_client.rb | 1 + lib/datadog_api_client/api_client.rb | 7 +- lib/datadog_api_client/inflector.rb | 6 +- lib/datadog_api_client/models.rb | 3 +- lib/datadog_api_client/v1/model_base.rb | 10 +- .../v1_20270101/api/dashboards_api.rb | 121 ++++++++ .../v1_20270101/model_base.rb | 291 ++++++++++++++++++ .../v1_20270101/models/dashboard_summary.rb | 117 +++++++ .../models/dashboard_summary_definition.rb | 278 +++++++++++++++++ .../models/dashboard_summary_id.rb | 63 ++++ lib/datadog_api_client/v2/model_base.rb | 10 +- 13 files changed, 1009 insertions(+), 19 deletions(-) create mode 100644 lib/datadog_api_client/v1_20270101/api/dashboards_api.rb create mode 100644 lib/datadog_api_client/v1_20270101/model_base.rb create mode 100644 lib/datadog_api_client/v1_20270101/models/dashboard_summary.rb create mode 100644 lib/datadog_api_client/v1_20270101/models/dashboard_summary_definition.rb create mode 100644 lib/datadog_api_client/v1_20270101/models/dashboard_summary_id.rb diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 7056d83d64b3..817b35746caf 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -1780,14 +1780,11 @@ components: - INVITE - EMBED DashboardSummary: - description: Dashboard summary response. - properties: - dashboards: - description: List of dashboard definitions. - items: - $ref: "#/components/schemas/DashboardSummaryDefinition" - type: array - type: object + description: Dashboard summary response with API-versioned representations. + oneOf: + - $ref: "#/components/schemas/DashboardSummary_V1" + - $ref: "#/components/schemas/DashboardSummary_20270101" + x-datadog-api-versioned: true DashboardSummaryDefinition: description: Dashboard definition. properties: @@ -1825,6 +1822,108 @@ components: description: URL of the dashboard. type: string type: object + DashboardSummaryDefinition_20270101: + description: Dashboard definition. + properties: + author: + $ref: "#/components/schemas/Creator" + created: + description: Date of creation of the dashboard. + format: date-time + nullable: true + readOnly: true + type: string + icon: + description: URL to the icon of the dashboard. + nullable: true + readOnly: true + type: string + id: + $ref: "#/components/schemas/DashboardSummaryID_20270101" + integration_id: + description: The short name of the integration. + nullable: true + readOnly: true + type: string + is_favorite: + description: Whether the dashboard is in the favorites. + readOnly: true + type: boolean + is_read_only: + description: Whether the dashboard is read only. + readOnly: true + type: boolean + is_shared: + description: Whether the dashboard is publicly shared. + readOnly: true + type: boolean + last_view_date: + description: Date when the dashboard was last viewed. + nullable: true + readOnly: true + type: string + modified: + description: Date of last edition of the dashboard. + format: date-time + nullable: true + readOnly: true + type: string + popularity: + description: Popularity of the dashboard. + format: int32 + maximum: 5 + readOnly: true + type: integer + tags: + description: List of team names representing ownership of the dashboard. + items: + description: The name of a Datadog team, formatted as `team:`. + type: string + nullable: true + readOnly: true + type: array + title: + description: Title of the dashboard. + readOnly: true + type: string + type: + description: The type of the dashboard. + readOnly: true + type: string + url: + description: URL path to the dashboard. + readOnly: true + type: string + type: object + DashboardSummaryID_20270101: + description: ID of the dashboard. + oneOf: + - type: string + - format: int64 + type: integer + DashboardSummary_20270101: + description: Dashboard summary response. + properties: + dashboards: + description: List of dashboard definitions. + items: + $ref: "#/components/schemas/DashboardSummaryDefinition_20270101" + type: array + total: + description: Number of dashboards. + format: int64 + readOnly: true + type: integer + type: object + DashboardSummary_V1: + description: Dashboard summary response. + properties: + dashboards: + description: List of dashboard definitions. + items: + $ref: "#/components/schemas/DashboardSummaryDefinition" + type: array + type: object DashboardTab: description: Dashboard tab for organizing widgets. properties: diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index dba8508d0703..ae6e047469fa 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -840,6 +840,12 @@ "user_handle" => "String", "body" => "User", }, + "v1_20270101.ListDashboards" => { + "filter_shared" => "Boolean", + "filter_deleted" => "Boolean", + "count" => "Integer", + "start" => "Integer", + }, "v2.ListFleetAgentTracers" => { "agent_key" => "String", "page_number" => "Integer", diff --git a/lib/datadog_api_client.rb b/lib/datadog_api_client.rb index 06fdb1afb2b4..0daa0539ff55 100644 --- a/lib/datadog_api_client.rb +++ b/lib/datadog_api_client.rb @@ -21,6 +21,7 @@ loader.collapse("#{__dir__}/datadog_api_client/*/models/") loader.collapse("#{__dir__}/datadog_api_client/*/api/") loader.push_dir("#{__dir__}/datadog_api_client/v1", namespace: DatadogAPIClient::V1) +loader.push_dir("#{__dir__}/datadog_api_client/v1_20270101", namespace: DatadogAPIClient::V1_20270101) loader.push_dir("#{__dir__}/datadog_api_client/v2", namespace: DatadogAPIClient::V2) # Ignore model_base.rb from being loaded in by zeitwerk as it is loaded in by default loader.ignore("#{__dir__}/datadog_api_client/*/model_base.rb") diff --git a/lib/datadog_api_client/api_client.rb b/lib/datadog_api_client/api_client.rb index 0e018768fb62..3180c7ced7b0 100644 --- a/lib/datadog_api_client/api_client.rb +++ b/lib/datadog_api_client/api_client.rb @@ -352,7 +352,7 @@ def convert_to_type(data, return_type, api_version) end else # models (e.g. Pet) or oneOf - klass = DatadogAPIClient.const_get(api_version).const_get(return_type) + klass = DatadogAPIClient.const_get(api_version).model_class(return_type) klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data) end end @@ -369,7 +369,8 @@ def sanitize_filename(filename) def build_request_url(path, opts = {}) # Add leading and trailing slashes to path path = "/#{path}".gsub(/\/+/, '/') - @config.base_url("#{opts[:api_version].respond_to?(:downcase) ? opts[:api_version].downcase : opts[:api_version]}.#{opts[:operation]}") + path + path_version = opts[:path_version] || opts[:api_version] + @config.base_url("#{path_version.respond_to?(:downcase) ? path_version.downcase : path_version}.#{opts[:operation]}") + path end # Update header and query params based on authentication settings. @@ -526,7 +527,7 @@ def set_attribute_from_path(api_version, obj, attribute_path, builder, value) else obj = obj.send(attr) end - builder = DatadogAPIClient.const_get(api_version).const_get(builder.openapi_types[attr.to_sym]) if i > 0 + builder = DatadogAPIClient.const_get(api_version).model_class(builder.openapi_types[attr.to_sym]) if i > 0 obj = builder.new if obj.nil? i += 1 end diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 1ec1a4339186..4e7a5c7bf171 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -3,7 +3,7 @@ module DatadogAPIClient class DatadogAPIClientInflector < Zeitwerk::Inflector def camelize(basename, abspath) - model_name = "#{abspath.match(/datadog_api_client\/(v[0-9])\//)&.captures&.first}.#{basename}" + model_name = "#{abspath.match(/datadog_api_client\/(v[0-9](?:_[0-9]{8})?)\//)&.captures&.first}.#{basename}" overrides[model_name] || basename.split('_').each(&:capitalize!).join end @@ -1173,6 +1173,9 @@ def overrides "v1.wildcard_widget_request" => "WildcardWidgetRequest", "v1.wildcard_widget_specification" => "WildcardWidgetSpecification", "v1.wildcard_widget_specification_type" => "WildcardWidgetSpecificationType", + "v1_20270101.dashboard_summary" => "DashboardSummary", + "v1_20270101.dashboard_summary_definition" => "DashboardSummaryDefinition", + "v1_20270101.dashboard_summary_id" => "DashboardSummaryID", "v2.access_token_list_item" => "AccessTokenListItem", "v2.access_token_list_item_relationships" => "AccessTokenListItemRelationships", "v2.access_token_owner_type" => "AccessTokenOwnerType", @@ -8848,6 +8851,7 @@ def overrides "v1.usage_metering_api" => "UsageMeteringAPI", "v1.users_api" => "UsersAPI", "v1.webhooks_integration_api" => "WebhooksIntegrationAPI", + "v1_20270101.dashboards_api" => "DashboardsAPI", "v2.action_connection_api" => "ActionConnectionAPI", "v2.actions_datastores_api" => "ActionsDatastoresAPI", "v2.agent_observability_api" => "AgentObservabilityAPI", diff --git a/lib/datadog_api_client/models.rb b/lib/datadog_api_client/models.rb index f40daba4374e..5e9edca973e0 100644 --- a/lib/datadog_api_client/models.rb +++ b/lib/datadog_api_client/models.rb @@ -22,12 +22,13 @@ # Model base ## Load in the model_base modules which also initializes the V1 and V2 namespaces require 'datadog_api_client/v1/model_base' +require 'datadog_api_client/v1_20270101/model_base' require 'datadog_api_client/v2/model_base' module DatadogAPIClient class << self # Customize default settings for the SDK using block. - # DatadogAPIClient::V2.configure do |config| + # DatadogAPIClient::V1.configure do |config| # config.username = "xxx" # config.password = "xxx" # end diff --git a/lib/datadog_api_client/v1/model_base.rb b/lib/datadog_api_client/v1/model_base.rb index 203568f08509..4a13accf03f3 100644 --- a/lib/datadog_api_client/v1/model_base.rb +++ b/lib/datadog_api_client/v1/model_base.rb @@ -14,6 +14,10 @@ =end module DatadogAPIClient::V1 + def self.model_class(type) + type.to_s.include?('::') ? Object.const_get(type.to_s) : const_get(type) + end + module BaseEnumModel # Builds the enum from string # @param value [String] The enum value in the form of the string @@ -137,8 +141,8 @@ def _deserialize(type, value) end end else # model - # models (e.g. Pet) or oneOf - klass = DatadogAPIClient::V1.const_get(type) + # models (e.g. Pet), including models from the base API namespace, or oneOf + klass = DatadogAPIClient::V1.model_class(type) res = klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) if res.instance_of? DatadogAPIClient::UnparsedObject self._unparsed = true @@ -267,7 +271,7 @@ def find_and_cast_into_type(klass, data) return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } end else # model - const = DatadogAPIClient::V1.const_get(klass) + const = DatadogAPIClient::V1.model_class(klass) if const if const.respond_to?(:openapi_one_of) # nested oneOf model model = const.build(data) diff --git a/lib/datadog_api_client/v1_20270101/api/dashboards_api.rb b/lib/datadog_api_client/v1_20270101/api/dashboards_api.rb new file mode 100644 index 000000000000..c19218a94006 --- /dev/null +++ b/lib/datadog_api_client/v1_20270101/api/dashboards_api.rb @@ -0,0 +1,121 @@ +=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 'cgi' + +module DatadogAPIClient::V1_20270101 + class DashboardsAPI + attr_accessor :api_client + + def initialize(api_client = DatadogAPIClient::APIClient.default) + @api_client = api_client + end + + # Get all dashboards. + # + # @see #list_dashboards_with_http_info + def list_dashboards(opts = {}) + data, _status_code, _headers = list_dashboards_with_http_info(opts) + data + end + + # Get all dashboards. + # + # Get all dashboards. + # + # **Note**: This query will only return custom created or cloned dashboards. + # This query will not return preset dashboards. + # + # @param opts [Hash] the optional parameters + # @option opts [Boolean] :filter_shared When `true`, this query only returns shared custom created or cloned dashboards. + # @option opts [Boolean] :filter_deleted When `true`, this query returns only deleted custom-created or cloned dashboards. This parameter is incompatible with `filter[shared]`. + # @option opts [Integer] :count The maximum number of dashboards returned in the list. + # @option opts [Integer] :start The specific offset to use as the beginning of the returned response. + # @return [Array<(DashboardSummary, Integer, Hash)>] DashboardSummary data, response status code and response headers + def list_dashboards_with_http_info(opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: DashboardsAPI.list_dashboards ...' + end + # resource path + local_var_path = '/api/v1/dashboard' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'filter[shared]'] = opts[:'filter_shared'] if !opts[:'filter_shared'].nil? + query_params[:'filter[deleted]'] = opts[:'filter_deleted'] if !opts[:'filter_deleted'].nil? + query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil? + query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'DD-API-Version' + header_params['DD-API-Version'] = '2027-01-01' + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'DashboardSummary' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_dashboards, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V1_20270101", + :path_version => "V1" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: DashboardsAPI#list_dashboards\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get all dashboards. + # + # Provide a paginated version of {#list_dashboards}, returning all items. + # + # To use it you need to use a block: list_dashboards_with_pagination { |item| p item } + # + # @yield [DashboardSummaryDefinition] Paginated items + def list_dashboards_with_pagination(opts = {}) + api_version = "V1_20270101" + page_size = @api_client.get_attribute_from_path(opts, "count", 100) + @api_client.set_attribute_from_path(api_version, opts, "count", Integer, page_size) + while true do + response = list_dashboards(opts) + @api_client.get_attribute_from_path(response, "dashboards").each { |item| yield(item) } + if @api_client.get_attribute_from_path(response, "dashboards").length < page_size + break + end + @api_client.set_attribute_from_path(api_version, opts, "start", Integer, @api_client.get_attribute_from_path(opts, "start", 0) + page_size) + end + end + end +end diff --git a/lib/datadog_api_client/v1_20270101/model_base.rb b/lib/datadog_api_client/v1_20270101/model_base.rb new file mode 100644 index 000000000000..5bab1d398a2b --- /dev/null +++ b/lib/datadog_api_client/v1_20270101/model_base.rb @@ -0,0 +1,291 @@ +=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 + +module DatadogAPIClient::V1_20270101 + def self.model_class(type) + type.to_s.include?('::') ? Object.const_get(type.to_s) : const_get(type) + end + + module BaseEnumModel + # Builds the enum from string + # @param value [String] The enum value in the form of the string + # @return [String] The enum value + # @!visibility private + def build_from_hash(value) + constantValues = self.class.constants.select { |c| self.class::const_get(c) == value } + constantValues.empty? ? DatadogAPIClient::UnparsedObject.new(value) : value + end + + module ClassMethods + # Builds the enum from string + # @param value [String] The enum value in the form of the string + # @return [String] The enum value + # @!visibility private + def build_from_hash(value) + new.build_from_hash(value) + end + end + + def self.included(base) + base.extend(ClassMethods) + end + end + + module BaseGenericModel + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # @see the `==` method implementation in child classes + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Builds the object from hash + # @param attributes [Hash] Model attributes in the form of hash + # @return [Object] Returns the model itself + # @!visibility private + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + unless self.respond_to?(:additional_properties) + unless attributes.keys.all? { |key| self.class.openapi_types.key?(key) } + raise SchemaMismatchError, "Additional properties are not allowed" + end + end + self.class.openapi_types.each_pair do |key, type| + if attributes.key?(self.class.attribute_map[key]) && 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? + res = _deserialize(type, attributes[self.class.attribute_map[key]]) + if res.instance_of? DatadogAPIClient::UnparsedObject + self._unparsed = true + elsif (res.kind_of? DatadogAPIClient::V1_20270101::BaseGenericModel) && res._unparsed + self._unparsed = true + end + self.send("#{key}=", res) + end + end + + if self.respond_to?(:additional_properties) + attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + end + } + end + + self + end + + # Deserializes the data based on type + # @param type [string] Data type + # @param value [string] Value to be deserialized + # @return [Object] Deserialized data + # @!visibility private + def _deserialize(type, value) + return nil if value == nil + 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 :UUID + value.to_s + 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), including models from the base API namespace, or oneOf + klass = DatadogAPIClient::V1_20270101.model_class(type) + res = klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + if res.instance_of? DatadogAPIClient::UnparsedObject + self._unparsed = true + end + res + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + # @!visibility private + 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 + # @!visibility private + def to_body + to_hash + end + + # Returns the object in the form of hash + # @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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param value [Object] Any valid value + # @return [Hash] Returns the value in the form of hash + # @!visibility private + 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 + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + true + end + + module ClassMethods + # Builds the object from hash + # @param attributes [Hash] Model attributes in the form of hash + # @return [Object] Returns the model itself + # @!visibility private + def build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # List of attributes with nullable: true + # @!visibility private + def openapi_nullable + Set[] + end + end + + def self.included(base) + base.extend(ClassMethods) + end + end + + module BaseOneOfModel + attr_accessor :_unparsed + end + + module BaseOneOfModelNoDiscriminator + + private + + SchemaMismatchError = Class.new(StandardError) + + # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. + def find_and_cast_into_type(klass, data) + return if data.nil? + + case klass.to_s + when 'Boolean' + return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass) + when 'Float' + return data if data.instance_of?(Float) || data.instance_of?(Integer) + when 'Integer' + return data if data.instance_of?(Integer) + when 'Time' + return Time.parse(data) + when 'Date' + return Date.parse(data) + when 'String' + return data if data.instance_of?(String) + when 'Object' # "type: object" + return data if data.instance_of?(Hash) + when 'UUID' + return UUIDTools::UUID.parse(data) + when /\AArray<(?.+)>\z/ # "type: array" + if data.instance_of?(Array) + sub_type = Regexp.last_match[:sub_type] + return data.map { |item| find_and_cast_into_type(sub_type, item) } + end + when /\AHash.+)>\z/ # "type: object" with "additionalProperties: { ... }" + if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) } + sub_type = Regexp.last_match[:sub_type] + return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } + end + else # model + const = DatadogAPIClient::V1_20270101.model_class(klass) + if const + if const.respond_to?(:openapi_one_of) # nested oneOf model + model = const.build(data) + return model if model + else + model = const.build_from_hash(data) + return model if model && model.valid? + end + end + end + + raise # if no match by now, raise + rescue + raise SchemaMismatchError, "#{data} doesn't match the #{klass} type" + end + end +end diff --git a/lib/datadog_api_client/v1_20270101/models/dashboard_summary.rb b/lib/datadog_api_client/v1_20270101/models/dashboard_summary.rb new file mode 100644 index 000000000000..8146cac34b1a --- /dev/null +++ b/lib/datadog_api_client/v1_20270101/models/dashboard_summary.rb @@ -0,0 +1,117 @@ +=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_20270101 + # Dashboard summary response. + class DashboardSummary + include BaseGenericModel + + # List of dashboard definitions. + attr_accessor :dashboards + + # Number of dashboards. + attr_accessor :total + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'dashboards' => :'dashboards', + :'total' => :'total' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'dashboards' => :'Array', + :'total' => :'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_20270101::DashboardSummary` 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?(:'dashboards') + if (value = attributes[:'dashboards']).is_a?(Array) + self.dashboards = value + end + end + + if attributes.key?(:'total') + self.total = attributes[:'total'] + end + 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 && + dashboards == o.dashboards && + total == o.total && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [dashboards, total, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1_20270101/models/dashboard_summary_definition.rb b/lib/datadog_api_client/v1_20270101/models/dashboard_summary_definition.rb new file mode 100644 index 000000000000..5150e859a5a7 --- /dev/null +++ b/lib/datadog_api_client/v1_20270101/models/dashboard_summary_definition.rb @@ -0,0 +1,278 @@ +=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_20270101 + # Dashboard definition. + class DashboardSummaryDefinition + include BaseGenericModel + + # Object describing the creator of the shared element. + attr_accessor :author + + # Date of creation of the dashboard. + attr_accessor :created + + # URL to the icon of the dashboard. + attr_accessor :icon + + # ID of the dashboard. + attr_accessor :id + + # The short name of the integration. + attr_accessor :integration_id + + # Whether the dashboard is in the favorites. + attr_accessor :is_favorite + + # Whether the dashboard is read only. + attr_accessor :is_read_only + + # Whether the dashboard is publicly shared. + attr_accessor :is_shared + + # Date when the dashboard was last viewed. + attr_accessor :last_view_date + + # Date of last edition of the dashboard. + attr_accessor :modified + + # Popularity of the dashboard. + attr_reader :popularity + + # List of team names representing ownership of the dashboard. + attr_accessor :tags + + # Title of the dashboard. + attr_accessor :title + + # The type of the dashboard. + attr_accessor :type + + # URL path to the dashboard. + attr_accessor :url + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'author' => :'author', + :'created' => :'created', + :'icon' => :'icon', + :'id' => :'id', + :'integration_id' => :'integration_id', + :'is_favorite' => :'is_favorite', + :'is_read_only' => :'is_read_only', + :'is_shared' => :'is_shared', + :'last_view_date' => :'last_view_date', + :'modified' => :'modified', + :'popularity' => :'popularity', + :'tags' => :'tags', + :'title' => :'title', + :'type' => :'type', + :'url' => :'url' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'author' => :'DatadogAPIClient::V1::Creator', + :'created' => :'Time', + :'icon' => :'String', + :'id' => :'DashboardSummaryID', + :'integration_id' => :'String', + :'is_favorite' => :'Boolean', + :'is_read_only' => :'Boolean', + :'is_shared' => :'Boolean', + :'last_view_date' => :'String', + :'modified' => :'Time', + :'popularity' => :'Integer', + :'tags' => :'Array', + :'title' => :'String', + :'type' => :'String', + :'url' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'created', + :'icon', + :'integration_id', + :'last_view_date', + :'modified', + :'tags', + ]) + 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_20270101::DashboardSummaryDefinition` 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?(:'author') + self.author = attributes[:'author'] + end + + if attributes.key?(:'created') + self.created = attributes[:'created'] + end + + if attributes.key?(:'icon') + self.icon = attributes[:'icon'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'integration_id') + self.integration_id = attributes[:'integration_id'] + end + + if attributes.key?(:'is_favorite') + self.is_favorite = attributes[:'is_favorite'] + end + + if attributes.key?(:'is_read_only') + self.is_read_only = attributes[:'is_read_only'] + end + + if attributes.key?(:'is_shared') + self.is_shared = attributes[:'is_shared'] + end + + if attributes.key?(:'last_view_date') + self.last_view_date = attributes[:'last_view_date'] + end + + if attributes.key?(:'modified') + self.modified = attributes[:'modified'] + end + + if attributes.key?(:'popularity') + self.popularity = attributes[:'popularity'] + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + + if attributes.key?(:'title') + self.title = attributes[:'title'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'url') + self.url = attributes[:'url'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if !@popularity.nil? && @popularity > 5 + true + end + + # Custom attribute writer method with validation + # @param popularity [Object] Object to be assigned + # @!visibility private + def popularity=(popularity) + if !popularity.nil? && popularity > 5 + fail ArgumentError, 'invalid value for "popularity", must be smaller than or equal to 5.' + end + @popularity = popularity + 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 && + author == o.author && + created == o.created && + icon == o.icon && + id == o.id && + integration_id == o.integration_id && + is_favorite == o.is_favorite && + is_read_only == o.is_read_only && + is_shared == o.is_shared && + last_view_date == o.last_view_date && + modified == o.modified && + popularity == o.popularity && + tags == o.tags && + title == o.title && + type == o.type && + url == o.url && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [author, created, icon, id, integration_id, is_favorite, is_read_only, is_shared, last_view_date, modified, popularity, tags, title, type, url, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1_20270101/models/dashboard_summary_id.rb b/lib/datadog_api_client/v1_20270101/models/dashboard_summary_id.rb new file mode 100644 index 000000000000..4823e123d3ca --- /dev/null +++ b/lib/datadog_api_client/v1_20270101/models/dashboard_summary_id.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_20270101 + # ID of the dashboard. + module DashboardSummaryID + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'String', + :'Integer' + ] + 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/v2/model_base.rb b/lib/datadog_api_client/v2/model_base.rb index 7bdfde0c6bcd..a429f3851e68 100644 --- a/lib/datadog_api_client/v2/model_base.rb +++ b/lib/datadog_api_client/v2/model_base.rb @@ -14,6 +14,10 @@ =end module DatadogAPIClient::V2 + def self.model_class(type) + type.to_s.include?('::') ? Object.const_get(type.to_s) : const_get(type) + end + module BaseEnumModel # Builds the enum from string # @param value [String] The enum value in the form of the string @@ -137,8 +141,8 @@ def _deserialize(type, value) end end else # model - # models (e.g. Pet) or oneOf - klass = DatadogAPIClient::V2.const_get(type) + # models (e.g. Pet), including models from the base API namespace, or oneOf + klass = DatadogAPIClient::V2.model_class(type) res = klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) if res.instance_of? DatadogAPIClient::UnparsedObject self._unparsed = true @@ -267,7 +271,7 @@ def find_and_cast_into_type(klass, data) return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) } end else # model - const = DatadogAPIClient::V2.const_get(klass) + const = DatadogAPIClient::V2.model_class(klass) if const if const.respond_to?(:openapi_one_of) # nested oneOf model model = const.build(data)