datadog-api-client


Namedatadog-api-client JSON
Version 2.22.0 PyPI version JSON
download
home_pagehttps://github.com/DataDog/datadog-api-client-python
SummaryCollection of all Datadog Public endpoints
upload_time2024-02-06 21:01:09
maintainer
docs_urlNone
authorDatadog, Inc.
requires_python>=3.7
licenseBSD
keywords openapi api client openapi-generator datadog
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # datadog-api-client-python

This repository contains a Python API client for the [Datadog API](https://docs.datadoghq.com/api/).

## Requirements

Building and using the API client library requires [Python 3.7+](https://www.python.org/downloads/).

## Installation

To install the API client library, simply execute:

```shell
pip install datadog-api-client
```

## Getting Started

Please follow the [installation](#installation) instruction and execute the following Python code:

```python
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:

```python
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:

```python
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:

```python
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:

```python
configuration.compress = False
```

### Enable requests logging

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

```python
configuration.debug = True
```

### Enable retry

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

```python
    configuration.enable_retry = True
```

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

```python
    configuration.max_retries = 5
```

### Configure proxy

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

```python
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:

```python
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]`.

```python
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:

```python
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](https://datadog-api-client.readthedocs.io/).

## Documentation for Authorization

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

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

## Author

support@datadoghq.com

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/DataDog/datadog-api-client-python",
    "name": "datadog-api-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "openapi,api,client,openapi-generator,datadog",
    "author": "Datadog, Inc.",
    "author_email": "packages@datadoghq.com",
    "download_url": "https://files.pythonhosted.org/packages/a5/98/6d6ae95d8547e735e8c27b6e9ab9e2347be67abd40158f8f59d3330441f9/datadog-api-client-2.22.0.tar.gz",
    "platform": "any",
    "description": "# datadog-api-client-python\n\nThis repository contains a Python API client for the [Datadog API](https://docs.datadoghq.com/api/).\n\n## Requirements\n\nBuilding and using the API client library requires [Python 3.7+](https://www.python.org/downloads/).\n\n## Installation\n\nTo install the API client library, simply execute:\n\n```shell\npip install datadog-api-client\n```\n\n## Getting Started\n\nPlease follow the [installation](#installation) instruction and execute the following Python code:\n\n```python\nfrom datadog_api_client import ApiClient, Configuration\nfrom datadog_api_client.v1.api.monitors_api import MonitorsApi\nfrom datadog_api_client.v1.model.monitor import Monitor\nfrom datadog_api_client.v1.model.monitor_type import MonitorType\n\nbody = Monitor(\n    name=\"example\",\n    type=MonitorType(\"log alert\"),\n    query='logs(\"service:foo AND type:error\").index(\"main\").rollup(\"count\").by(\"source\").last(\"5m\") > 2',\n    message=\"some message Notify: @hipchat-channel\",\n    tags=[\"test:example\", \"env:ci\"],\n    priority=3,\n)\n\nconfiguration = Configuration()\nwith ApiClient(configuration) as api_client:\n    api_instance = MonitorsApi(api_client)\n    response = api_instance.create_monitor(body=body)\n    print(response)\n```\n\n### Authentication\n\nBy default the library will use the `DD_API_KEY` and `DD_APP_KEY` environment variables to authenticate against the Datadog API.\nTo provide your own set of credentials, you need to set some keys on the configuration:\n\n```python\nconfiguration.api_key[\"apiKeyAuth\"] = \"<API KEY>\"\nconfiguration.api_key[\"appKeyAuth\"] = \"<APPLICATION KEY>\"\n```\n\n### Unstable Endpoints\n\nThis 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:\n\n```python\nconfiguration.unstable_operations[\"<OperationName>\"] = True\n```\n\nwhere `<OperationName>` is the name of the method used to interact with that endpoint. For example: `list_log_indexes`, or `get_logs_index`\n\n### Changing Server\n\nWhen talking to a different server, like the `eu` instance, change the `server_variables` on your configuration object:\n\n```python\nconfiguration.server_variables[\"site\"] = \"datadoghq.eu\"\n```\n\n### Disable compressed payloads\n\nIf you want to disable GZIP compressed responses, set the `compress` flag\non your configuration object:\n\n```python\nconfiguration.compress = False\n```\n\n### Enable requests logging\n\nIf you want to enable requests logging, set the `debug` flag on your configuration object:\n\n```python\nconfiguration.debug = True\n```\n\n### Enable retry\n\nIf you want to enable retry when getting status code `429` rate-limited, set `enable_retry` to `True`\n\n```python\n    configuration.enable_retry = True\n```\n\nThe default max retry is `3`, you can change it with `max_retries`\n\n```python\n    configuration.max_retries = 5\n```\n\n### Configure proxy\n\nYou can configure the client to use proxy by setting the `proxy` key on configuration object:\n\n```python\nconfiguration.proxy = \"http://127.0.0.1:80\"\n```\n\n### Threads support\n\nYou can run API calls in a thread by using `ThreadedApiClient` in place of `ApiClient`. API calls will then\nreturn a `AsyncResult` instance on which you can call get to retrieve the result:\n\n```python\nfrom datadog_api_client import Configuration, ThreadedApiClient\nfrom datadog_api_client.v1.api.dashboards_api import DashboardsApi\n\nconfiguration = Configuration()\nwith ThreadedApiClient(configuration) as api_client:\n    api_instance = DashboardsApi(api_client)\n    result = api_instance.list_dashboards()\n    dashboards = result.get()\n    print(dashboards)\n```\n\n### Asyncio support\n\nThe library supports asynchronous operations when using `AsyncApiClient` for the transport. When that client is used,\nthe API methods will then return coroutines that you can wait for.\n\nTo make async support available, you need to install the extra `async` qualifiers during installation: `pip install datadog-api-client[async]`.\n\n```python\nimport asyncio\n\nfrom datadog_api_client import Configuration, AsyncApiClient\nfrom datadog_api_client.v1.api.dashboards_api import DashboardsApi\n\nasync def main():\n    configuration = Configuration()\n    async with AsyncApiClient(configuration) as api_client:\n        api_instance = DashboardsApi(api_client)\n        dashboards = await api_instance.list_dashboards()\n        print(dashboards)\n\nasyncio.run(main())\n```\n\n### Pagination\n\nSeveral listing operations have a pagination method to help consume all the items available.\nFor example, to retrieve all your incidents:\n\n```python\nfrom datadog_api_client import ApiClient, Configuration\nfrom datadog_api_client.v2.api.incidents_api import IncidentsApi\n\nconfiguration = Configuration()\nconfiguration.unstable_operations[\"list_incidents\"] = True\nwith ApiClient(configuration) as api_client:\n    api_instance = IncidentsApi(api_client)\n    for incident in api_instance.list_incidents_with_pagination():\n        print(incident.id)\n```\n\n## Documentation for API Endpoints and Models\n\nDocumentation for API endpoints and models are available on [readthedocs](https://datadog-api-client.readthedocs.io/).\n\n## Documentation for Authorization\n\nAuthenticate with the API by providing your API and Application keys in the configuration:\n\n```python\nconfiguration.api_key[\"apiKeyAuth\"] = \"YOUR_API_KEY\"\nconfiguration.api_key[\"appKeyAuth\"] = \"YOUR_APPLICATION_KEY\"\n```\n\n## Author\n\nsupport@datadoghq.com\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Collection of all Datadog Public endpoints",
    "version": "2.22.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/DataDog/datadog-api-client-python/issues",
        "Documentation": "https://docs.datadoghq.com/api/",
        "Homepage": "https://github.com/DataDog/datadog-api-client-python",
        "Source Code": "https://github.com/DataDog/datadog-api-client-python"
    },
    "split_keywords": [
        "openapi",
        "api",
        "client",
        "openapi-generator",
        "datadog"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d04b856360c1acdb51b3c14681cb05382d9ab7d1edb7e02eaab1c271dad8e5d5",
                "md5": "4632d2e8a090212976e16acae1867ee3",
                "sha256": "a0e85fa191fec5fcb2301d4dc30732deda5e1e20907257ca9c812a779ab63944"
            },
            "downloads": -1,
            "filename": "datadog_api_client-2.22.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4632d2e8a090212976e16acae1867ee3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 2344554,
            "upload_time": "2024-02-06T21:01:06",
            "upload_time_iso_8601": "2024-02-06T21:01:06.546640Z",
            "url": "https://files.pythonhosted.org/packages/d0/4b/856360c1acdb51b3c14681cb05382d9ab7d1edb7e02eaab1c271dad8e5d5/datadog_api_client-2.22.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a5986d6ae95d8547e735e8c27b6e9ab9e2347be67abd40158f8f59d3330441f9",
                "md5": "2b2875c4e52311657e958a2020f1ca1d",
                "sha256": "d40c92139f901560f4dc206f21d3ca9432b31ff60e32afe16c9d50218dd5795d"
            },
            "downloads": -1,
            "filename": "datadog-api-client-2.22.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2b2875c4e52311657e958a2020f1ca1d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 2052800,
            "upload_time": "2024-02-06T21:01:09",
            "upload_time_iso_8601": "2024-02-06T21:01:09.498685Z",
            "url": "https://files.pythonhosted.org/packages/a5/98/6d6ae95d8547e735e8c27b6e9ab9e2347be67abd40158f8f59d3330441f9/datadog-api-client-2.22.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-06 21:01:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DataDog",
    "github_project": "datadog-api-client-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "datadog-api-client"
}
        
Elapsed time: 0.18576s