Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                string       baseUrl      = "http://github.com/api/v3";
                RestSharpAPI restSharpAPI = new RestSharpAPI(baseUrl);

                Console.ReadKey(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught: {0}", ex);
                Console.ReadKey(true);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GitHubAPI"/> class.
 /// </summary>
 /// <param name="client">The RestClient.</param>
 public GitHubAPI(RestSharpAPI restSharpAPI, RestClient client)
 {
     this.restSharpAPI = restSharpAPI;
     this.client       = client;
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                RestSharpAPI restSharpAPI = new RestSharpAPI(baseUrl);
                //RestClient client = restSharpAPI.getClient(myUser, myPassword);
                RestClient client    = restSharpAPI.getClient2(myUser, myToken);
                GitHubAPI  gitHubAPI = new GitHubAPI(restSharpAPI, client);

                List <GitHubRepo>   repos   = new List <GitHubRepo>();
                List <GitHubTeam>   teams   = new List <GitHubTeam>();
                List <GitHubUser>   users   = new List <GitHubUser>();
                List <GitHubCommit> commits = new List <GitHubCommit>();

                string since = "2016-01-01T00:00:00Z";
                string path  = "GitHubAuditReport_" + System.DateTime.Now.ToString("dd-MM-yyyy") + ".txt";

                string org = "Trade-Efficiencies-CRD";
                //string org = "DevOps";
                string createText = "Audit Report for GitHub Organization: " + org + "\n";
                createText = createText + "===============================================\n";
                //string repo = "Sample";
                repos = gitHubAPI.GetOrgRepos(org);

                foreach (GitHubRepo repo in repos) // Loop through List with foreach.
                {
                    Console.WriteLine("repo info: {0} \n", repo.name);
                    createText = createText + "\nRepository : " + repo.name + "\n";
                    createText = createText + "------------------------------------------\n";
                    commits    = gitHubAPI.GetCommits(org, repo.name, since);
                    if (commits.Count == 0)
                    {
                        createText = createText + "No new change in this repo.\n";
                        continue;
                    }
                    foreach (GitHubCommit item in commits) // Loop through List with foreach.
                    {
                        Console.WriteLine("commit info: {0} \n", item.sha);
                        createText = createText + "\nChange: " + item.message + "\n";
                        GitHubCommit commit = gitHubAPI.GetCommit(org, repo.name, item.sha);
                        createText = createText + commit.ToString();
                    }
                }
                // Write to a file
                createText = createText + Environment.NewLine;
                File.WriteAllText(path, createText);
                Console.WriteLine("File " + path + " created");

                /// print single commit
                //string sha = "60cf9d282af07d138504c0af987dd0fcdfe45ec6";
                //GitHubCommit commit = gitHubAPI.GetCommit(org, repo, sha);
                //Console.WriteLine("Commit info: {0}", commit.ToString());
                // Write to a file
                //string path = "GitHubAuditReport_" + System.DateTime.Now.ToString("dd-MM-yyyy") + ".txt";
                //string createText = commit.ToString() + Environment.NewLine;
                //File.WriteAllText(path, createText);
                //Console.WriteLine("file created");

                //repos = gitHubAPI.GetOrgRepos(org);
                //foreach (GitHubRepo repo in repos) // Loop through List with foreach.
                //{
                //     Console.WriteLine("Repo info: {0}", repo.ToString());
                //}

                //string userId = "huj";
                //repos = gitHubAPI.GetUserRepos(userId);

                //teams = gitHubAPI.GetOrgTeams(org);
                //foreach (GitHubTeam team in teams) // Loop through List with foreach.
                //{
                //    Console.WriteLine("Team info: {0}", team.ToString());
                //    users = gitHubAPI.GetTeamMembers(team.id);
                //    foreach (GitHubUser user in users) // Loop through List with foreach.
                //    {
                //        Console.WriteLine("User info: {0}", user.ToString());
                //    }
                //}


                /// User Operations
                //GitHubUser gitHubUser = gitHubAPI.GetGitHubUser();
                //Console.WriteLine("User1 info: {0}", gitHubUser.ToString());

                //GitHubUser gitHubUser2 = gitHubAPI.GetGitHubUser2();
                //Console.WriteLine("User2 info: {0}", gitHubUser2.ToString());

                //GitHubUser gitHubUser3 = gitHubAPI.GetGitHubUser3();
                //Console.WriteLine("User3 info: {0}", gitHubUser3.ToString());

                //List<GitHubUser> users = new List<GitHubUser>();
                //users = gitHubAPI.GetAllUsers();
                //foreach (GitHubUser user in users) // Loop through List with foreach.
                //{
                //     Console.WriteLine("User info: {0}", user.ldap_dn);
                //}

                Console.ReadKey(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught: {0}", ex);
                Console.ReadKey(true);
            }
        }