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
482 changes: 482 additions & 0 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions examples/v2/ddsql/ExecuteDdsqlTabularQuery.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Execute a tabular DDSQL query returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.execute_ddsql_tabular_query".to_sym] = true
end
api_instance = DatadogAPIClient::V2::DDSQLAPI.new

body = DatadogAPIClient::V2::DdsqlTabularQueryRequest.new({
data: DatadogAPIClient::V2::DdsqlTabularQueryRequestData.new({
attributes: DatadogAPIClient::V2::DdsqlTabularQueryRequestAttributes.new({
query: "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
row_limit: 1000,
time: DatadogAPIClient::V2::DdsqlTabularQueryTimeWindow.new({
from_timestamp: 1736942400000,
to_timestamp: 1736946000000,
}),
}),
type: DatadogAPIClient::V2::DdsqlTabularQueryRequestType::DDSQL_QUERY_REQUEST,
}),
})
p api_instance.execute_ddsql_tabular_query(body)
17 changes: 17 additions & 0 deletions examples/v2/ddsql/FetchDdsqlTabularQuery.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Fetch the result of a DDSQL query returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.fetch_ddsql_tabular_query".to_sym] = true
end
api_instance = DatadogAPIClient::V2::DDSQLAPI.new

body = DatadogAPIClient::V2::DdsqlTabularQueryFetchRequest.new({
data: DatadogAPIClient::V2::DdsqlTabularQueryFetchRequestData.new({
attributes: DatadogAPIClient::V2::DdsqlTabularQueryFetchRequestAttributes.new({
query_id: "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ==",
}),
type: DatadogAPIClient::V2::DdsqlTabularQueryFetchRequestType::DDSQL_QUERY_FETCH_REQUEST,
}),
})
p api_instance.fetch_ddsql_tabular_query(body)
6 changes: 6 additions & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3109,6 +3109,12 @@
"dataset_id" => "String",
"body" => "DatasetUpdateRequest",
},
"v2.ExecuteDdsqlTabularQuery" => {
"body" => "DdsqlTabularQueryRequest",
},
"v2.FetchDdsqlTabularQuery" => {
"body" => "DdsqlTabularQueryFetchRequest",
},
"v2.CreateDataDeletionRequest" => {
"product" => "String",
"body" => "CreateDataDeletionRequestBody",
Expand Down
44 changes: 44 additions & 0 deletions features/v2/ddsql.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@endpoint(ddsql) @endpoint(ddsql-v2)
Feature: DDSQL
Execute DDSQL queries against the Datadog data catalog and poll for their
results. Queries are dispatched asynchronously: the initial request may
return a `running` state with a `query_id`, and clients poll the fetch
endpoint until the response transitions to `completed` with a column-major
result set.

Background:
Given a valid "apiKeyAuth" key in the system
And a valid "appKeyAuth" key in the system
And an instance of "DDSQL" API

@generated @skip @team:DataDog/query-apis
Scenario: Execute a tabular DDSQL query returns "Bad Request" response
Given operation "ExecuteDdsqlTabularQuery" enabled
And new "ExecuteDdsqlTabularQuery" request
And body with value {"data": {"attributes": {"query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider", "row_limit": 1000, "time": {"from_timestamp": 1736942400000, "to_timestamp": 1736946000000}}, "type": "ddsql_query_request"}}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/query-apis
Scenario: Execute a tabular DDSQL query returns "OK" response
Given operation "ExecuteDdsqlTabularQuery" enabled
And new "ExecuteDdsqlTabularQuery" request
And body with value {"data": {"attributes": {"query": "SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider", "row_limit": 1000, "time": {"from_timestamp": 1736942400000, "to_timestamp": 1736946000000}}, "type": "ddsql_query_request"}}
When the request is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/query-apis
Scenario: Fetch the result of a DDSQL query returns "Bad Request" response
Given operation "FetchDdsqlTabularQuery" enabled
And new "FetchDdsqlTabularQuery" request
And body with value {"data": {"attributes": {"query_id": "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ=="}, "type": "ddsql_query_fetch_request"}}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/query-apis
Scenario: Fetch the result of a DDSQL query returns "OK" response
Given operation "FetchDdsqlTabularQuery" enabled
And new "FetchDdsqlTabularQuery" request
And body with value {"data": {"attributes": {"query_id": "eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ=="}, "type": "ddsql_query_fetch_request"}}
When the request is sent
Then the response status is 200 OK
12 changes: 12 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2285,6 +2285,18 @@
"type": "idempotent"
}
},
"ExecuteDdsqlTabularQuery": {
"tag": "DDSQL",
"undo": {
"type": "idempotent"
}
},
"FetchDdsqlTabularQuery": {
"tag": "DDSQL",
"undo": {
"type": "safe"
}
},
"CreateDataDeletionRequest": {
"tag": "Data Deletion",
"undo": {
Expand Down
2 changes: 2 additions & 0 deletions lib/datadog_api_client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ def initialize
"v2.get_all_datasets": false,
"v2.get_dataset": false,
"v2.update_dataset": false,
"v2.execute_ddsql_tabular_query": false,
"v2.fetch_ddsql_tabular_query": false,
"v2.cancel_data_deletion_request": false,
"v2.create_data_deletion_request": false,
"v2.get_data_deletion_requests": false,
Expand Down
17 changes: 17 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2829,6 +2829,22 @@ def overrides
"v2.data_transform" => "DataTransform",
"v2.data_transform_properties" => "DataTransformProperties",
"v2.data_transform_type" => "DataTransformType",
"v2.ddsql_tabular_query_column" => "DdsqlTabularQueryColumn",
"v2.ddsql_tabular_query_fetch_request" => "DdsqlTabularQueryFetchRequest",
"v2.ddsql_tabular_query_fetch_request_attributes" => "DdsqlTabularQueryFetchRequestAttributes",
"v2.ddsql_tabular_query_fetch_request_data" => "DdsqlTabularQueryFetchRequestData",
"v2.ddsql_tabular_query_fetch_request_type" => "DdsqlTabularQueryFetchRequestType",
"v2.ddsql_tabular_query_request" => "DdsqlTabularQueryRequest",
"v2.ddsql_tabular_query_request_attributes" => "DdsqlTabularQueryRequestAttributes",
"v2.ddsql_tabular_query_request_data" => "DdsqlTabularQueryRequestData",
"v2.ddsql_tabular_query_request_type" => "DdsqlTabularQueryRequestType",
"v2.ddsql_tabular_query_response" => "DdsqlTabularQueryResponse",
"v2.ddsql_tabular_query_response_attributes" => "DdsqlTabularQueryResponseAttributes",
"v2.ddsql_tabular_query_response_data" => "DdsqlTabularQueryResponseData",
"v2.ddsql_tabular_query_response_meta" => "DdsqlTabularQueryResponseMeta",
"v2.ddsql_tabular_query_response_type" => "DdsqlTabularQueryResponseType",
"v2.ddsql_tabular_query_state" => "DdsqlTabularQueryState",
"v2.ddsql_tabular_query_time_window" => "DdsqlTabularQueryTimeWindow",
"v2.default_rulesets_per_language_data" => "DefaultRulesetsPerLanguageData",
"v2.default_rulesets_per_language_data_attributes" => "DefaultRulesetsPerLanguageDataAttributes",
"v2.default_rulesets_per_language_data_type" => "DefaultRulesetsPerLanguageDataType",
Expand Down Expand Up @@ -8146,6 +8162,7 @@ def overrides
"v2.data_deletion_api" => "DataDeletionAPI",
"v2.data_observability_api" => "DataObservabilityAPI",
"v2.datasets_api" => "DatasetsAPI",
"v2.ddsql_api" => "DDSQLAPI",
"v2.deployment_gates_api" => "DeploymentGatesAPI",
"v2.domain_allowlist_api" => "DomainAllowlistAPI",
"v2.dora_metrics_api" => "DORAMetricsAPI",
Expand Down
177 changes: 177 additions & 0 deletions lib/datadog_api_client/v2/api/ddsql_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
=begin
#Datadog API V2 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::V2
class DDSQLAPI
attr_accessor :api_client

def initialize(api_client = DatadogAPIClient::APIClient.default)
@api_client = api_client
end

# Execute a tabular DDSQL query.
#
# @see #execute_ddsql_tabular_query_with_http_info
def execute_ddsql_tabular_query(body, opts = {})
data, _status_code, _headers = execute_ddsql_tabular_query_with_http_info(body, opts)
data
end

# Execute a tabular DDSQL query.
#
# Submit a DDSQL statement and return either a `running` state with an opaque `query_id`
# for the client to poll, or a `completed` state with the column-major result set inlined
# when the query finishes quickly enough to be served synchronously.
#
# @param body [DdsqlTabularQueryRequest]
# @param opts [Hash] the optional parameters
# @return [Array<(DdsqlTabularQueryResponse, Integer, Hash)>] DdsqlTabularQueryResponse data, response status code and response headers
def execute_ddsql_tabular_query_with_http_info(body, opts = {})
unstable_enabled = @api_client.config.unstable_operations["v2.execute_ddsql_tabular_query".to_sym]
if unstable_enabled
@api_client.config.logger.warn format("Using unstable operation '%s'", "v2.execute_ddsql_tabular_query")
else
raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.execute_ddsql_tabular_query"))
end

if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: DDSQLAPI.execute_ddsql_tabular_query ...'
end
# verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling DDSQLAPI.execute_ddsql_tabular_query"
end
# resource path
local_var_path = '/api/v2/ddsql/query/tabular'

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

# return_type
return_type = opts[:debug_return_type] || 'DdsqlTabularQueryResponse'

# auth_names
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

new_options = opts.merge(
:operation => :execute_ddsql_tabular_query,
: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 => "V2"
)

data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: DDSQLAPI#execute_ddsql_tabular_query\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Fetch the result of a DDSQL query.
#
# @see #fetch_ddsql_tabular_query_with_http_info
def fetch_ddsql_tabular_query(body, opts = {})
data, _status_code, _headers = fetch_ddsql_tabular_query_with_http_info(body, opts)
data
end

# Fetch the result of a DDSQL query.
#
# Poll a previously submitted DDSQL query for results. Pass the opaque `query_id` returned
# by a prior `ExecuteDdsqlTabularQuery` (or by a prior `FetchDdsqlTabularQuery` that
# returned `state: running`) and the server returns either a `running` state to poll again
# or a `completed` state with the column-major result set inlined.
#
# @param body [DdsqlTabularQueryFetchRequest]
# @param opts [Hash] the optional parameters
# @return [Array<(DdsqlTabularQueryResponse, Integer, Hash)>] DdsqlTabularQueryResponse data, response status code and response headers
def fetch_ddsql_tabular_query_with_http_info(body, opts = {})
unstable_enabled = @api_client.config.unstable_operations["v2.fetch_ddsql_tabular_query".to_sym]
if unstable_enabled
@api_client.config.logger.warn format("Using unstable operation '%s'", "v2.fetch_ddsql_tabular_query")
else
raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.fetch_ddsql_tabular_query"))
end

if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: DDSQLAPI.fetch_ddsql_tabular_query ...'
end
# verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling DDSQLAPI.fetch_ddsql_tabular_query"
end
# resource path
local_var_path = '/api/v2/ddsql/query/tabular/fetch'

# query parameters
query_params = opts[:query_params] || {}

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

# return_type
return_type = opts[:debug_return_type] || 'DdsqlTabularQueryResponse'

# auth_names
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

new_options = opts.merge(
:operation => :fetch_ddsql_tabular_query,
: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 => "V2"
)

data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: DDSQLAPI#fetch_ddsql_tabular_query\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
Loading
Loading