Appdynamics / api-commandline-tool

AppDynamics Command Line Tool
Apache License 2.0
45 stars 40 forks source link

can we add an update policy API ? #40

Closed nanjum88 closed 1 year ago

nanjum88 commented 1 year ago

Currently, there are APIs to export and import alert policies. The import policy API does a POST call to create a new policy , however if users want to update existing policy to add/delete new eventTypes, then it has to be either done manually or use the controller V1 API controller/alerting/rest/v1/applications/{applicationID}/policies/{policyID}, which is not very handy.

The V1 API requires mandatory fields regardless, if those fields were present in the original policy. Additionally, the GET policy call in V1 API doesn't return the healthRuleScope , but it mandatorily requires users to pass that field with values when updating the policy, in this case users are better off using the controller UI to update alert policies, but challenging when we have to update hundreds of policies.

So, checking if we can add Update alert policy to the act.sh

svrnm commented 1 year ago

please have a look at the updated version, you should now be able to do:

./act.sh -E ceer policy get $POLICY_ID > policy.json

The policy.json contains an array of policies, so you have to remove the [] before running the update:

./act.sh -E ceer policy update -d @policy.json