Skip to content

Commit 375ea8f

Browse files
committed
Add policy import & export
1 parent 4552f78 commit 375ea8f

File tree

5 files changed

+73
-9
lines changed

5 files changed

+73
-9
lines changed

USAGE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,14 @@ Retrieve nodes within a business application
282282
| markhistorical | Mark nodes as historical. Provide a comma separated list of node ids. | `act.sh node markhistorical -n 45,46` |
283283

284284

285-
## policies
285+
## policy
286286

287287
Import and export policies
288288

289289
| Command | Description | Example |
290290
| ------- | ----------- | ------- |
291-
| list | List all policies. Provide an application (-a) as parameter. | `act.sh policies list -a 29` |
291+
| export | List all policies. Provide an application (-a) as parameter. | `act.sh policy export -a 29` |
292+
| import | Import a policy. Provide an application (-a) and a policy file or json (-d) as parameter. | `act.sh policy import -a 29 -d @examples/policy.json` |
292293

293294

294295
## sam

act.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
ACT_VERSION="v0.4.0"
3-
ACT_LAST_COMMIT="43a2301ebe6ce3e819b9ac5a09a6fb0a3687c4a7"
3+
ACT_LAST_COMMIT="4552f78b04ab60b8ca907d6214afd2605e715600"
44
USER_CONFIG="$HOME/.appdynamics/act/config.sh"
55
GLOBAL_CONFIG="/etc/appdynamics/act/config.sh"
66
CONFIG_CONTROLLER_COOKIE_LOCATION="/tmp/appdynamics-controller-cookie.txt"
@@ -220,11 +220,13 @@ function node_list { apiCall '/controller/rest/applications/{{a:application}}/no
220220
rde node_list "List all nodes." "Provide the application id as parameter (-a)." "-a 29"
221221
function node_markhistorical { apiCall -X POST '/controller/rest/mark-nodes-historical?application-component-node-ids={{n:nodes}}' "$@" ; }
222222
rde node_markhistorical "Mark nodes as historical." "Provide a comma separated list of node ids." "-n 45,46"
223-
doc policies << EOF
223+
doc policy << EOF
224224
Import and export policies
225225
EOF
226-
function policies_list { apiCall '/controller/policies/{{a:application}}' "$@" ; }
227-
rde policies_list "List all policies." "Provide an application (-a) as parameter." "-a 29"
226+
function policy_export { apiCall '/controller/policies/{{a:application}}' "$@" ; }
227+
rde policy_export "List all policies." "Provide an application (-a) as parameter." "-a 29"
228+
function policy_import { apiCall -X POST -F 'file={{d:policy}}' '/controller/policies/{{a:application}}' "$@" ; }
229+
rde policy_import "Import a policy." "Provide an application (-a) and a policy file or json (-d) as parameter." "-a 29 -d @examples/policy.json"
228230
doc sam << EOF
229231
Manage service monitoring configurations
230232
EOF

commands.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,15 +382,22 @@ node:
382382
example: -n 45,46
383383
method: POST
384384
endpoint: /controller/rest/mark-nodes-historical?application-component-node-ids={{n:nodes}}
385-
policies:
385+
policy:
386386
title: Policies API
387387
description: Import and export policies
388-
list:
388+
export:
389389
title: List all policies.
390390
description: Provide an application (-a) as parameter.
391391
example: -a 29
392392
method: GET
393393
endpoint: /controller/policies/{{a:application}}
394+
import:
395+
title: Import a policy.
396+
description: Provide an application (-a) and a policy file or json (-d) as parameter.
397+
example: -a 29 -d @examples/policy.json
398+
method: POST
399+
endpoint: /controller/policies/{{a:application}}
400+
form: file={{d:policy}}
394401
sam:
395402
title: Service Availability Monitoring
396403
description: Manage service monitoring configurations

examples/policy.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[ {
2+
"applicationName" : "example application",
3+
"name" : "example policy",
4+
"reactorType" : "IMMEDIATE",
5+
"enabled" : true,
6+
"batchActionsPerMinute" : true,
7+
"durationInMin" : 1,
8+
"eventFilterTemplate" : {
9+
"applicationName" : "example application",
10+
"healthRuleNames" : null,
11+
"eventTypes" : null,
12+
"rsdTypes" : [ "SLOW", "VERY_SLOW", "STALL" ],
13+
"customEventFilters" : null,
14+
"specificEntityNamesByType" : null
15+
},
16+
"entityFilterTemplates" : [ ],
17+
"actionWrapperTemplates" : [ {
18+
"actionTag" : "example",
19+
"type" : "PERCENTAGE",
20+
"value" : 10,
21+
"notes" : "",
22+
"entityIdentifierTemplates" : [ ]
23+
} ]
24+
} ]

postman-collection.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@
15581558
},
15591559
"description": "Provide a comma separated list of node ids."
15601560
}
1561-
}]},{"name": "policies","item": [{
1561+
}]},{"name": "policy","item": [{
15621562
"name": "List all policies.",
15631563
"request": {
15641564
"method": "GET",
@@ -1588,6 +1588,36 @@
15881588
},
15891589
"description": "Provide an application (-a) as parameter."
15901590
}
1591+
},{
1592+
"name": "Import a policy.",
1593+
"request": {
1594+
"method": "POST",
1595+
"header": [
1596+
{
1597+
"key": "Content-Type",
1598+
"value": "application/json;charset=UTF-8",
1599+
"type": "text"
1600+
},
1601+
{
1602+
"key": "X-CSRF-TOKEN",
1603+
"value": "{{X-CSRF-TOKEN}}",
1604+
"type": "text"
1605+
}
1606+
],
1607+
"body": {
1608+
"mode": "raw",
1609+
"raw": ""
1610+
},
1611+
"url": {
1612+
"raw": "{{controller_host}}/controller/policies/{{a:application}}",
1613+
"host": [
1614+
"{{controller_host}}"
1615+
],
1616+
"path": ["controller","policies","{{application}}"],
1617+
"query": []
1618+
},
1619+
"description": "Provide an application (-a) and a policy file or json (-d) as parameter."
1620+
}
15911621
}]},{"name": "sam","item": [{
15921622
"name": "Create a monitor.",
15931623
"request": {

0 commit comments

Comments
 (0)