Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()
var success: Bool
http.SetRequestHeader("Accept", value: "application/json")
let sbResponseBody = CkoStringBuilder()
success = http.QuickGetSb("https://api.app.ddog-gov.com/api/v2/security_monitoring/rules/:rule_id", sbContent: sbResponseBody)
if success == false {
print("\(http.LastErrorText)")
return
}
let jResp = CkoJsonObject()
jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = false
print("Response Body:")
print("\(jResp.Emit())")
var respStatusCode: Int = http.LastStatus.intValue
print("Response Status Code = \(respStatusCode)")
if respStatusCode >= 400 {
print("Response Header:")
print("\(http.LastHeader)")
print("Failed.")
return
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "cases": [
// {
// "condition": "<string>",
// "name": "<string>",
// "notifications": [
// "<string>",
// "<string>"
// ],
// "status": "medium"
// },
// {
// "condition": "<string>",
// "name": "<string>",
// "notifications": [
// "<string>",
// "<string>"
// ],
// "status": "critical"
// }
// ],
// "complianceSignalOptions": {
// "defaultActivationStatus": "<boolean>",
// "defaultGroupByFields": [
// "<string>",
// "<string>"
// ],
// "userActivationStatus": "<boolean>",
// "userGroupByFields": [
// "<string>",
// "<string>"
// ]
// },
// "createdAt": "<long>",
// "creationAuthorId": "<long>",
// "deprecationDate": "<long>",
// "filters": [
// {
// "action": "suppress",
// "query": "<string>"
// },
// {
// "action": "require",
// "query": "<string>"
// }
// ],
// "hasExtendedTitle": "<boolean>",
// "id": "<string>",
// "isDefault": "<boolean>",
// "isDeleted": "<boolean>",
// "isEnabled": "<boolean>",
// "message": "<string>",
// "name": "<string>",
// "options": {
// "complianceRuleOptions": {
// "complexRule": "<boolean>",
// "regoRule": {
// "policy": "<string>",
// "resourceTypes": [
// "<string>",
// "<string>"
// ]
// },
// "resourceType": "<string>"
// },
// "decreaseCriticalityBasedOnEnv": "<boolean>",
// "detectionMethod": "third_party",
// "evaluationWindow": 300,
// "hardcodedEvaluatorType": "log4shell",
// "impossibleTravelOptions": {
// "baselineUserLocations": "<boolean>"
// },
// "keepAlive": 300,
// "maxSignalDuration": 900,
// "newValueOptions": {
// "forgetAfter": 28,
// "learningDuration": 0,
// "learningMethod": "duration",
// "learningThreshold": 0
// }
// },
// "queries": [
// {
// "aggregation": "max",
// "distinctFields": [
// "<string>",
// "<string>"
// ],
// "groupByFields": [
// "<string>",
// "<string>"
// ],
// "metric": "<string>",
// "metrics": [
// "<string>",
// "<string>"
// ],
// "name": "<string>",
// "query": "<string>"
// },
// {
// "aggregation": "max",
// "distinctFields": [
// "<string>",
// "<string>"
// ],
// "groupByFields": [
// "<string>",
// "<string>"
// ],
// "metric": "<string>",
// "metrics": [
// "<string>",
// "<string>"
// ],
// "name": "<string>",
// "query": "<string>"
// }
// ],
// "tags": [
// "<string>",
// "<string>"
// ],
// "type": "application_security",
// "updateAuthorId": "<long>",
// "version": "<long>"
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var condition: String?
var status: String?
var j: Int
var count_j: Int
var strVal: String?
var action: String?
var query: String?
var aggregation: String?
var metric: String?
var DefaultActivationStatus: String? = jResp.StringOf("complianceSignalOptions.defaultActivationStatus")
var UserActivationStatus: String? = jResp.StringOf("complianceSignalOptions.userActivationStatus")
var createdAt: String? = jResp.StringOf("createdAt")
var creationAuthorId: String? = jResp.StringOf("creationAuthorId")
var deprecationDate: String? = jResp.StringOf("deprecationDate")
var hasExtendedTitle: String? = jResp.StringOf("hasExtendedTitle")
var id: String? = jResp.StringOf("id")
var isDefault: String? = jResp.StringOf("isDefault")
var isDeleted: String? = jResp.StringOf("isDeleted")
var isEnabled: String? = jResp.StringOf("isEnabled")
var message: String? = jResp.StringOf("message")
var name: String? = jResp.StringOf("name")
var ComplexRule: String? = jResp.StringOf("options.complianceRuleOptions.complexRule")
var Policy: String? = jResp.StringOf("options.complianceRuleOptions.regoRule.policy")
var ResourceType: String? = jResp.StringOf("options.complianceRuleOptions.resourceType")
var DecreaseCriticalityBasedOnEnv: String? = jResp.StringOf("options.decreaseCriticalityBasedOnEnv")
var DetectionMethod: String? = jResp.StringOf("options.detectionMethod")
var EvaluationWindow: Int = jResp.IntOf("options.evaluationWindow").intValue
var HardcodedEvaluatorType: String? = jResp.StringOf("options.hardcodedEvaluatorType")
var BaselineUserLocations: String? = jResp.StringOf("options.impossibleTravelOptions.baselineUserLocations")
var KeepAlive: Int = jResp.IntOf("options.keepAlive").intValue
var MaxSignalDuration: Int = jResp.IntOf("options.maxSignalDuration").intValue
var ForgetAfter: Int = jResp.IntOf("options.newValueOptions.forgetAfter").intValue
var LearningDuration: Int = jResp.IntOf("options.newValueOptions.learningDuration").intValue
var LearningMethod: String? = jResp.StringOf("options.newValueOptions.learningMethod")
var LearningThreshold: Int = jResp.IntOf("options.newValueOptions.learningThreshold").intValue
var v_type: String? = jResp.StringOf("type")
var updateAuthorId: String? = jResp.StringOf("updateAuthorId")
var version: String? = jResp.StringOf("version")
var i: Int = 0
var count_i: Int = jResp.SizeOfArray("cases").intValue
while i < count_i {
jResp.I = i
condition = jResp.StringOf("cases[i].condition")
name = jResp.StringOf("cases[i].name")
status = jResp.StringOf("cases[i].status")
j = 0
count_j = jResp.SizeOfArray("cases[i].notifications").intValue
while j < count_j {
jResp.J = j
strVal = jResp.StringOf("cases[i].notifications[j]")
j = j + 1
}
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("complianceSignalOptions.defaultGroupByFields").intValue
while i < count_i {
jResp.I = i
strVal = jResp.StringOf("complianceSignalOptions.defaultGroupByFields[i]")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("complianceSignalOptions.userGroupByFields").intValue
while i < count_i {
jResp.I = i
strVal = jResp.StringOf("complianceSignalOptions.userGroupByFields[i]")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("filters").intValue
while i < count_i {
jResp.I = i
action = jResp.StringOf("filters[i].action")
query = jResp.StringOf("filters[i].query")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("options.complianceRuleOptions.regoRule.resourceTypes").intValue
while i < count_i {
jResp.I = i
strVal = jResp.StringOf("options.complianceRuleOptions.regoRule.resourceTypes[i]")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("queries").intValue
while i < count_i {
jResp.I = i
aggregation = jResp.StringOf("queries[i].aggregation")
metric = jResp.StringOf("queries[i].metric")
name = jResp.StringOf("queries[i].name")
query = jResp.StringOf("queries[i].query")
j = 0
count_j = jResp.SizeOfArray("queries[i].distinctFields").intValue
while j < count_j {
jResp.J = j
strVal = jResp.StringOf("queries[i].distinctFields[j]")
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("queries[i].groupByFields").intValue
while j < count_j {
jResp.J = j
strVal = jResp.StringOf("queries[i].groupByFields[j]")
j = j + 1
}
j = 0
count_j = jResp.SizeOfArray("queries[i].metrics").intValue
while j < count_j {
jResp.J = j
strVal = jResp.StringOf("queries[i].metrics[j]")
j = j + 1
}
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("tags").intValue
while i < count_i {
jResp.I = i
strVal = jResp.StringOf("tags[i]")
i = i + 1
}
}
Curl Command
curl -X GET
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/security_monitoring/rules/:rule_id
Postman Collection Item JSON
{
"name": "Get a rule's details",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/security_monitoring/rules/:rule_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"rules",
":rule_id"
],
"variable": [
{
"key": "rule_id",
"value": "<string>"
}
]
},
"description": "Get a rule's details."
},
"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/v2/security_monitoring/rules/:rule_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"rules",
":rule_id"
],
"variable": [
{
"key": "rule_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"cases\": [\n {\n \"condition\": \"<string>\",\n \"name\": \"<string>\",\n \"notifications\": [\n \"<string>\",\n \"<string>\"\n ],\n \"status\": \"medium\"\n },\n {\n \"condition\": \"<string>\",\n \"name\": \"<string>\",\n \"notifications\": [\n \"<string>\",\n \"<string>\"\n ],\n \"status\": \"critical\"\n }\n ],\n \"complianceSignalOptions\": {\n \"defaultActivationStatus\": \"<boolean>\",\n \"defaultGroupByFields\": [\n \"<string>\",\n \"<string>\"\n ],\n \"userActivationStatus\": \"<boolean>\",\n \"userGroupByFields\": [\n \"<string>\",\n \"<string>\"\n ]\n },\n \"createdAt\": \"<long>\",\n \"creationAuthorId\": \"<long>\",\n \"deprecationDate\": \"<long>\",\n \"filters\": [\n {\n \"action\": \"suppress\",\n \"query\": \"<string>\"\n },\n {\n \"action\": \"require\",\n \"query\": \"<string>\"\n }\n ],\n \"hasExtendedTitle\": \"<boolean>\",\n \"id\": \"<string>\",\n \"isDefault\": \"<boolean>\",\n \"isDeleted\": \"<boolean>\",\n \"isEnabled\": \"<boolean>\",\n \"message\": \"<string>\",\n \"name\": \"<string>\",\n \"options\": {\n \"complianceRuleOptions\": {\n \"complexRule\": \"<boolean>\",\n \"regoRule\": {\n \"policy\": \"<string>\",\n \"resourceTypes\": [\n \"<string>\",\n \"<string>\"\n ]\n },\n \"resourceType\": \"<string>\"\n },\n \"decreaseCriticalityBasedOnEnv\": \"<boolean>\",\n \"detectionMethod\": \"third_party\",\n \"evaluationWindow\": 300,\n \"hardcodedEvaluatorType\": \"log4shell\",\n \"impossibleTravelOptions\": {\n \"baselineUserLocations\": \"<boolean>\"\n },\n \"keepAlive\": 300,\n \"maxSignalDuration\": 900,\n \"newValueOptions\": {\n \"forgetAfter\": 28,\n \"learningDuration\": 0,\n \"learningMethod\": \"duration\",\n \"learningThreshold\": 0\n }\n },\n \"queries\": [\n {\n \"aggregation\": \"max\",\n \"distinctFields\": [\n \"<string>\",\n \"<string>\"\n ],\n \"groupByFields\": [\n \"<string>\",\n \"<string>\"\n ],\n \"metric\": \"<string>\",\n \"metrics\": [\n \"<string>\",\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"query\": \"<string>\"\n },\n {\n \"aggregation\": \"max\",\n \"distinctFields\": [\n \"<string>\",\n \"<string>\"\n ],\n \"groupByFields\": [\n \"<string>\",\n \"<string>\"\n ],\n \"metric\": \"<string>\",\n \"metrics\": [\n \"<string>\",\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"query\": \"<string>\"\n }\n ],\n \"tags\": [\n \"<string>\",\n \"<string>\"\n ],\n \"type\": \"application_security\",\n \"updateAuthorId\": \"<long>\",\n \"version\": \"<long>\"\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/v2/security_monitoring/rules/:rule_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"rules",
":rule_id"
],
"variable": [
{
"key": "rule_id"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\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/v2/security_monitoring/rules/:rule_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"rules",
":rule_id"
],
"variable": [
{
"key": "rule_id"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
}
]
}