Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
queryParams.i = CkJsonObject::ckCreate()
If queryParams.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateString(queryParams,"with_configured_alert_ids","true")
CkHttp::ckSetRequestHeader(http,"Accept","application/json")
resp.i = CkHttp::ckQuickRequestParams(http,"GET","https://api.app.ddog-gov.com/api/v1/slo/:slo_id",queryParams)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(queryParams)
ProcedureReturn
EndIf
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttpResponse::ckGetBodySb(resp,sbResponseBody)
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,sbResponseBody)
CkJsonObject::setCkEmitCompact(jResp, 0)
Debug "Response Body:"
Debug CkJsonObject::ckEmit(jResp)
respStatusCode.i = CkHttpResponse::ckStatusCode(resp)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttpResponse::ckHeader(resp)
Debug "Failed."
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(queryParams)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndIf
CkHttpResponse::ckDispose(resp)
; 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
intVal.i
strVal.s
target.i
timeframe.s
warning.i
Created_at.i = CkJsonObject::ckIntOf(jResp,"data.created_at")
v_Email.s = CkJsonObject::ckStringOf(jResp,"data.creator.email")
Handle.s = CkJsonObject::ckStringOf(jResp,"data.creator.handle")
Name.s = CkJsonObject::ckStringOf(jResp,"data.creator.name")
Description.s = CkJsonObject::ckStringOf(jResp,"data.description")
Id.s = CkJsonObject::ckStringOf(jResp,"data.id")
Modified_at.i = CkJsonObject::ckIntOf(jResp,"data.modified_at")
dataName.s = CkJsonObject::ckStringOf(jResp,"data.name")
Numerator.s = CkJsonObject::ckStringOf(jResp,"data.query.numerator")
Denominator.s = CkJsonObject::ckStringOf(jResp,"data.query.denominator")
Target_threshold.s = CkJsonObject::ckStringOf(jResp,"data.target_threshold")
Timeframe.s = CkJsonObject::ckStringOf(jResp,"data.timeframe")
v_Type.s = CkJsonObject::ckStringOf(jResp,"data.type")
Warning_threshold.s = CkJsonObject::ckStringOf(jResp,"data.warning_threshold")
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"data.configured_alert_ids")
While i < count_i
CkJsonObject::setCkI(jResp, i)
intVal = CkJsonObject::ckIntOf(jResp,"data.configured_alert_ids[i]")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"data.groups")
While i < count_i
CkJsonObject::setCkI(jResp, i)
strVal = CkJsonObject::ckStringOf(jResp,"data.groups[i]")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"data.monitor_ids")
While i < count_i
CkJsonObject::setCkI(jResp, i)
intVal = CkJsonObject::ckIntOf(jResp,"data.monitor_ids[i]")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"data.monitor_tags")
While i < count_i
CkJsonObject::setCkI(jResp, i)
strVal = CkJsonObject::ckStringOf(jResp,"data.monitor_tags[i]")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"data.tags")
While i < count_i
CkJsonObject::setCkI(jResp, i)
strVal = CkJsonObject::ckStringOf(jResp,"data.tags[i]")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"data.thresholds")
While i < count_i
CkJsonObject::setCkI(jResp, i)
target = CkJsonObject::ckIntOf(jResp,"data.thresholds[i].target")
timeframe = CkJsonObject::ckStringOf(jResp,"data.thresholds[i].timeframe")
warning = CkJsonObject::ckIntOf(jResp,"data.thresholds[i].warning")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(jResp,"errors")
While i < count_i
CkJsonObject::setCkI(jResp, i)
strVal = CkJsonObject::ckStringOf(jResp,"errors[i]")
i = i + 1
Wend
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(queryParams)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
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}"
}
]
}