-
Notifications
You must be signed in to change notification settings - Fork 0
/
BulkDelete.cs
44 lines (40 loc) · 1.55 KB
/
BulkDelete.cs
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
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Rally.RestApi;
using Rally.RestApi.Response;
namespace BulkDelete
{
class Program
{
static void Main(string[] args)
{
RallyRestApi restApi;
restApi = new RallyRestApi("user@co.com", "secret", "https://rally1.rallydev.com", "v2.0");
String workspaceRef = "/workspace/12352608129"; //use your workspace object id
Request defectRequest = new Request("defect");
defectRequest.Workspace = workspaceRef;
defectRequest.Query = new Query("LastUpdateDate", Query.Operator.GreaterThanOrEqualTo, "2014-07-20");
defectRequest.Fetch = new List<string>()
{
"Name",
"FormattedID"
};
int stopAfter = 2; //KEEP IT LOW UNTIL YOU MAKE SURE IT IS DELETING THE INTENDED SUBSET OF YOUR DATA
int count = 0;
QueryResult queryDefectResults = restApi.Query(defectRequest);
foreach (var d in queryDefectResults.Results)
{
if (count == stopAfter)
{
break;
}
Console.WriteLine("Deleting: " + d["FormattedID"] + " " + d["Name"]);
OperationResult deleteResult = restApi.Delete(workspaceRef, d["_ref"]); //DELTED DEFECTS WILL BE FOUND IN THE RECYCLE BIN
count++;
}
}
}
}