Classic ASP / Squadcast API V3 / Get Tagging Rules
Back to Collection Items
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Http")
set http = Server.CreateObject("Chilkat.Http")
http.SetRequestHeader "Authorization",""
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.StringBuilder")
set sbResponseBody = Server.CreateObject("Chilkat.StringBuilder")
success = http.QuickGetSb("https://api.squadcast.com/v3/services/:serviceID/tagging-rules",sbResponseBody)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
Response.End
End If
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.JsonObject")
set jResp = Server.CreateObject("Chilkat.JsonObject")
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0
Response.Write "<pre>" & Server.HTMLEncode( "Response Body:") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( jResp.Emit()) & "</pre>"
respStatusCode = http.LastStatus
Response.Write "<pre>" & Server.HTMLEncode( "Response Status Code = " & respStatusCode) & "</pre>"
If (respStatusCode >= 400) Then
Response.Write "<pre>" & Server.HTMLEncode( "Response Header:") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( http.LastHeader) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Failed.") & "</pre>"
Response.End
End If
' Sample JSON response:
' (Sample code for parsing the JSON response is shown below)
' {
' "data": {
' "id": "5d89e22915e52fa3f8620d37",
' "created_at": "2019-09-24T09:30:17.463Z",
' "updated_at": "2019-09-24T09:30:17.463Z",
' "deleted_at": null,
' "service_id": "5d81d9687000fb6b9def7e35",
' "organization_id": "5d81d9187000fb6b9def7e32",
' "rules": [
' {
' "expression": "re(current.labels.alertname, \"^CPUThrottlingHigh.*\") && re(past.labels.alertname, \"^CPUThrottlingHigh.*\")",
' "tags": {
' "foo": "bar",
' "severity": "asa",
' "tag2": "as"
' }
' }
' ]
' }
' }
' Sample code for parsing the JSON response...
' Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Id = jResp.StringOf("data.id")
Created_at = jResp.StringOf("data.created_at")
Updated_at = jResp.StringOf("data.updated_at")
Deleted_at = jResp.StringOf("data.deleted_at")
Service_id = jResp.StringOf("data.service_id")
Organization_id = jResp.StringOf("data.organization_id")
i = 0
count_i = jResp.SizeOfArray("data.rules")
Do While i < count_i
jResp.I = i
expression = jResp.StringOf("data.rules[i].expression")
Foo = jResp.StringOf("data.rules[i].tags.foo")
Severity = jResp.StringOf("data.rules[i].tags.severity")
Tag2 = jResp.StringOf("data.rules[i].tags.tag2")
i = i + 1
Loop
%>
</body>
</html>
Curl Command
curl -X GET
-H "Authorization: "
https://api.squadcast.com/v3/services/:serviceID/tagging-rules
Postman Collection Item JSON
{
"name": "Get Tagging Rules",
"request": {
"auth": {
"type": "noauth"
},
"method": "GET",
"header": [
{
"key": "Authorization",
"value": ""
}
],
"url": {
"raw": "{{baseUrl}}/services/:serviceID/tagging-rules",
"host": [
"{{baseUrl}}"
],
"path": [
"services",
":serviceID",
"tagging-rules"
],
"variable": [
{
"key": "serviceID",
"value": "<string>",
"type": "string",
"description": "(Required) service id"
}
]
},
"description": "This endpoint returns the default tagging rules for the service if not already created.\nRequires `access_token` as a `Bearer {{token}}` in the `Authorization` header with `read` scope."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/services/:serviceID/tagging-rules",
"host": [
"{{baseUrl}}"
],
"path": [
"services",
":serviceID",
"tagging-rules"
],
"variable": [
{
"key": "serviceID"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"id\": \"5d89e22915e52fa3f8620d37\",\n \"created_at\": \"2019-09-24T09:30:17.463Z\",\n \"updated_at\": \"2019-09-24T09:30:17.463Z\",\n \"deleted_at\": null,\n \"service_id\": \"5d81d9687000fb6b9def7e35\",\n \"organization_id\": \"5d81d9187000fb6b9def7e32\",\n \"rules\": [\n {\n \"expression\": \"re(current.labels.alertname, \\\"^CPUThrottlingHigh.*\\\") && re(past.labels.alertname, \\\"^CPUThrottlingHigh.*\\\")\",\n \"tags\": {\n \"foo\": \"bar\",\n \"severity\": \"asa\",\n \"tag2\": \"as\"\n }\n }\n ]\n }\n}"
}
]
}