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
let queryParams = CkoJsonObject()!
queryParams.updateInt("page[size]", value: 10)
queryParams.updateInt("page[number]", value: 0)
http.setRequestHeader("Accept", value: "application/json")
var resp: CkoHttpResponse? = http.quickRequestParams("GET", url: "https://api.app.ddog-gov.com/api/v2/security_monitoring/rules", json: queryParams)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
let sbResponseBody = CkoStringBuilder()!
resp!.getBodySb(sbResponseBody)
let jResp = CkoJsonObject()!
jResp.loadSb(sbResponseBody)
jResp.emitCompact = false
print("Response Body:")
print("\(jResp.emit()!)")
var respStatusCode: Int = resp!.statusCode.intValue
print("Response Status Code = \(respStatusCode)")
if respStatusCode >= 400 {
print("Response Header:")
print("\(resp!.header!)")
print("Failed.")
resp = nil
return
}
resp = nil
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": [
// {
// "cases": [
// {
// "condition": "<string>",
// "name": "<string>",
// "notifications": [
// "<string>",
// "<string>"
// ],
// "status": "medium"
// },
// {
// "condition": "<string>",
// "name": "<string>",
// "notifications": [
// "<string>",
// "<string>"
// ],
// "status": "info"
// }
// ],
// "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>",
// "sunt__": {}
// },
// "decreaseCriticalityBasedOnEnv": "<boolean>",
// "detectionMethod": "threshold",
// "evaluationWindow": 7200,
// "hardcodedEvaluatorType": "log4shell",
// "impossibleTravelOptions": {
// "baselineUserLocations": "<boolean>"
// },
// "keepAlive": 60,
// "maxSignalDuration": 60,
// "newValueOptions": {
// "forgetAfter": 14,
// "learningDuration": 0,
// "learningMethod": "duration",
// "learningThreshold": 0
// }
// },
// "queries": [
// {
// "aggregation": "geo_data",
// "distinctFields": [
// "<string>",
// "<string>"
// ],
// "groupByFields": [
// "<string>",
// "<string>"
// ],
// "metric": "<string>",
// "metrics": [
// "<string>",
// "<string>"
// ],
// "name": "<string>",
// "query": "<string>"
// },
// {
// "aggregation": "new_value",
// "distinctFields": [
// "<string>",
// "<string>"
// ],
// "groupByFields": [
// "<string>",
// "<string>"
// ],
// "metric": "<string>",
// "metrics": [
// "<string>",
// "<string>"
// ],
// "name": "<string>",
// "query": "<string>"
// }
// ],
// "tags": [
// "<string>",
// "<string>"
// ],
// "type": "log_detection",
// "updateAuthorId": "<long>",
// "version": "<long>"
// },
// {
// "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": "suppress",
// "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>",
// "mollit_4": {},
// "culpa_2": {}
// },
// "decreaseCriticalityBasedOnEnv": "<boolean>",
// "detectionMethod": "hardcoded",
// "evaluationWindow": 300,
// "hardcodedEvaluatorType": "log4shell",
// "impossibleTravelOptions": {
// "baselineUserLocations": "<boolean>"
// },
// "keepAlive": 21600,
// "maxSignalDuration": 10800,
// "newValueOptions": {
// "forgetAfter": 2,
// "learningDuration": 0,
// "learningMethod": "duration",
// "learningThreshold": 0
// }
// },
// "queries": [
// {
// "aggregation": "new_value",
// "distinctFields": [
// "<string>",
// "<string>"
// ],
// "groupByFields": [
// "<string>",
// "<string>"
// ],
// "metric": "<string>",
// "metrics": [
// "<string>",
// "<string>"
// ],
// "name": "<string>",
// "query": "<string>"
// },
// {
// "aggregation": "geo_data",
// "distinctFields": [
// "<string>",
// "<string>"
// ],
// "groupByFields": [
// "<string>",
// "<string>"
// ],
// "metric": "<string>",
// "metrics": [
// "<string>",
// "<string>"
// ],
// "name": "<string>",
// "query": "<string>"
// }
// ],
// "tags": [
// "<string>",
// "<string>"
// ],
// "type": "infrastructure_configuration",
// "updateAuthorId": "<long>",
// "version": "<long>"
// }
// ],
// "meta": {
// "page": {
// "total_count": "<long>",
// "total_filtered_count": "<long>"
// }
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var DefaultActivationStatus: String?
var UserActivationStatus: String?
var createdAt: String?
var creationAuthorId: String?
var deprecationDate: String?
var hasExtendedTitle: String?
var id: String?
var isDefault: String?
var isDeleted: String?
var isEnabled: String?
var message: String?
var name: String?
var ComplexRule: String?
var Policy: String?
var ResourceType: String?
var DecreaseCriticalityBasedOnEnv: String?
var DetectionMethod: String?
var EvaluationWindow: Int
var HardcodedEvaluatorType: String?
var BaselineUserLocations: String?
var KeepAlive: Int
var MaxSignalDuration: Int
var ForgetAfter: Int
var LearningDuration: Int
var LearningMethod: String?
var LearningThreshold: Int
var v_type: String?
var updateAuthorId: String?
var version: String?
var j: Int
var count_j: Int
var condition: String?
var status: String?
var k: Int
var count_k: Int
var strVal: String?
var action: String?
var query: String?
var aggregation: String?
var metric: String?
var Total_count: String? = jResp.string(of: "meta.page.total_count")
var Total_filtered_count: String? = jResp.string(of: "meta.page.total_filtered_count")
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "data").intValue
while i < count_i {
jResp.i = i
DefaultActivationStatus = jResp.string(of: "data[i].complianceSignalOptions.defaultActivationStatus")
UserActivationStatus = jResp.string(of: "data[i].complianceSignalOptions.userActivationStatus")
createdAt = jResp.string(of: "data[i].createdAt")
creationAuthorId = jResp.string(of: "data[i].creationAuthorId")
deprecationDate = jResp.string(of: "data[i].deprecationDate")
hasExtendedTitle = jResp.string(of: "data[i].hasExtendedTitle")
id = jResp.string(of: "data[i].id")
isDefault = jResp.string(of: "data[i].isDefault")
isDeleted = jResp.string(of: "data[i].isDeleted")
isEnabled = jResp.string(of: "data[i].isEnabled")
message = jResp.string(of: "data[i].message")
name = jResp.string(of: "data[i].name")
ComplexRule = jResp.string(of: "data[i].options.complianceRuleOptions.complexRule")
Policy = jResp.string(of: "data[i].options.complianceRuleOptions.regoRule.policy")
ResourceType = jResp.string(of: "data[i].options.complianceRuleOptions.resourceType")
DecreaseCriticalityBasedOnEnv = jResp.string(of: "data[i].options.decreaseCriticalityBasedOnEnv")
DetectionMethod = jResp.string(of: "data[i].options.detectionMethod")
EvaluationWindow = jResp.int(of: "data[i].options.evaluationWindow").intValue
HardcodedEvaluatorType = jResp.string(of: "data[i].options.hardcodedEvaluatorType")
BaselineUserLocations = jResp.string(of: "data[i].options.impossibleTravelOptions.baselineUserLocations")
KeepAlive = jResp.int(of: "data[i].options.keepAlive").intValue
MaxSignalDuration = jResp.int(of: "data[i].options.maxSignalDuration").intValue
ForgetAfter = jResp.int(of: "data[i].options.newValueOptions.forgetAfter").intValue
LearningDuration = jResp.int(of: "data[i].options.newValueOptions.learningDuration").intValue
LearningMethod = jResp.string(of: "data[i].options.newValueOptions.learningMethod")
LearningThreshold = jResp.int(of: "data[i].options.newValueOptions.learningThreshold").intValue
v_type = jResp.string(of: "data[i].type")
updateAuthorId = jResp.string(of: "data[i].updateAuthorId")
version = jResp.string(of: "data[i].version")
j = 0
count_j = jResp.size(ofArray: "data[i].cases").intValue
while j < count_j {
jResp.j = j
condition = jResp.string(of: "data[i].cases[j].condition")
name = jResp.string(of: "data[i].cases[j].name")
status = jResp.string(of: "data[i].cases[j].status")
k = 0
count_k = jResp.size(ofArray: "data[i].cases[j].notifications").intValue
while k < count_k {
jResp.k = k
strVal = jResp.string(of: "data[i].cases[j].notifications[k]")
k = k + 1
}
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "data[i].complianceSignalOptions.defaultGroupByFields").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "data[i].complianceSignalOptions.defaultGroupByFields[j]")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "data[i].complianceSignalOptions.userGroupByFields").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "data[i].complianceSignalOptions.userGroupByFields[j]")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "data[i].filters").intValue
while j < count_j {
jResp.j = j
action = jResp.string(of: "data[i].filters[j].action")
query = jResp.string(of: "data[i].filters[j].query")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "data[i].options.complianceRuleOptions.regoRule.resourceTypes").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "data[i].options.complianceRuleOptions.regoRule.resourceTypes[j]")
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "data[i].queries").intValue
while j < count_j {
jResp.j = j
aggregation = jResp.string(of: "data[i].queries[j].aggregation")
metric = jResp.string(of: "data[i].queries[j].metric")
name = jResp.string(of: "data[i].queries[j].name")
query = jResp.string(of: "data[i].queries[j].query")
k = 0
count_k = jResp.size(ofArray: "data[i].queries[j].distinctFields").intValue
while k < count_k {
jResp.k = k
strVal = jResp.string(of: "data[i].queries[j].distinctFields[k]")
k = k + 1
}
k = 0
count_k = jResp.size(ofArray: "data[i].queries[j].groupByFields").intValue
while k < count_k {
jResp.k = k
strVal = jResp.string(of: "data[i].queries[j].groupByFields[k]")
k = k + 1
}
k = 0
count_k = jResp.size(ofArray: "data[i].queries[j].metrics").intValue
while k < count_k {
jResp.k = k
strVal = jResp.string(of: "data[i].queries[j].metrics[k]")
k = k + 1
}
j = j + 1
}
j = 0
count_j = jResp.size(ofArray: "data[i].tags").intValue
while j < count_j {
jResp.j = j
strVal = jResp.string(of: "data[i].tags[j]")
j = j + 1
}
i = i + 1
}
}
Curl Command
curl -G -d "page[size]=10"
-d "page[number]=0"
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/security_monitoring/rules
Postman Collection Item JSON
{
"name": "List rules",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/security_monitoring/rules?page[size]=10&page[number]=0",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"rules"
],
"query": [
{
"key": "page[size]",
"value": "10",
"description": "Size for a given page. The maximum allowed value is 100."
},
{
"key": "page[number]",
"value": "0",
"description": "Specific page number to return."
}
]
},
"description": "List rules."
},
"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?page[size]=10&page[number]=0",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"rules"
],
"query": [
{
"key": "page[size]",
"value": "10",
"description": "Size for a given page. The maximum allowed value is 100."
},
{
"key": "page[number]",
"value": "0",
"description": "Specific page number to return."
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": [\n {\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\": \"info\"\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 \"sunt__\": {}\n },\n \"decreaseCriticalityBasedOnEnv\": \"<boolean>\",\n \"detectionMethod\": \"threshold\",\n \"evaluationWindow\": 7200,\n \"hardcodedEvaluatorType\": \"log4shell\",\n \"impossibleTravelOptions\": {\n \"baselineUserLocations\": \"<boolean>\"\n },\n \"keepAlive\": 60,\n \"maxSignalDuration\": 60,\n \"newValueOptions\": {\n \"forgetAfter\": 14,\n \"learningDuration\": 0,\n \"learningMethod\": \"duration\",\n \"learningThreshold\": 0\n }\n },\n \"queries\": [\n {\n \"aggregation\": \"geo_data\",\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\": \"new_value\",\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\": \"log_detection\",\n \"updateAuthorId\": \"<long>\",\n \"version\": \"<long>\"\n },\n {\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\": \"suppress\",\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 \"mollit_4\": {},\n \"culpa_2\": {}\n },\n \"decreaseCriticalityBasedOnEnv\": \"<boolean>\",\n \"detectionMethod\": \"hardcoded\",\n \"evaluationWindow\": 300,\n \"hardcodedEvaluatorType\": \"log4shell\",\n \"impossibleTravelOptions\": {\n \"baselineUserLocations\": \"<boolean>\"\n },\n \"keepAlive\": 21600,\n \"maxSignalDuration\": 10800,\n \"newValueOptions\": {\n \"forgetAfter\": 2,\n \"learningDuration\": 0,\n \"learningMethod\": \"duration\",\n \"learningThreshold\": 0\n }\n },\n \"queries\": [\n {\n \"aggregation\": \"new_value\",\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\": \"geo_data\",\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\": \"infrastructure_configuration\",\n \"updateAuthorId\": \"<long>\",\n \"version\": \"<long>\"\n }\n ],\n \"meta\": {\n \"page\": {\n \"total_count\": \"<long>\",\n \"total_filtered_count\": \"<long>\"\n }\n }\n}"
},
{
"name": "Bad Request",
"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?page[size]=10&page[number]=0",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"rules"
],
"query": [
{
"key": "page[size]",
"value": "10",
"description": "Size for a given page. The maximum allowed value is 100."
},
{
"key": "page[number]",
"value": "0",
"description": "Specific page number to return."
}
]
}
},
"status": "Bad Request",
"code": 400,
"_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?page[size]=10&page[number]=0",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"rules"
],
"query": [
{
"key": "page[size]",
"value": "10",
"description": "Size for a given page. The maximum allowed value is 100."
},
{
"key": "page[number]",
"value": "0",
"description": "Specific page number to return."
}
]
}
},
"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}"
}
]
}