Chilkat Online Tools

PowerBuilder / Datadog API Collection / List all AWS integrations

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Access_key_id
string ls_Account_id
integer li_Auto_scaling
integer li_Opswork
integer li_Cspm_resource_collection_enabled
integer li_Metrics_collection_enabled
integer li_Resource_collection_enabled
string ls_Role_name
string ls_Secret_access_key
integer j
integer li_Count_j
string ls_StrVal
integer i
integer li_Count_i

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_QueryParams = create oleobject
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_QueryParams.UpdateString("account_id","cupidatat Ut Duis")
loo_QueryParams.UpdateString("role_name","cupidatat Ut Duis")
loo_QueryParams.UpdateString("access_key_id","cupidatat Ut Duis")

loo_Http.SetRequestHeader("Accept","application/json")

loo_Resp = loo_Http.QuickRequestParams("GET","https://api.app.ddog-gov.com/api/v1/integration/aws",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "accounts": [
//     {
//       "access_key_id": "sit Lorem commodo est",
//       "account_id": "123456789012",
//       "account_specific_namespace_rules": {
//         "auto_scaling": false,
//         "opswork": false
//       },
//       "cspm_resource_collection_enabled": true,
//       "excluded_regions": [
//         "us-east-1",
//         "us-west-2"
//       ],
//       "filter_tags": [
//         "$KEY:$VALUE"
//       ],
//       "host_tags": [
//         "$KEY:$VALUE"
//       ],
//       "metrics_collection_enabled": false,
//       "resource_collection_enabled": true,
//       "role_name": "DatadogAWSIntegrationRole",
//       "secret_access_key": "qui veniam sint anim"
//     },
//     {
//       "access_key_id": "quis enim laboris",
//       "account_id": "123456789012",
//       "account_specific_namespace_rules": {
//         "auto_scaling": false,
//         "opswork": false
//       },
//       "cspm_resource_collection_enabled": true,
//       "excluded_regions": [
//         "us-east-1",
//         "us-west-2"
//       ],
//       "filter_tags": [
//         "$KEY:$VALUE"
//       ],
//       "host_tags": [
//         "$KEY:$VALUE"
//       ],
//       "metrics_collection_enabled": false,
//       "resource_collection_enabled": true,
//       "role_name": "DatadogAWSIntegrationRole",
//       "secret_access_key": "ea esse Duis"
//     }
//   ]
// }

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

i = 0
li_Count_i = loo_JResp.SizeOfArray("accounts")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Access_key_id = loo_JResp.StringOf("accounts[i].access_key_id")
    ls_Account_id = loo_JResp.StringOf("accounts[i].account_id")
    li_Auto_scaling = loo_JResp.BoolOf("accounts[i].account_specific_namespace_rules.auto_scaling")
    li_Opswork = loo_JResp.BoolOf("accounts[i].account_specific_namespace_rules.opswork")
    li_Cspm_resource_collection_enabled = loo_JResp.BoolOf("accounts[i].cspm_resource_collection_enabled")
    li_Metrics_collection_enabled = loo_JResp.BoolOf("accounts[i].metrics_collection_enabled")
    li_Resource_collection_enabled = loo_JResp.BoolOf("accounts[i].resource_collection_enabled")
    ls_Role_name = loo_JResp.StringOf("accounts[i].role_name")
    ls_Secret_access_key = loo_JResp.StringOf("accounts[i].secret_access_key")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("accounts[i].excluded_regions")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("accounts[i].excluded_regions[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("accounts[i].filter_tags")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("accounts[i].filter_tags[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("accounts[i].host_tags")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("accounts[i].host_tags[j]")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -G -d "account_id=cupidatat%20Ut%20Duis"
	-d "role_name=cupidatat%20Ut%20Duis"
	-d "access_key_id=cupidatat%20Ut%20Duis"
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/integration/aws

Postman Collection Item JSON

{
  "name": "List all AWS integrations",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v1/integration/aws?account_id=cupidatat Ut Duis&role_name=cupidatat Ut Duis&access_key_id=cupidatat Ut Duis",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "integration",
        "aws"
      ],
      "query": [
        {
          "key": "account_id",
          "value": "cupidatat Ut Duis",
          "description": "Only return AWS accounts that matches this `account_id`."
        },
        {
          "key": "role_name",
          "value": "cupidatat Ut Duis",
          "description": "Only return AWS accounts that matches this role_name."
        },
        {
          "key": "access_key_id",
          "value": "cupidatat Ut Duis",
          "description": "Only return AWS accounts that matches this `access_key_id`."
        }
      ]
    },
    "description": "List all Datadog-AWS integrations available in your Datadog organization."
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v1/integration/aws?account_id=cupidatat Ut Duis&role_name=cupidatat Ut Duis&access_key_id=cupidatat Ut Duis",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "integration",
            "aws"
          ],
          "query": [
            {
              "key": "account_id",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this `account_id`."
            },
            {
              "key": "role_name",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this role_name."
            },
            {
              "key": "access_key_id",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this `access_key_id`."
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"accounts\": [\n    {\n      \"access_key_id\": \"sit Lorem commodo est\",\n      \"account_id\": \"123456789012\",\n      \"account_specific_namespace_rules\": {\n        \"auto_scaling\": false,\n        \"opswork\": false\n      },\n      \"cspm_resource_collection_enabled\": true,\n      \"excluded_regions\": [\n        \"us-east-1\",\n        \"us-west-2\"\n      ],\n      \"filter_tags\": [\n        \"$KEY:$VALUE\"\n      ],\n      \"host_tags\": [\n        \"$KEY:$VALUE\"\n      ],\n      \"metrics_collection_enabled\": false,\n      \"resource_collection_enabled\": true,\n      \"role_name\": \"DatadogAWSIntegrationRole\",\n      \"secret_access_key\": \"qui veniam sint anim\"\n    },\n    {\n      \"access_key_id\": \"quis enim laboris\",\n      \"account_id\": \"123456789012\",\n      \"account_specific_namespace_rules\": {\n        \"auto_scaling\": false,\n        \"opswork\": false\n      },\n      \"cspm_resource_collection_enabled\": true,\n      \"excluded_regions\": [\n        \"us-east-1\",\n        \"us-west-2\"\n      ],\n      \"filter_tags\": [\n        \"$KEY:$VALUE\"\n      ],\n      \"host_tags\": [\n        \"$KEY:$VALUE\"\n      ],\n      \"metrics_collection_enabled\": false,\n      \"resource_collection_enabled\": true,\n      \"role_name\": \"DatadogAWSIntegrationRole\",\n      \"secret_access_key\": \"ea esse Duis\"\n    }\n  ]\n}"
    },
    {
      "name": "Bad Request",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v1/integration/aws?account_id=cupidatat Ut Duis&role_name=cupidatat Ut Duis&access_key_id=cupidatat Ut Duis",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "integration",
            "aws"
          ],
          "query": [
            {
              "key": "account_id",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this `account_id`."
            },
            {
              "key": "role_name",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this role_name."
            },
            {
              "key": "access_key_id",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this `access_key_id`."
            }
          ]
        }
      },
      "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": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v1/integration/aws?account_id=cupidatat Ut Duis&role_name=cupidatat Ut Duis&access_key_id=cupidatat Ut Duis",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "integration",
            "aws"
          ],
          "query": [
            {
              "key": "account_id",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this `account_id`."
            },
            {
              "key": "role_name",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this role_name."
            },
            {
              "key": "access_key_id",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this `access_key_id`."
            }
          ]
        }
      },
      "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": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v1/integration/aws?account_id=cupidatat Ut Duis&role_name=cupidatat Ut Duis&access_key_id=cupidatat Ut Duis",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "integration",
            "aws"
          ],
          "query": [
            {
              "key": "account_id",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this `account_id`."
            },
            {
              "key": "role_name",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this role_name."
            },
            {
              "key": "access_key_id",
              "value": "cupidatat Ut Duis",
              "description": "Only return AWS accounts that matches this `access_key_id`."
            }
          ]
        }
      },
      "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}"
    }
  ]
}