public static async Task<Repository> RenameRepository(string repositoryName, Rename renameParam) { HttpClient client = GetHttpClient(); string uri = string.Format("api/v1/repos/{0}", repositoryName); using (client) { HttpResponseMessage response = await client.PutAsJsonAsync(uri, renameParam); if (response.StatusCode != System.Net.HttpStatusCode.OK) throw new Exception(string.Format( "API Status Code {0}. Expected OK.", response.StatusCode)); return await response.Content.ReadAsAsync<Repository>(); } }
static void RenameRepository() { ListRepositories(); Console.Write("Write the name of the repository to rename: "); string repository = Console.ReadLine(); Console.Write(string.Format("Write a new name for {0}: ", repository)); string newName = Console.ReadLine(); Rename action = new Rename() { Name = newName }; Repository renamedRepo = ApiUtils.RenameRepository(repository, action).Result; Console.Write(string.Format("Repository {0} successfully renamed to {1}.", repository, renamedRepo.Name)); }