Chilkat Online Tools

PowerBuilder / Datadog API Collection / List Scanning Groups

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Id
string ls_V_type
string ls_Description
string ls_Is_enabled
string ls_Name
string ls_Pattern
string ls_Number_of_chars
string ls_Replacement_string
string ls_Text_replacementType
string ls_DataId
string ls_DataType
integer j
integer li_Count_j
string ls_StrVal
string ls_Id
string ls_V_Type
string ls_Count_limit
string ls_Group_count_limit
string ls_Has_highlight_enabled
string ls_Has_multi_pass_enabled
string ls_Is_pci_compliant
string ls_Version
integer i
integer li_Count_i

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.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
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://api.app.ddog-gov.com/api/v2/sensitive-data-scanner/config",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
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.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": {
//       "ametf": {},
//       "ead6": {},
//       "dolore03e": {}
//     },
//     "id": "<string>",
//     "relationships": {
//       "groups": {
//         "data": [
//           {
//             "id": "<string>",
//             "type": "sensitive_data_scanner_group"
//           },
//           {
//             "id": "<string>",
//             "type": "sensitive_data_scanner_group"
//           }
//         ]
//       }
//     },
//     "type": "sensitive_data_scanner_configuration"
//   },
//   "included": [
//     {
//       "attributes": {
//         "description": "<string>",
//         "excluded_namespaces": [
//           "<string>",
//           "<string>"
//         ],
//         "is_enabled": "<boolean>",
//         "name": "<string>",
//         "namespaces": [
//           "<string>",
//           "<string>"
//         ],
//         "pattern": "<string>",
//         "tags": [
//           "<string>",
//           "<string>"
//         ],
//         "text_replacement": {
//           "number_of_chars": "<long>",
//           "replacement_string": "<string>",
//           "type": "none"
//         }
//       },
//       "id": "<string>",
//       "relationships": {
//         "group": {
//           "data": {
//             "id": "<string>",
//             "type": "sensitive_data_scanner_group"
//           }
//         },
//         "standard_pattern": {
//           "data": {
//             "id": "<string>",
//             "type": "sensitive_data_scanner_standard_pattern"
//           }
//         }
//       },
//       "type": "sensitive_data_scanner_rule"
//     },
//     {
//       "attributes": {
//         "description": "<string>",
//         "excluded_namespaces": [
//           "<string>",
//           "<string>"
//         ],
//         "is_enabled": "<boolean>",
//         "name": "<string>",
//         "namespaces": [
//           "<string>",
//           "<string>"
//         ],
//         "pattern": "<string>",
//         "tags": [
//           "<string>",
//           "<string>"
//         ],
//         "text_replacement": {
//           "number_of_chars": "<long>",
//           "replacement_string": "<string>",
//           "type": "none"
//         }
//       },
//       "id": "<string>",
//       "relationships": {
//         "group": {
//           "data": {
//             "id": "<string>",
//             "type": "sensitive_data_scanner_group"
//           }
//         },
//         "standard_pattern": {
//           "data": {
//             "id": "<string>",
//             "type": "sensitive_data_scanner_standard_pattern"
//           }
//         }
//       },
//       "type": "sensitive_data_scanner_rule"
//     }
//   ],
//   "meta": {
//     "count_limit": "<long>",
//     "group_count_limit": "<long>",
//     "has_highlight_enabled": "<boolean>",
//     "has_multi_pass_enabled": "<boolean>",
//     "is_pci_compliant": "<boolean>",
//     "version": "<long>"
//   }
// }

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

ls_Id = loo_JResp.StringOf("data.id")
ls_V_Type = loo_JResp.StringOf("data.type")
ls_Count_limit = loo_JResp.StringOf("meta.count_limit")
ls_Group_count_limit = loo_JResp.StringOf("meta.group_count_limit")
ls_Has_highlight_enabled = loo_JResp.StringOf("meta.has_highlight_enabled")
ls_Has_multi_pass_enabled = loo_JResp.StringOf("meta.has_multi_pass_enabled")
ls_Is_pci_compliant = loo_JResp.StringOf("meta.is_pci_compliant")
ls_Version = loo_JResp.StringOf("meta.version")
i = 0
li_Count_i = loo_JResp.SizeOfArray("data.relationships.groups.data")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Id = loo_JResp.StringOf("data.relationships.groups.data[i].id")
    ls_V_type = loo_JResp.StringOf("data.relationships.groups.data[i].type")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("included")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Description = loo_JResp.StringOf("included[i].attributes.description")
    ls_Is_enabled = loo_JResp.StringOf("included[i].attributes.is_enabled")
    ls_Name = loo_JResp.StringOf("included[i].attributes.name")
    ls_Pattern = loo_JResp.StringOf("included[i].attributes.pattern")
    ls_Number_of_chars = loo_JResp.StringOf("included[i].attributes.text_replacement.number_of_chars")
    ls_Replacement_string = loo_JResp.StringOf("included[i].attributes.text_replacement.replacement_string")
    ls_Text_replacementType = loo_JResp.StringOf("included[i].attributes.text_replacement.type")
    ls_Id = loo_JResp.StringOf("included[i].id")
    ls_DataId = loo_JResp.StringOf("included[i].relationships.group.data.id")
    ls_DataType = loo_JResp.StringOf("included[i].relationships.group.data.type")
    ls_DataId = loo_JResp.StringOf("included[i].relationships.standard_pattern.data.id")
    ls_DataType = loo_JResp.StringOf("included[i].relationships.standard_pattern.data.type")
    ls_V_type = loo_JResp.StringOf("included[i].type")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("included[i].attributes.excluded_namespaces")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("included[i].attributes.excluded_namespaces[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("included[i].attributes.namespaces")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("included[i].attributes.namespaces[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("included[i].attributes.tags")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("included[i].attributes.tags[j]")
        j = j + 1
    loop
    i = i + 1
loop


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/sensitive-data-scanner/config

Postman Collection Item JSON

{
  "name": "List Scanning Groups",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/sensitive-data-scanner/config",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "sensitive-data-scanner",
        "config"
      ]
    },
    "description": "List all the Scanning groups in your organization."
  },
  "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/sensitive-data-scanner/config",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "sensitive-data-scanner",
            "config"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"data\": {\n    \"attributes\": {\n      \"ametf\": {},\n      \"ead6\": {},\n      \"dolore03e\": {}\n    },\n    \"id\": \"<string>\",\n    \"relationships\": {\n      \"groups\": {\n        \"data\": [\n          {\n            \"id\": \"<string>\",\n            \"type\": \"sensitive_data_scanner_group\"\n          },\n          {\n            \"id\": \"<string>\",\n            \"type\": \"sensitive_data_scanner_group\"\n          }\n        ]\n      }\n    },\n    \"type\": \"sensitive_data_scanner_configuration\"\n  },\n  \"included\": [\n    {\n      \"attributes\": {\n        \"description\": \"<string>\",\n        \"excluded_namespaces\": [\n          \"<string>\",\n          \"<string>\"\n        ],\n        \"is_enabled\": \"<boolean>\",\n        \"name\": \"<string>\",\n        \"namespaces\": [\n          \"<string>\",\n          \"<string>\"\n        ],\n        \"pattern\": \"<string>\",\n        \"tags\": [\n          \"<string>\",\n          \"<string>\"\n        ],\n        \"text_replacement\": {\n          \"number_of_chars\": \"<long>\",\n          \"replacement_string\": \"<string>\",\n          \"type\": \"none\"\n        }\n      },\n      \"id\": \"<string>\",\n      \"relationships\": {\n        \"group\": {\n          \"data\": {\n            \"id\": \"<string>\",\n            \"type\": \"sensitive_data_scanner_group\"\n          }\n        },\n        \"standard_pattern\": {\n          \"data\": {\n            \"id\": \"<string>\",\n            \"type\": \"sensitive_data_scanner_standard_pattern\"\n          }\n        }\n      },\n      \"type\": \"sensitive_data_scanner_rule\"\n    },\n    {\n      \"attributes\": {\n        \"description\": \"<string>\",\n        \"excluded_namespaces\": [\n          \"<string>\",\n          \"<string>\"\n        ],\n        \"is_enabled\": \"<boolean>\",\n        \"name\": \"<string>\",\n        \"namespaces\": [\n          \"<string>\",\n          \"<string>\"\n        ],\n        \"pattern\": \"<string>\",\n        \"tags\": [\n          \"<string>\",\n          \"<string>\"\n        ],\n        \"text_replacement\": {\n          \"number_of_chars\": \"<long>\",\n          \"replacement_string\": \"<string>\",\n          \"type\": \"none\"\n        }\n      },\n      \"id\": \"<string>\",\n      \"relationships\": {\n        \"group\": {\n          \"data\": {\n            \"id\": \"<string>\",\n            \"type\": \"sensitive_data_scanner_group\"\n          }\n        },\n        \"standard_pattern\": {\n          \"data\": {\n            \"id\": \"<string>\",\n            \"type\": \"sensitive_data_scanner_standard_pattern\"\n          }\n        }\n      },\n      \"type\": \"sensitive_data_scanner_rule\"\n    }\n  ],\n  \"meta\": {\n    \"count_limit\": \"<long>\",\n    \"group_count_limit\": \"<long>\",\n    \"has_highlight_enabled\": \"<boolean>\",\n    \"has_multi_pass_enabled\": \"<boolean>\",\n    \"is_pci_compliant\": \"<boolean>\",\n    \"version\": \"<long>\"\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/sensitive-data-scanner/config",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "sensitive-data-scanner",
            "config"
          ]
        }
      },
      "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": "Authentication Error",
      "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/sensitive-data-scanner/config",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "sensitive-data-scanner",
            "config"
          ]
        }
      },
      "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": "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/sensitive-data-scanner/config",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "sensitive-data-scanner",
            "config"
          ]
        }
      },
      "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}"
    }
  ]
}