Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
loQueryParams = createobject("CkJsonObject")
loQueryParams.UpdateString("with_configured_alert_ids","true")
loHttp.SetRequestHeader("Accept","application/json")
loResp = loHttp.QuickRequestParams("GET","https://api.app.ddog-gov.com/api/v1/slo/:slo_id",loQueryParams)
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loQueryParams
return
endif
loSbResponseBody = createobject("CkStringBuilder")
loResp.GetBodySb(loSbResponseBody)
loJResp = createobject("CkJsonObject")
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = .F.
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + str(lnRespStatusCode)
if (lnRespStatusCode >= 400) then
? "Response Header:"
? loResp.Header
? "Failed."
release loResp
release loHttp
release loQueryParams
release loSbResponseBody
release loJResp
return
endif
release loResp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "configured_alert_ids": [
// 123,
// 456,
// 789
// ],
// "created_at": 17466638,
// "creator": {
// "email": "proident ex ullamco",
// "handle": "laborum ad ex non",
// "name": "officia dolor consectetur nisi"
// },
// "description": "est id",
// "groups": [
// "env:prod",
// "role:mysql"
// ],
// "id": "esse cillum anim ",
// "modified_at": -26273532,
// "monitor_ids": [
// -91642399,
// 93741
// ],
// "monitor_tags": [
// "aliquip nulla Lorem ut",
// "reprehenderit velit"
// ],
// "name": "Custom Metric SLO",
// "query": {
// "numerator": "sum:my.custom.metric{type:good}.as_count()",
// "denominator": "sum:my.custom.metric{*}.as_count()"
// },
// "tags": [
// "env:prod",
// "app:core"
// ],
// "target_threshold": 99.9,
// "thresholds": [
// {
// "target": 95,
// "timeframe": "7d"
// },
// {
// "target": 95,
// "timeframe": "30d",
// "warning": 97
// }
// ],
// "timeframe": "30d",
// "type": "metric",
// "warning_threshold": 99.95
// },
// "errors": [
// "consectetur velit",
// "elit in"
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
lnCreated_at = loJResp.IntOf("data.created_at")
lcV_Email = loJResp.StringOf("data.creator.email")
lcHandle = loJResp.StringOf("data.creator.handle")
lcName = loJResp.StringOf("data.creator.name")
lcDescription = loJResp.StringOf("data.description")
lcId = loJResp.StringOf("data.id")
lnModified_at = loJResp.IntOf("data.modified_at")
lcDataName = loJResp.StringOf("data.name")
lcNumerator = loJResp.StringOf("data.query.numerator")
lcDenominator = loJResp.StringOf("data.query.denominator")
lcTarget_threshold = loJResp.StringOf("data.target_threshold")
lcTimeframe = loJResp.StringOf("data.timeframe")
lcV_Type = loJResp.StringOf("data.type")
lcWarning_threshold = loJResp.StringOf("data.warning_threshold")
i = 0
lnCount_i = loJResp.SizeOfArray("data.configured_alert_ids")
do while i < lnCount_i
loJResp.I = i
lnIntVal = loJResp.IntOf("data.configured_alert_ids[i]")
i = i + 1
enddo
i = 0
lnCount_i = loJResp.SizeOfArray("data.groups")
do while i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("data.groups[i]")
i = i + 1
enddo
i = 0
lnCount_i = loJResp.SizeOfArray("data.monitor_ids")
do while i < lnCount_i
loJResp.I = i
lnIntVal = loJResp.IntOf("data.monitor_ids[i]")
i = i + 1
enddo
i = 0
lnCount_i = loJResp.SizeOfArray("data.monitor_tags")
do while i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("data.monitor_tags[i]")
i = i + 1
enddo
i = 0
lnCount_i = loJResp.SizeOfArray("data.tags")
do while i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("data.tags[i]")
i = i + 1
enddo
i = 0
lnCount_i = loJResp.SizeOfArray("data.thresholds")
do while i < lnCount_i
loJResp.I = i
lnTarget = loJResp.IntOf("data.thresholds[i].target")
lcTimeframe = loJResp.StringOf("data.thresholds[i].timeframe")
lnWarning = loJResp.IntOf("data.thresholds[i].warning")
i = i + 1
enddo
i = 0
lnCount_i = loJResp.SizeOfArray("errors")
do while i < lnCount_i
loJResp.I = i
lcStrVal = loJResp.StringOf("errors[i]")
i = i + 1
enddo
release loHttp
release loQueryParams
release loSbResponseBody
release loJResp
Curl Command
curl -G -d "with_configured_alert_ids=true"
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/slo/:slo_id
Postman Collection Item JSON
{
"name": "Get an SLO's details",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v1/slo/:slo_id?with_configured_alert_ids=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
":slo_id"
],
"query": [
{
"key": "with_configured_alert_ids",
"value": "true",
"description": "Get the IDs of SLO monitors that reference this SLO."
}
],
"variable": [
{
"key": "slo_id",
"value": "tempor Ut sed velit"
}
]
},
"description": "Get a service level objective object."
},
"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/slo/:slo_id?with_configured_alert_ids=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
":slo_id"
],
"query": [
{
"key": "with_configured_alert_ids",
"value": "true",
"description": "Get the IDs of SLO monitors that reference this SLO."
}
],
"variable": [
{
"key": "slo_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"configured_alert_ids\": [\n 123,\n 456,\n 789\n ],\n \"created_at\": 17466638,\n \"creator\": {\n \"email\": \"proident ex ullamco\",\n \"handle\": \"laborum ad ex non\",\n \"name\": \"officia dolor consectetur nisi\"\n },\n \"description\": \"est id\",\n \"groups\": [\n \"env:prod\",\n \"role:mysql\"\n ],\n \"id\": \"esse cillum anim \",\n \"modified_at\": -26273532,\n \"monitor_ids\": [\n -91642399,\n 93741\n ],\n \"monitor_tags\": [\n \"aliquip nulla Lorem ut\",\n \"reprehenderit velit\"\n ],\n \"name\": \"Custom Metric SLO\",\n \"query\": {\n \"numerator\": \"sum:my.custom.metric{type:good}.as_count()\",\n \"denominator\": \"sum:my.custom.metric{*}.as_count()\"\n },\n \"tags\": [\n \"env:prod\",\n \"app:core\"\n ],\n \"target_threshold\": 99.9,\n \"thresholds\": [\n {\n \"target\": 95,\n \"timeframe\": \"7d\"\n },\n {\n \"target\": 95,\n \"timeframe\": \"30d\",\n \"warning\": 97\n }\n ],\n \"timeframe\": \"30d\",\n \"type\": \"metric\",\n \"warning_threshold\": 99.95\n },\n \"errors\": [\n \"consectetur velit\",\n \"elit in\"\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/v1/slo/:slo_id?with_configured_alert_ids=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
":slo_id"
],
"query": [
{
"key": "with_configured_alert_ids",
"value": "true",
"description": "Get the IDs of SLO monitors that reference this SLO."
}
],
"variable": [
{
"key": "slo_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": "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/slo/:slo_id?with_configured_alert_ids=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
":slo_id"
],
"query": [
{
"key": "with_configured_alert_ids",
"value": "true",
"description": "Get the IDs of SLO monitors that reference this SLO."
}
],
"variable": [
{
"key": "slo_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/slo/:slo_id?with_configured_alert_ids=true",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"slo",
":slo_id"
],
"query": [
{
"key": "with_configured_alert_ids",
"value": "true",
"description": "Get the IDs of SLO monitors that reference this SLO."
}
],
"variable": [
{
"key": "slo_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}"
}
]
}