Skip to content

Commit 6632402

Browse files
committed
Add commands for deleting and importing analytics searches
1 parent 6630a07 commit 6632402

File tree

9 files changed

+88
-69
lines changed

9 files changed

+88
-69
lines changed

USAGE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ These commands allow you to import and export email/http saved analytics searche
9696

9797
| Command | Description | Example |
9898
| ------- | ----------- | ------- |
99-
| get | Get an analytics search by id. Provide the id as parameter (-i) | `act.sh analyticssearch get -i 6` |
100-
| list | List all analytics searches. This command requires no further arguments | `act.sh analyticssearch list ` |
101-
| import | Import an analytics search. Provide a json file as parameter. | `act.sh analyticssearch import search.json` |
99+
| delete | Delete an analytics search by id. Provide the id as parameter (-i). | `act.sh analyticssearch delete -i 6` |
100+
| get | Get an analytics search by id. Provide the id as parameter (-i). | `act.sh analyticssearch get -i 6` |
101+
| import | Import an analytics search. Provide a json string or a file (with @ as prefix) as parameter (-d). | `act.sh analyticssearch import -d search.json` |
102+
| list | List all analytics searches. This command requires no further arguments. | `act.sh analyticssearch list ` |
102103

103104

104105
## application

act.sh

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
ACT_VERSION="v0.5.0"
3-
ACT_LAST_COMMIT="5a6d252f76898b17bc683271831c6e1ff8d4bc83"
3+
ACT_LAST_COMMIT="6630a07da02f01b8a872b194aba2f3927ef35c8d"
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"
@@ -103,10 +103,14 @@ rde analyticsschema_list "List all analytics schemas." "This command requires no
103103
doc analyticssearch << EOF
104104
These commands allow you to import and export email/http saved analytics searches.
105105
EOF
106+
analyticssearch_delete() { apiCall -X POST '/controller/restui/analyticsSavedSearches/deleteAnalyticsSavedSearch/{{i:analytics_search_id}}' "$@" ; }
107+
rde analyticssearch_delete "Delete an analytics search by id." "Provide the id as parameter (-i)." "-i 6"
106108
analyticssearch_get() { apiCall '/controller/restui/analyticsSavedSearches/getAnalyticsSavedSearchById/{{i:analytics_search_id}}' "$@" ; }
107-
rde analyticssearch_get "Get an analytics search by id." "Provide the id as parameter (-i)" "-i 6"
109+
rde analyticssearch_get "Get an analytics search by id." "Provide the id as parameter (-i)." "-i 6"
110+
analyticssearch_import() { apiCall -X POST -d '{{d:analytics_search}}' '/controller/restui/analyticsSavedSearches/createAnalyticsSavedSearch' "$@" ; }
111+
rde analyticssearch_import "Import an analytics search." "Provide a json string or a file (with @ as prefix) as parameter (-d)." "-d search.json"
108112
analyticssearch_list() { apiCall '/controller/restui/analyticsSavedSearches/getAllAnalyticsSavedSearches' "$@" ; }
109-
rde analyticssearch_list "List all analytics searches." "This command requires no further arguments" ""
113+
rde analyticssearch_list "List all analytics searches." "This command requires no further arguments." ""
110114
doc application << EOF
111115
The applications API lets you retrieve information about the monitored environment as modeled in AppDynamics.
112116
EOF
@@ -1490,33 +1494,6 @@ EOF
14901494
example event_list << EOF
14911495
-a 15 -t BEFORE_NOW -d 60 -s ALL -e ALL
14921496
EOF
1493-
analyticssearch_import() {
1494-
FILE="$*"
1495-
if [ -r "${FILE}" ] ; then
1496-
DATA="$(<${FILE})"
1497-
regex='("id" *: *[0-9]+,)'
1498-
if [[ ${DATA} =~ $regex ]]; then
1499-
DATA=${DATA/${BASH_REMATCH[0]}/}
1500-
fi
1501-
if [[ $DATA == '['* ]]
1502-
then
1503-
COMMAND_RESULT=""
1504-
error "File contains multiple saved searches. Please provide only a single element."
1505-
else
1506-
controller_call -X POST -d "${DATA}" '/controller/restui/analyticsSavedSearches/createAnalyticsSavedSearch'
1507-
fi
1508-
else
1509-
COMMAND_RESULT=""
1510-
error "File not found or not readable: $FILE"
1511-
fi
1512-
}
1513-
register analyticssearch_import Import an analytics search. Provide a json file as parameter.
1514-
describe analyticssearch_import << EOF
1515-
Import an analytics search. Provide a json file as parameter.
1516-
EOF
1517-
example analyticssearch_import << EOF
1518-
search.json
1519-
EOF
15201497
recursiveSource() {
15211498
if [ -d "$*" ]; then
15221499
debug "Sourcing plugins from $*"

commands.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,29 @@ analyticssearch:
101101
description: These commands allow you to import and export email/http saved analytics searches.
102102
get:
103103
title: Get an analytics search by id.
104-
description: Provide the id as parameter (-i)
104+
description: Provide the id as parameter (-i).
105105
example: -i 6
106106
method: GET
107107
endpoint: /controller/restui/analyticsSavedSearches/getAnalyticsSavedSearchById/{{i:analytics_search_id}}
108108
list:
109109
title: List all analytics searches.
110-
description: This command requires no further arguments
110+
description: This command requires no further arguments.
111111
example:
112112
method: GET
113113
endpoint: /controller/restui/analyticsSavedSearches/getAllAnalyticsSavedSearches
114+
delete:
115+
title: Delete an analytics search by id.
116+
description: Provide the id as parameter (-i).
117+
example: -i 6
118+
method: POST
119+
endpoint: /controller/restui/analyticsSavedSearches/deleteAnalyticsSavedSearch/{{i:analytics_search_id}}
120+
import:
121+
title: Import an analytics search.
122+
description: Provide a json string or a file (with @ as prefix) as parameter (-d).
123+
example: -d search.json
124+
method: POST
125+
endpoint: /controller/restui/analyticsSavedSearches/createAnalyticsSavedSearch
126+
payload: {{d:analytics_search}}
114127
analyticsmetric:
115128
title: Analytics metrics
116129
description: Manage custom analytics metrics

commands/analyticssearch/import.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

postman-collection.json

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,36 @@
299299
"description": "This command requires no further arguments"
300300
}
301301
}]},{"name": "analyticssearch","item": [{
302+
"name": "Delete an analytics search by id.",
303+
"request": {
304+
"method": "POST",
305+
"header": [
306+
{
307+
"key": "Content-Type",
308+
"value": "application/json;charset=UTF-8",
309+
"type": "text"
310+
},
311+
{
312+
"key": "X-CSRF-TOKEN",
313+
"value": "{{X-CSRF-TOKEN}}",
314+
"type": "text"
315+
}
316+
],
317+
"body": {
318+
"mode": "raw",
319+
"raw": ""
320+
},
321+
"url": {
322+
"raw": "{{controller_host}}/controller/restui/analyticsSavedSearches/deleteAnalyticsSavedSearch/{{i:analytics_search_id}}",
323+
"host": [
324+
"{{controller_host}}"
325+
],
326+
"path": ["controller","restui","analyticsSavedSearches","deleteAnalyticsSavedSearch","{{analytics_search_id}}"],
327+
"query": []
328+
},
329+
"description": "Provide the id as parameter (-i)."
330+
}
331+
},{
302332
"name": "Get an analytics search by id.",
303333
"request": {
304334
"method": "GET",
@@ -326,7 +356,37 @@
326356
"path": ["controller","restui","analyticsSavedSearches","getAnalyticsSavedSearchById","{{analytics_search_id}}"],
327357
"query": []
328358
},
329-
"description": "Provide the id as parameter (-i)"
359+
"description": "Provide the id as parameter (-i)."
360+
}
361+
},{
362+
"name": "Import an analytics search.",
363+
"request": {
364+
"method": "POST",
365+
"header": [
366+
{
367+
"key": "Content-Type",
368+
"value": "application/json;charset=UTF-8",
369+
"type": "text"
370+
},
371+
{
372+
"key": "X-CSRF-TOKEN",
373+
"value": "{{X-CSRF-TOKEN}}",
374+
"type": "text"
375+
}
376+
],
377+
"body": {
378+
"mode": "raw",
379+
"raw": "{{analytics_search}}"
380+
},
381+
"url": {
382+
"raw": "{{controller_host}}/controller/restui/analyticsSavedSearches/createAnalyticsSavedSearch",
383+
"host": [
384+
"{{controller_host}}"
385+
],
386+
"path": ["controller","restui","analyticsSavedSearches","createAnalyticsSavedSearch"],
387+
"query": []
388+
},
389+
"description": "Provide a json string or a file (with @ as prefix) as parameter (-d)."
330390
}
331391
},{
332392
"name": "List all analytics searches.",
@@ -356,7 +416,7 @@
356416
"path": ["controller","restui","analyticsSavedSearches","getAllAnalyticsSavedSearches"],
357417
"query": []
358418
},
359-
"description": "This command requires no further arguments"
419+
"description": "This command requires no further arguments."
360420
}
361421
}]},{"name": "application","item": [{
362422
"name": "Create a new application.",

recipes/create_applications.sh

100644100755
File mode changed.

recipes/delete_all_applications.sh

100644100755
File mode changed.

recipes/exportDashboardsApplications.sh

100644100755
File mode changed.

recipes/new_release.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)