Hi I am creating a workflow to help manage our tenant. I want to find any Custom Logs at that environment scope and disable them if certain criteria are met.
I use the SDK to call get const res = await settingsObjectsClient.getSettingsObjects(params); successfully which gives me a list of custom logs and their objectIds
On my environment, I only have one test custom log source and it is disabled.
So using the I want to update the object IDs by enabling which I have chosen the method ettingsObjectsClient.putSettingsObjectByObjectId(config); but my code fails with some validation errors, as per below
Updating settings sandpit
config
{“schemaId”:“builtin:logmonitoring.custom-log-source-settings”,“schemaVersion”:“1.1”,“scope”:“environment”,“objectId”:“vu9U3hXa3xxxxxxxxxlYGG-71TeFdrerQ”,“updateToken”:“vu9UxxxxxxrQ”,“body”:{“value”:{“enabled”:true}}}
error raised. 400: Validation failed for 2 Validators.
2 questions
What is wrong with my code?
How can I find out what the validation error might be referring to?
import { settingsObjectsClient } from "@dynatrace-sdk/client-classic-environment-v2";
export default async function updateSettingsExample()
{
try{
console.log("Updating settings");
const config = {
schemaId: "builtin:logmonitoring.custom-log-source-settings",
schemaVersion: "1.1",
scope: "environment",
objectId: 'vu9U3hXa3q0AAAABADBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxidWlsdGluOlYzYtYTEyMi1iZGU1MzliNzJlMGG-71TeFdrerQ',
updateToken: "vu9U3hxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxeFdjerQ",
body: {
value: {
enabled: true,
},
},
};
console.log("config");
console.log(JSON.stringify(config));
const data = await settingsObjectsClient.putSettingsObjectByObjectId(config);
console.log("result");
console.log(JSON.stringify(data));
}
catch (error)
{
console.log(`error raised. ${error}`);
}
}

