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.

7 changes: 7 additions & 0 deletions docs/datadog_api_client.v2.api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ datadog\_api\_client.v2.api.datasets\_api module
:members:
:show-inheritance:

datadog\_api\_client.v2.api.ddsql\_api module
---------------------------------------------

.. automodule:: datadog_api_client.v2.api.ddsql_api
:members:
:show-inheritance:

datadog\_api\_client.v2.api.deployment\_gates\_api module
---------------------------------------------------------

Expand Down
112 changes: 112 additions & 0 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11771,6 +11771,118 @@ datadog\_api\_client.v2.model.datastore\_trigger\_wrapper module
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_column module
------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_column
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_fetch\_request module
--------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_fetch_request
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_fetch\_request\_attributes module
--------------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_fetch_request_attributes
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_fetch\_request\_data module
--------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_fetch_request_data
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_fetch\_request\_type module
--------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_fetch_request_type
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_request module
-------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_request
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_request\_attributes module
-------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_request_attributes
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_request\_data module
-------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_request_data
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_request\_type module
-------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_request_type
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_response module
--------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_response
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_response\_attributes module
--------------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_response_attributes
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_response\_data module
--------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_response_data
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_response\_meta module
--------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_response_meta
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_response\_type module
--------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_response_type
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_state module
-----------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_state
:members:
:show-inheritance:

datadog\_api\_client.v2.model.ddsql\_tabular\_query\_time\_window module
------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.ddsql_tabular_query_time_window
:members:
:show-inheritance:

datadog\_api\_client.v2.model.default\_rulesets\_per\_language\_data module
---------------------------------------------------------------------------

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

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.ddsql_api import DDSQLApi
from datadog_api_client.v2.model.ddsql_tabular_query_request import DdsqlTabularQueryRequest
from datadog_api_client.v2.model.ddsql_tabular_query_request_attributes import DdsqlTabularQueryRequestAttributes
from datadog_api_client.v2.model.ddsql_tabular_query_request_data import DdsqlTabularQueryRequestData
from datadog_api_client.v2.model.ddsql_tabular_query_request_type import DdsqlTabularQueryRequestType
from datadog_api_client.v2.model.ddsql_tabular_query_time_window import DdsqlTabularQueryTimeWindow

body = DdsqlTabularQueryRequest(
data=DdsqlTabularQueryRequestData(
attributes=DdsqlTabularQueryRequestAttributes(
query="SELECT cloud_provider, count(*) FROM dd.hosts group by cloud_provider",
row_limit=1000,
time=DdsqlTabularQueryTimeWindow(
from_timestamp=1736942400000,
to_timestamp=1736946000000,
),
),
type=DdsqlTabularQueryRequestType.DDSQL_QUERY_REQUEST,
),
)

configuration = Configuration()
configuration.unstable_operations["execute_ddsql_tabular_query"] = True
with ApiClient(configuration) as api_client:
api_instance = DDSQLApi(api_client)
response = api_instance.execute_ddsql_tabular_query(body=body)

print(response)
29 changes: 29 additions & 0 deletions examples/v2/ddsql/FetchDdsqlTabularQuery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Fetch the result of a DDSQL query returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.ddsql_api import DDSQLApi
from datadog_api_client.v2.model.ddsql_tabular_query_fetch_request import DdsqlTabularQueryFetchRequest
from datadog_api_client.v2.model.ddsql_tabular_query_fetch_request_attributes import (
DdsqlTabularQueryFetchRequestAttributes,
)
from datadog_api_client.v2.model.ddsql_tabular_query_fetch_request_data import DdsqlTabularQueryFetchRequestData
from datadog_api_client.v2.model.ddsql_tabular_query_fetch_request_type import DdsqlTabularQueryFetchRequestType

body = DdsqlTabularQueryFetchRequest(
data=DdsqlTabularQueryFetchRequestData(
attributes=DdsqlTabularQueryFetchRequestAttributes(
query_id="eyJxdWVyeSI6ICJTRUxFQ1QgKiBGUk9NIGxvZ3MifQ==",
),
type=DdsqlTabularQueryFetchRequestType.DDSQL_QUERY_FETCH_REQUEST,
),
)

configuration = Configuration()
configuration.unstable_operations["fetch_ddsql_tabular_query"] = True
with ApiClient(configuration) as api_client:
api_instance = DDSQLApi(api_client)
response = api_instance.fetch_ddsql_tabular_query(body=body)

print(response)
2 changes: 2 additions & 0 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ def __init__(
"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
103 changes: 103 additions & 0 deletions src/datadog_api_client/v2/api/ddsql_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 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 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Any, Dict

from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint
from datadog_api_client.configuration import Configuration
from datadog_api_client.v2.model.ddsql_tabular_query_response import DdsqlTabularQueryResponse
from datadog_api_client.v2.model.ddsql_tabular_query_request import DdsqlTabularQueryRequest
from datadog_api_client.v2.model.ddsql_tabular_query_fetch_request import DdsqlTabularQueryFetchRequest


class DDSQLApi:
"""
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.
"""

def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient(Configuration())
self.api_client = api_client

self._execute_ddsql_tabular_query_endpoint = _Endpoint(
settings={
"response_type": (DdsqlTabularQueryResponse,),
"auth": ["apiKeyAuth", "appKeyAuth"],
"endpoint_path": "/api/v2/ddsql/query/tabular",
"operation_id": "execute_ddsql_tabular_query",
"http_method": "POST",
"version": "v2",
},
params_map={
"body": {
"required": True,
"openapi_types": (DdsqlTabularQueryRequest,),
"location": "body",
},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
api_client=api_client,
)

self._fetch_ddsql_tabular_query_endpoint = _Endpoint(
settings={
"response_type": (DdsqlTabularQueryResponse,),
"auth": ["apiKeyAuth", "appKeyAuth"],
"endpoint_path": "/api/v2/ddsql/query/tabular/fetch",
"operation_id": "fetch_ddsql_tabular_query",
"http_method": "POST",
"version": "v2",
},
params_map={
"body": {
"required": True,
"openapi_types": (DdsqlTabularQueryFetchRequest,),
"location": "body",
},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
api_client=api_client,
)

def execute_ddsql_tabular_query(
self,
body: DdsqlTabularQueryRequest,
) -> DdsqlTabularQueryResponse:
"""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.

:type body: DdsqlTabularQueryRequest
:rtype: DdsqlTabularQueryResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["body"] = body

return self._execute_ddsql_tabular_query_endpoint.call_with_http_info(**kwargs)

def fetch_ddsql_tabular_query(
self,
body: DdsqlTabularQueryFetchRequest,
) -> DdsqlTabularQueryResponse:
"""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.

:type body: DdsqlTabularQueryFetchRequest
:rtype: DdsqlTabularQueryResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["body"] = body

return self._fetch_ddsql_tabular_query_endpoint.call_with_http_info(**kwargs)
2 changes: 2 additions & 0 deletions src/datadog_api_client/v2/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from datadog_api_client.v2.api.container_images_api import ContainerImagesApi
from datadog_api_client.v2.api.containers_api import ContainersApi
from datadog_api_client.v2.api.customer_org_api import CustomerOrgApi
from datadog_api_client.v2.api.ddsql_api import DDSQLApi
from datadog_api_client.v2.api.dora_metrics_api import DORAMetricsApi
from datadog_api_client.v2.api.dashboard_lists_api import DashboardListsApi
from datadog_api_client.v2.api.dashboard_secure_embed_api import DashboardSecureEmbedApi
Expand Down Expand Up @@ -175,6 +176,7 @@
"ContainerImagesApi",
"ContainersApi",
"CustomerOrgApi",
"DDSQLApi",
"DORAMetricsApi",
"DashboardListsApi",
"DashboardSecureEmbedApi",
Expand Down
56 changes: 56 additions & 0 deletions src/datadog_api_client/v2/model/ddsql_tabular_query_column.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Any, List

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
date,
datetime,
none_type,
UUID,
)


class DdsqlTabularQueryColumn(ModelNormal):
@cached_property
def openapi_types(_):
return {
"name": (str,),
"type": (str,),
"values": ([bool, date, datetime, dict, float, int, list, str, UUID, none_type],),
}

attribute_map = {
"name": "name",
"type": "type",
"values": "values",
}

def __init__(self_, name: str, type: str, values: List[Any], **kwargs):
"""
A single column of a DDSQL tabular query result.

:param name: Name of the column as projected by the SQL statement.
:type name: str

:param type: DDSQL data type of the column's values, for example ``VARCHAR`` , ``BIGINT`` ,
``DECIMAL`` , ``BOOLEAN`` , ``TIMESTAMP`` , ``JSON`` , or an array variant such as
``VARCHAR[]``. See the
`DDSQL data-types reference <https://docs.datadoghq.com/ddsql_reference/#data-types>`_
for the full, up-to-date list.
:type type: str

:param values: Column values in row order. The element type matches the column's ``type`` ;
for example a ``VARCHAR`` column carries strings, a ``TIMESTAMP`` column carries
Unix-millisecond integers. ``null`` is allowed for missing values.
:type values: [bool, date, datetime, dict, float, int, list, str, UUID, none_type]
"""
super().__init__(kwargs)

self_.name = name
self_.type = type
self_.values = values
Loading
Loading