static void Main(string[] args) { try { RestSharpAPI restSharpAPI = new RestSharpAPI(baseUrl); //RestClient client = restSharpAPI.getClient(); //works RestClient client = restSharpAPI.getClient(user, password); // works if (restSharpAPI == null || client == null) { Console.WriteLine("restSharpAPI or client is null"); Environment.Exit(1); } NexusAPI nexusAPI = new NexusAPI(restSharpAPI, client); //nexusAPI.testDelete(); //Console.ReadKey(true); List<NexusContent> contents = new List<NexusContent>(); string repository = "otpp-snapshots"; //string repository = "releases"; string pattern = ".zip"; int days = 0; contents = nexusAPI.getContent(repository, "/"); nexusAPI.findArtifacts(repository, contents, days, pattern); Console.WriteLine("Size of artifacts: {0}", nexusAPI.urls.Count); nexusAPI.removeLastFromList(repository); for (int i = nexusAPI.urls.Count - 1; i >= 0; i--) { nexusAPI.urls[i].TrimEnd('/'); int local = nexusAPI.urls[i].IndexOf("/local/"); nexusAPI.urls[i] = nexusAPI.urls[i].Substring(local + 6); Console.WriteLine("URL to be deleted: {0}", nexusAPI.urls[i]); } //nexusAPI.deleteArtifact(nexusAPI.urls, repository); Console.ReadKey(true); List<NexusRepo> repos = new List<NexusRepo>(); repos = nexusAPI.GetAllRepos(); if (repos == null) { Console.WriteLine("repos is null"); Console.ReadKey(true); Environment.Exit(1); } else { Console.WriteLine("Size of repos: {0}", repos.Count); } foreach (NexusRepo repo in repos) { // Console.WriteLine("Repo info: {0}", repo.ToString()); } //nexusAPI.uploadArtifact(); //nexusAPI.uploadArtifact1(); //nexusAPI.uploadArtifact2(); //nexusAPI.uploadArtifact3(); //List<NexusArtifact> artifacts = new List<NexusArtifact>(); //artifacts = nexusAPI.searchMetadata(); //if (artifacts == null) //{ // Console.WriteLine("artifacts is null"); // Console.ReadKey(true); // Environment.Exit(1); //} //else { // Console.WriteLine("Size of repos: {0}", artifacts.Count); //} Console.ReadKey(true); } catch (Exception ex) { Console.WriteLine("Exception caught: {0}", ex); Console.ReadKey(true); } }
static void Main(string[] args) { try { RestSharpAPI restSharpAPI = new RestSharpAPI(baseUrl); //RestClient client = restSharpAPI.getClient(); //works RestClient client = restSharpAPI.getClient(user, password); // works if (restSharpAPI == null || client == null) { Console.WriteLine("restSharpAPI or client is null"); Environment.Exit(1); } NexusAPI nexusAPI = new NexusAPI(restSharpAPI, client); //nexusAPI.testDelete(); //Console.ReadKey(true); List <NexusContent> contents = new List <NexusContent>(); string repository = "otpp-snapshots"; //string repository = "releases"; string pattern = ".zip"; int days = 0; contents = nexusAPI.getContent(repository, "/"); nexusAPI.findArtifacts(repository, contents, days, pattern); Console.WriteLine("Size of artifacts: {0}", nexusAPI.urls.Count); nexusAPI.removeLastFromList(repository); for (int i = nexusAPI.urls.Count - 1; i >= 0; i--) { nexusAPI.urls[i].TrimEnd('/'); int local = nexusAPI.urls[i].IndexOf("/local/"); nexusAPI.urls[i] = nexusAPI.urls[i].Substring(local + 6); Console.WriteLine("URL to be deleted: {0}", nexusAPI.urls[i]); } //nexusAPI.deleteArtifact(nexusAPI.urls, repository); Console.ReadKey(true); List <NexusRepo> repos = new List <NexusRepo>(); repos = nexusAPI.GetAllRepos(); if (repos == null) { Console.WriteLine("repos is null"); Console.ReadKey(true); Environment.Exit(1); } else { Console.WriteLine("Size of repos: {0}", repos.Count); } foreach (NexusRepo repo in repos) { // Console.WriteLine("Repo info: {0}", repo.ToString()); } //nexusAPI.uploadArtifact(); //nexusAPI.uploadArtifact1(); //nexusAPI.uploadArtifact2(); //nexusAPI.uploadArtifact3(); //List<NexusArtifact> artifacts = new List<NexusArtifact>(); //artifacts = nexusAPI.searchMetadata(); //if (artifacts == null) //{ // Console.WriteLine("artifacts is null"); // Console.ReadKey(true); // Environment.Exit(1); //} //else { // Console.WriteLine("Size of repos: {0}", artifacts.Count); //} Console.ReadKey(true); } catch (Exception ex) { Console.WriteLine("Exception caught: {0}", ex); Console.ReadKey(true); } }