Ejemplo n.º 1
0
        private static void TestApiV1()
        {
            var sharpBucket = new SharpBucketV1();
            // Decide on which authentication you wish to use
            //ReadTestDataBasic();
            //sharpBucket.BasicAuthentication(email, password);

            ReadTestDataOauth();
            // Two legged OAuth, just supply the consumerKey and the consumerSecretKey and you are done
            sharpBucket.OAuth2LeggedAuthentication(consumerKey, consumerSecretKey);

            // Three legged OAuth. We can supply our own callback url to which bitbucket will send our pin
            // If we use "oob" as the callback url we will get the bitbuckets url address which will have our pin
            //var authenticator = sharpBucket.OAuth3LeggedAuthentication(consumerKey, consumerSecretKey, "oob");
            //var uri = authenticator.StartAuthentication();
            //Process.Start(uri);
            //var pin = Console.ReadLine();
            // we can now do the final step by using the pin to get our access tokens
            //authenticator.AuthenticateWithPin(pin);

            // of if you saved the tokens you can simply use those
            // var authenticator = sharpBucket.OAuth3LeggedAuthentication(consumerKey, consumerSecretKey, "oauthtoken", "oauthtokensecret");
            TestUserEndPoint(sharpBucket);
            TestIssuesEndPoint(sharpBucket);
            TestRepositoriesEndPoint(sharpBucket);
            TestUsersEndPoint(sharpBucket);
            TestPrivilegesEndPoint(sharpBucket);
        }
Ejemplo n.º 2
0
 private static void TestUsersEndPoint(SharpBucketV1 sharpBucket)
 {
     var usersEndPoint = sharpBucket.UsersEndPoint(accountName);
     //var userEvents = usersEP.ListUserEvents();
     //var userPrivileges = usersEP.ListUserPrivileges();
     var invitations = usersEndPoint.ListInvitations();
     var email = "*****@*****.**";
     var invitationsForEmail = usersEndPoint.GetInvitationsFor(email);
     var followers = usersEndPoint.ListFollowers();
     var consumers = usersEndPoint.ListConsumers();
     int? CONSUMER_ID = consumers[0].id;
     var consumer = usersEndPoint.GetConsumer(CONSUMER_ID);
     var ssh_keys = usersEndPoint.ListSSHKeys();
     int? PK = ssh_keys[0].pk;
     var getSSH = usersEndPoint.GetSSHKey(PK);
 }
Ejemplo n.º 3
0
 private static void TestUserEndPoint(SharpBucketV1 sharpBucket)
 {
     var userEndPoint = sharpBucket.UserEndPoint();
     var info = userEndPoint.GetInfo();
     var privileges = userEndPoint.ListPrivileges();
     var follows = userEndPoint.ListFollows();
     var userRepos = userEndPoint.ListRepositories();
     var userReposOverview = userEndPoint.RepositoriesOverview();
     var userRepositoryDashboard = userEndPoint.GetRepositoryDasboard();
 }
Ejemplo n.º 4
0
 private static void TestRepositoriesEndPoint(SharpBucketV1 sharpBucket)
 {
     var repositoriesEndPoint = sharpBucket.RepositoriesEndPoint(accountName, repository);
     var tags = repositoriesEndPoint.ListTags();
     var branches = repositoriesEndPoint.ListBranches();
     var mainBranch = repositoriesEndPoint.GetMainBranch();
     string WIKI_PAGE = "";
     var wiki = repositoriesEndPoint.GetWiki(WIKI_PAGE);
     var newPage = new Wiki{data = "Hello to my new page"};
     var newWiki = repositoriesEndPoint.PostWiki(newPage, "NewPage");
     var changeSet = repositoriesEndPoint.ListChangeset();
     var change = changeSet.changesets[4];
     var getChange = repositoriesEndPoint.GetChangeset(change.node);
     var diffStats = repositoriesEndPoint.GetChangesetDiffstat(change.node);
     var repoEvents = repositoriesEndPoint.ListEvents();
     var links = repositoriesEndPoint.ListLinks();
     var newLink = new Link{id = 100};
     var newLinkResponse = repositoriesEndPoint.PostLink(newLink);
     var link = repositoriesEndPoint.GetLink(newLinkResponse.id);
     newLinkResponse.handler.name = "sfsdf";
     var updatedLink = repositoriesEndPoint.PutLink(newLinkResponse);
     repositoriesEndPoint.DeleteLink(updatedLink);
 }
Ejemplo n.º 5
0
 private static void TestPrivilegesEndPoint(SharpBucketV1 sharpBucket)
 {
     var privilegesEndPoint = sharpBucket.PrivilegesEndPoint(accountName);
     var privileges = privilegesEndPoint.ListRepositoryPrivileges(repository);
     var privilege = privilegesEndPoint.GetPrivilegesForAccount(repository, accountName);
 }
Ejemplo n.º 6
0
        private static void TestIssuesEndPoint(SharpBucketV1 sharpBucket)
        {
            var issuesResource = sharpBucket.RepositoriesEndPoint(accountName, repository).IssuesResource();

            int ISSUE_ID = 5;
            // Issues
            var issues = issuesResource.ListIssues();
            var newIssue = new Issue{title = "Let's add a new issue", content = "Some issue content", status = "new", priority = "trivial", kind = "bug"};
            var newIssueResult = issuesResource.PostIssue(newIssue);
            var issue = issuesResource.GetIssue(newIssueResult.local_id);
            var changedIssue = new Issue{title = "Completely new title", content = "Hi!", status = "new", local_id = issue.local_id};
            var changedIssueResult = issuesResource.PutIssue(changedIssue);
            issuesResource.DeleteIssue(changedIssueResult.local_id);

            // Issue comments
            var issueResource = issuesResource.IssueResource(ISSUE_ID);
            var issueComments = issueResource.ListComments();
            var newComment = new Comment{content = "This bug is really annoying!"};
            var newCommentResult = issueResource.PostComment(newComment);
            var comment = issueResource.GetIssueComment(newCommentResult.comment_id);
            comment.content = "The bug is still annoying";
            var updatedCommentRes = issueResource.PutIssueComment(comment);
            issueResource.DeleteIssueComment(updatedCommentRes.comment_id);

            // Issue followers
            var issueFollowers = issueResource.ListFollowers();

            // Components
            var components = issuesResource.ListComponents();
            var newComponent = new Component{name = "Awesome component"};
            var newComponentRes = issuesResource.PostComponent(newComponent);
            var component = issuesResource.GetComponent(newComponentRes.id);
            component.name = "Even more awesome component";
            var updatedComponent = issuesResource.PutComponent(component);
            issuesResource.DeleteComponent(updatedComponent.id);

            // Milestones
            var milestones = issuesResource.ListMilestones();
            var newMilestone = new Milestone{name = "Awesome milestone"};
            var newMilestoneRes = issuesResource.PostMilestone(newMilestone);
            var milestone = issuesResource.GetMilestone(newMilestoneRes.id);
            milestone.name = "Even more awesome milestone";
            var updatedMilestone = issuesResource.PutMilestone(milestone);
            issuesResource.DeleteMilestone(updatedMilestone.id);

            // Versions
            var versions = issuesResource.ListVersions();
            var newVersion = new Version{name = "Awesome version"};
            var newVersionRes = issuesResource.PostVersion(newVersion);
            var version = issuesResource.GetVersion(newVersionRes.id);
            version.name = "Even more awesome version";
            var updatedversion = issuesResource.PutVersion(version);
            issuesResource.DeleteVersion(updatedversion.id);
        }