コード例 #1
0
		public void ExampleMethodText()
		{
			string username = "******";
			string password = "******";
			// Initialize the REST API. You can specify a web service version if needed in the constructor.
			RallyRestApi restApi = new RallyRestApi();
			restApi.Authenticate(username, password, "https://preview.rallydev.com", proxy: null, allowSSO: false);

			//Create an item
			DynamicJsonObject toCreate = new DynamicJsonObject();
			toCreate["Name"] = "My Defect";
			CreateResult createResult = restApi.Create("defect", toCreate);

			//Update the item
			DynamicJsonObject toUpdate = new DynamicJsonObject();
			toUpdate["Description"] = "This is my defect.";
			OperationResult updateResult = restApi.Update(createResult.Reference,
											toUpdate);

			//Get the item
			DynamicJsonObject item = restApi.GetByReference(createResult.Reference);

			//Query for items
			Request request = new Request("defect");
			request.Fetch = new List<string>() { "Name", "Description", "FormattedID" };
			request.Query = new Query("Name", Query.Operator.Equals, "My Defect");
			QueryResult queryResult = restApi.Query(request);
			foreach (var result in queryResult.Results)
			{
				//Process item as needed
			}

			//Delete the item
			OperationResult deleteResult = restApi.Delete(createResult.Reference);
		}
コード例 #2
0
		public static RallyRestApi GetRallyRestApi(string userName = "", string password = "",
			string server = "", string wsapiVersion = "")
		{
			if (String.IsNullOrWhiteSpace(userName))
			{
				userName = Settings.Default.UserName;
			}

			if (String.IsNullOrWhiteSpace(password))
			{
				password = Settings.Default.Password;
			}

			if (String.IsNullOrWhiteSpace(server))
			{
				server = Settings.Default.TestServer;
			}

			if (String.IsNullOrWhiteSpace(wsapiVersion))
			{
				wsapiVersion = RallyRestApi.DEFAULT_WSAPI_VERSION;
			}

			RallyRestApi api = new RallyRestApi(webServiceVersion: wsapiVersion);
			api.Authenticate(userName, password, server);
			return api;
		}
コード例 #3
0
 private void AssertCanCreate(RallyRestApi restApi)
 {
     var dynamicJson = new DynamicJsonObject();
     dynamicJson["Name"] = "C# Json Rest Toolkit Test Defect";
     CreateResult response = restApi.Create("defect", dynamicJson);
     Assert.AreEqual(0, response.Errors.Count);
     Assert.IsTrue(response.Reference.ToLower().Contains("defect"));
     dynamic testDefect = restApi.GetByReference(response.Reference);
     Assert.AreEqual(dynamicJson["Name"], testDefect.Name);
     defectOid = Ref.GetOidFromRef(response.Reference);
 }
コード例 #4
0
		public static RallyRestApi GetRallyRestApiWithApiKey(string apiKey = "",
			string server = RallyRestApi.DEFAULT_SERVER, string wsapiVersion = "")
		{
			if (String.IsNullOrWhiteSpace(apiKey))
			{
				apiKey = Settings.Default.ApiKey;
			}

			RallyRestApi api = new RallyRestApi(webServiceVersion: wsapiVersion);
			RallyRestApi.AuthenticationResult authResult = api.AuthenticateWithApiKey(apiKey, server);
			Assert.AreEqual(RallyRestApi.AuthenticationResult.Authenticated, authResult);
			return api;
		}
コード例 #5
0
		private void AssertCanDelete(RallyRestApi restApi, bool includeFullData = false)
		{
			var dynamicJson = new DynamicJsonObject();
			dynamicJson["Name"] = "C# Json Rest Toolkit Test Defect";
			if (includeFullData)
			{
				dynamicJson["Owner"] = restApi.GetCurrentUser()["_ref"];
				dynamicJson["Package"] = "Package A";
			}
			CreateResult response = restApi.Create("defect", dynamicJson);
			Assert.AreEqual(0, response.Errors.Count);
			Assert.IsTrue(response.Reference.ToLower().Contains("defect"));
			OperationResult deleteResponse = restApi.Delete(Ref.GetRelativeRef(response.Reference));
			dynamic testDefectEmpty = restApi.GetByReference(response.Reference);
			Assert.IsNull(testDefectEmpty);
		}
コード例 #6
0
		private void AssertCreateFailure(RallyRestApi restApi)
		{
			var defect = new DynamicJsonObject();
			defect["Name"] = "Sample Defect with invalid field";
			defect["Iteration"] = "Foo";
			CreateResult creationResult = restApi.Create("defect", defect);
			Assert.IsNull(creationResult.Reference);
			Assert.AreEqual(1, creationResult.Errors.Count);
			Assert.IsFalse(creationResult.Success);
		}
コード例 #7
0
		/// <summary>
		/// Notifies the login window that SSO has been completed.
		/// </summary>
		/// <param name="authenticationResult">The current state of the authentication process. <see cref="RallyRestApi.AuthenticationResult"/></param>
		/// <param name="api">The API that was authenticated against.</param>
		protected abstract void NotifyLoginWindowSsoComplete(
			RallyRestApi.AuthenticationResult authenticationResult, RallyRestApi api);
コード例 #8
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="isUiSupported">Does this authentication manager support a UI?</param>
		/// <param name="applicationToken">An application token to be used as the file name to store data as (no extension needed). Each 
		/// consuming application should use a unique name in order to ensure that the user credentials are not 
		/// overwritten by other applications. An exception will be thrown elsewhere if this is not a valid file name.</param>
		/// <param name="encryptionKey">The encryption key, or salt, to be used for any encryption routines. This salt 
		/// should be different for each user, and not the same for everyone consuming the same application. Only used 
		/// for UI support.</param>
		/// <param name="encryptionRoutines">The encryption routines to use for encryption/decryption of data. Only used for UI support.</param>
		/// <param name="webServiceVersion">The version of the WSAPI API to use.</param>
		protected ApiAuthManager(bool isUiSupported, string applicationToken, string encryptionKey,
			IEncryptionRoutines encryptionRoutines, string webServiceVersion = RallyRestApi.DEFAULT_WSAPI_VERSION)
		{
			if (isUiSupported)
			{
				if (String.IsNullOrWhiteSpace(applicationToken))
				{
					throw new ArgumentNullException("applicationToken",
						"You must provide an application token.");
				}

				if (encryptionKey == null)
				{
					throw new ArgumentNullException("encryptionKey",
						"You must provide an encryption key that will be used to keep user data safe.");
				}

				if (encryptionRoutines == null)
				{
					throw new ArgumentNullException("encryptionRoutines",
						"You must provide encryption routines that will be used to keep user data safe.");
				}

				ApplicationToken = applicationToken;
				EncryptionKey = encryptionKey;
				EncryptionRoutines = encryptionRoutines;

				LoginDetails = new LoginDetails(this);
				LoginDetails.LoadFromDisk();
			}

			IsUiSupported = isUiSupported;
			Api = new RallyRestApi(this, webServiceVersion: webServiceVersion);
		}
コード例 #9
0
        public void CreateSadPath2x()
        {
            RallyRestApi restApi = GetRallyRestApi2x();

            AssertCreateFailure(restApi);
        }
コード例 #10
0
		internal void SsoAuthenticationComplete(RallyRestApi.AuthenticationResult authenticationResult, RallyRestApi api)
		{
			if (authenticationResult == RallyRestApi.AuthenticationResult.Authenticated)
				Close();
			else
			{
				UpdateLoginState();
			}
		}
コード例 #11
0
		private void AssertCanDelete(RallyRestApi restApi, bool includeFullData = false)
		{
			// Create test defect
			var defect = TestHelperCreateDefect(restApi, includeFullData);
			var defectOid = Ref.GetOidFromRef(defect);

			OperationResult deleteResponse = restApi.Delete(Ref.GetRelativeRef(defect));
			dynamic testDefectEmpty = restApi.GetByReference(defect);
			Assert.IsNull(testDefectEmpty);
		}
コード例 #12
0
 private void AssertCanDelete(RallyRestApi restApi)
 {
     var dynamicJson = new DynamicJsonObject();
     dynamicJson["Name"] = "C# Json Rest Toolkit Test Defect";
     CreateResult response = restApi.Create("defect", dynamicJson);
     Assert.AreEqual(0, response.Errors.Count);
     Assert.IsTrue(response.Reference.ToLower().Contains("defect"));
     OperationResult deleteResponse = restApi.Delete(Ref.GetRelativeRef(response.Reference));
     dynamic testDefectEmpty = restApi.GetByReference(response.Reference);
     Assert.IsNull(testDefectEmpty);
 }
コード例 #13
0
        public void ApiKeyCanDelete()
        {
            RallyRestApi restApi = GetRallyRestApiWithApiKey();

            AssertCanDelete(restApi, true);
        }
コード例 #14
0
        public void Update2x()
        {
            RallyRestApi restApi = GetRallyRestApi2x();

            AssertCanUpdate(restApi);
        }
コード例 #15
0
        public void Delete2x()
        {
            RallyRestApi restApi = GetRallyRestApi2x();

            AssertCanDelete(restApi);
        }
コード例 #16
0
		private void AssertCanUpdate(RallyRestApi restApi)
		{
			// Create test defect
			var defect = TestHelperCreateDefect(restApi);
			var defectOid = Ref.GetOidFromRef(defect);

			var dynamicJson = new DynamicJsonObject();
			dynamicJson["Name"] = "Dont delete me please " + DateTime.Now.Second;
			OperationResult response = restApi.Update("Defect", defectOid, dynamicJson);
			Assert.AreEqual(0, response.Errors.Count);
			dynamic updateDefect = restApi.GetByReference("/Defect/" + defectOid + ".js");
			Assert.AreEqual(dynamicJson["Name"], updateDefect.Name);

			// Now delete it
			TestHelperDeleteItem(restApi, defect);
		}
コード例 #17
0
		private void AssertCanUpdate(RallyRestApi restApi)
		{
			var dynamicJson = new DynamicJsonObject();
			dynamicJson["Name"] = "Dont delete me please " + DateTime.Now.Second;
			OperationResult response = restApi.Update("Defect", defectOid, dynamicJson);
			Assert.AreEqual(0, response.Errors.Count);
			dynamic updateDefect = restApi.GetByReference("/Defect/" + defectOid + ".js");
			Assert.AreEqual(dynamicJson["Name"], updateDefect.Name);
		}
コード例 #18
0
		private string TestHelperCreateDefect(RallyRestApi restApi, bool includeFullData = false)
		{
			var dynamicJson = new DynamicJsonObject();
			dynamicJson["Name"] = "C# Json Rest Toolkit Test Defect";
			if (includeFullData)
			{
				dynamicJson["Owner"] = restApi.GetCurrentUser()["_ref"];
				dynamicJson["Package"] = "Package A";
			}

			CreateResult response = restApi.Create("defect", dynamicJson);
			Assert.AreEqual(0, response.Errors.Count);
			Assert.IsTrue(response.Reference.ToLower().Contains("defect"));

			return response.Reference;
		}
コード例 #19
0
		/// <summary>
		/// Notifies the login window that SSO has been completed.
		/// </summary>
		/// <param name="authenticationResult">The current state of the authentication process. <see cref="RallyRestApi.AuthenticationResult"/></param>
		/// <param name="api">The API that was authenticated against.</param>
		protected override void NotifyLoginWindowSsoComplete(
			RallyRestApi.AuthenticationResult authenticationResult, RallyRestApi api)
		{
			if (LoginWindowSsoAuthenticationComplete != null)
				LoginWindowSsoAuthenticationComplete.Invoke(authenticationResult, api);
		}
コード例 #20
0
		private void TestHelperDeleteItem(RallyRestApi restApi, string reference)
		{
			OperationResult deleteResponse = restApi.Delete(Ref.GetRelativeRef(reference));
			dynamic testEmpty = restApi.GetByReference(reference);
			Assert.IsNull(testEmpty);
		}
コード例 #21
0
		/// <summary>
		/// Notifies the login window that SSO has been completed.
		/// </summary>
		/// <param name="authenticationResult">The current state of the authentication process. <see cref="RallyRestApi.AuthenticationResult"/></param>
		/// <param name="api">The API that was authenticated against.</param>
		/// <exception cref="NotImplementedException">This method is not supported for this authentication manager.</exception>
		protected override void NotifyLoginWindowSsoComplete(
			RallyRestApi.AuthenticationResult authenticationResult, RallyRestApi api)
		{
			throw new NotImplementedException("This authorization manager does not support UI elements.");
		}
コード例 #22
0
        public void CreateTest2x()
        {
            RallyRestApi restApi = GetRallyRestApi2x();

            AssertCanCreate(restApi);
        }