Giter VIP home page Giter VIP logo

datadog-api-client-python's Introduction

datadog-api-client-python

This repository contains a Python API client for the Datadog API.

Requirements

Building and using the API client library requires Python 3.7+.

Installation

To install the API client library, simply execute:

pip install datadog-api-client

Getting Started

Please follow the installation instruction and execute the following Python code:

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_type import MonitorType

body = Monitor(
    name="example",
    type=MonitorType("log alert"),
    query='logs("service:foo AND type:error").index("main").rollup("count").by("source").last("5m") > 2',
    message="some message Notify: @hipchat-channel",
    tags=["test:example", "env:ci"],
    priority=3,
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.create_monitor(body=body)
    print(response)

Authentication

By default the library will use the DD_API_KEY and DD_APP_KEY environment variables to authenticate against the Datadog API. To provide your own set of credentials, you need to set some keys on the configuration:

configuration.api_key["apiKeyAuth"] = "<API KEY>"
configuration.api_key["appKeyAuth"] = "<APPLICATION KEY>"

Unstable Endpoints

This client includes access to Datadog API endpoints while they are in an unstable state and may undergo breaking changes. An extra configuration step is required to enable these endpoints:

configuration.unstable_operations["<OperationName>"] = True

where <OperationName> is the name of the method used to interact with that endpoint. For example: list_log_indexes, or get_logs_index

Changing Server

When talking to a different server, like the eu instance, change the server_variables on your configuration object:

configuration.server_variables["site"] = "datadoghq.eu"

Disable compressed payloads

If you want to disable GZIP compressed responses, set the compress flag on your configuration object:

configuration.compress = False

Enable requests logging

If you want to enable requests logging, set the debug flag on your configuration object:

configuration.debug = True

Enable retry

If you want to enable retry when getting status code 429 rate-limited, set enable_retry to True

    configuration.enable_retry = True

The default max retry is 3, you can change it with max_retries

    configuration.max_retries = 5

Configure proxy

You can configure the client to use proxy by setting the proxy key on configuration object:

configuration.proxy = "http://127.0.0.1:80"

Threads support

You can run API calls in a thread by using ThreadedApiClient in place of ApiClient. API calls will then return a AsyncResult instance on which you can call get to retrieve the result:

from datadog_api_client import Configuration, ThreadedApiClient
from datadog_api_client.v1.api.dashboards_api import DashboardsApi

configuration = Configuration()
with ThreadedApiClient(configuration) as api_client:
    api_instance = DashboardsApi(api_client)
    result = api_instance.list_dashboards()
    dashboards = result.get()
    print(dashboards)

Asyncio support

The library supports asynchronous operations when using AsyncApiClient for the transport. When that client is used, the API methods will then return coroutines that you can wait for.

To make async support available, you need to install the extra async qualifiers during installation: pip install datadog-api-client[async].

import asyncio

from datadog_api_client import Configuration, AsyncApiClient
from datadog_api_client.v1.api.dashboards_api import DashboardsApi

async def main():
    configuration = Configuration()
    async with AsyncApiClient(configuration) as api_client:
        api_instance = DashboardsApi(api_client)
        dashboards = await api_instance.list_dashboards()
        print(dashboards)

asyncio.run(main())

Pagination

Several listing operations have a pagination method to help consume all the items available. For example, to retrieve all your incidents:

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.incidents_api import IncidentsApi

configuration = Configuration()
configuration.unstable_operations["list_incidents"] = True
with ApiClient(configuration) as api_client:
    api_instance = IncidentsApi(api_client)
    for incident in api_instance.list_incidents_with_pagination():
        print(incident.id)

Documentation for API Endpoints and Models

Documentation for API endpoints and models are available on readthedocs.

Documentation for Authorization

Authenticate with the API by providing your API and Application keys in the configuration:

configuration.api_key["apiKeyAuth"] = "YOUR_API_KEY"
configuration.api_key["appKeyAuth"] = "YOUR_APPLICATION_KEY"

Author

[email protected]

datadog-api-client-python's People

Contributors

antonio-ramadas-dd avatar api-clients-generation-pipeline[bot] avatar chowmean avatar dependabot[bot] avatar fabianvf avatar gbmarc1 avatar hantingzhang2 avatar jack-edmonds-dd avatar jirikuncar avatar jmini avatar juan-fernandez avatar kylmakalle avatar loveisgrief avatar meadsteve avatar nkzou avatar nmuesch avatar nouemankhal avatar ronnypfannschmidt avatar saigiridhar21 avatar sarod avatar sebastien-rosset avatar skarimo avatar spacether avatar therve avatar timgclark avatar tomplus avatar vvb avatar wing328 avatar wy193777 avatar zippolyte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

datadog-api-client-python's Issues

Can't use requests with datadog-api

When requests.py is imported with the datadog-api, requests do not work.

To Reproduce
Import requests.py and follow one of the examples from the documentation.

Expected behavior
The datadog-api library working with other business logic that uses the popular requests library.

Screenshots

Traceback (most recent call last):
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 485, in wrap_socket
    cnx.do_handshake()
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1934, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/OpenSSL/SSL.py", line 1671, in _raise_ssl_error
    _raise_current_error()
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/connection.py", line 394, in connect
    ssl_context=context,
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 370, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 491, in wrap_socket
    raise ssl.SSLError("bad handshake: %r" % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  ...

  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/datadog_api_client/v2/api/logs_api.py", line 260, in list_logs
    return self._list_logs_endpoint.call_with_http_info(**kwargs)
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/datadog_api_client/v2/api_client.py", line 861, in call_with_http_info
    collection_formats=params["collection_format"],
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/datadog_api_client/v2/api_client.py", line 402, in call_api
    _check_type,
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/datadog_api_client/v2/api_client.py", line 189, in __call_api
    _request_timeout=_request_timeout,
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/datadog_api_client/v2/api_client.py", line 473, in request
    body=body,
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/datadog_api_client/v2/rest.py", line 308, in POST
    body=body,
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/datadog_api_client/v2/rest.py", line 161, in request
    headers=headers,
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/request.py", line 80, in request
    method, url, fields=fields, headers=headers, **urlopen_kw
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/connectionpool.py", line 762, in urlopen
    **response_kw
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/connectionpool.py", line 762, in urlopen
    **response_kw
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/connectionpool.py", line 762, in urlopen
    **response_kw
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/Users/paulstenius/.pyenv/versions/3.7.2/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.datadoghq.com', port=443): Max retries exceeded with url: /api/v2/logs/events/search (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

Environment and Versions
requests==2.22.0
datadog-api-client==1.0.0

TypeERror validation exceptions for new version 1.10.0 (working in 1.9.0)

Describe the bug

SDK is throwing exceptions in the validation of strings in both input and output parameters even in simple operations like list_orgs.

Exception when calling OrganizationsApi->list_orgs: TypeError("'>' not supported between instances of 'str' and 'int'")

kind/bug
severity/major

To Reproduce

You can get the erros with just having a simple piece of code like this:

import asyncio
from datadog_api_client.v1 import (
    AsyncApiClient,
    Configuration
)
from datadog_api_client.v1.api import (
    organizations_api,
)
from datadog_api_client.v1.models import (
    OrganizationCreateBody,
)

configuration = Configuration()
configuration.api_key["apiKeyAuth"] = "YOUR_API_KEY"
configuration.api_key["appKeyAuth"] = "YOUR_APPLICATION_KEY"

async def list_orgs():
    async with AsyncApiClient(configuration) as api_client:
        api_instance = organizations_api.OrganizationsApi(api_client)
        try:
            orgs = await api_instance.list_orgs()
            return orgs
        except Exception as e:
            print(f"Exception when calling OrganizationsApi->list_orgs: {repr(e)}\n")
            raise e


async def create_org(name: str):
    async with AsyncApiClient(configuration) as api_client:
        body = OrganizationCreateBody(
            name
        )
        return body

try:
    org = asyncio.run(list_orgs())
except Exception as e:
    print(e)

try:
    body = asyncio.run(create_org("test_name"))
except Exception as e:
    print(e)

Expected behavior

The expected behaviour is the code to work without exceptions, like in the previous version 1.09

Full Stack Trace

  File "/opt/python/3.8.12/lib/python3.8/unittest/async_case.py", line 65, in _callTestMethod
    self._callMaybeAsync(method)
  File "/opt/python/3.8.12/lib/python3.8/unittest/async_case.py", line 88, in _callMaybeAsync
    return self._asyncioTestLoop.run_until_complete(fut)
  File "/opt/python/3.8.12/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/opt/python/3.8.12/lib/python3.8/unittest/async_case.py", line 102, in _asyncioLoopRunner
    ret = await awaitable
  File "/home/travis/build/cloud-governance/catalogue/src/tests/test_adapters_datadog.py", line 95, in test_create_org
    result = await self._api_adapter.create_org('New child org')
  File "/home/travis/build/cloud-governance/catalogue/src/adapters/datadog/__init__.py", line 32, in create_org
    body = OrganizationCreateBody(
  File "/home/travis/virtualenv/python3.8.12/lib/python3.8/site-packages/datadog_api_client/v1/model/organization_create_body.py", line 62, in __init__
    self.name = name
  File "/home/travis/virtualenv/python3.8.12/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 189, in __setattr__
    self[attr] = value
  File "/home/travis/virtualenv/python3.8.12/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 560, in __setitem__
    self.set_attribute(name, value)
  File "/home/travis/virtualenv/python3.8.12/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 174, in set_attribute
    check_validations(self.validations[name], name, value, self._configuration)
  File "/home/travis/virtualenv/python3.8.12/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1039, in check_validations
    and max_val > validations["inclusive_maximum"]
TypeError: '>' not supported between instances of 'str' and 'int'

Environment and Versions:

  • Both Mac and Linux
  • Python version 3.8.5
  • datadog-api-client[async] 1.10.0

Additional context

In some of the GET queries (list_orgs or get_org), adding _check_return_type=False to the function parameters works as a workaround, but not for the creation of an organization.

Synthetics API GET Request Fails on UI Allowed Configuration

Describe the bug
A clear and concise description of what the bug is.

The bug occurs when you attempt to pull through GET request a synthetic test by ID that has a tick_every value of 600. In the UI you are able to set this value to 10m as a suggested "quick select" option, however when pulling from Datadog, this test will not be able to be retrieved due to the invalid configuration

Stack Trace identifying the value in question.

{
"errorMessage": "Invalid value for value (600), must be one of [60, 300, 900, 1800, 3600, 21600, 43200, 86400, 604800]",
"errorType": "ApiValueError",
"stackTrace": [
" File "/var/task/lambda_retagger_datadog.py", line 184, in lambda_handler\n monitors = get_monitors()\n",
" File "/var/task/lambda_retagger_datadog.py", line 162, in get_monitors\n response = api_instance.get_api_test(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/api/synthetics_api.py", line 1532, in get_api_test\n return self._get_api_test_endpoint.call_with_http_info(**kwargs)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 842, in call_with_http_info\n return self.api_client.call_api(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 386, in call_api\n return self.__call_api(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 214, in __call_api\n return_data = self.deserialize(response_data, response_type, _check_type)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 307, in deserialize\n deserialized_data = validate_and_convert_types(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1305, in validate_and_convert_types\n converted_instance = attempt_convert_item(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1202, in attempt_convert_item\n raise conversion_exc\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1194, in attempt_convert_item\n return deserialize_model(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1110, in deserialize_model\n return model_class(**kw_args)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1478, in wrapped_init\n return fn(self, *args, **kwargs)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model/synthetics_api_test.py", line 208, in init\n setattr(self, var_name, var_value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 143, in setattr\n self[attr] = value\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 316, in setitem\n self.set_attribute(name, value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 119, in set_attribute\n value = validate_and_convert_types(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1305, in validate_and_convert_types\n converted_instance = attempt_convert_item(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1202, in attempt_convert_item\n raise conversion_exc\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1194, in attempt_convert_item\n return deserialize_model(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1110, in deserialize_model\n return model_class(**kw_args)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1478, in wrapped_init\n return fn(self, *args, **kwargs)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model/synthetics_test_options.py", line 206, in init\n setattr(self, var_name, var_value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 143, in setattr\n self[attr] = value\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 316, in setitem\n self.set_attribute(name, value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 119, in set_attribute\n value = validate_and_convert_types(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1305, in validate_and_convert_types\n converted_instance = attempt_convert_item(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1202, in attempt_convert_item\n raise conversion_exc\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1194, in attempt_convert_item\n return deserialize_model(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1105, in deserialize_model\n return model_class(model_data, **kw_args)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1478, in wrapped_init\n return fn(self, *args, **kwargs)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model/synthetics_tick_interval.py", line 177, in init\n self.value = value\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 143, in setattr\n self[attr] = value\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 263, in setitem\n self.set_attribute(name, value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 128, in set_attribute\n check_allowed_values(self.allowed_values, (name,), value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 639, in check_allowed_values\n raise ApiValueError(\n"
]
}

Label the issue properly.

I think it's somewhat severe as it's preventing the use of the get one synthetic test and the list all synthetics tests api endpoint for my use case.

  • Add severity/ label.
  • Add documentation label if this issue is related to documentation changes.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://app.datadoghq.com/
  2. Click on UX Monitoring => Synthetic Tests => New Test
  3. Create your test with the setting 10m on Section 5: Define scheduling and alert conditions
  4. Use the Datadog API to request the Synthetic Test with the public ID of the one you created like below

Copied from the API Docs
"""
Get an API test returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = SyntheticsApi(api_client)
response = api_instance.get_api_test(
public_id="public_id",
)

print(response)

Expected behavior
The expected behavior is that the details of the Synthetics test will be retrieved.

Screenshots
{
"errorMessage": "Invalid value for value (600), must be one of [60, 300, 900, 1800, 3600, 21600, 43200, 86400, 604800]",
"errorType": "ApiValueError",
"stackTrace": [
" File "/var/task/lambda_retagger_datadog.py", line 184, in lambda_handler\n monitors = get_monitors()\n",
" File "/var/task/lambda_retagger_datadog.py", line 162, in get_monitors\n response = api_instance.get_api_test(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/api/synthetics_api.py", line 1532, in get_api_test\n return self._get_api_test_endpoint.call_with_http_info(**kwargs)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 842, in call_with_http_info\n return self.api_client.call_api(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 386, in call_api\n return self.__call_api(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 214, in __call_api\n return_data = self.deserialize(response_data, response_type, _check_type)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 307, in deserialize\n deserialized_data = validate_and_convert_types(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1305, in validate_and_convert_types\n converted_instance = attempt_convert_item(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1202, in attempt_convert_item\n raise conversion_exc\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1194, in attempt_convert_item\n return deserialize_model(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1110, in deserialize_model\n return model_class(**kw_args)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1478, in wrapped_init\n return fn(self, *args, **kwargs)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model/synthetics_api_test.py", line 208, in init\n setattr(self, var_name, var_value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 143, in setattr\n self[attr] = value\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 316, in setitem\n self.set_attribute(name, value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 119, in set_attribute\n value = validate_and_convert_types(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1305, in validate_and_convert_types\n converted_instance = attempt_convert_item(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1202, in attempt_convert_item\n raise conversion_exc\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1194, in attempt_convert_item\n return deserialize_model(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1110, in deserialize_model\n return model_class(**kw_args)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1478, in wrapped_init\n return fn(self, *args, **kwargs)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model/synthetics_test_options.py", line 206, in init\n setattr(self, var_name, var_value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 143, in setattr\n self[attr] = value\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 316, in setitem\n self.set_attribute(name, value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 119, in set_attribute\n value = validate_and_convert_types(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1305, in validate_and_convert_types\n converted_instance = attempt_convert_item(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1202, in attempt_convert_item\n raise conversion_exc\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1194, in attempt_convert_item\n return deserialize_model(\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1105, in deserialize_model\n return model_class(model_data, **kw_args)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1478, in wrapped_init\n return fn(self, *args, **kwargs)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model/synthetics_tick_interval.py", line 177, in init\n self.value = value\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 143, in setattr\n self[attr] = value\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 263, in setitem\n self.set_attribute(name, value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 128, in set_attribute\n check_allowed_values(self.allowed_values, (name,), value)\n",
" File "/opt/python/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 639, in check_allowed_values\n raise ApiValueError(\n"
]
}

Setting the time to one of the selected values from the array in the stack trace yields the correct result and displays the test.

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

Version 2.16.0 of the datadog_api_client installed via pip then uploaded to AWS Lambda as a layer
The snippet shown above in steps to reproduce with a specific ID to a synthetic I have made.

Additional context
Add any other context about the problem here.

No support for RUM datasource in scalar data queries

Doc says RUM is supported - https://docs.datadoghq.com/api/latest/metrics/?code-lang=python#query-scalar-data-across-multiple-products

This endpoint is GA for the metrics, real user monitoring (RUM) and cloud cost data sources. Support for logs is in beta. We are gradually onboarding support for more sources. If you have any feedback, contact Datadog support.

However, it appears only metrics and cloud_cost are supported - Would you be able to update the python SDK to support this?
https://github.com/DataDog/datadog-api-client-python/blob/master/src/datadog_api_client/v2/model/metrics_data_source.py#L23

Receiving 'invalid' value for query error when creating anomaly monitor

Describe the bug
I'm creating an anomaly monitor using the MonitorsApi API. I receive a 400 error telling me that my query is invalid

Label the issue properly.

  • Add severity/normal label. (I don't have permissions to edit the labels on this issue myself)

To Reproduce
Steps to reproduce the behavior:

  1. Create a monitor of a type "query alert"
  2. Provide a valid anomaly query string for the query field

See code sample:

from dotenv import load_dotenv
from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_type import MonitorType

load_dotenv()

monitor = Monitor(
    name="Reproduce Anomaly Creation Error",
    type=MonitorType("query alert"),
    query="avg(last_1d):anomalies(sum:metric_name{placement:tag}.as_count(),'agile',2,direction='below',alert_window='last_1h',interval=300,count_default_zero='true',seasonality='hourly')>=1",
    message="repro"
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    api_instance.create_monitor(body=monitor)

Expected behavior
Anomaly monitor is created

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

  • Using library version 1.7.0
  • Python 3.9.9, poetry package manager, python-dotenv library

Additional context
Error Log:

Traceback (most recent call last):
  File "/Users/isaiah/workspace/tool/datadog/datadog-alert-generator/simple_repro.py", line 19, in <module>
    api_instance.create_monitor(body=monitor)
  File "/Users/isaiah/Library/Caches/pypoetry/virtualenvs/datadog-alert-generator-saQsB-sU-py3.9/lib/python3.9/site-packages/datadog_api_client/v1/api/monitors_api.py", line 406, in create_monitor
    return self._create_monitor_endpoint.call_with_http_info(**kwargs)
  File "/Users/isaiah/Library/Caches/pypoetry/virtualenvs/datadog-alert-generator-saQsB-sU-py3.9/lib/python3.9/site-packages/datadog_api_client/v1/api_client.py", line 705, in call_with_http_info
    return self.api_client.call_api(
  File "/Users/isaiah/Library/Caches/pypoetry/virtualenvs/datadog-alert-generator-saQsB-sU-py3.9/lib/python3.9/site-packages/datadog_api_client/v1/api_client.py", line 370, in call_api
    return self._call_api(
  File "/Users/isaiah/Library/Caches/pypoetry/virtualenvs/datadog-alert-generator-saQsB-sU-py3.9/lib/python3.9/site-packages/datadog_api_client/v1/api_client.py", line 127, in _call_api
    response = self.rest_client.request(
  File "/Users/isaiah/Library/Caches/pypoetry/virtualenvs/datadog-alert-generator-saQsB-sU-py3.9/lib/python3.9/site-packages/datadog_api_client/v1/rest.py", line 221, in request
    raise ApiException(http_resp=r)
datadog_api_client.v1.exceptions.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Date': 'Wed, 05 Jan 2022 00:27:16 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'pragma': 'no-cache', 'cache-control': 'no-cache', 'x-ratelimit-name': 'post_monitors', 'x-ratelimit-remaining': '499', 'x-ratelimit-limit': '500', 'x-ratelimit-period': '10', 'x-ratelimit-reset': '4', 'vary': 'Accept-Encoding', 'content-encoding': 'gzip', 'x-content-type-options': 'nosniff', 'strict-transport-security': 'max-age=15724800;', 'content-security-policy': "frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report", 'x-frame-options': 'SAMEORIGIN'})
HTTP response body: {'errors': ["The value provided for parameter 'query' is invalid"]}

HostsApi.lists_hosts can't parse Macos/Darwin hosts

Describe the bug

Calling HostsApi.list_hosts() will fail if one or more of the hosts is of type Macos/Darwin.
This is because the library expects the nix_v metadata field to not be None. However that field only seems to be set on linux hosts.

To Reproduce

  1. Run the datadog agent on a macos host
  2. Confirm the host shows up in your infrastructure list
  3. Run the basic list_host example

Expected behavior
A response is returned without errors

Actual behavior

The stack trace I consistently get when the library fails to convert the None values.

Traceback (most recent call last):
  File "/home/user/Code/datadog-cost-allocation/src/hack/get_untagged_hosts.py", line 41, in main
    response = api_instance.list_hosts(count=1000)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/v1/api/hosts_api.py", line 254, in list_hosts
    return self._list_hosts_endpoint.call_with_http_info(**kwargs)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/api_client.py", line 738, in call_with_http_info
    return self.api_client.call_api(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/api_client.py", line 362, in call_api
    return self._call_api(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/api_client.py", line 152, in _call_api
    return_data = self.deserialize(response_data, response_type, _check_type)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/api_client.py", line 242, in deserialize
    deserialized_data = validate_and_convert_types(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1593, in validate_and_convert_types
    return attempt_convert_item(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1492, in attempt_convert_item
    raise conversion_exc
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1484, in attempt_convert_item
    return deserialize_model(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1403, in deserialize_model
    return model_class._new_from_openapi_data(**kw_args)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 42, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 341, in _new_from_openapi_data
    return cls._from_openapi_data(*args, **kwargs)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/v1/model/host_list_response.py", line 55, in _from_openapi_data
    self = super(HostListResponse, cls)._from_openapi_data(kwargs)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 642, in _from_openapi_data
    setattr(self, var_name, var_value)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 196, in __setattr__
    self[attr] = value
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 567, in __setitem__
    self.set_attribute(name, value)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 165, in set_attribute
    value = validate_and_convert_types(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1639, in validate_and_convert_types
    validate_and_convert_types(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1593, in validate_and_convert_types
    return attempt_convert_item(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1492, in attempt_convert_item
    raise conversion_exc
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1484, in attempt_convert_item
    return deserialize_model(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1403, in deserialize_model
    return model_class._new_from_openapi_data(**kw_args)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 42, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 341, in _new_from_openapi_data
    return cls._from_openapi_data(*args, **kwargs)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/v1/model/host.py", line 112, in _from_openapi_data
    self = super(Host, cls)._from_openapi_data(kwargs)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 642, in _from_openapi_data
    setattr(self, var_name, var_value)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 196, in __setattr__
    self[attr] = value
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 567, in __setitem__
    self.set_attribute(name, value)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 165, in set_attribute
    value = validate_and_convert_types(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1593, in validate_and_convert_types
    return attempt_convert_item(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1492, in attempt_convert_item
    raise conversion_exc
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1484, in attempt_convert_item
    return deserialize_model(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1403, in deserialize_model
    return model_class._new_from_openapi_data(**kw_args)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 42, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 341, in _new_from_openapi_data
    return cls._from_openapi_data(*args, **kwargs)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/v1/model/host_meta.py", line 117, in _from_openapi_data
    self = super(HostMeta, cls)._from_openapi_data(kwargs)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 642, in _from_openapi_data
    setattr(self, var_name, var_value)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 196, in __setattr__
    self[attr] = value
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 567, in __setitem__
    self.set_attribute(name, value)
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 165, in set_attribute
    value = validate_and_convert_types(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1639, in validate_and_convert_types
    validate_and_convert_types(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1593, in validate_and_convert_types
    return attempt_convert_item(
  File "/home/user/.cache/pypoetry/virtualenvs/datadog-cost-allocation-8apYjUwq-py3.9/lib/python3.9/site-packages/datadog_api_client/model_utils.py", line 1497, in attempt_convert_item
    raise get_type_error(input_value, path_to_item, valid_classes, key_type=key_type)
datadog_api_client.exceptions.ApiTypeError: Invalid type for variable '0'. Required value type is str and passed type was NoneType at ['received_data']['host_list'][526]['meta']['nix_v'][0]

Screenshots

Not sure if this helps ๐Ÿคทโ€โ™‚๏ธ
screenshot-1657137957

Environment and Versions (please complete the following information):

[[package]]
name = "datadog-api-client"
version = "1.11.0"
  • python3.9
  • debian

Additional context

The null value first shows up here: https://github.com/DataDog/datadog-api-client-python/blob/master/src/datadog_api_client/model_utils.py#L1603
The exception happens here https://github.com/DataDog/datadog-api-client-python/blob/1.11.0/src/datadog_api_client/model_utils.py#L1497 since must_convert is True. Maybe the conversion should be optional?

`list_events` should handle float timestamps

If you call list_events with a float, no client-side validation rejects this, but the API server doesn't handle floats, and the request fails.

To Reproduce
Steps to reproduce the behavior:

  1. Do list_events(1, 1). This works (returns an empty list generally).
  2. Do list_events(1.0, 1.0). This fails with an obscure error:
HTTP response body: {"errors": ["The value provided for parameter 'start' is invalid"]}

Expected behavior
Either this library should coerce to int (dropping the fractional part) or raise some sort of validation error before sending the request.

Environment and Versions (please complete the following information):

$ pip list | grep datadog
datadog-api-client 1.0.0b6

Additional context

datetime.timestamp() returns a float, which is how I was trying to use this method.

Also the documentation examples could be better. They specify the ints 1 and 1 for both start and end, a thing that would never happen. Suggest showing something relative to datetime.utcnow().

Relationship key in list_application_keys does not return any value

Describe the bug
When getting the application keys using list_application_keys, the "relationships" key in the response is blank when there is data available.

  • Low severity

To Reproduce
Steps to reproduce the behavior:

from datadog_api_client.v2.api import key_management_api

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = key_management_api.KeyManagementApi(api_client)
    print(api_instance.list_application_keys())

Expected behavior
"relationships" key with the correct values

Type error when getting a dashboard

Describe the bug
When trying to retrieve a dashboard by using the call dashboards_api.get_dashboard(dashboard.get("id")), I get an error saying datadog_api_client.v1.exceptions.ApiTypeError: Invalid type for variable 'x'. Required value type is int and passed type was float at ['received_data']['widgets'][15]['layout']['x']

To Reproduce
Steps to reproduce the behavior:

  1. Have a dashboard that has and X value that is a float and not an int
  2. Call get_dashboard for said dashboard
  3. See error

Expected behavior
The dashboard is returned with the float value for X

Environment and Versions (please complete the following information):

  • Windows 10
  • Python 3.10
  • api client v1

Unable to pull synthetic tests to to invalid type - edge.laptop_large

Describe the bug

Getting the following error:

Invalid value for `value` (edge.laptop_large), must be one of ['laptop_large', 'tablet', 'mobile_small', 'chrome.laptop_large', 'chrome.tablet', 'chrome.mobile_small', 'firefox.laptop_large', 'firefox.tablet', 'firefox.mobile_small']

It looks like the recent addition of edge broke clients due to the strict validity.

To Reproduce

Set up synthetic browser test with one of the edge types selected. And then call list_tests() on the API instance.

api_instance = synthetics_api.SyntheticsApi(api_client)
res = api_instance.list_tests()

Expected behavior

All synthetic tests are listed, including ones with edge.

Screenshots

image

Environment and Versions (please complete the following information):

Python 3.9 with both 1.1.0 API client or master

Additional context

Looks to be related to this validation

Getting an exception while fetching JSON log from Datadog

Getting an exception while fetching JSON log from Datadog
We are having JSON and RAW logs pushed to Datadog from our application. While fetching RAW log using list_logs_get method, it is able to fetch successfully whereas the API call throws exception with JSON logs.

severity/high

To Reproduce
Steps to reproduce the behavior:

  1. Upload JSON logs to Datadog
  2. Fetch logs using list_logs_get method in Python client with filter_from and filter_to parameters
  3. Getting below exceptions:
    calendar.IllegalMonthError: bad month number 0; must be 1-12

Expected behavior
It should work similarly to RAW logs

Screenshots
NA

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

Exception Logs
filter_query=@cliIP:198.18.39.124, filter_index=main, filter_from=2021-09-07 11:01:28+00:00, filter_to=2021-09-07 12:47:17+00:00, sort=timestamp, page_limit=1000
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api_client.py:787: UserWarning: Using unstable operation 'list_logs_get'
warnings.warn("Using unstable operation '{0}'".format(self.settings["operation_id"]))
Exception occured: unsupported operand type(s) for +: 'int' and 'str'
Retrying with different search filter: @accLang:DATADOG_PERF_TEST_0907123306%20SPACE%20IN%20THE%20ACCEPT%20LANGUAGE
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 655, in parse
ret = self._build_naive(res, default)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 1238, in _build_naive
if cday > monthrange(cyear, cmonth)[1]:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/calendar.py", line 124, in monthrange
raise IllegalMonthError(month)
calendar.IllegalMonthError: bad month number 0; must be 1-12

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/vechandr/git_repo/mdsqa_python3_automation/DSL_Automation/util/DatadogUtil.py", line 50, in fetch_data_from_datadog
api_response = api_instance.list_logs_get(filter_query=filter_query, filter_index=filter_index, filter_from=filter_from, filter_to=filter_to, sort=sort, page_limit=page_limit)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api/logs_api.py", line 307, in list_logs_get
return self._list_logs_get_endpoint.call_with_http_info(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api_client.py", line 844, in call_with_http_info
return self.api_client.call_api(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api_client.py", line 386, in call_api
return self.__call_api(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api_client.py", line 214, in __call_api
return_data = self.deserialize(response_data, response_type, _check_type)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api_client.py", line 307, in deserialize
deserialized_data = validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1552, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1439, in attempt_convert_item
return deserialize_model(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1355, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 313, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model/logs_list_response.py", line 140, in _from_openapi_data
self = super(LogsListResponse, cls)._from_openapi_data(kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 583, in _from_openapi_data
setattr(self, var_name, var_value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 168, in setattr
self[attr] = value
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 509, in setitem
self.set_attribute(name, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 137, in set_attribute
value = validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1602, in validate_and_convert_types
validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1552, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1439, in attempt_convert_item
return deserialize_model(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1355, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 313, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model/log.py", line 138, in _from_openapi_data
self = super(Log, cls)._from_openapi_data(kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 583, in _from_openapi_data
setattr(self, var_name, var_value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 168, in setattr
self[attr] = value
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 509, in setitem
self.set_attribute(name, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 137, in set_attribute
value = validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1552, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1439, in attempt_convert_item
return deserialize_model(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1355, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 313, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model/log_attributes.py", line 141, in _from_openapi_data
self = super(LogAttributes, cls)._from_openapi_data(kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 583, in _from_openapi_data
setattr(self, var_name, var_value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 168, in setattr
self[attr] = value
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 509, in setitem
self.set_attribute(name, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 137, in set_attribute
value = validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1622, in validate_and_convert_types
result[inner_key] = validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1573, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1444, in attempt_convert_item
return deserialize_primitive(input_value, valid_class, path_to_item)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1235, in deserialize_primitive
parsed_datetime = parse(data)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 1374, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 657, in parse
six.raise_from(ParserError(e.args[0] + ": %s", timestr), e)
TypeError: unsupported operand type(s) for +: 'int' and 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 655, in parse
ret = self._build_naive(res, default)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 1238, in _build_naive
if cday > monthrange(cyear, cmonth)[1]:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/calendar.py", line 124, in monthrange
raise IllegalMonthError(month)
calendar.IllegalMonthError: bad month number 0; must be 1-12

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/vechandr/git_repo/mdsqa_python3_automation/DSL_Automation/util/DatadogUtil.py", line 108, in
fetch_data_from_datadog(filter_query,filter_from,filter_to,expected_log_lines,unique_string)
File "/Users/vechandr/git_repo/mdsqa_python3_automation/DSL_Automation/util/DatadogUtil.py", line 53, in fetch_data_from_datadog
api_response = api_instance.list_logs_get(filter_query=filter_query_unique_string,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api/logs_api.py", line 307, in list_logs_get
return self._list_logs_get_endpoint.call_with_http_info(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api_client.py", line 844, in call_with_http_info
return self.api_client.call_api(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api_client.py", line 386, in call_api
return self.__call_api(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api_client.py", line 214, in __call_api
return_data = self.deserialize(response_data, response_type, _check_type)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/api_client.py", line 307, in deserialize
deserialized_data = validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1552, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1439, in attempt_convert_item
return deserialize_model(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1355, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 313, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model/logs_list_response.py", line 140, in _from_openapi_data
self = super(LogsListResponse, cls)._from_openapi_data(kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 583, in _from_openapi_data
setattr(self, var_name, var_value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 168, in setattr
self[attr] = value
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 509, in setitem
self.set_attribute(name, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 137, in set_attribute
value = validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1602, in validate_and_convert_types
validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1552, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1439, in attempt_convert_item
return deserialize_model(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1355, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 313, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model/log.py", line 138, in _from_openapi_data
self = super(Log, cls)._from_openapi_data(kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 583, in _from_openapi_data
setattr(self, var_name, var_value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 168, in setattr
self[attr] = value
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 509, in setitem
self.set_attribute(name, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 137, in set_attribute
value = validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1552, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1439, in attempt_convert_item
return deserialize_model(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1355, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 313, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 40, in wrapped_init
return fn(_self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model/log_attributes.py", line 141, in _from_openapi_data
self = super(LogAttributes, cls)._from_openapi_data(kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 583, in _from_openapi_data
setattr(self, var_name, var_value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 168, in setattr
self[attr] = value
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 509, in setitem
self.set_attribute(name, value)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 137, in set_attribute
value = validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1622, in validate_and_convert_types
result[inner_key] = validate_and_convert_types(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1573, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1444, in attempt_convert_item
return deserialize_primitive(input_value, valid_class, path_to_item)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/datadog_api_client/v2/model_utils.py", line 1235, in deserialize_primitive
parsed_datetime = parse(data)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 1374, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 657, in parse
six.raise_from(ParserError(e.args[0] + ": %s", timestr), e)
TypeError: unsupported operand type(s) for +: 'int' and 'str'

Process finished with exit code 1

Getting too many request error (429)

When I am tying to use the function list_logs_get_with_pagination in LogsApi class while list_logs_get works fine with data lesser than 1000 records. When I used list_logs_get_with_pagination, it gaves an error although the data is consit of 10K records

Here is the screenshot of the error..
image

This is the function which is not working.
image

This functions works fine though which is getting logs without paging.

image

LogsAggregateRequest fails due to multiple oneOf exception

Description

The request for aggregated logs below always fails with this error:

  • "datadog_api_client.v2.exceptions.ApiValueError: Invalid inputs given to generate an instance of LogsAggregateBucketValue. Multiple oneOf schemas matched the inputs, but a max of one is allowed."
api = logs_api.LogsApi(client)

body = LogsAggregateRequest(
        compute=[
            LogsCompute(
                aggregation=LogsAggregationFunction("count"),
            ),
        ],
        filter=LogsQueryFilter(
            query='env:production @path:"/v1/graphql" @response_time_ms:[1 TO 10000] @request_body.query:*',
        ),
        group_by=[
            LogsGroupBy(
                facet="@request_body.query",
                limit=1000,
            ),
        ]
    )

api.aggregate_logs(body)

Expected behavior
I expect to get aggregated logs.

Environment and Versions (please complete the following information):

  • MacOS Big Sur v11.2.1
  • Python v3.9.0
  • datadog-api-client v1.0.0-beta.5

Unable to set the display mode in Toplist

Describe the bug
The class datadog_api_client.v1.model.toplist_widget_definition.ToplistWidgetDefinition does not have a field called "display_mode" or something similar. Without that field, the API is unable set the display mode (absolute vs relative) of a Toplist widget.

To Reproduce
Steps to reproduce the behavior:
Check datadog_api_client.v1.model.toplist_widget_definition.ToplistWidgetDefinition

Expected behavior
There's a "display_mode" field or something similar which allows the caller to set the display mode of the toplist widget.

Screenshots
N/A

Environment and Versions (please complete the following information):
Python 3.11.3 and the datadog-api-client 2.17.0

  • services, libraries, languages and tools list and versions.

Additional context
Add any other context about the problem here.

create_monitor documentation unreadable

Describe the bug
Something is up with the markdown in this section of the documentation: https://github.com/DataDog/datadog-api-client-python/blob/master/docs/v1/MonitorsApi.md#create_monitor

Labels
kind/bug
severity/low
documentation

To Reproduce
Go to https://github.com/DataDog/datadog-api-client-python/blob/master/docs/v1/MonitorsApi.md#create_monitor
Also visible on readthedocs here. https://datadog-api-client.readthedocs.io/en/latest/v1/MonitorsApi/#create_monitor

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
Screen Shot 2021-05-25 at 4 27 18 PM

Environment and Versions (please complete the following information):
on chrome on both GH and Readthedocs. Also reproduced by pulling the raw md into my IDE

list_logs and list_logs_with_pagination do not return logs when using a query containing specific values in @ prefixed fields

Describe the bug
I can run the following query in the DataDog UI and it successfully returns the log I'm looking for (as seen in screenshot 1):

@event:Processing\ completed\ for\ sample\ 05d5f80e-a512-47cc-9049-e19e1b710188*

When I construct the same request using this Python library, I get 0 logs returned.

To Reproduce
Steps to reproduce the behavior:

  1. Code snippet to search logs using the list_logs function from the LogsApi class:
configuration = Configuration(host="https://api.datadoghq.eu", api_key={"apiKeyAuth": api_key, "appKeyAuth": app_key})
request_body = LogsListRequest(
    filter=LogsQueryFilter(
        query="@event:Processing\ completed\ for\ sample\ 05d5f80e-a512-47cc-9049-e19e1b710188*",
        indexes=["default"],
    ),
    sort=LogsSort.TIMESTAMP_ASCENDING,
    page=LogsListRequestPage(limit=500),
)
with ApiClient(configuration=configuration) as api_client:
    logs_api = LogsApi(api_client)
    logs = logs_api.list_logs(body=request_body)
  1. The logs["data"] key will return an empty list ([])

I've confirmed my API and app keys are valid by using the validate() method from the AuthenticationApi class. I've also confirmed that the default index exists using the list_log_indexes() method from the LogsIndexesApi class.

I've tried lots of combinations of the @event: filter in the query and can confirm the following:

  • @event:* returns 1 or more logs
  • @event:Processing* returns 0 logs (any term following the :, even if it's wildcarded, doesn't seem to work)

It seems like any value added to the @ prefixed filters in searches do not seem to yield results? I've also tried to search for logs using other @ prefixed filters:

  • @dd.service:* returns 1 or more logs
  • @dd.service:worker returns 0 logs (any term following the :, even if it's wildcarded, doesn't seem to work)
  • @logger:* returns 1 or more logs
  • @logger:analysis* returns 0 logs (any term following the :, even if it's wildcarded, doesn't seem to work)

Is this a limitation of searching via this library?

Expected behavior
I would expect the same query in the DataDog UI to return the identical logs when using the same query in this Python library.

Screenshots
Screenshot 1
image

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

  • We have a company account in the DataDog EU region
  • datadog-api-client version: 2.12.0

"behavior" is misspelled as "behaviro" in TESTING.md .

Describe the bug
"behavior" is not spelled correctly in TESTING.md

To Reproduce
Steps to reproduce the behavior:

  1. Go to TESTING.md
  2. See that "behavior" is spelled "behaviro"

Expected behavior
"behaviro" should be spelled "behavior".

Screenshots
image

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

  • Current master
  • N/A

Can't import v2 models from pypi package

Describe the bug
I've installed 1.10.0 and tried running some examples from the website, from here to be precise https://docs.datadoghq.com/api/latest/metrics/#submit-metrics

I get the following error:
ModuleNotFoundError: No module named 'datadog_api_client.v2.model.metric_intake_type'

This goes for every model.

I've checked the locally installed package and run
grep -rn 'MetricIntakeType' .

This yields no results

I've also downloaded both releases from here:
https://pypi.org/project/datadog-api-client/#files

unpacked them and repeated the grep, to no avail.

The models are clearly available on Github so it might be me.

To Reproduce
Run through a v2 example

Expected behavior
The models to be imported as per the example

Environment and Versions:
Pipenv, python

  • datadog-api-client: 1.10
  • python: 3.10.2
  • pipenv: 3.10.2

OS: MacOS Monterey 12.3.1

Error submitting metrics with async api client

Describe the bug
When using the Datadog API async client, an error occurs when submitting metrics data:

HTTP response body: Payload is not in the expected format: invalid character 's' looking for beginning of value

Exact same metrics data can be successfully submitted using the non-async client.

To Reproduce
The following code (adapted from the async example in the README) will reproduce the error:

from datadog_api_client.v1 import AsyncApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi
from datadog_api_client.v1.model.metrics_payload import MetricsPayload
from datadog_api_client.v1.model.point import Point
from datadog_api_client.v1.model.series import Series

try:
    body = MetricsPayload(
        series=[
            Series(
                metric="system.load.1",
                type="gauge",
                points=[Point([datetime.now().timestamp(), 2.1])],
                tags=["test:ExampleSubmitmetricsreturnsPayloadacceptedresponse"],
            )
        ]
    )

    configuration = Configuration()
    async with AsyncApiClient(configuration) as api_client:
        api_instance = MetricsApi(api_client)
        response = await api_instance.submit_metrics(body=body)
        print(response)

except BaseException as ex:
    logger.exception('Error submitting metrics to datadog: {}', ex)

Error response:

datadog_api_client.v1.exceptions.ApiException: (400)
Reason: Bad
HTTP response headers: HttpHeaders({'Date': 'Fri, 08 Apr 2022 20:26:30 GMT', 'Content-Type': 'text/plain; charset=utf-8', 'Content-Length': '91', 'Connection': 'keep-alive', 'x-content-type-options': 'nosniff', 'strict-transport-security': 'max-age=15724800;', 'content-security-policy': "frame-ancestors 'self'; report-uri https://logs.browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pube4f163c23bbf91c16b8f57f56af9fc58&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=site%3Adatadoghq.com", 'x-frame-options': 'SAMEORIGIN'})
HTTP response body: Payload is not in the expected format: invalid character 's' looking for beginning of value

Expected behavior
Request should succeed and metrics data should be available in the DataDog metrics explorer. (Like it is when making the request with the non-async client.)

Screenshots
If applicable, add screenshots to help explain your problem.

Environment and Versions (please complete the following information):
Linux with Python v3.8.10 and datadog-api-client = {extras = ["async"], version = "^1.10.0"}

Additional context
After looking at the differences between the non-async and async API clients, I noticed that it appears the async client never actually serializes the provided body data.

For reference, the non-async client does it here, but I did not see similar code for the async client.

Unable to use 'list_security_monitoring_signals' or 'search_security_monitoring_signals'

Describe the bug
Both of the operations mentioned in the title of this report are said to be "disabled" by the sdk despite being documented in Datadog documentation + these operations will work if you modify the source of the sdk.

To Reproduce
Steps to reproduce the behavior:

run something like this:
...
api_instance = SecurityMonitoringApi(api_client)
response = api_instance.search_security_monitoring_signals(body=body)

Expected behavior
The api client should allow these operations to be performed.

Screenshots
image

Environment and Versions (please complete the following information):
datadog-api-client 1.12
python 3.8.12

ImportError: cannot import name 'MetricsPayload'

Describe the bug
The type MetricsPayload described in the docs appears missing

Label the issue properly.

  • Add severity/critical label.

To Reproduce
Steps to reproduce the behavior:

  1. python3 -m pip install datadog-api-client
  2. Create a simple python script with,
#!/usr/bin/env python3

from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import metrics_api
from datadog_api_client.v1.models import Point
from datadog_api_client.v1.models import MetricsPayload

print("here...")
  1. Run the script
  2. See error
Traceback (most recent call last):
  File "./test.py", line 6, in <module>
    from datadog_api_client.v1.models import MetricsPayload
ImportError: cannot import name 'MetricsPayload'

Expected behavior
The MetricsPayload should be imported

Screenshots
N/a

Environment and Versions (please complete the following information):
Ubuntu 18.04

Additional context
Trying to use the API client for the first time.

Note that I also tried installing the latest from the master branch of this repo, using python3 -m pip install git+https://github.com/DataDog/datadog-api-client-python/ which gave me version datadog-api-client 1.0.0b8.dev34. The error was still there.

calling `get_browser_test_result` results in `TypeError`

Describe the bug
if calling the get_browser_test_result method on a test that has completed and suceeded, datadog will internally throw a TypeError-

Label the issue properly.

  • Add severity/ label.
  • Add documentation label if this issue is related to documentation changes.

To Reproduce
See above

Expected behavior
an object should be returned

Screenshots

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

datadog-api-client==1.12 on python 3.9

Additional context
in under 2 hours I've uncovered serious bugs in both get_browser_test_result and get_api_test_result. Maybe consider testing this libraries a bit better? it's super annoying to have to revert to http clients after having spent time setting up this sdk.

Package cannot be built from release tarball

Describe the bug
I am trying to build this library from the source tarball on the release page (https://github.com/DataDog/datadog-api-client-python/releases/tag/1.9.0) and it is unbuildable due to not being a git checkout:

LookupError: setuptools-scm was unable to detect version for '/tmp/datadog-api-client-python-1.9.0'.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

While I can obviously work around this by doing a git checkout instead or by using the wheel from PyPI, this strikes me as a bug. Either building should "just work" from the tarball or there should be a way to override setuptools-scm.

To Reproduce
Steps to reproduce the behavior:

  1. Download tarball from https://github.com/DataDog/datadog-api-client-python/archive/refs/tags/1.9.0.tar.gz
  2. Extract the tarball and cd into it.
  3. Run python setup.py install
  4. See error

Expected behavior
Package should build

Environment and Versions (please complete the following information):
Debian bullseye running python 3.9

Search Incidents Api error

Describe the bug
As per the datadog Api docs its mentioned to use the browser query into the query parameter of the Api After entering a search query in your Incidents page , use the query parameter value in the URL of the page as the value for this parameter. which sometimes also contains the from_ts & to_ts fields however when used with these fields the API gives the following error which i think should be working, I want to use these params to only search for incidents within a specific timeframe.

Exception

root@b8ed42750901:/app# python app.py
/usr/local/lib/python3.11/site-packages/datadog_api_client/api_client.py:655: UserWarning: Using unstable operation 'search_incidents'
  warnings.warn("Using unstable operation '{0}'".format(self.settings["operation_id"]))
{"event": " failed to pull data from datadog API due to: Exception=(400)\nReason: Bad Request\nHTTP response headers: HTTPHeaderDict({'Date': 'Thu, 28 Sep 2023 17:49:30 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'x-frame-options': 'SAMEORIGIN', 'content-security-policy': \"frame-ancestors 'self'; report-uri https://logs.browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pube4f163c23bbf91c16b8f57f56af9fc58&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=site%3Adatadoghq.com\", 'vary': 'Accept-Encoding', 'content-encoding': 'gzip', 'x-ratelimit-limit': '100', 'x-ratelimit-period': '60', 'x-ratelimit-remaining': '99', 'x-ratelimit-reset': '30', 'x-ratelimit-name': 'incidents_search_incidents', 'x-content-type-options': 'nosniff', 'strict-transport-security': 'max-age=31536000; includeSubDomains; preload'})\nHTTP response body: {'errors': [\"Query should be of form: 'key1:value1 AND (key2:value2 OR key3:value3)'\"]}\n", "level": "error", "timestamp": "2023-09-28T17:49:30.983679Z"}
Traceback (most recent call last):

my fucntion

def get_incident_data(search_query):
    configuration = Configuration()
    configuration.unstable_operations["search_incidents"] = True
    try:
        with ApiClient(configuration) as api_client:
            api_instance = IncidentsApi(api_client)
            response = api_instance.search_incidents(query=search_query)
    except Exception as e:
        LOGGER.error(f" failed to pull data from datadog API due to: Exception={e}")
    return response

where search_query is "state:(active OR stable OR resolved OR completed)&from_ts=1693233872794&to_ts=1695912272794"
I also tried with raw query like state%3A%28active%20OR%20stable%20OR%20resolved%20OR%20completed%29&page=1&from_ts=1693233872794&to_ts=1695912272794 but it also doesn't work.

To Reproduce
Steps to reproduce the behavior:

  1. Export DD site, API_key and App_key
  2. define the search_query param
  3. run the above function
  4. See error

Expected behavior
the API should return the response without any errors

Screenshots
If applicable, add screenshots to help explain your problem.

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

  • python3.11
  • datadog-api-client==2.14.0

Additional context
when running inside ipython on my mac it works fine but inside the container it doesn't

Error parsing `get_api_test_result` data

Describe the bug
When checking the status of a synthetics test, I'm getting the following error (if the test has completed and failed):

datadog_api_client.exceptions.ApiTypeError: Invalid type for variable 'date'. Required value type is dict and passed type was str at ['received_data']['result']['response_headers']['date']

To Reproduce
this only happens if the configured test has completed and the test failed, for example if the api returns a 500 while the test assertion required a 200 status.

Expected behavior
the call should not fail

Screenshots

Environment and Versions (please complete the following information):
datadog-api-client==1.12 on python 3.9

Additional context
Add any other context about the problem here.

Type error when calling get_monitor() on a monitor with a null silence downtime

Describe the bug

I have a monitor that is returning "silenced":{"*":null} from the GET API call, i.e. it is referencing a null downtime. This causes get_monitor() to fail unless I specify _check_return_type=False:

datadog_api_client.v1.exceptions.ApiTypeError: Invalid type for variable '*'. Required value type is int and passed type was NoneType at ['received_data']['options']['silenced']['*']

It looks like this should be easily fixed by updating the type expectation to include none_type (PR forthcoming)

To Reproduce

Have a silenced monitor without associated downtime and try to call get_monitor() on it.

Expected behavior

get_monitor() should not fail type checking

Environment and Versions (please complete the following information):

The bug is present in HEAD

v1 list_monitors cannot find monitor tags with spaces

Describe the bug
If a monitor has a tag whose key has spaces in it, then list_monitors() cannot find it by tag.

To Reproduce

  1. Go to 'Monitors'
  2. Click on 'Edit' (pencil icon) for any monitor
  3. Scroll down to 'tags'
  4. Add a new tag "Tag With Spaces"
  5. click 'Save'

run following python script:

from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import downtimes_api, monitors_api
from datadog_api_client.v1.models import *
import os

configuration = Configuration()
api_client = ApiClient(configuration)
monitor_api = monitors_api.MonitorsApi(api_client)

rv = monitor_api.list_monitors(with_downtimes=True, monitor_tags="Tag With Spaces")
print(len(rv))

Expected behavior
list_monitors() returns least one monitor that matches the tag

Environment and Versions (please complete the following information):
Python 3.11.4
datadog-api-client==2.17.0

There is nothing in API documentation or UI to suggest that tags with spaces are not supported.

Discrepancy/Improper Documentation Around Synthetic Tests

Describe the bug
When using the example python code from here: https://docs.datadoghq.com/api/latest/synthetics/#create-a-browser-test There seems to be multiple issues in the current documentation that will not give you a successful example.

After some tinkering i was able to get this to work but found multiple things in the example that seemed wrong or just poorly documented.

  1. It seems like the SyntheticsAssertion class is expecting a configuration object passed in but that doesn't seem to be documented anywhere.

Creating an SyntheticsAssertion object such as
SyntheticsAssertion(operator='lessThan', type='responseTime', target=3000)

Produces an error

    SyntheticsAssertion(),
  File "/Users/u6030582/virtualenvs/python3env/lib/python3.9/site-packages/datadog_api_client/v1/model_utils.py", line 1482, in wrapped_init
    return fn(self, *args, **kwargs)
  File "/Users/u6030582/virtualenvs/python3env/lib/python3.9/site-packages/datadog_api_client/v1/model/synthetics_assertion.py", line 198, in __init__
    composed_info = validate_get_composed_info(constant_args, model_args, self)
  File "/Users/u6030582/virtualenvs/python3env/lib/python3.9/site-packages/datadog_api_client/v1/model_utils.py", line 1759, in validate_get_composed_info
    oneof_instance = get_oneof_instance(self.__class__, model_args, constant_args)
  File "/Users/u6030582/virtualenvs/python3env/lib/python3.9/site-packages/datadog_api_client/v1/model_utils.py", line 1559, in get_oneof_instance
    discard_configuration.discard_unknown_keys = False
AttributeError: 'NoneType' object has no attribute 'discard_unknown_keys'

Passing in the API Configuration as the _configuration value fixes this.
SyntheticsAssertion(operator='lessThan', type='responseTime', target=3000, _configuration=configuration),

I am not sure if this is a bug or just not documented correctly.

  1. Smaller issues that are I'm assuming incorrect documentation:
    SyntheticsTestRequest.number_of_packets and SyntheticsTestRequest.should_track_hops is listed in the example, API complains about both properties:

HTTP response body: {"errors": ["properties.config.properties.request.additionalProperties: Additional properties are not allowed (u'numberOfPackets', u'shouldTrackHops' were unexpected

SyntheticsTestRequest.timeout and SyntheticsTestOptionsRetry.interval both need to be floats

tick_every should be an SyntheticsTickInterval object

Label the issue properly.

  • Severity: Low
  • Documentation issue

To Reproduce
Steps to reproduce the behavior:

  1. Use the python example code at https://docs.datadoghq.com/api/latest/synthetics/#create-a-browser-test
  2. Running the code without any changes will produce the discard_unknown_keys error
  3. After passing in the configuration you can see the other errors as the API rejects your request.

Expected behavior
I would expect the documentation examples to work out of the box with minor-ish changes.

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

  • Latest datadog-api-client version Name: datadog-api-client Version: 1.1.0 Summary: Collection of all Datadog Public endpoints Home-page: https://github.com/DataDog/datadog-api-client-python Author: Datadog, Inc. Author-email: [email protected] License: BSD Location: /Users/u6030582/virtualenvs/python3env/lib/python3.9/site-packages Requires: python-dateutil, six, certifi, urllib3 Required-by:

Additional context
N/A

Proxy the API doesn't accept self signed certificate

Describe the bug

I try to proxy the API request to BURP in order to debug and replay quickly some request but the datadog api client doesn't accept self signed certificate. Is there a workaround ?

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 701, in urlopen
    self._prepare_proxy(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 997, in _prepare_proxy
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/usr/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/bonclay/sigma/lucca-scripts/synchro-datadog.py", line 31, in <module>
    response = api_instance.list_security_monitoring_rules()
  File "/usr/local/lib/python3.10/dist-packages/datadog_api_client/v2/api/security_monitoring_api.py", line 658, in list_security_monitoring_rules
    return self._list_security_monitoring_rules_endpoint.call_with_http_info(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/datadog_api_client/api_client.py", line 712, in call_with_http_info
    return self.api_client.call_api(
  File "/usr/local/lib/python3.10/dist-packages/datadog_api_client/api_client.py", line 326, in call_api
    return self._call_api(
  File "/usr/local/lib/python3.10/dist-packages/datadog_api_client/api_client.py", line 99, in _call_api
    response = self.rest_client.request(
  File "/usr/local/lib/python3.10/dist-packages/datadog_api_client/rest.py", line 195, in request
    r = self.pool_manager.request(
  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 74, in request
    return self.request_encode_url(
  File "/usr/lib/python3/dist-packages/urllib3/request.py", line 96, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
  File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 533, in urlopen
    return super(ProxyManager, self).urlopen(method, url, redirect=redirect, **kw)
  File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 376, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 814, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 814, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 814, in urlopen
    return self.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 786, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.datadoghq.com', port=443): Max retries exceeded with url: /api/v2/security_monitoring/rules (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:997)')))

To Reproduce

configuration.proxy = "http://127.0.0.1:8080"

Expected behavior
A parameter to accept self signed certificate

Breaking change to metrics_query_metadata.py

Describe the bug
There was a change to the client response for MetricsApi(api_client).query_metrics where the type for a pointlist was changed from List[Point] to List[List[float]] which breaks any existing script using the pointlist.

To Reproduce
have a script using the pointlist like

from datetime import datetime
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.metrics_api import MetricsApi

import argparse
import json

argParser = argparse.ArgumentParser()
argParser.add_argument("-d", "--date", help="Date")
args = argParser.parse_args()

startdate = args.date + 'T00:00:00-05:00'
enddate = args.date + 'T20:00:00-05:00'

configuration = Configuration()

def get_point_total(response):
    total = 0.0
    pointlist = response.series[0].get('pointlist', None)
    for x in pointlist:
        total += x.value[1]
    return total

def query_metric(query_string):
    with ApiClient(configuration) as api_client:
        api_instance = MetricsApi(api_client)
        response = api_instance.query_metrics(
            _from=int((datetime.fromisoformat(startdate).timestamp())),
            to=int(datetime.fromisoformat(enddate).timestamp()),
            query=query_string,
        )
        return response

request_count_response = query_metric("sum:aws.applicationelb.request_count{*}.as_count()")
request_count = get_point_total(request_count_response)

json_summary = {
    "blocks": [
        {
	    "type": "header",
	    "text": {
	        "type": "plain_text",
	        "text": "Day end summary for {}".format(args.date)
            }
	},
        {
	    "type": "section",
            "fields": [
                {
	            "type": "mrkdwn",
	            "text": "*App Requests:*\n{}".format(round(request_count))
                }
            ]
	},
    ]
}

print(json.dumps(json.dumps(json_summary)))

where you call it with

python get_dd_metrics.py --date 2023-06-02

Expected behavior
I would expect an output of

"{\"blocks\": [{\"type\": \"header\", \"text\": {\"type\": \"plain_text\", \"text\": \"Day end summary for 2023-06-02\"}}, {\"type\": \"section\", \"fields\": [{\"type\": \"mrkdwn\", \"text\": \"*App Requests:*\\n1403599\"}]}]}"

Actual behavior

Traceback (most recent call last):
  File "/home/myuser/dd-scripts/test.py", line 35, in <module>
    request_count = get_point_total(request_count_response)
  File "/home/myuser/dd-scripts/test.py", line 21, in get_point_total
    total += x.value[1]
AttributeError: 'list' object has no attribute 'value'

Proposed Resolution
Seeing as this is a breaking change, and I believe you all follow semver standards I would expect there to be a bump in the major version of your release tag. If you introduce backwards incompatible changes then you should bump the major version to indicate that there is a break so that users are not caught unaware along with a comparison of the old usage and the new usage.

Environment and Versions (please complete the following information):
A clear and precise description of your setup:
You can reproduce this with:

  • Python 3.10.11
  • datadog-api-client 2.13.1
  • argparse 1.4.0
  • Ubuntu 20.04.5 LTS (Focal Fossa)

Additional Context
This change seems to have been introduced in #1431 and you can find the specific change here

Should depend on typing_extensions >=4.0.0

Describe the bug
api_client.py imports Self from typing_extensions. However, this was added in version 4.0.0 of typing_extensions. There does not appear to be a dependency specified for typing_extensions. When installing using the documented instructions (pip install datadog-api-client) in environments with older versions of typing_extensions, importing datadog_api_client will fail at runtime:

ImportError: cannot import name 'Self' from 'typing_extensions'

To Reproduce
Steps to reproduce the behavior:

  1. Install via pip on Ubuntu 22.04.2 LTS.
  2. import datadog_api_client
  3. Observe ImportError

list_tests() - TypeError: __init__() missing 1 required positional argument: 'example'

Describe the bug
The list_tests() example from here:

import os
from dateutil.parser import parse as dateutil_parser
from datadog_api_client.v1 import ApiClient, ApiException, Configuration
from datadog_api_client.v1.api import synthetics_api
from datadog_api_client.v1.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
configuration = Configuration()

# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = synthetics_api.SyntheticsApi(api_client)

    # example, this endpoint has no required or optional parameters
    try:
        # Get the list of all tests
        api_response = api_instance.list_tests()
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling SyntheticsApi->list_tests: %s\n" % e)

Returns this error: TypeError: __init__() missing 1 required positional argument: 'example'

Environment and Versions (please complete the following information):
datadog-api-client==1.1.0

Additional context
Full stack trace:

Traceback (most recent call last):
  File "/Users/marius/bin/datadog", line 8, in <module>
    sys.exit(main())
  File "/marius/lib/python3.8/site-packages/gdev/contrib/datadog/__main__.py", line 120, in main
    run_cli_with_reporting(datadog, 'datadog', cfg.get_username(), owner='sre')
  File "/marius/lib/python3.8/site-packages/gdev/cli_utils.py", line 16, in run_cli_with_reporting
    raise e
  File "/marius/lib/python3.8/site-packages/gdev/cli_utils.py", line 13, in run_cli_with_reporting
    tool(prog_name=prog_name)
  File "/marius/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/marius/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/marius/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/marius/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/marius/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/marius/lib/python3.8/site-packages/gdev/contrib/datadog/__main__.py", line 86, in pull
    dogman.pull()
  File "/marius/lib/python3.8/site-packages/gdev/controllers/datadog/controller.py", line 127, in pull
    self.handler.pull()
  File "/marius/lib/python3.8/site-packages/gdev/controllers/datadog/monitor.py", line 566, in pull
    api_response = api_instance.list_tests()
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/api/synthetics_api.py", line 1966, in list_tests
    return self._list_tests_endpoint.call_with_http_info(**kwargs)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 842, in call_with_http_info
    return self.api_client.call_api(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 386, in call_api
    return self.__call_api(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 214, in __call_api
    return_data = self.deserialize(response_data, response_type, _check_type)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/api_client.py", line 307, in deserialize
    deserialized_data = validate_and_convert_types(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1305, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1194, in attempt_convert_item
    return deserialize_model(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1110, in deserialize_model
    return model_class(**kw_args)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1478, in wrapped_init
    return fn(self, *args, **kwargs)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model/synthetics_list_tests_response.py", line 170, in __init__
    setattr(self, var_name, var_value)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 143, in __setattr__
    self[attr] = value
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 316, in __setitem__
    self.set_attribute(name, value)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 119, in set_attribute
    value = validate_and_convert_types(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1355, in validate_and_convert_types
    validate_and_convert_types(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1305, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1194, in attempt_convert_item
    return deserialize_model(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1110, in deserialize_model
    return model_class(**kw_args)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1478, in wrapped_init
    return fn(self, *args, **kwargs)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model/synthetics_test_details.py", line 213, in __init__
    setattr(self, var_name, var_value)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 143, in __setattr__
    self[attr] = value
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 316, in __setitem__
    self.set_attribute(name, value)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 119, in set_attribute
    value = validate_and_convert_types(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1305, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1194, in attempt_convert_item
    return deserialize_model(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1110, in deserialize_model
    return model_class(**kw_args)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1478, in wrapped_init
    return fn(self, *args, **kwargs)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model/synthetics_test_config.py", line 190, in __init__
    setattr(self, var_name, var_value)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 143, in __setattr__
    self[attr] = value
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 316, in __setitem__
    self.set_attribute(name, value)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 119, in set_attribute
    value = validate_and_convert_types(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1355, in validate_and_convert_types
    validate_and_convert_types(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1305, in validate_and_convert_types
    converted_instance = attempt_convert_item(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1194, in attempt_convert_item
    return deserialize_model(
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1110, in deserialize_model
    return model_class(**kw_args)
  File "/marius/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1478, in wrapped_init
    return fn(self, *args, **kwargs)
TypeError: __init__() missing 1 required positional argument: 'example'

ModuleNotFoundError: scalar_formula_request_queries

This morning I started getting this error in my workload.

pip install datadog-api-client

from datadog_api_client.v2.model.scalar_formula_request_queries import ScalarFormulaRequestQueries
ModuleNotFoundError: No module named 'datadog_api_client.v2.model.scalar_formula_request_queries'

Default to certifi when using slim docker containers

The urllib3 package defaults to using system certs, however, if they aren't there its never detected by urllib3. It would be nice if the Datadog API client could at the very least detect this and default to certifi.

This is relevant for doing pure python docker containers with the need for extra install overhead with the OS package manager. In my case I pull from the official python docker in order to build my WSGI apps.

Thankfully there's a workaround since the Configuration object passes a lot of the same options into urllb3 I'm able to add it.

Configuration(
            ssl_ca_cert=certifi.where()
)

Not possible to add [APM Request Latency] via DistributionWidgetDefinition class widget

Describe the bug
No possibility to add apm_stats_query to the DistributionWidgetDefinition widget class.
apm_query=LogQueryDefinition does not make it possible to reproduce APM Request Latency distribution chart for the service.

Label the issue properly.
severity/medium

To Reproduce
Steps to reproduce the behavior:

  1. Add DistributionWidgetDefinition widget to the Dashboard class as follows:
            Widget(
                definition=DistributionWidgetDefinition(
                    title="Latency distribution",
                    title_size="16",
                    show_legend=False,
                    title_align=WidgetTextAlign("left"),
                    type=DistributionWidgetDefinitionType("distribution"),
                    xaxis=DistributionWidgetXAxis(max="p95"),
                    yaxis=DistributionWidgetYAxis(scale="linear"),
                    requests=[
                        DistributionWidgetRequest(
                            apm_stats_query=ApmStatsQueryDefinition(
                                env="env",
                                name="service_request",
                                primary_tag="",
                                row_type=ApmStatsQueryRowType("service"),
                                service="service",
                            ),
                        ),
                    ],
                ),
            ),

Expected behavior
Possibility to add apm_stats_query parameter and ApmStatsQueryDefinition class to the DistributionWidgetDefinition class is added.

Screenshots
obraz
I Would like to have this option via Python API for the distribution widget which is not possible now.

Environment and Versions (please complete the following information):
OS: Ubuntu 20.04 LTS
Python: 3.8.10
datadog-api-client: 1.3.0

Additional context
Add any other context about the problem here.

get_dashboard: Invalid value for `x`, must be a value greater than or equal to `0`

Describe the bug
When trying to retrieve some dashboards with the get_dashboard() method, I get Invalid value for x, must be a value greater than or equal to 0 for some dashboards. Most dashboards work ok though.

Downloading the JSON from the dashboard Webpage does not show any x that are not 0 or greater and all of them are int. The dashboard has been created with the GUI, not via API, so I'd expect it to be fitting with the model.

Seems to be similar to #920, but here it is not the type that is wrong, but the value

To Reproduce
Steps to reproduce the behavior:

Since this is not a public datadog, I do not know how to give advice on how to reproduce, but for me it is:

  1. dashboard_data = self.api_instance.get_dashboard( dashboard_id=id, )
  2. Find the exception
  3. Download the named dashboard from GUI
  4. Check all 'x' values
  5. All of them set, int and >= 0

Expected behavior
Being able to properly download the dashboard

Environment and Versions (please complete the following information):

Python 3.10.x
datadog-api-client==2.3.0
Using the EU instance of Datadog

import requests gives SSL error in datadog client

Describe the bug
If the line import requests is added to the code example for service checks, I get an SSL error from the datadog api client.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://docs.datadoghq.com/api/latest/service-checks/
  2. Run the python code example and see that it indeed works with response {'status': 'ok'}
  3. Add import requests to that code example.
  4. See error, with traceback ending with something as follows
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.datadoghq.eu', port=443): Max retries exceeded with url: /api/v1/check_run (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

Expected behavior
The import of requests should cause no change in behavior.

Environment and Versions (please complete the following information):
linux

  • version for this project in use.

  • 1.10.0

  • services, libraries, languages and tools list and versions.
    requests==2.22.0
    pyOpenSSL==22.0.0
    datadog_api_client==1.10.0
    python 3.8.12

SSL Configuration Arguments Not Passed To Async Client

Describe the bug
The Async API Client is misconfigured and wont handle ssl configuration settings correctly.
Severity: Low

To Reproduce

  1. Pass a proxy to the async datadog api client or pass a have a proxy running on the system.
  2. Disable ssl verification in the configuration. configuration.verify_ssl = False
  3. Run the code

Expected behavior
Expected to not get the ssl verify error after disabling verify ssl in configuration.
configuration.verify_ssl = False

Environment and Versions (please complete the following information):
System: Macbook
Name: datadog-api-client
Version: 2.16.0

import asyncio

from datadog_api_client import ApiClient, AsyncApiClient, Configuration
from datadog_api_client.v1.api.events_api import EventsApi
from datadog_api_client.v1.model.event_create_request import EventCreateRequest

API_KEY = "..."
APPLICATION_KEY = "..."


body = EventCreateRequest(
    title="Example-Event",
    text="A text message.",
    tags=[
        "test:ExampleEvent",
    ],
)

configuration = Configuration(
    api_key={
        "apiKeyAuth": API_KEY,
        "appKeyAuth": APPLICATION_KEY,
    },
)
configuration.verify_ssl = False


async def main() -> None:
    async with AsyncApiClient(configuration) as api_client:
        api_instance = EventsApi(api_client)
        response = await api_instance.create_event(body=body)

        print(response)


if __name__ == "__main__":
    asyncio.run(main())

Pull Request: #1655

Parameters specified in the Configuration should take priority over envvars

Describe the bug

In case the environment variable DD_API_KEY is set it will always be used despite specifying a different API key in the configuration object.
In my case, the instance used to communicate with the DD API is also monitored with DD. This results in the variable DD_API_KEY being set, but in the configuration I would like to use a different value. It currently requires a work-around, but the variables explicitly specified in the configuration should always take priority over environment variables.

To Reproduce

os.environ["DD_API_KEY"] = "SOME_KEY"

configuration = Configuration(
    api_key={
        "apiKeyAuth": "API_KEY_1",
        "appKeyAuth": "APP_KEY_1",
    },
)

print(configuration.api_key)  # {'apiKeyAuth': 'SOME_KEY', 'appKeyAuth': 'APP_KEY_1'}

Expected behavior
Variables explicitly specified in the configuration object should take priority over environment variables.

list_ci_app_pipeline_events_with_pagination should not bubble up 429s

Is your feature request related to a problem? Please describe.
The problem is that when I was using the list_ci_app_pipeline_events_with_pagination method, I got a 429 due to rate limiting. My understanding was that this method would handle pagination for me, including retrying 429s.

Describe the solution you'd like
I would like list_ci_app_pipeline_events_with_pagination to retry 429s for me, by waiting for the reset period that was indicated in the response headers of the 429 response and then retrying. Ideally there would also be a way for the user to know how much time was spent waiting due to rate limiting.

Describe alternatives you've considered
I could switch to using list_ci_app_pipeline_events instead of list_ci_app_pipeline_events_with_pagination and handle the 429s myself. I will also follow up with Datadog to get the limits increased to a threshold that will suffice for my needs, but that wouldn't solve the underlying issue.

Get an SLO's history is not working with Target as expected

Describe the bug
I am trying to use Get an SLO's history API with Target to get the value of error_budget_remaining but it is not working. I used the same example in here

Filled the params as follows:

slo_id = "xxxxxxx" # str | The ID of the service level objective object.
from_ts = int(time.time()) - (60 * 60 * 24 * 30) # int | The from timestamp for the query window in epoch seconds.
to_ts = int(time.time()) # int | The `to` timestamp for the query window in epoch seconds.
target = 90.25 # float | The SLO target. If `target` is passed in, the response will include the error budget that remains.


The error I am getting when I try this API :         

api_response = api_instance.get_slo_history(slo_id, from_ts, to_ts, target=target)

 
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/uvicorn/protocols/http/h11_impl.py", line 369, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 59, in __call__
    return await self.app(scope, receive, send)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastapi/applications.py", line 199, in __call__
    await super().__call__(scope, receive, send)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/starlette/routing.py", line 580, in __call__
    await route.handle(scope, receive, send)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/starlette/routing.py", line 241, in handle
    await self.app(scope, receive, send)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/starlette/routing.py", line 52, in app
    response = await func(request)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastapi/routing.py", line 202, in app
    dependant=dependant, values=values, is_coroutine=is_coroutine
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/fastapi/routing.py", line 148, in run_endpoint_function
    return await dependant.call(**values)
  File "./app/routers/status.py", line 43, in test_dd_status
    api_response = api_instance.get_slo_history(slo_id, from_ts, to_ts, target=target)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/api/service_level_objectives_api.py", line 664, in get_slo_history
    return self._get_slo_history_endpoint.call_with_http_info(**kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/api_client.py", line 861, in call_with_http_info
    collection_formats=params["collection_format"],
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/api_client.py", line 402, in call_api
    _check_type,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/api_client.py", line 214, in __call_api
    return_data = self.deserialize(response_data, response_type, _check_type)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/api_client.py", line 308, in deserialize
    received_data, response_type, ["received_data"], True, _check_type, configuration=self.configuration
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1317, in validate_and_convert_types
    check_type=_check_type,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1206, in attempt_convert_item
    raise conversion_exc
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1199, in attempt_convert_item
    input_value, valid_class, path_to_item, check_type, configuration, spec_property_naming
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1114, in deserialize_model
    return model_class(**kw_args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1482, in wrapped_init
    return fn(self, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model/slo_history_response.py", line 175, in __init__
    setattr(self, var_name, var_value)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 143, in __setattr__
    self[attr] = value
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 318, in __setitem__
    self.set_attribute(name, value)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 125, in set_attribute
    configuration=self._configuration,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1317, in validate_and_convert_types
    check_type=_check_type,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1206, in attempt_convert_item
    raise conversion_exc
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1199, in attempt_convert_item
    input_value, valid_class, path_to_item, check_type, configuration, spec_property_naming
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1114, in deserialize_model
    return model_class(**kw_args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1482, in wrapped_init
    return fn(self, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model/slo_history_response_data.py", line 205, in __init__
    setattr(self, var_name, var_value)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 143, in __setattr__
    self[attr] = value
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 318, in __setitem__
    self.set_attribute(name, value)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 125, in set_attribute
    configuration=self._configuration,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1385, in validate_and_convert_types
    configuration=configuration,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1317, in validate_and_convert_types
    check_type=_check_type,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1206, in attempt_convert_item
    raise conversion_exc
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1199, in attempt_convert_item
    input_value, valid_class, path_to_item, check_type, configuration, spec_property_naming
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1114, in deserialize_model
    return model_class(**kw_args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1482, in wrapped_init
    return fn(self, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model/slo_threshold.py", line 176, in __init__
    self.timeframe = timeframe
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 143, in __setattr__
    self[attr] = value
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 318, in __setitem__
    self.set_attribute(name, value)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 125, in set_attribute
    configuration=self._configuration,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1317, in validate_and_convert_types
    check_type=_check_type,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1206, in attempt_convert_item
    raise conversion_exc
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1199, in attempt_convert_item
    input_value, valid_class, path_to_item, check_type, configuration, spec_property_naming
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1109, in deserialize_model
    return model_class(model_data, **kw_args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 1482, in wrapped_init
    return fn(self, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model/slo_timeframe.py", line 171, in __init__
    self.value = value
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 143, in __setattr__
    self[attr] = value
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 265, in __setitem__
    self.set_attribute(name, value)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 128, in set_attribute
    check_allowed_values(self.allowed_values, (name,), value)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/datadog_api_client/v1/model_utils.py", line 645, in check_allowed_values
    % (input_variable_path[0], input_values, these_allowed_values)
datadog_api_client.v1.exceptions.ApiValueError: Invalid value for `value` (custom), must be one of ['7d', '30d', '90d']

New Python library version returning AttributeError: 'NoneType' object has no attribute '_composed_schemas'

Describe the bug

Error AttributeError: 'NoneType' object has no attribute '_composed_schemas' after upgrading DD Python libs to datadog==0.40.1 and datadog-api-client==1.0.0b6, when querying MetricsAPI.

To Reproduce
Steps to reproduce the behavior:

  1. Create your new Venv
  2. Install the latest DD libs (versions stated above)
  3. Follow the exact documentation for search query, as here https://docs.datadoghq.com/api/latest/metrics/#search-metrics, but a slightly change:
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = metrics_api.MetricsApi(api_client)
    _from = datetime(2021, 2, 1).strftime('%s')  # int | Start of the queried time period, seconds since the Unix epoch.
    to = datetime(2021, 3, 1).strftime('%s')  # int | End of the queried time period, seconds since the Unix epoch.
    query = 'avg:aws.apigateway.latency{component:tag-tag-tag,sla:true}'  # str | Query string.

    print(_from, to)
    print(api_instance)
    # example passing only required values which don't have defaults set
    try:
        # Query timeseries points
        api_response = api_instance.query_metrics(_from, to, query)
    except ApiException as e:
        print("Exception when calling MetricsApi->query_metrics: %s\n" % e)

Expected behavior
The correct object returned in console

Screenshots
Error:

Traceback (most recent call last):
  File "ddn.py", line 30, in <module>
    pprint(api_response)
  File "/usr/lib/python3.8/pprint.py", line 53, in pprint
    printer.pprint(object)
  File "/usr/lib/python3.8/pprint.py", line 148, in pprint
    self._format(object, self._stream, 0, 0, {}, 0)
  File "/usr/lib/python3.8/pprint.py", line 170, in _format
    rep = self._repr(object, context, level)
  File "/usr/lib/python3.8/pprint.py", line 404, in _repr
    repr, readable, recursive = self.format(object, context.copy(),
  File "/usr/lib/python3.8/pprint.py", line 417, in format
    return _safe_repr(object, context, maxlevels, level, self._sort_dicts)
  File "/usr/lib/python3.8/pprint.py", line 569, in _safe_repr
    rep = repr(object)
  File "/home/ab000113/workspace/venv-test/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 135, in __repr__
    return self.to_str()
  File "/home/ab000113/workspace/venv-test/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 347, in to_str
    return pprint.pformat(self.to_dict())
  File "/home/ab000113/workspace/venv-test/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 343, in to_dict
    return model_to_dict(self, serialize=False)
  File "/home/ab000113/workspace/venv-test/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1410, in model_to_dict
    result[attr] = [model_to_dict(x, serialize=serialize) for x in value]
  File "/home/ab000113/workspace/venv-test/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1410, in <listcomp>
    result[attr] = [model_to_dict(x, serialize=serialize) for x in value]
  File "/home/ab000113/workspace/venv-test/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1410, in model_to_dict
    result[attr] = [model_to_dict(x, serialize=serialize) for x in value]
  File "/home/ab000113/workspace/venv-test/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1410, in <listcomp>
    result[attr] = [model_to_dict(x, serialize=serialize) for x in value]
  File "/home/ab000113/workspace/venv-test/lib/python3.8/site-packages/datadog_api_client/v1/model_utils.py", line 1395, in model_to_dict
    if model_instance._composed_schemas:
AttributeError: 'NoneType' object has no attribute '_composed_schemas'

Environment and Versions (please complete the following information):
A clear and precise description of your setup:
Working version as tested here: datadog==0.39.0, datadog-api-client==1.0.0b5
Broken version: datadog==0.40.1, datadog-api-client==1.0.0b6
Python ver: 3.8.5
Ubuntu: 20.04

Additional context
Add any other context about the problem here.

Type error when using `filter_from`or `filter_to` argument with SpansApi.list_spans_get()

Describe the bug

  • I get a datadog_api_client.exceptions.ApiException: (400) response when using the filter_from arg in the SpansApi despite adhering the required types (timestamp, datemath, or isoformat string).
    The same string format can be used with various other Apis within the datadog_api_client.v2.api library successfully.

  • Furthermore, I am unable to pass datetime objects to the filter_from argument, as I am able to with other APIs, such as the LogsApi. When I attempt to do this, I get

datadog_api_client.exceptions.ApiTypeError: Invalid type for variable 'filter_from'. Required value type is str and passed type was datetime at ['filter_from']

To Reproduce
Steps to reproduce the Api Exception:

from datadog_api_client.v2 import ApiClient, Configuration
from datadog_api_client.v2.api.spans_api import SpansApi
import datetime


configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = SpansApi(api_client)
    response = api_instance.list_spans_get(filter_query="service:aorta env:dev",filter_to=datetime.datetime.now().isoformat())
    print(response)

Steps to reproduce the ApiTypeError:

from datadog_api_client.v2 import ApiClient, Configuration
from datadog_api_client.v2.api.spans_api import SpansApi
import datetime


configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = SpansApi(api_client)
    response = api_instance.list_spans_get(filter_from=datetime.datetime.now()-datetime.timedelta(minutes=120))
    print(response)

Expected behavior
Response should filter the data using the given timestamp

Environment and Versions (please complete the following information):
datadog-api==2.15
python3.10

Timeout passed to aiosonic is of incorrect type.

Describe the bug
A clear and concise description of what the bug is.

aiosonic expects the request timeout to be passed in a timeout object but the dd AsyncApiClient passes an integer instead which causes an error

To Reproduce
Steps to reproduce the behavior:

async with AsyncApiClient(Configuration(request_timeout=10.0)) as api_client:
    # make any request with the client

Raises an `'int' object has no attribute 'request_timeout' error

...
File "/opt/venv/lib/python3.10/site-packages/aiosonic/__init__.py", line 769, in request
   _do_request(
timeout=(timeouts or self.connector.timeouts).request_timeout,

certificate verify failed (_ssl.c:897)

from datadog_api_client.v1 import ApiClient, Configuration
from datadog_api_client.v1.api.tags_api import TagsApi
from datadog_api_client.v1.model.host_tags import HostTags


DD_APP_KEY="xxxx" 
DD_API_KEY="xxxxx" 
DD_SITE="xxxx"

#configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = TagsApi(api_client)
    response = api_instance.list_host_tags()
    print(response)

python3.6 1.py

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 358, in connect
    ssl_context=context)
  File "/usr/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 354, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib64/python3.6/ssl.py", line 365, in wrap_socket
    _context=self, _session=session)
  File "/usr/lib64/python3.6/ssl.py", line 776, in __init__
    self.do_handshake()
  File "/usr/lib64/python3.6/ssl.py", line 1036, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib64/python3.6/ssl.py", line 648, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "1.py", line 17, in <module>
    response = api_instance.list_host_tags()
  File "/usr/local/lib/python3.6/site-packages/datadog_api_client/v1/api/tags_api.py", line 346, in list_host_tags
    return self._list_host_tags_endpoint.call_with_http_info(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/datadog_api_client/v1/api_client.py", line 788, in call_with_http_info
    collection_formats=params["collection_format"],
  File "/usr/local/lib/python3.6/site-packages/datadog_api_client/v1/api_client.py", line 382, in call_api
    _check_type,
  File "/usr/local/lib/python3.6/site-packages/datadog_api_client/v1/api_client.py", line 133, in _call_api
    _request_timeout=_request_timeout,
  File "/usr/local/lib/python3.6/site-packages/datadog_api_client/v1/rest.py", line 197, in request
    method, url, fields=query_params, preload_content=_preload_content, timeout=timeout, headers=headers
  File "/usr/lib/python3.6/site-packages/urllib3/request.py", line 68, in request
    **urlopen_kw)
  File "/usr/lib/python3.6/site-packages/urllib3/request.py", line 89, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
  File "/usr/lib/python3.6/site-packages/urllib3/poolmanager.py", line 324, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen
    **response_kw)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen
    **response_kw)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen
    **response_kw)
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.datadoghq.com', port=443): Max retries exceeded with url: /api/v1/tags/hosts (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:897)'),))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.