Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.1 KB
Raw Blame
import { AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
import { client } from '@datadog/datadog-api-client';
import { datadogAuth } from './auth';

export const getDatadogConfiguration = (
  auth: AppConnectionValueForAuthProperty<typeof datadogAuth>
) => {
  const configuration = client.createConfiguration({
    authMethods: {
      apiKeyAuth: auth.props.apiKey,
      ...(auth.props.appKey ? { appKeyAuth: auth.props.appKey } : {}),
    },
  });
  configuration.setServerVariables({
    site: auth.props.site,
  });
  return configuration;
};

export const constructDatadogBaseUrl = (
  auth: AppConnectionValueForAuthProperty<typeof datadogAuth>,
  subdomain = 'api',
  version = 'v2'
) => {
  return `https://${subdomain}.${auth.props.site}/api/${version}`;
};

export const constructDatadogBaseHeaders = (
  auth: AppConnectionValueForAuthProperty<typeof datadogAuth>
) => {
  return {
    Accept: 'application/json',
    'DD-API-KEY': auth.props.apiKey,
    ...(auth.props.appKey ? { 'DD-APPLICATION-KEY': auth.props.appKey } : {}),
  };
};