Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 107 additions & 8 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:<name>`.
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:
Expand Down
6 changes: 6 additions & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 4 additions & 3 deletions lib/datadog_api_client/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion lib/datadog_api_client/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions lib/datadog_api_client/v1/model_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
121 changes: 121 additions & 0 deletions lib/datadog_api_client/v1_20270101/api/dashboards_api.rb
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading