Esempio n. 1
0
        /// <summary>
        /// Gets all repositories owned by the specified organization.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/repos/#list-organization-repositories">API documentation</a> for more information.
        /// The default page size on GitHub.com is 30.
        /// </remarks>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
        public Task <IReadOnlyList <Repository> > GetAllForOrg(string organization)
        {
            Ensure.ArgumentNotNullOrEmptyString(organization, "organization");

            return(ApiConnection.GetAll <Repository>(ApiUrls.OrganizationRepositories(organization)));
        }
Esempio n. 2
0
        /// <summary>
        /// Gets all the collaborators on a repository.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The id of the repository</param>
        /// <param name="options">Options for changing the API response</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        public Task <IReadOnlyList <User> > GetAll(long repositoryId, ApiOptions options)
        {
            Ensure.ArgumentNotNull(options, "options");

            return(ApiConnection.GetAll <User>(ApiUrls.RepoCollaborators(repositoryId), options));
        }
        /// <summary>
        /// Creates a reaction for a specified Pull Request Review Comment.
        /// </summary>
        /// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="number">The comment id</param>
        /// <param name="reaction">The reaction to create</param>
        public Task <Reaction> Create(long repositoryId, int number, NewReaction reaction)
        {
            Ensure.ArgumentNotNull(reaction, nameof(reaction));

            return(ApiConnection.Post <Reaction>(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview));
        }
Esempio n. 4
0
        /// <summary>
        /// Gets all <see cref="Authorization"/>s for the authenticated user.
        /// </summary>
        /// <remarks>
        /// This method requires authentication.
        /// See the <a href="http://developer.github.com/v3/oauth/#list-your-authorizations">API documentation</a> for more information.
        /// </remarks>
        /// <param name="options">Options for changing the API response</param>
        /// <exception cref="AuthorizationException">
        /// Thrown when the current user does not have permission to make the request.
        /// </exception>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>A list of <see cref="Authorization"/>s for the authenticated user.</returns>
        public Task <IReadOnlyList <Authorization> > GetAll(ApiOptions options)
        {
            Ensure.ArgumentNotNull(options, "options");

            return(ApiConnection.GetAll <Authorization>(ApiUrls.Authorizations(), options));
        }
Esempio n. 5
0
        /// <summary>
        /// Invites a new collaborator to the repo
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/repos/collaborators/#add-collaborator">API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The id of the repository.</param>
        /// <param name="user">The name of the user to invite.</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        public Task <RepositoryInvitation> Invite(long repositoryId, string user)
        {
            Ensure.ArgumentNotNullOrEmptyString(user, "user");

            return(ApiConnection.Put <RepositoryInvitation>(ApiUrls.RepoCollaborator(repositoryId, user), new object(), null, AcceptHeaders.InvitationsApiPreview));
        }
Esempio n. 6
0
        public Task <CheckSuite> Create(long repositoryId, NewCheckSuite newCheckSuite)
        {
            Ensure.ArgumentNotNull(newCheckSuite, nameof(newCheckSuite));

            return(ApiConnection.Post <CheckSuite>(ApiUrls.CheckSuites(repositoryId), newCheckSuite, AcceptHeaders.ChecksApiPreview));
        }
Esempio n. 7
0
 /// <summary>
 /// Deletes the specified <see cref="Authorization"/>.
 /// </summary>
 /// <remarks>
 /// This method requires authentication.
 /// See the <a href="http://developer.github.com/v3/oauth/#delete-an-authorization">API
 /// documentation</a> for more details.
 /// </remarks>
 /// <param name="id">The system-wide Id of the authorization to delete</param>
 /// <exception cref="AuthorizationException">
 /// Thrown when the current user does not have permission to make the request.
 /// </exception>
 /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
 /// <returns>A <see cref="Task"/> for the request's execution.</returns>
 public Task Delete(int id)
 {
     return(ApiConnection.Delete(ApiUrls.Authorizations(id)));
 }
Esempio n. 8
0
        /// <summary>
        /// Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
        public async Task <CodeFrequency> GetCodeFrequency(long repositoryId, CancellationToken cancellationToken)
        {
            var rawFrequencies = await ApiConnection.GetQueuedOperation <long[]>(ApiUrls.StatsCodeFrequency(repositoryId), cancellationToken).ConfigureAwait(false);

            return(new CodeFrequency(rawFrequencies));
        }
Esempio n. 9
0
        /// <summary>
        /// Returns the total commit counts for the owner and total commit counts in total.
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
        public async Task <Participation> GetParticipation(long repositoryId, CancellationToken cancellationToken)
        {
            var result = await ApiConnection.GetQueuedOperation <Participation>(ApiUrls.StatsParticipation(repositoryId), cancellationToken).ConfigureAwait(false);

            return(result.FirstOrDefault());
        }
Esempio n. 10
0
 /// <summary>
 /// Get a pull request by number.
 /// </summary>
 /// <remarks>
 /// http://developer.github.com/v3/pulls/#get-a-single-pull-request
 /// </remarks>
 public Task <PullRequest> Get(long repositoryId, int number)
 {
     return(ApiConnection.Get <PullRequest>(ApiUrls.PullRequest(repositoryId, number)));
 }
Esempio n. 11
0
        /// <summary>
        /// Returns the last year of commit activity grouped by week.
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
        public async Task <CommitActivity> GetCommitActivity(long repositoryId, CancellationToken cancellationToken)
        {
            var activity = await ApiConnection.GetQueuedOperation <WeeklyCommitActivity>(ApiUrls.StatsCommitActivity(repositoryId), cancellationToken).ConfigureAwait(false);

            return(new CommitActivity(activity));
        }
Esempio n. 12
0
 /// <summary>
 /// Get the list of files on a pull request.
 /// </summary>
 /// <remarks>https://developer.github.com/v3/pulls/#list-pull-requests-files</remarks>
 /// <param name="repositoryId">The Id of the repository</param>
 /// <param name="number">The pull request number</param>
 public Task <IReadOnlyList <PullRequestFile> > Files(long repositoryId, int number)
 {
     return(ApiConnection.GetAll <PullRequestFile>(ApiUrls.PullRequestFiles(repositoryId, number)));
 }
Esempio n. 13
0
        /// <summary>
        /// Create a pull request for the specified repository.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/pulls/#update-a-pull-request</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="number">The PullRequest number</param>
        /// <param name="pullRequestUpdate">An <see cref="PullRequestUpdate"/> instance describing the changes to make to the PullRequest
        /// </param>
        public Task <PullRequest> Update(long repositoryId, int number, PullRequestUpdate pullRequestUpdate)
        {
            Ensure.ArgumentNotNull(pullRequestUpdate, "pullRequestUpdate");

            return(ApiConnection.Patch <PullRequest>(ApiUrls.PullRequest(repositoryId, number), pullRequestUpdate));
        }
Esempio n. 14
0
        /// <summary>
        /// Create a pull request for the specified repository.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/pulls/#create-a-pull-request</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="newPullRequest">A <see cref="NewPullRequest"/> instance describing the new PullRequest to create</param>
        public Task <PullRequest> Create(long repositoryId, NewPullRequest newPullRequest)
        {
            Ensure.ArgumentNotNull(newPullRequest, "newPullRequest");

            return(ApiConnection.Post <PullRequest>(ApiUrls.PullRequests(repositoryId), newPullRequest));
        }
Esempio n. 15
0
        /// <summary>
        /// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user.
        /// </summary>
        /// <param name="options">Options for changing API's response.</param>
        /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
        /// <returns>
        /// A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>(ies) watched by the current authenticated user.
        /// </returns>
        public Task <IReadOnlyList <Repository> > GetAllForCurrent(ApiOptions options)
        {
            Ensure.ArgumentNotNull(options, "options");

            return(ApiConnection.GetAll <Repository>(ApiUrls.Watched(), options));
        }
Esempio n. 16
0
        /// <summary>
        /// Returns a list of the number of commits per hour in each day
        /// </summary>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
        public async Task <PunchCard> GetPunchCard(long repositoryId, CancellationToken cancellationToken)
        {
            var punchCardData = await ApiConnection.GetQueuedOperation <int[]>(ApiUrls.StatsPunchCard(repositoryId), cancellationToken).ConfigureAwait(false);

            return(new PunchCard(punchCardData));
        }
Esempio n. 17
0
        public Task <CheckSuitePreferencesResponse> UpdatePreferences(long repositoryId, CheckSuitePreferences preferences)
        {
            Ensure.ArgumentNotNull(preferences, nameof(preferences));

            return(ApiConnection.Patch <CheckSuitePreferencesResponse>(ApiUrls.CheckSuitePreferences(repositoryId), preferences, AcceptHeaders.ChecksApiPreview));
        }
Esempio n. 18
0
 /// <summary>
 /// Returns a list of <see cref="Contributor"/> for the given repository
 /// </summary>
 /// <param name="repositoryId">The Id of the repository</param>
 /// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
 public Task <IReadOnlyList <Contributor> > GetContributors(long repositoryId, CancellationToken cancellationToken)
 {
     return(ApiConnection.GetQueuedOperation <Contributor>(ApiUrls.StatsContributors(repositoryId), cancellationToken));
 }
Esempio n. 19
0
 public Task <CheckSuite> Get(long repositoryId, long checkSuiteId)
 {
     return(ApiConnection.Get <CheckSuite>(ApiUrls.CheckSuite(repositoryId, checkSuiteId), null, AcceptHeaders.ChecksApiPreview));
 }
Esempio n. 20
0
        /// <summary>
        /// Returns the last year of commit activity grouped by week.
        /// </summary>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="cancellationToken">A token used to cancel this potentially long running request</param>
        public async Task <CommitActivity> GetCommitActivity(string owner, string name, CancellationToken cancellationToken)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            var activity = await ApiConnection.GetQueuedOperation <WeeklyCommitActivity>(ApiUrls.StatsCommitActivity(owner, name), cancellationToken).ConfigureAwait(false);

            return(new CommitActivity(activity));
        }
Esempio n. 21
0
 /// <summary>
 /// Deletes the specified <see cref="Authorization"/>.
 /// </summary>
 /// <remarks>
 /// This method requires authentication.
 /// See the <a href="http://developer.github.com/v3/oauth/#delete-an-authorization">API
 /// documentation</a> for more details.
 /// </remarks>
 /// <param name="id">The system-wide Id of the authorization to delete</param>
 /// <param name="twoFactorAuthenticationCode">Two factor authorization code</param>
 /// <exception cref="AuthorizationException">
 /// Thrown when the current user does not have permission to make the request.
 /// </exception>
 /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
 /// <returns>A <see cref="Task"/> for the request's execution.</returns>
 public Task Delete(int id, string twoFactorAuthenticationCode)
 {
     return(ApiConnection.Delete(ApiUrls.Authorizations(id), twoFactorAuthenticationCode));
 }
Esempio n. 22
0
 /// <summary>
 /// Returns all <see cref="Organization" />s.
 /// </summary>
 /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
 /// <returns>A list of <see cref="Organization"/>s.</returns>
 public Task <IReadOnlyList <Organization> > GetAll()
 {
     return(ApiConnection.GetAll <Organization>(ApiUrls.AllOrganizations()));
 }
Esempio n. 23
0
 /// <summary>
 /// Gets a specific <see cref="Authorization"/> for the authenticated user.
 /// </summary>
 /// <remarks>
 /// This method requires authentication.
 /// See the <a href="http://developer.github.com/v3/oauth/#get-a-single-authorization">API documentation</a> for more information.
 /// </remarks>
 /// <param name="id">The Id of the <see cref="Authorization"/> to get</param>
 /// <exception cref="AuthorizationException">
 /// Thrown when the current user does not have permission to make this request.
 /// </exception>
 /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
 /// <returns>The specified <see cref="Authorization"/>.</returns>
 public Task <Authorization> Get(int id)
 {
     return(ApiConnection.Get <Authorization>(ApiUrls.Authorizations(id), null));
 }
Esempio n. 24
0
        /// <summary>
        /// Returns the specified <see cref="Organization"/>.
        /// </summary>
        /// <param name="org">login of the organization to get</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>The specified <see cref="Organization"/>.</returns>
        public Task <Organization> Get(string org)
        {
            Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));

            return(ApiConnection.Get <Organization>(ApiUrls.Organization(org)));
        }
Esempio n. 25
0
        /// <summary>
        /// Deletes a collaborator from the repository.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/repos/collaborators/#remove-collaborator">API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The id of the repository</param>
        /// <param name="user">Username of the deleted collaborator</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        public Task Delete(long repositoryId, string user)
        {
            Ensure.ArgumentNotNullOrEmptyString(user, "user");

            return(ApiConnection.Delete(ApiUrls.RepoCollaborator(repositoryId, user)));
        }
Esempio n. 26
0
        /// <summary>
        /// Returns all <see cref="Organization" />s for the current user.
        /// </summary>
        /// <param name="options">Options for changing the API response</param>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>A list of the current user's <see cref="Organization"/>s.</returns>
        public Task <IReadOnlyList <Organization> > GetAllForCurrent(ApiOptions options)
        {
            Ensure.ArgumentNotNull(options, nameof(options));

            return(ApiConnection.GetAll <Organization>(ApiUrls.UserOrganizations(), options));
        }
        /// <summary>
        /// Get all reactions for a specified Pull Request Review Comment.
        /// </summary>
        /// <remarks>https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="number">The comment id</param>
        /// <param name="options">Options for changing the API response</param>
        public Task <IReadOnlyList <Reaction> > GetAll(long repositoryId, int number, ApiOptions options)
        {
            Ensure.ArgumentNotNull(options, nameof(options));

            return(ApiConnection.GetAll <Reaction>(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options));
        }
Esempio n. 28
0
        /// <summary>
        /// List all public keys (must be Site Admin user).
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/enterprise/2.5/v3/users/administration/#list-all-public-keys">API documentation</a>
        /// for more information.
        /// </remarks>
        /// <returns></returns>
        public Task <IReadOnlyList <PublicKey> > ListAllPublicKeys()
        {
            var endpoint = ApiUrls.UserAdministrationPublicKeys();

            return(ApiConnection.GetAll <PublicKey>(endpoint));
        }
Esempio n. 29
0
 /// <summary>
 /// Deletes the specified repository.
 /// </summary>
 /// <remarks>
 /// See the <a href="http://developer.github.com/v3/repos/#delete-a-repository">API documentation</a> for more information.
 /// Deleting a repository requires admin access. If OAuth is used, the `delete_repo` scope is required.
 /// </remarks>
 /// <param name="repositoryId">The Id of the repository</param>
 /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
 public Task Delete(long repositoryId)
 {
     return(ApiConnection.Delete(ApiUrls.Repository(repositoryId)));
 }
Esempio n. 30
0
        /// <summary>
        /// Gets all repositories owned by the specified user.
        /// </summary>
        /// <remarks>
        /// See the <a href="http://developer.github.com/v3/repos/#list-user-repositories">API documentation</a> for more information.
        /// The default page size on GitHub.com is 30.
        /// </remarks>
        /// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
        /// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
        public Task <IReadOnlyList <Repository> > GetAllForUser(string login)
        {
            Ensure.ArgumentNotNullOrEmptyString(login, "login");

            return(ApiConnection.GetAll <Repository>(ApiUrls.Repositories(login)));
        }