Chilkat Online Tools

Foxpro / Datadog API Collection / List Confluent accounts

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcApi_key
LOCAL lcId
LOCAL lcV_type
LOCAL j
LOCAL lnCount_j
LOCAL lcResource_type
LOCAL lnEnable_custom_metrics
LOCAL k
LOCAL lnCount_k
LOCAL lcStrVal
LOCAL i
LOCAL lnCount_i

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

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

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://api.app.ddog-gov.com/api/v2/integrations/confluent-cloud/accounts",loSbResponseBody)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loHttp.LastHeader
    ? "Failed."
    RELEASE loHttp
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

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

* {
*   "data": [
*     {
*       "attributes": {
*         "api_key": "<string>",
*         "resources": [
*           {
*             "resource_type": "<string>",
*             "enable_custom_metrics": false,
*             "id": "<string>",
*             "tags": [
*               "<string>",
*               "<string>"
*             ]
*           },
*           {
*             "resource_type": "<string>",
*             "enable_custom_metrics": false,
*             "id": "<string>",
*             "tags": [
*               "<string>",
*               "<string>"
*             ]
*           }
*         ],
*         "tags": [
*           "<string>",
*           "<string>"
*         ]
*       },
*       "id": "<string>",
*       "type": "confluent-cloud-accounts"
*     },
*     {
*       "attributes": {
*         "api_key": "<string>",
*         "resources": [
*           {
*             "resource_type": "<string>",
*             "enable_custom_metrics": false,
*             "id": "<string>",
*             "tags": [
*               "<string>",
*               "<string>"
*             ]
*           },
*           {
*             "resource_type": "<string>",
*             "enable_custom_metrics": false,
*             "id": "<string>",
*             "tags": [
*               "<string>",
*               "<string>"
*             ]
*           }
*         ],
*         "tags": [
*           "<string>",
*           "<string>"
*         ]
*       },
*       "id": "<string>",
*       "type": "confluent-cloud-accounts"
*     }
*   ]
* }

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

i = 0
lnCount_i = loJResp.SizeOfArray("data")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcApi_key = loJResp.StringOf("data[i].attributes.api_key")
    lcId = loJResp.StringOf("data[i].id")
    lcV_type = loJResp.StringOf("data[i].type")
    j = 0
    lnCount_j = loJResp.SizeOfArray("data[i].attributes.resources")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcResource_type = loJResp.StringOf("data[i].attributes.resources[j].resource_type")
        lnEnable_custom_metrics = loJResp.BoolOf("data[i].attributes.resources[j].enable_custom_metrics")
        lcId = loJResp.StringOf("data[i].attributes.resources[j].id")
        k = 0
        lnCount_k = loJResp.SizeOfArray("data[i].attributes.resources[j].tags")
        DO WHILE k < lnCount_k
            loJResp.K = k
            lcStrVal = loJResp.StringOf("data[i].attributes.resources[j].tags[k]")
            k = k + 1
        ENDDO
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("data[i].attributes.tags")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcStrVal = loJResp.StringOf("data[i].attributes.tags[j]")
        j = j + 1
    ENDDO
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp

Curl Command

curl -X GET
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/integrations/confluent-cloud/accounts

Postman Collection Item JSON

{
  "name": "List Confluent accounts",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/integrations/confluent-cloud/accounts",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "integrations",
        "confluent-cloud",
        "accounts"
      ]
    },
    "description": "List Confluent accounts."
  },
  "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/v2/integrations/confluent-cloud/accounts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "integrations",
            "confluent-cloud",
            "accounts"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"data\": [\n    {\n      \"attributes\": {\n        \"api_key\": \"<string>\",\n        \"resources\": [\n          {\n            \"resource_type\": \"<string>\",\n            \"enable_custom_metrics\": false,\n            \"id\": \"<string>\",\n            \"tags\": [\n              \"<string>\",\n              \"<string>\"\n            ]\n          },\n          {\n            \"resource_type\": \"<string>\",\n            \"enable_custom_metrics\": false,\n            \"id\": \"<string>\",\n            \"tags\": [\n              \"<string>\",\n              \"<string>\"\n            ]\n          }\n        ],\n        \"tags\": [\n          \"<string>\",\n          \"<string>\"\n        ]\n      },\n      \"id\": \"<string>\",\n      \"type\": \"confluent-cloud-accounts\"\n    },\n    {\n      \"attributes\": {\n        \"api_key\": \"<string>\",\n        \"resources\": [\n          {\n            \"resource_type\": \"<string>\",\n            \"enable_custom_metrics\": false,\n            \"id\": \"<string>\",\n            \"tags\": [\n              \"<string>\",\n              \"<string>\"\n            ]\n          },\n          {\n            \"resource_type\": \"<string>\",\n            \"enable_custom_metrics\": false,\n            \"id\": \"<string>\",\n            \"tags\": [\n              \"<string>\",\n              \"<string>\"\n            ]\n          }\n        ],\n        \"tags\": [\n          \"<string>\",\n          \"<string>\"\n        ]\n      },\n      \"id\": \"<string>\",\n      \"type\": \"confluent-cloud-accounts\"\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/v2/integrations/confluent-cloud/accounts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "integrations",
            "confluent-cloud",
            "accounts"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\n  ]\n}"
    },
    {
      "name": "Forbidden",
      "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/v2/integrations/confluent-cloud/accounts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "integrations",
            "confluent-cloud",
            "accounts"
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\n  ]\n}"
    },
    {
      "name": "Not Found",
      "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/v2/integrations/confluent-cloud/accounts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "integrations",
            "confluent-cloud",
            "accounts"
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\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/v2/integrations/confluent-cloud/accounts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "integrations",
            "confluent-cloud",
            "accounts"
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"<string>\",\n    \"<string>\"\n  ]\n}"
    }
  ]
}