-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresolve
More file actions
48 lines (37 loc) · 1.45 KB
/
Copy pathresolve
File metadata and controls
48 lines (37 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
mytoken=$1
buidnum=$2
myItemsList=itemslists
myItemsFile=items
newFile=newcommand
myConfigFile=command
buidnum=$2
echo "Resolving items now"
rm -rf $myItemsFile $myItemsList $myConfigFile $newFile
curl -H "X-Rollbar-Access-Token: $mytoken" 'https://api.rollbar.com/api/1/items/?status=active' | tee $myItemsFile
cat $myItemsFile | grep '"id":' | awk '{print $2}' | sed 's/,/ /g' > $myItemsList
# pick a random item from the list
# get num of file lines
filelength=$(cat $myItemsList | wc -l)
# generate a random number between 1 and the num of lines in the file
number=$(( ( RANDOM % $filelength ) + 1 ))
# obtain the item
item=$(cat $myItemsList | head -$number | tail -1)
echo $item > $newFile
# for i in `cat $myItemsList`
for i in `cat $newFile`
do
echo "Resolving item: " $i " using token:" $mytoken
echo "https://api.rollbar.com/api/1/item/$i"
#curl -H \"X-Rollbar-Access-Token: $mytoken\" \ -X GET 'https://api.rollbar.com/api/1/item/$i'
echo "curl -H \"X-Rollbar-Access-Token: $mytoken\" \
-H \"Content-Type: application/json\" -X PATCH 'https://api.rollbar.com/api/1/item/$i' \
--data '{\"status\": \"resolved\",\"resolved_in_version\": \"$buidnum:\"}'" >> $myConfigFile
echo "" >> $myConfigFile
# delete all occurences
#curl -H "X-Rollbar-Access-Token: $mytoken" \
#-H "Content-Type: application/json" -X PATCH 'https://api.rollbar.com/api/1/item/$i' \
#--data '{"status": "resolved"}'
done
chmod 755 $myConfigFile
./$myConfigFile