Is there a basic example of how to authenticate to datadog using the python lib datadog_api_client.v2? I was looking at their documentation https://datadoghq.dev/datadog-api-client-python/v2/#apikeyauth and am not seeing any examples I was expecting something along the lines of:
import datadog_api_client.v2
import os
from datadog_api_client.v2 import list_tag_configurations
configuration = datadog_api_client.v2.Configuration(
host = "https://api.datadoghq.com"
)
configuration.api_key['apiKeyAuth'] = os.getenv('123')
with datadog_api_client.v2.ApiClient(configuration) as api_client:
api_instance = list_tag_configurations(api_client)
print(api_instance)
This is the only v2 authentication example I found on how to use Configuration in the github repo source code for datadog_api_client / v2 / configuration.py starting on line 83:
conf = datadog_api_client.v2.Configuration(
api_key={'cookieAuth': 'abc123'}
api_key_prefix={'cookieAuth': 'JSESSIONID'}
)
My guess is using the example for v1 for authentication but changing v1 to v2 would work.
This is the first part of their v1 example from their root github readme.md
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v1
from datadog_api_client.v1.api import aws_integration_api
from datadog_api_client.v1.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v1.Configuration(
host = "https://api.datadoghq.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')
# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')
And here's an example from their documentation for v2 on list_tag_configurations: https://datadoghq.dev/datadog-api-client-python/v2/MetricsApi/#list_tag_configurations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With