Chilkat Online Tools

PowerBuilder / Datadog API Collection / Get a dashboard

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_V_Type
string ls_Alert_id
string ls_Viz_type
string ls_Live_span
string ls_Title
string ls_Title_align
string ls_Title_size
integer li_Id_int
integer X
integer Y
integer li_Width
integer li_Height
integer li_Is_column_break
string ls_StrVal
string ls_Name
integer j
integer li_Count_j
string ls_Value
integer k
integer li_Count_k
string ls_Default
string ls_Prefix
string ls_Title
string ls_Layout_type
string ls_Author_handle
string ls_Author_name
string ls_Created_at
string ls_Description
string ls_Id
integer li_Is_read_only
string ls_Modified_at
string ls_Reflow_type
string ls_Url
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_Http.SetRequestHeader("Accept","application/json")

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

li_Success = loo_Http.QuickGetSb("https://api.app.ddog-gov.com/api/v1/dashboard/:dashboard_id",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

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_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

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

// {
//   "title": "",
//   "layout_type": "ordered",
//   "widgets": [
//     {
//       "definition": {
//         "type": "alert_graph",
//         "alert_id": "",
//         "viz_type": "timeseries",
//         "time": {
//           "live_span": "5m"
//         },
//         "title": "nisi et cupidatat sunt",
//         "title_align": "right",
//         "title_size": "officia anim occaecat aliq"
//       },
//       "id": 45068649,
//       "layout": {
//         "x": 0,
//         "y": 0,
//         "width": 0,
//         "height": 0,
//         "is_column_break": true
//       }
//     },
//     {
//       "definition": {
//         "type": "alert_graph",
//         "alert_id": "",
//         "viz_type": "timeseries",
//         "time": {
//           "live_span": "5m"
//         },
//         "title": "laborum dolor cillum ad",
//         "title_align": "center",
//         "title_size": "et"
//       },
//       "id": -40196020,
//       "layout": {
//         "x": 0,
//         "y": 0,
//         "width": 0,
//         "height": 0,
//         "is_column_break": false
//       }
//     }
//   ],
//   "author_handle": "test@datadoghq.com",
//   "author_name": "John Doe",
//   "created_at": "2017-08-17T07:10:36.438Z",
//   "description": "eiusmod do est velit enim",
//   "id": "123-abc-456",
//   "is_read_only": false,
//   "modified_at": "1996-07-08T08:32:43.112Z",
//   "notify_list": [
//     "commodo voluptate eu",
//     "consectetur amet"
//   ],
//   "reflow_type": "fixed",
//   "restricted_roles": [
//     "id cupidatat",
//     "quis ullamco"
//   ],
//   "tags": [
//     "quis qui mollit ex",
//     "ullamco enim cupidatat"
//   ],
//   "template_variable_presets": [
//     {
//       "name": "Lorem ex enim",
//       "template_variables": [
//         {
//           "name": "sed ",
//           "value": "quis eu",
//           "values": [
//             "in"
//           ]
//         },
//         {
//           "name": "non",
//           "value": "ea dolore esse elit Lorem",
//           "values": [
//             "sed voluptate nulla"
//           ]
//         }
//       ]
//     },
//     {
//       "name": "est ",
//       "template_variables": [
//         {
//           "name": "ullamco sint",
//           "value": "ad ex irure",
//           "values": [
//             "Duis elit dolor"
//           ]
//         },
//         {
//           "name": "proident adipisicing culpa cons",
//           "value": "occaecat",
//           "values": [
//             "esse fugiat"
//           ]
//         }
//       ]
//     }
//   ],
//   "template_variables": [
//     {
//       "name": "host1",
//       "available_values": [
//         "my-host",
//         "host1",
//         "host2"
//       ],
//       "default": "my-host",
//       "defaults": [
//         "my-host-1",
//         "my-host-2"
//       ],
//       "prefix": "host"
//     },
//     {
//       "name": "host1",
//       "available_values": [
//         "my-host",
//         "host1",
//         "host2"
//       ],
//       "default": "my-host",
//       "defaults": [
//         "my-host-1",
//         "my-host-2"
//       ],
//       "prefix": "host"
//     }
//   ],
//   "url": "/dashboard/123-abc-456/example-dashboard-title"
// }

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

ls_Title = loo_JResp.StringOf("title")
ls_Layout_type = loo_JResp.StringOf("layout_type")
ls_Author_handle = loo_JResp.StringOf("author_handle")
ls_Author_name = loo_JResp.StringOf("author_name")
ls_Created_at = loo_JResp.StringOf("created_at")
ls_Description = loo_JResp.StringOf("description")
ls_Id = loo_JResp.StringOf("id")
li_Is_read_only = loo_JResp.BoolOf("is_read_only")
ls_Modified_at = loo_JResp.StringOf("modified_at")
ls_Reflow_type = loo_JResp.StringOf("reflow_type")
ls_Url = loo_JResp.StringOf("url")
i = 0
li_Count_i = loo_JResp.SizeOfArray("widgets")
do while i < li_Count_i
    loo_JResp.I = i
    ls_V_Type = loo_JResp.StringOf("widgets[i].definition.type")
    ls_Alert_id = loo_JResp.StringOf("widgets[i].definition.alert_id")
    ls_Viz_type = loo_JResp.StringOf("widgets[i].definition.viz_type")
    ls_Live_span = loo_JResp.StringOf("widgets[i].definition.time.live_span")
    ls_Title = loo_JResp.StringOf("widgets[i].definition.title")
    ls_Title_align = loo_JResp.StringOf("widgets[i].definition.title_align")
    ls_Title_size = loo_JResp.StringOf("widgets[i].definition.title_size")
    li_Id_int = loo_JResp.IntOf("widgets[i].id")
    X = loo_JResp.IntOf("widgets[i].layout.x")
    Y = loo_JResp.IntOf("widgets[i].layout.y")
    li_Width = loo_JResp.IntOf("widgets[i].layout.width")
    li_Height = loo_JResp.IntOf("widgets[i].layout.height")
    li_Is_column_break = loo_JResp.BoolOf("widgets[i].layout.is_column_break")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("notify_list")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("notify_list[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("restricted_roles")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("restricted_roles[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("tags")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("tags[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("template_variable_presets")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Name = loo_JResp.StringOf("template_variable_presets[i].name")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("template_variable_presets[i].template_variables")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Name = loo_JResp.StringOf("template_variable_presets[i].template_variables[j].name")
        ls_Value = loo_JResp.StringOf("template_variable_presets[i].template_variables[j].value")
        k = 0
        li_Count_k = loo_JResp.SizeOfArray("template_variable_presets[i].template_variables[j].values")
        do while k < li_Count_k
            loo_JResp.K = k
            ls_StrVal = loo_JResp.StringOf("template_variable_presets[i].template_variables[j].values[k]")
            k = k + 1
        loop
        j = j + 1
    loop
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("template_variables")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Name = loo_JResp.StringOf("template_variables[i].name")
    ls_Default = loo_JResp.StringOf("template_variables[i].default")
    ls_Prefix = loo_JResp.StringOf("template_variables[i].prefix")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("template_variables[i].available_values")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("template_variables[i].available_values[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("template_variables[i].defaults")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("template_variables[i].defaults[j]")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -X GET
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/dashboard/:dashboard_id

Postman Collection Item JSON

{
  "name": "Get a dashboard",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v1/dashboard/:dashboard_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "dashboard",
        ":dashboard_id"
      ],
      "variable": [
        {
          "key": "dashboard_id",
          "value": "tempor Ut sed velit"
        }
      ]
    },
    "description": "Get a dashboard using the specified ID."
  },
  "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/dashboard/:dashboard_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            ":dashboard_id"
          ],
          "variable": [
            {
              "key": "dashboard_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"title\": \"\",\n  \"layout_type\": \"ordered\",\n  \"widgets\": [\n    {\n      \"definition\": {\n        \"type\": \"alert_graph\",\n        \"alert_id\": \"\",\n        \"viz_type\": \"timeseries\",\n        \"time\": {\n          \"live_span\": \"5m\"\n        },\n        \"title\": \"nisi et cupidatat sunt\",\n        \"title_align\": \"right\",\n        \"title_size\": \"officia anim occaecat aliq\"\n      },\n      \"id\": 45068649,\n      \"layout\": {\n        \"x\": 0,\n        \"y\": 0,\n        \"width\": 0,\n        \"height\": 0,\n        \"is_column_break\": true\n      }\n    },\n    {\n      \"definition\": {\n        \"type\": \"alert_graph\",\n        \"alert_id\": \"\",\n        \"viz_type\": \"timeseries\",\n        \"time\": {\n          \"live_span\": \"5m\"\n        },\n        \"title\": \"laborum dolor cillum ad\",\n        \"title_align\": \"center\",\n        \"title_size\": \"et\"\n      },\n      \"id\": -40196020,\n      \"layout\": {\n        \"x\": 0,\n        \"y\": 0,\n        \"width\": 0,\n        \"height\": 0,\n        \"is_column_break\": false\n      }\n    }\n  ],\n  \"author_handle\": \"test@datadoghq.com\",\n  \"author_name\": \"John Doe\",\n  \"created_at\": \"2017-08-17T07:10:36.438Z\",\n  \"description\": \"eiusmod do est velit enim\",\n  \"id\": \"123-abc-456\",\n  \"is_read_only\": false,\n  \"modified_at\": \"1996-07-08T08:32:43.112Z\",\n  \"notify_list\": [\n    \"commodo voluptate eu\",\n    \"consectetur amet\"\n  ],\n  \"reflow_type\": \"fixed\",\n  \"restricted_roles\": [\n    \"id cupidatat\",\n    \"quis ullamco\"\n  ],\n  \"tags\": [\n    \"quis qui mollit ex\",\n    \"ullamco enim cupidatat\"\n  ],\n  \"template_variable_presets\": [\n    {\n      \"name\": \"Lorem ex enim\",\n      \"template_variables\": [\n        {\n          \"name\": \"sed \",\n          \"value\": \"quis eu\",\n          \"values\": [\n            \"in\"\n          ]\n        },\n        {\n          \"name\": \"non\",\n          \"value\": \"ea dolore esse elit Lorem\",\n          \"values\": [\n            \"sed voluptate nulla\"\n          ]\n        }\n      ]\n    },\n    {\n      \"name\": \"est \",\n      \"template_variables\": [\n        {\n          \"name\": \"ullamco sint\",\n          \"value\": \"ad ex irure\",\n          \"values\": [\n            \"Duis elit dolor\"\n          ]\n        },\n        {\n          \"name\": \"proident adipisicing culpa cons\",\n          \"value\": \"occaecat\",\n          \"values\": [\n            \"esse fugiat\"\n          ]\n        }\n      ]\n    }\n  ],\n  \"template_variables\": [\n    {\n      \"name\": \"host1\",\n      \"available_values\": [\n        \"my-host\",\n        \"host1\",\n        \"host2\"\n      ],\n      \"default\": \"my-host\",\n      \"defaults\": [\n        \"my-host-1\",\n        \"my-host-2\"\n      ],\n      \"prefix\": \"host\"\n    },\n    {\n      \"name\": \"host1\",\n      \"available_values\": [\n        \"my-host\",\n        \"host1\",\n        \"host2\"\n      ],\n      \"default\": \"my-host\",\n      \"defaults\": [\n        \"my-host-1\",\n        \"my-host-2\"\n      ],\n      \"prefix\": \"host\"\n    }\n  ],\n  \"url\": \"/dashboard/123-abc-456/example-dashboard-title\"\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/dashboard/:dashboard_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            ":dashboard_id"
          ],
          "variable": [
            {
              "key": "dashboard_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": "Item 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/v1/dashboard/:dashboard_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            ":dashboard_id"
          ],
          "variable": [
            {
              "key": "dashboard_id"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_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/dashboard/:dashboard_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "dashboard",
            ":dashboard_id"
          ],
          "variable": [
            {
              "key": "dashboard_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}"
    }
  ]
}