Chilkat Online Tools

Perl / Datadog API Collection / Create an Azure integration

Back to Collection Items

use chilkat();

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

$http = chilkat::CkHttp->new();

# Use this online tool to generate code from sample JSON: Generate Code to Create JSON

# The following JSON is sent in the request body.

# {
#   "app_service_plan_filters": "key:value,filter:example",
#   "automute": true,
#   "client_id": "testc7f6-1234-5678-9101-3fcbf464test",
#   "client_secret": "testingx./Sw*g/Y33t..R1cH+hScMDt",
#   "cspm_enabled": true,
#   "custom_metrics_enabled": true,
#   "errors": [
#     "*"
#   ],
#   "host_filters": "key:value,filter:example",
#   "new_client_id": "new1c7f6-1234-5678-9101-3fcbf464test",
#   "new_tenant_name": "new1c44-1234-5678-9101-cc00736ftest",
#   "tenant_name": "testc44-1234-5678-9101-cc00736ftest"
# }

$json = chilkat::CkJsonObject->new();
$json->UpdateString("app_service_plan_filters","key:value,filter:example");
$json->UpdateBool("automute",1);
$json->UpdateString("client_id","testc7f6-1234-5678-9101-3fcbf464test");
$json->UpdateString("client_secret","testingx./Sw*g/Y33t..R1cH+hScMDt");
$json->UpdateBool("cspm_enabled",1);
$json->UpdateBool("custom_metrics_enabled",1);
$json->UpdateString("errors[0]","*");
$json->UpdateString("host_filters","key:value,filter:example");
$json->UpdateString("new_client_id","new1c7f6-1234-5678-9101-3fcbf464test");
$json->UpdateString("new_tenant_name","new1c44-1234-5678-9101-cc00736ftest");
$json->UpdateString("tenant_name","testc44-1234-5678-9101-cc00736ftest");

$http->SetRequestHeader("Content-Type","application/json");
$http->SetRequestHeader("Accept","application/json");

# resp is a HttpResponse
$resp = $http->PostJson3("https://api.app.ddog-gov.com/api/v1/integration/azure","application/json",$json);
if ($http->get_LastMethodSuccess() == 0) {
    print $http->lastErrorText() . "\r\n";
    exit;
}

$sbResponseBody = chilkat::CkStringBuilder->new();
$resp->GetBodySb($sbResponseBody);

$jResp = chilkat::CkJsonObject->new();
$jResp->LoadSb($sbResponseBody);
$jResp->put_EmitCompact(0);

print "Response Body:" . "\r\n";
print $jResp->emit() . "\r\n";

$respStatusCode = $resp->get_StatusCode();
print "Response Status Code = " . $respStatusCode . "\r\n";
if ($respStatusCode >= 400) {
    print "Response Header:" . "\r\n";
    print $resp->header() . "\r\n";
    print "Failed." . "\r\n";

    exit;
}

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-H "Accept: application/json"
	-d '{
  "app_service_plan_filters": "key:value,filter:example",
  "automute": true,
  "client_id": "testc7f6-1234-5678-9101-3fcbf464test",
  "client_secret": "testingx./Sw*g/Y33t..R1cH+hScMDt",
  "cspm_enabled": true,
  "custom_metrics_enabled": true,
  "errors": [
    "*"
  ],
  "host_filters": "key:value,filter:example",
  "new_client_id": "new1c7f6-1234-5678-9101-3fcbf464test",
  "new_tenant_name": "new1c44-1234-5678-9101-cc00736ftest",
  "tenant_name": "testc44-1234-5678-9101-cc00736ftest"
}'
https://api.app.ddog-gov.com/api/v1/integration/azure

Postman Collection Item JSON

{
  "name": "Create an Azure integration",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"app_service_plan_filters\": \"key:value,filter:example\",\n  \"automute\": true,\n  \"client_id\": \"testc7f6-1234-5678-9101-3fcbf464test\",\n  \"client_secret\": \"testingx./Sw*g/Y33t..R1cH+hScMDt\",\n  \"cspm_enabled\": true,\n  \"custom_metrics_enabled\": true,\n  \"errors\": [\n    \"*\"\n  ],\n  \"host_filters\": \"key:value,filter:example\",\n  \"new_client_id\": \"new1c7f6-1234-5678-9101-3fcbf464test\",\n  \"new_tenant_name\": \"new1c44-1234-5678-9101-cc00736ftest\",\n  \"tenant_name\": \"testc44-1234-5678-9101-cc00736ftest\"\n}",
      "options": {
        "raw": {
          "headerFamily": "json",
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/api/v1/integration/azure",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "integration",
        "azure"
      ]
    },
    "description": "Create a Datadog-Azure integration.\n\nUsing the `POST` method updates your integration configuration by adding your new\nconfiguration to the existing one in your Datadog organization.\n\nUsing the `PUT` method updates your integration configuration by replacing your\ncurrent configuration with the new one sent to your Datadog organization."
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"app_service_plan_filters\": \"key:value,filter:example\",\n  \"automute\": true,\n  \"client_id\": \"testc7f6-1234-5678-9101-3fcbf464test\",\n  \"client_secret\": \"testingx./Sw*g/Y33t..R1cH+hScMDt\",\n  \"cspm_enabled\": true,\n  \"custom_metrics_enabled\": true,\n  \"errors\": [\n    \"*\"\n  ],\n  \"host_filters\": \"key:value,filter:example\",\n  \"new_client_id\": \"new1c7f6-1234-5678-9101-3fcbf464test\",\n  \"new_tenant_name\": \"new1c44-1234-5678-9101-cc00736ftest\",\n  \"tenant_name\": \"testc44-1234-5678-9101-cc00736ftest\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/integration/azure",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "integration",
            "azure"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{}"
    },
    {
      "name": "Bad Request",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"app_service_plan_filters\": \"key:value,filter:example\",\n  \"automute\": true,\n  \"client_id\": \"testc7f6-1234-5678-9101-3fcbf464test\",\n  \"client_secret\": \"testingx./Sw*g/Y33t..R1cH+hScMDt\",\n  \"cspm_enabled\": true,\n  \"custom_metrics_enabled\": true,\n  \"errors\": [\n    \"*\"\n  ],\n  \"host_filters\": \"key:value,filter:example\",\n  \"new_client_id\": \"new1c7f6-1234-5678-9101-3fcbf464test\",\n  \"new_tenant_name\": \"new1c44-1234-5678-9101-cc00736ftest\",\n  \"tenant_name\": \"testc44-1234-5678-9101-cc00736ftest\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/integration/azure",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "integration",
            "azure"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    },
    {
      "name": "Authentication Error",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"app_service_plan_filters\": \"key:value,filter:example\",\n  \"automute\": true,\n  \"client_id\": \"testc7f6-1234-5678-9101-3fcbf464test\",\n  \"client_secret\": \"testingx./Sw*g/Y33t..R1cH+hScMDt\",\n  \"cspm_enabled\": true,\n  \"custom_metrics_enabled\": true,\n  \"errors\": [\n    \"*\"\n  ],\n  \"host_filters\": \"key:value,filter:example\",\n  \"new_client_id\": \"new1c7f6-1234-5678-9101-3fcbf464test\",\n  \"new_tenant_name\": \"new1c44-1234-5678-9101-cc00736ftest\",\n  \"tenant_name\": \"testc44-1234-5678-9101-cc00736ftest\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/integration/azure",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "integration",
            "azure"
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    },
    {
      "name": "Too many requests",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"app_service_plan_filters\": \"key:value,filter:example\",\n  \"automute\": true,\n  \"client_id\": \"testc7f6-1234-5678-9101-3fcbf464test\",\n  \"client_secret\": \"testingx./Sw*g/Y33t..R1cH+hScMDt\",\n  \"cspm_enabled\": true,\n  \"custom_metrics_enabled\": true,\n  \"errors\": [\n    \"*\"\n  ],\n  \"host_filters\": \"key:value,filter:example\",\n  \"new_client_id\": \"new1c7f6-1234-5678-9101-3fcbf464test\",\n  \"new_tenant_name\": \"new1c44-1234-5678-9101-cc00736ftest\",\n  \"tenant_name\": \"testc44-1234-5678-9101-cc00736ftest\"\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/api/v1/integration/azure",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "integration",
            "azure"
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    }
  ]
}