public override List <string> GetALMDomains() { List <string> domains = new List <string>(); try { if (!string.IsNullOrEmpty(ALMCore.DefaultAlmConfig.ALMUserName) && !string.IsNullOrEmpty(ALMCore.DefaultAlmConfig.ALMPassword) && !string.IsNullOrEmpty(ALMCore.DefaultAlmConfig.ALMServerURL)) { if (restApi.AuthenticationState != RallyRestApi.AuthenticationResult.Authenticated) { restApi.Authenticate(ALMCore.DefaultAlmConfig.ALMUserName, ALMCore.DefaultAlmConfig.ALMPassword, ALMCore.DefaultAlmConfig.ALMServerURL, proxy: null, allowSSO: false); } DynamicJsonObject sub = restApi.GetSubscription("Workspaces"); Request wRequest = new Request(sub["Workspaces"]); wRequest.Limit = 1000; QueryResult queryResult = restApi.Query(wRequest); foreach (var result in queryResult.Results) { domains.Add(Convert.ToString(result["Name"])); } } } catch (Exception ex) { throw ex; } return(domains); }
/// <summary> /// Returns all the existing workspaces in Rally /// </summary> public void GetWorkspaces() { //Authenticate this.EnsureRallyIsAuthenticated(); //instantiate a DynamicJsonObject obj DynamicJsonObject djo = _rallyRestApi.GetSubscription(RALLYQUERY.Workspaces); Request workspaceRequest = new Request(djo[RALLYQUERY.Workspaces]); try { //query for the workspaces QueryResult returnWorkspaces = _rallyRestApi.Query(workspaceRequest); //iterate through the list and return the list of workspaces foreach (var value in returnWorkspaces.Results) { var workspaceReference = value[RALLYQUERY.Reference]; var workspaceName = value[RALLY.Name]; Console.WriteLine(RALLYQUERY.WorkspaceMessage + workspaceName); } } catch (WebException) { Console.WriteLine(RALLYQUERY.WebExceptionMessage); } }
/// <summary> /// Gives all work spaces present in the env /// </summary> /// <returns></returns> public QueryResult GetAllWorkSpaces() { DynamicJsonObject sub = restApi.GetSubscription("Workspaces"); Request wRequest = new Request(sub["Workspaces"]); wRequest.Limit = 1000; return(restApi.Query(wRequest)); }
public void GetSubscription() { RallyRestApi restApi = GetRallyRestApi(); dynamic user = restApi.GetCurrentUser("Subscription", "ObjectID"); dynamic subscription = restApi.GetSubscription(); Assert.AreEqual("subscription", Ref.GetTypeFromRef(subscription._ref), "Type test"); Assert.AreEqual(user.Subscription.ObjectID, subscription.ObjectID, "Subscription Id"); }
public void BadAuth2x() { try { RallyRestApi restApi = GetRallyRestApi(userName: "******", wsapiVersion: "v2.0"); restApi.GetSubscription(); Assert.Fail(); } catch (Exception e) { Assert.AreEqual(e.Message, "The remote server returned an error: (401) Unauthorized."); } }
static void Main(string[] args) { //Initialize the REST API RallyRestApi restApi; //with this user I get hundreds of workspaces - this is a subadmin restApi = new RallyRestApi("*****@*****.**", "supersecret", "https://rally1.rallydev.com", "v2.0"); //with this user I get only two workspaces //restApi = new RallyRestApi("*****@*****.**", "scret", "https://rally1.rallydev.com", "v2.0"); /***************THIS CODE PRINTS OUT ALL WORKSPACES AND PROJECTS IN THE SUB ******************************/ //get the current subscription DynamicJsonObject sub = restApi.GetSubscription("Workspaces"); Request wRequest = new Request(sub["Workspaces"]); wRequest.Limit = 1000; QueryResult queryResult = restApi.Query(wRequest); int allProjects = 0; foreach (var result in queryResult.Results) { var workspaceReference = result["_ref"]; var workspaceName = result["Name"]; Console.WriteLine("Workspace: " + workspaceName); Request projectsRequest = new Request(result["Projects"]); projectsRequest.Fetch = new List <string>() { "Name", "State", }; projectsRequest.Limit = 10000; //project requests are made per workspace QueryResult queryProjectResult = restApi.Query(projectsRequest); int projectsPerWorkspace = 0; foreach (var p in queryProjectResult.Results) { allProjects++; projectsPerWorkspace++; Console.WriteLine(projectsPerWorkspace + " Project: " + p["Name"] + " State: " + p["State"]); } Console.WriteLine("----------------------------"); } Console.WriteLine("Returned " + allProjects + " projects in the subscription"); }
static void Main(string[] args) { string tagName = "T3$T"; RallyRestApi restApi = new RallyRestApi("*****@*****.**", "secret", "https://rally1.rallydev.com", "v2.0"); //get current user DynamicJsonObject user = new DynamicJsonObject(); user = restApi.GetCurrentUser(); Console.Out.WriteLine("owner " + user["_ref"]); //find workspaces owned by this user //equivalent to this endpoint: https://rally1.rallydev.com/slm/webservice/v2.0/subscription/1154643/workspaces?query=(Owner%20=%20%22/user/12345%22) DynamicJsonObject sub = restApi.GetSubscription("Workspaces"); Request wRequest = new Request(sub["Workspaces"]); wRequest.Query = new Query("Owner", Query.Operator.Equals, user["_ref"]); QueryResult wResult = restApi.Query(wRequest); foreach (var workspace in wResult.Results) { //Console.Out.WriteLine(workspace["_refObjectName"] + " : " + workspace["_ref"]); Request tagRequest = new Request("tag"); tagRequest.Query = new Query("Name", Query.Operator.Equals, tagName); QueryResult tagResult = restApi.Query(tagRequest); if (tagResult.TotalResultCount == 0) { Console.Out.WriteLine("TAG " + tagName + " not found, creating"); DynamicJsonObject newTag = new DynamicJsonObject(); newTag["Name"] = tagName; newTag["Workspace"] = workspace["_ref"]; CreateResult createResult = restApi.Create("Tag", newTag); Console.Out.WriteLine(createResult.Reference + " created in workspace " + workspace["_refObjectName"]); } else { Console.Out.WriteLine("TAG " + tagName + " found in " + workspace["_refObjectName"]); Console.Out.WriteLine(tagResult.Results.First()["_refObjectName"] + " " + tagResult.Results.First()["_ref"]); } } }
static void Main(string[] args) { //Initialize the REST API using API KEYd RallyRestApi restApi; restApi = new RallyRestApi("_abc123", "https://rally1.rallydev.com"); DateTime now = DateTime.Today; DateTime checkback = now.AddDays(-2); //last two days String checkbackString = checkback.ToString("yyyy-MM-dd"); //get the subscription DynamicJsonObject sub = restApi.GetSubscription("Workspaces"); Request wRequest = new Request(sub["Workspaces"]); wRequest.Limit = 1000; QueryResult queryResult = restApi.Query(wRequest); foreach (var result in queryResult.Results) { var workspaceReference = result["_ref"]; var workspaceName = result["Name"]; Request projectsRequest = new Request(result["Projects"]); projectsRequest.Fetch = new List <string>() { "Name" }; projectsRequest.Limit = 1000; QueryResult queryProjectResult = restApi.Query(projectsRequest); foreach (var p in queryProjectResult.Results) { Request artifactRequest = new Request("artifact"); artifactRequest.Project = p["_ref"]; artifactRequest.Query = new Query("LastUpdateDate", Query.Operator.GreaterThanOrEqualTo, checkbackString); QueryResult queryResults = restApi.Query(artifactRequest); if (queryResults.TotalResultCount > 0) { Console.WriteLine("Project: " + p["Name"] + " (Workspace " + workspaceName + ")"); } } } }
static void Main(string[] args) { //Initialize the REST API RallyRestApi restApi; restApi = new RallyRestApi("*****@*****.**", "secret", "https://rally1.rallydev.com", "v2.0"); //get the current subscription DynamicJsonObject sub = restApi.GetSubscription("Workspaces"); Request wRequest = new Request(sub["Workspaces"]); //query the Workspaces collection QueryResult queryResult = restApi.Query(wRequest); foreach (var result in queryResult.Results) { var workspaceReference = result["_ref"]; var workspaceName = result["Name"]; Console.WriteLine(workspaceName + " " + workspaceReference); } }
public ObservableList <RallyTestPlan> GetRallyTestPlansByProject(string RallyServerUrl, string RallyUserName, string RallyPassword, string RallyProject, string solutionFolder, string projName) { ObservableList <RallyTestPlan> rallyTestPlanList = new ObservableList <RallyTestPlan>(); RallyRestApi restApi = new RallyRestApi(); restApi.Authenticate(RallyUserName, RallyPassword, RallyServerUrl, proxy: null, allowSSO: false); if (restApi.AuthenticationState == RallyRestApi.AuthenticationResult.Authenticated) { DynamicJsonObject sub = restApi.GetSubscription("Workspaces"); Request wRequest = new Request(sub["Workspaces"]); wRequest.Limit = 1000; int projectId = 0; QueryResult queryWSResult = restApi.Query(wRequest); foreach (var result in queryWSResult.Results) { Request projectsRequest = new Request(result["Projects"]); projectsRequest.Fetch = new List <string>() { "Name", "ObjectID" }; projectsRequest.Limit = 10000; QueryResult queryProjectResult = restApi.Query(projectsRequest); foreach (var p in queryProjectResult.Results) { if (Convert.ToString(p["Name"]) == projName) { int.TryParse(Convert.ToString(p["ObjectID"]), out projectId); break; } } } if (projectId > 0) { //Query for items Request request = new Request("testset"); var projectRef = "/project/" + projectId; request.Query = new Query("Project", Query.Operator.Equals, projectRef); QueryResult queryTestSetResult = restApi.Query(request); foreach (var result in queryTestSetResult.Results) { RallyTestPlan plan = new RallyTestPlan(); int testSetId = 0; int.TryParse(Convert.ToString(result["ObjectID"]), out testSetId); if (testSetId > 0) { plan.Name = Convert.ToString(result["Name"]); plan.RallyID = Convert.ToString(result["ObjectID"]); plan.Description = Convert.ToString(result["Description"]); plan.CreatedBy = Convert.ToString(result["Owner"]["_refObjectName"]); plan.CreationDate = Convert.ToDateTime(result["CreationDate"]); plan.TestCases = new ObservableList <RallyTestCase>(); } rallyTestPlanList.Add(plan); } } } return(rallyTestPlanList); }
public RallyTestPlan GetRallyTestPlanFullData(string RallyServerUrl, string RallyUserName, string RallyPassword, string RallyProject, RallyTestPlan testPlan) { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; RallyTestPlan plan = new RallyTestPlan(); RallyRestApi restApi = new RallyRestApi(); restApi.Authenticate(RallyUserName, RallyPassword, RallyServerUrl, proxy: null, allowSSO: false); if (restApi.AuthenticationState == RallyRestApi.AuthenticationResult.Authenticated) { DynamicJsonObject sub = restApi.GetSubscription("Workspaces"); Request wRequest = new Request(sub["Workspaces"]); wRequest.Limit = 1000; int projectId = 0; QueryResult queryWSResult = restApi.Query(wRequest); foreach (var result in queryWSResult.Results) { Request projectsRequest = new Request(result["Projects"]); projectsRequest.Fetch = new List <string>() { "Name", "ObjectID" }; projectsRequest.Limit = 10000; QueryResult queryProjectResult = restApi.Query(projectsRequest); foreach (var p in queryProjectResult.Results) { if (Convert.ToString(p["Name"]) == RallyProject) { int.TryParse(Convert.ToString(p["ObjectID"]), out projectId); break; } } } if (projectId > 0) { //Query for items Request request = new Request("testset"); var projectRef = "/project/" + projectId; request.Query = new Query("Project", Query.Operator.Equals, projectRef); QueryResult queryTestSetResult = restApi.Query(request); foreach (var result in queryTestSetResult.Results) { int testSetId = 0; int.TryParse(Convert.ToString(result["ObjectID"]), out testSetId); if (testSetId > 0 && testPlan.RallyID == Convert.ToString(result["ObjectID"])) { plan.Name = Convert.ToString(result["Name"]); plan.RallyID = Convert.ToString(result["ObjectID"]); plan.Description = Convert.ToString(result["Description"]); plan.CreatedBy = Convert.ToString(result["Owner"]["_refObjectName"]); plan.CreationDate = Convert.ToDateTime(result["CreationDate"]); plan.TestCases = new ObservableList <RallyTestCase>(); Request reqTestCase = new Request("testcase"); var testSetIdRef = "/testset/" + testSetId; reqTestCase.Query = new Query("TestSets", Query.Operator.Equals, testSetIdRef); QueryResult queryTestcaseResult = restApi.Query(reqTestCase); foreach (var testCaseResult in queryTestcaseResult.Results) { string name = Convert.ToString(testCaseResult["Name"]); string id = Convert.ToString(testCaseResult["ObjectID"]); string desc = Convert.ToString(testCaseResult["Description"]); string owner = Convert.ToString(testCaseResult["Owner"]["_refObjectName"]); DateTime createDate = Convert.ToDateTime(testCaseResult["CreationDate"]); RallyTestCase tcase = new RallyTestCase(name, id, desc, owner, createDate); string scriptdesc = Convert.ToString(testCaseResult["ValidationInput"]); RallyTestStep script = new RallyTestStep("Test Step 1", string.Empty, scriptdesc, owner); tcase.TestSteps.Add(script); plan.TestCases.Add(tcase); } } } } } Mouse.OverrideCursor = null; return(plan); }