DataFlex / Squadcast API V3 / Get suppression rules
Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sDescription
String sExpression
Boolean iIs_basic
String sId
String sCreated_at
String sUpdated_at
String sService_id
String sOrganization_id
Integer i
Integer iCount_i
String sTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// Adds the "Authorization: Bearer <access_token>" header.
Set ComAuthToken Of hoHttp To "<access_token>"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComQuickGetSb Of hoHttp "https://api.squadcast.com/v3/services/:serviceID/suppression-rules" vSbResponseBody To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComLastStatus Of hoHttp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComLastHeader Of hoHttp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "id": "5fa50748a2e7e47f1436c0fc",
// "created_at": "2020-11-06T08:20:24.756Z",
// "updated_at": "2020-11-11T09:28:19.972Z",
// "service_id": "5f8ed89e39e4a959da360537",
// "organization_id": "5db92749f8d4da1473169533",
// "rules": [
// {
// "description": "Suppress low latency alerts",
// "expression": "re(payload.policy_name, \"low latency\")",
// "is_basic": false
// }
// ]
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Get ComStringOf Of hoJResp "data.id" To sId
Get ComStringOf Of hoJResp "data.created_at" To sCreated_at
Get ComStringOf Of hoJResp "data.updated_at" To sUpdated_at
Get ComStringOf Of hoJResp "data.service_id" To sService_id
Get ComStringOf Of hoJResp "data.organization_id" To sOrganization_id
Move 0 To i
Get ComSizeOfArray Of hoJResp "data.rules" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "data.rules[i].description" To sDescription
Get ComStringOf Of hoJResp "data.rules[i].expression" To sExpression
Get ComBoolOf Of hoJResp "data.rules[i].is_basic" To iIs_basic
Move (i + 1) To i
Loop
End_Procedure
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://api.squadcast.com/v3/services/:serviceID/suppression-rules
Postman Collection Item JSON
{
"name": "Get suppression rules",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{sq_pb_auth_header}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/services/:serviceID/suppression-rules",
"host": [
"{{baseUrl}}"
],
"path": [
"services",
":serviceID",
"suppression-rules"
],
"variable": [
{
"key": "serviceID",
"value": "5c7cf71ad517f500100b37d6",
"type": "string"
}
]
},
"description": "This endpoint returns the default suppression rules for the service if not already created. Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `read` scope."
},
"response": [
{
"name": "200 - suppression rules",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/services/:serviceID/suppression-rules",
"host": [
"{{baseUrl}}"
],
"path": [
"services",
":serviceID",
"suppression-rules"
],
"variable": [
{
"key": "serviceID",
"value": ""
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "Date",
"value": "Fri, 18 Sep 2020 06:21:12 GMT"
},
{
"key": "Content-Length",
"value": "63"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"id\": \"5fa50748a2e7e47f1436c0fc\",\n \"created_at\": \"2020-11-06T08:20:24.756Z\",\n \"updated_at\": \"2020-11-11T09:28:19.972Z\",\n \"service_id\": \"5f8ed89e39e4a959da360537\",\n \"organization_id\": \"5db92749f8d4da1473169533\",\n \"rules\": [\n {\n \"description\": \"Suppress low latency alerts\",\n \"expression\": \"re(payload.policy_name, \\\"low latency\\\")\",\n \"is_basic\": false\n }\n ]\n }\n}"
}
]
}