Node.js / Datadog API Collection / Get a Cloud Workload Security Agent rule
Back to Collection Items
var os = require('os');
if (os.platform() == 'win32') {
if (os.arch() == 'ia32') {
var chilkat = require('@chilkat/ck-node21-win-ia32');
} else {
var chilkat = require('@chilkat/ck-node21-win64');
}
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('@chilkat/ck-node21-arm');
} else if (os.arch() == 'x86') {
var chilkat = require('@chilkat/ck-node21-linux32');
} else {
var chilkat = require('@chilkat/ck-node21-linux64');
}
} else if (os.platform() == 'darwin') {
if (os.arch() == 'arm64') {
var chilkat = require('@chilkat/ck-node21-mac-m1');
} else {
var chilkat = require('@chilkat/ck-node21-macosx');
}
}
function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
var success;
http.SetRequestHeader("Accept","application/json");
var sbResponseBody = new chilkat.StringBuilder();
success = http.QuickGetSb("https://api.app.ddog-gov.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/:agent_rule_id",sbResponseBody);
if (success == false) {
console.log(http.LastErrorText);
return;
}
var jResp = new chilkat.JsonObject();
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = false;
console.log("Response Body:");
console.log(jResp.Emit());
var respStatusCode = http.LastStatus;
console.log("Response Status Code = " + respStatusCode);
if (respStatusCode >= 400) {
console.log("Response Header:");
console.log(http.LastHeader);
console.log("Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "attributes": {
// "agentConstraint": "<string>",
// "category": "<string>",
// "creationAuthorUuId": "<string>",
// "creationDate": "<long>",
// "creator": {
// "handle": "<string>",
// "name": "<string>"
// },
// "defaultRule": "<boolean>",
// "description": "<string>",
// "enabled": "<boolean>",
// "expression": "<string>",
// "name": "<string>",
// "updateAuthorUuId": "<string>",
// "updateDate": "<long>",
// "updatedAt": "<long>",
// "updater": {
// "handle": "<string>",
// "name": "<string>"
// },
// "version": "<long>"
// },
// "id": "<string>",
// "type": "agent_rule"
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var AgentConstraint = jResp.StringOf("data.attributes.agentConstraint");
var Category = jResp.StringOf("data.attributes.category");
var CreationAuthorUuId = jResp.StringOf("data.attributes.creationAuthorUuId");
var CreationDate = jResp.StringOf("data.attributes.creationDate");
var Handle = jResp.StringOf("data.attributes.creator.handle");
var Name = jResp.StringOf("data.attributes.creator.name");
var DefaultRule = jResp.StringOf("data.attributes.defaultRule");
var Description = jResp.StringOf("data.attributes.description");
var Enabled = jResp.StringOf("data.attributes.enabled");
var Expression = jResp.StringOf("data.attributes.expression");
var AttributesName = jResp.StringOf("data.attributes.name");
var UpdateAuthorUuId = jResp.StringOf("data.attributes.updateAuthorUuId");
var UpdateDate = jResp.StringOf("data.attributes.updateDate");
var UpdatedAt = jResp.StringOf("data.attributes.updatedAt");
var UpdaterHandle = jResp.StringOf("data.attributes.updater.handle");
var UpdaterName = jResp.StringOf("data.attributes.updater.name");
var Version = jResp.StringOf("data.attributes.version");
var Id = jResp.StringOf("data.id");
var v_Type = jResp.StringOf("data.type");
}
chilkatExample();
Curl Command
curl -X GET
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/:agent_rule_id
Postman Collection Item JSON
{
"name": "Get a Cloud Workload Security Agent rule",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/security_monitoring/cloud_workload_security/agent_rules/:agent_rule_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"cloud_workload_security",
"agent_rules",
":agent_rule_id"
],
"variable": [
{
"key": "agent_rule_id",
"value": "<string>"
}
]
},
"description": "Get the details of a specific Agent rule."
},
"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/cloud_workload_security/agent_rules/:agent_rule_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"cloud_workload_security",
"agent_rules",
":agent_rule_id"
],
"variable": [
{
"key": "agent_rule_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": {\n \"attributes\": {\n \"agentConstraint\": \"<string>\",\n \"category\": \"<string>\",\n \"creationAuthorUuId\": \"<string>\",\n \"creationDate\": \"<long>\",\n \"creator\": {\n \"handle\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"defaultRule\": \"<boolean>\",\n \"description\": \"<string>\",\n \"enabled\": \"<boolean>\",\n \"expression\": \"<string>\",\n \"name\": \"<string>\",\n \"updateAuthorUuId\": \"<string>\",\n \"updateDate\": \"<long>\",\n \"updatedAt\": \"<long>\",\n \"updater\": {\n \"handle\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"version\": \"<long>\"\n },\n \"id\": \"<string>\",\n \"type\": \"agent_rule\"\n }\n}"
},
{
"name": "Not Authorized",
"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/cloud_workload_security/agent_rules/:agent_rule_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"cloud_workload_security",
"agent_rules",
":agent_rule_id"
],
"variable": [
{
"key": "agent_rule_id"
}
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\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/v2/security_monitoring/cloud_workload_security/agent_rules/:agent_rule_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"cloud_workload_security",
"agent_rules",
":agent_rule_id"
],
"variable": [
{
"key": "agent_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/cloud_workload_security/agent_rules/:agent_rule_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"security_monitoring",
"cloud_workload_security",
"agent_rules",
":agent_rule_id"
],
"variable": [
{
"key": "agent_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}"
}
]
}