VB6 / Datadog API Collection / Update Azure integration host filters
Back to Collection Items
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim http As New ChilkatHttp
Dim success As Long
' Use this online tool to generate code from sample JSON: Generate Code to Create JSON
' The following JSON is sent in the request body.
' {
' "app_service_plan_filters": "key:value,filter:example",
' "automute": true,
' "client_id": "testc7f6-1234-5678-9101-3fcbf464test",
' "client_secret": "testingx./Sw*g/Y33t..R1cH+hScMDt",
' "cspm_enabled": true,
' "custom_metrics_enabled": true,
' "errors": [
' "*"
' ],
' "host_filters": "key:value,filter:example",
' "new_client_id": "new1c7f6-1234-5678-9101-3fcbf464test",
' "new_tenant_name": "new1c44-1234-5678-9101-cc00736ftest",
' "tenant_name": "testc44-1234-5678-9101-cc00736ftest"
' }
Dim json As New ChilkatJsonObject
success = json.UpdateString("app_service_plan_filters","key:value,filter:example")
success = json.UpdateBool("automute",1)
success = json.UpdateString("client_id","testc7f6-1234-5678-9101-3fcbf464test")
success = json.UpdateString("client_secret","testingx./Sw*g/Y33t..R1cH+hScMDt")
success = json.UpdateBool("cspm_enabled",1)
success = json.UpdateBool("custom_metrics_enabled",1)
success = json.UpdateString("errors[0]","*")
success = json.UpdateString("host_filters","key:value,filter:example")
success = json.UpdateString("new_client_id","new1c7f6-1234-5678-9101-3fcbf464test")
success = json.UpdateString("new_tenant_name","new1c44-1234-5678-9101-cc00736ftest")
success = json.UpdateString("tenant_name","testc44-1234-5678-9101-cc00736ftest")
http.SetRequestHeader "Content-Type","application/json"
http.SetRequestHeader "Accept","application/json"
Dim resp As ChilkatHttpResponse
Set resp = http.PostJson3("https://api.app.ddog-gov.com/api/v1/integration/azure/host_filters","application/json",json)
If (http.LastMethodSuccess = 0) Then
Debug.Print http.LastErrorText
Exit Sub
End If
Dim sbResponseBody As New ChilkatStringBuilder
success = resp.GetBodySb(sbResponseBody)
Dim jResp As New ChilkatJsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0
Debug.Print "Response Body:"
Debug.Print jResp.Emit()
Dim respStatusCode As Long
respStatusCode = resp.StatusCode
Debug.Print "Response Status Code = " & respStatusCode
If (respStatusCode >= 400) Then
Debug.Print "Response Header:"
Debug.Print resp.Header
Debug.Print "Failed."
Exit Sub
End If
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"app_service_plan_filters": "key:value,filter:example",
"automute": true,
"client_id": "testc7f6-1234-5678-9101-3fcbf464test",
"client_secret": "testingx./Sw*g/Y33t..R1cH+hScMDt",
"cspm_enabled": true,
"custom_metrics_enabled": true,
"errors": [
"*"
],
"host_filters": "key:value,filter:example",
"new_client_id": "new1c7f6-1234-5678-9101-3fcbf464test",
"new_tenant_name": "new1c44-1234-5678-9101-cc00736ftest",
"tenant_name": "testc44-1234-5678-9101-cc00736ftest"
}'
https://api.app.ddog-gov.com/api/v1/integration/azure/host_filters
Postman Collection Item JSON
{
"name": "Update Azure integration host filters",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"app_service_plan_filters\": \"key:value,filter:example\",\n \"automute\": true,\n \"client_id\": \"testc7f6-1234-5678-9101-3fcbf464test\",\n \"client_secret\": \"testingx./Sw*g/Y33t..R1cH+hScMDt\",\n \"cspm_enabled\": true,\n \"custom_metrics_enabled\": true,\n \"errors\": [\n \"*\"\n ],\n \"host_filters\": \"key:value,filter:example\",\n \"new_client_id\": \"new1c7f6-1234-5678-9101-3fcbf464test\",\n \"new_tenant_name\": \"new1c44-1234-5678-9101-cc00736ftest\",\n \"tenant_name\": \"testc44-1234-5678-9101-cc00736ftest\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/integration/azure/host_filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"integration",
"azure",
"host_filters"
]
},
"description": "Update the defined list of host filters for a given Datadog-Azure integration."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"app_service_plan_filters\": \"key:value,filter:example\",\n \"automute\": true,\n \"client_id\": \"testc7f6-1234-5678-9101-3fcbf464test\",\n \"client_secret\": \"testingx./Sw*g/Y33t..R1cH+hScMDt\",\n \"cspm_enabled\": true,\n \"custom_metrics_enabled\": true,\n \"errors\": [\n \"*\"\n ],\n \"host_filters\": \"key:value,filter:example\",\n \"new_client_id\": \"new1c7f6-1234-5678-9101-3fcbf464test\",\n \"new_tenant_name\": \"new1c44-1234-5678-9101-cc00736ftest\",\n \"tenant_name\": \"testc44-1234-5678-9101-cc00736ftest\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/integration/azure/host_filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"integration",
"azure",
"host_filters"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"app_service_plan_filters\": \"key:value,filter:example\",\n \"automute\": true,\n \"client_id\": \"testc7f6-1234-5678-9101-3fcbf464test\",\n \"client_secret\": \"testingx./Sw*g/Y33t..R1cH+hScMDt\",\n \"cspm_enabled\": true,\n \"custom_metrics_enabled\": true,\n \"errors\": [\n \"*\"\n ],\n \"host_filters\": \"key:value,filter:example\",\n \"new_client_id\": \"new1c7f6-1234-5678-9101-3fcbf464test\",\n \"new_tenant_name\": \"new1c44-1234-5678-9101-cc00736ftest\",\n \"tenant_name\": \"testc44-1234-5678-9101-cc00736ftest\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/integration/azure/host_filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"integration",
"azure",
"host_filters"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
},
{
"name": "Authentication Error",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"app_service_plan_filters\": \"key:value,filter:example\",\n \"automute\": true,\n \"client_id\": \"testc7f6-1234-5678-9101-3fcbf464test\",\n \"client_secret\": \"testingx./Sw*g/Y33t..R1cH+hScMDt\",\n \"cspm_enabled\": true,\n \"custom_metrics_enabled\": true,\n \"errors\": [\n \"*\"\n ],\n \"host_filters\": \"key:value,filter:example\",\n \"new_client_id\": \"new1c7f6-1234-5678-9101-3fcbf464test\",\n \"new_tenant_name\": \"new1c44-1234-5678-9101-cc00736ftest\",\n \"tenant_name\": \"testc44-1234-5678-9101-cc00736ftest\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/integration/azure/host_filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"integration",
"azure",
"host_filters"
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
},
{
"name": "Too many requests",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"app_service_plan_filters\": \"key:value,filter:example\",\n \"automute\": true,\n \"client_id\": \"testc7f6-1234-5678-9101-3fcbf464test\",\n \"client_secret\": \"testingx./Sw*g/Y33t..R1cH+hScMDt\",\n \"cspm_enabled\": true,\n \"custom_metrics_enabled\": true,\n \"errors\": [\n \"*\"\n ],\n \"host_filters\": \"key:value,filter:example\",\n \"new_client_id\": \"new1c7f6-1234-5678-9101-3fcbf464test\",\n \"new_tenant_name\": \"new1c44-1234-5678-9101-cc00736ftest\",\n \"tenant_name\": \"testc44-1234-5678-9101-cc00736ftest\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/integration/azure/host_filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"integration",
"azure",
"host_filters"
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
}
]
}