Chilkat Online Tools

PowerBuilder / Datadog API Collection / Get a Cloud Workload Security Agent rule

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_AgentConstraint
string ls_Category
string ls_CreationAuthorUuId
string ls_CreationDate
string ls_Handle
string ls_Name
string ls_DefaultRule
string ls_Description
string ls_Enabled
string ls_Expression
string ls_AttributesName
string ls_UpdateAuthorUuId
string ls_UpdateDate
string ls_UpdatedAt
string ls_UpdaterHandle
string ls_UpdaterName
string ls_Version
string ls_Id
string ls_V_Type

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.SetRequestHeader("Accept","application/json")

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://api.app.ddog-gov.com/api/v2/security_monitoring/cloud_workload_security/agent_rules/:agent_rule_id",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

// 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

ls_AgentConstraint = loo_JResp.StringOf("data.attributes.agentConstraint")
ls_Category = loo_JResp.StringOf("data.attributes.category")
ls_CreationAuthorUuId = loo_JResp.StringOf("data.attributes.creationAuthorUuId")
ls_CreationDate = loo_JResp.StringOf("data.attributes.creationDate")
ls_Handle = loo_JResp.StringOf("data.attributes.creator.handle")
ls_Name = loo_JResp.StringOf("data.attributes.creator.name")
ls_DefaultRule = loo_JResp.StringOf("data.attributes.defaultRule")
ls_Description = loo_JResp.StringOf("data.attributes.description")
ls_Enabled = loo_JResp.StringOf("data.attributes.enabled")
ls_Expression = loo_JResp.StringOf("data.attributes.expression")
ls_AttributesName = loo_JResp.StringOf("data.attributes.name")
ls_UpdateAuthorUuId = loo_JResp.StringOf("data.attributes.updateAuthorUuId")
ls_UpdateDate = loo_JResp.StringOf("data.attributes.updateDate")
ls_UpdatedAt = loo_JResp.StringOf("data.attributes.updatedAt")
ls_UpdaterHandle = loo_JResp.StringOf("data.attributes.updater.handle")
ls_UpdaterName = loo_JResp.StringOf("data.attributes.updater.name")
ls_Version = loo_JResp.StringOf("data.attributes.version")
ls_Id = loo_JResp.StringOf("data.id")
ls_V_Type = loo_JResp.StringOf("data.type")


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

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}"
    }
  ]
}