Skip to content

Commit

Permalink
List, delete time ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
svrnm committed Oct 10, 2017
1 parent 01ca985 commit e702afa
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
26 changes: 24 additions & 2 deletions adc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ function dbmon_create {
}
register dbmon_create Create a new database collector
function timerange_create {
while getopts "s:e:" opt "$@";
local START_TIME=-1
local END_TIME=-1
local DURATION_IN_MINUTES=0
local TYPE=BETWEEN_TIMES
while getopts "s:e:b:" opt "$@";
do
case "${opt}" in
s)
Expand All @@ -194,14 +198,32 @@ function timerange_create {
e)
END_TIME=${OPTARG}
;;
b)
DURATION_IN_MINUTES=${OPTARG}
TYPE="BEFORE_NOW"
;;
esac
done;
shiftOptInd
shift $SHIFTS
TIMERANGE_NAME=$@
controller_call -X POST -d "{\"name\":\"$TIMERANGE_NAME\",\"timeRange\":{\"type\":\"BETWEEN_TIMES\",\"durationInMinutes\":0,\"startTime\":$START_TIME,\"endTime\":$END_TIME}}" /controller/restui/user/createCustomRange
controller_call -X POST -d "{\"name\":\"$TIMERANGE_NAME\",\"timeRange\":{\"type\":\"$TYPE\",\"durationInMinutes\":$DURATION_IN_MINUTES,\"startTime\":$START_TIME,\"endTime\":$END_TIME}}" /controller/restui/user/createCustomRange
}
register timerange_create Create a custom time range
function timerange_list {
controller_call -X GET /controller/restui/user/getAllCustomTimeRanges
}
register timerange_list List all custom timeranges available on the controller
function timerange_delete {
local TIMERANGE_ID=$@
if [[ $TIMERANGE_ID =~ ^[0-9]+$ ]]; then
controller_call -X POST -d "$TIMERANGE_ID" /controller/restui/user/deleteCustomRange
else
COMMAND_RESULT=""
error "This is not a number: '$TIMERANGE_ID'"
fi
}
register timerange_delete Delete a specific time range by id
function dashboard_list {
controller_call -X GET /controller/restui/dashboards/getAllDashboardsByType/false
}
Expand Down
12 changes: 10 additions & 2 deletions commands/timerange/create.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/bin/bash

function timerange_create {
while getopts "s:e:" opt "$@";
local START_TIME=-1
local END_TIME=-1
local DURATION_IN_MINUTES=0
local TYPE=BETWEEN_TIMES
while getopts "s:e:b:" opt "$@";
do
case "${opt}" in
s)
Expand All @@ -10,12 +14,16 @@ function timerange_create {
e)
END_TIME=${OPTARG}
;;
b)
DURATION_IN_MINUTES=${OPTARG}
TYPE="BEFORE_NOW"
;;
esac
done;
shiftOptInd
shift $SHIFTS
TIMERANGE_NAME=$@
controller_call -X POST -d "{\"name\":\"$TIMERANGE_NAME\",\"timeRange\":{\"type\":\"BETWEEN_TIMES\",\"durationInMinutes\":0,\"startTime\":$START_TIME,\"endTime\":$END_TIME}}" /controller/restui/user/createCustomRange
controller_call -X POST -d "{\"name\":\"$TIMERANGE_NAME\",\"timeRange\":{\"type\":\"$TYPE\",\"durationInMinutes\":$DURATION_IN_MINUTES,\"startTime\":$START_TIME,\"endTime\":$END_TIME}}" /controller/restui/user/createCustomRange
}

register timerange_create Create a custom time range
13 changes: 13 additions & 0 deletions commands/timerange/delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

function timerange_delete {
local TIMERANGE_ID=$@
if [[ $TIMERANGE_ID =~ ^[0-9]+$ ]]; then
controller_call -X POST -d "$TIMERANGE_ID" /controller/restui/user/deleteCustomRange
else
COMMAND_RESULT=""
error "This is not a number: '$TIMERANGE_ID'"
fi
}

register timerange_delete Delete a specific time range by id
7 changes: 7 additions & 0 deletions commands/timerange/list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

function timerange_list {
controller_call -X GET /controller/restui/user/getAllCustomTimeRanges
}

register timerange_list List all custom timeranges available on the controller
2 changes: 2 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ source ./commands/controller/call.sh
source ./commands/dbmon/create.sh

source ./commands/timerange/create.sh
source ./commands/timerange/list.sh
source ./commands/timerange/delete.sh

source ./commands/dashboard/list.sh
source ./commands/dashboard/export.sh
Expand Down

0 comments on commit e702afa

Please sign in to comment.