public async Task <PullRequestMerge> Merge(long repositoryId, int number, MergePullRequest mergePullRequest) { Ensure.ArgumentNotNull(mergePullRequest, nameof(mergePullRequest)); try { var endpoint = ApiUrls.MergePullRequest(repositoryId, number); return(await ApiConnection.Put <PullRequestMerge>(endpoint, mergePullRequest).ConfigureAwait(false)); } catch (ApiException ex) { if (ex.StatusCode == HttpStatusCode.MethodNotAllowed) { throw new PullRequestNotMergeableException(ex.HttpResponse); } if (ex.StatusCode == HttpStatusCode.Conflict) { throw new PullRequestMismatchException(ex.HttpResponse); } throw; } }
/// <summary> /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. /// </summary> /// <remarks>https://developer.github.com/v3/issues/#lock-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue number</param> public Task Lock(int repositoryId, int number) { return(ApiConnection.Put <Issue>(ApiUrls.IssueLock(repositoryId, number), new object(), null, AcceptHeaders.IssueLockingUnlockingApiPreview)); }
/// <summary> /// Replaces all labels on the specified issues with the provided labels /// </summary> /// <remarks> /// See the <a href="http://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The number of the issue</param> /// <param name="labels">The names of the labels to set</param> public Task <IReadOnlyList <Label> > ReplaceAllForIssue(long repositoryId, int number, string[] labels) { Ensure.ArgumentNotNull(labels, "labels"); return(ApiConnection.Put <IReadOnlyList <Label> >(ApiUrls.IssueLabels(repositoryId, number), labels)); }
/// <summary> /// Watches a repository for the authenticated user. /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param> public Task <Subscription> WatchRepo(long repositoryId, NewSubscription newSubscription) { Ensure.ArgumentNotNull(newSubscription, nameof(newSubscription)); return(ApiConnection.Put <Subscription>(ApiUrls.Watched(repositoryId), newSubscription)); }
/// <summary> /// Marks all notifications as read. /// </summary> /// <param name="markAsReadRequest">The <see cref="MarkAsReadRequest"/> parameter which specifies which notifications to mark.</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#mark-as-read</remarks> /// <returns></returns> public Task MarkAsRead(MarkAsReadRequest markAsReadRequest) { return(ApiConnection.Put <object>(ApiUrls.Notifications(), markAsReadRequest)); }
/// <summary> /// Sets the authenticated user's subscription settings for a given thread. /// </summary> /// <param name="id">The Id of the thread to update.</param> /// <param name="threadSubscription">The subscription parameters to set.</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#set-a-thread-subscription</remarks> public Task <ThreadSubscription> SetThreadSubscription(int id, NewThreadSubscription threadSubscription) { Ensure.ArgumentNotNull(threadSubscription, "threadSubscription"); return(ApiConnection.Put <ThreadSubscription>(ApiUrls.NotificationSubscription(id), threadSubscription)); }
/// <summary> /// Marks all notifications as read. /// </summary> /// <param name="markAsReadRequest">The <see cref="MarkAsReadRequest"/> parameter which specifies which notifications to mark.</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#mark-as-read</remarks> public Task MarkAsRead(MarkAsReadRequest markAsReadRequest) { Ensure.ArgumentNotNull(markAsReadRequest, "markAsReadRequest"); return(ApiConnection.Put <object>(ApiUrls.Notifications(), markAsReadRequest)); }
/// <summary> /// Adds a new collaborator to the repository. /// </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">Username of the new collaborator</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public Task Add(long repositoryId, string user) { Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); return(ApiConnection.Put(ApiUrls.RepoCollaborator(repositoryId, user))); }
/// <summary> /// Add a repository to the team /// </summary> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> public Task AddRepository(int id, string organization, string repoName) { var endpoint = ApiUrls.TeamRepository(id, organization, repoName); return(ApiConnection.Put(endpoint)); }
/// <summary> /// Marks all notifications as read. /// </summary> /// <remarks>http://developer.github.com/v3/activity/notifications/#mark-as-read</remarks> public Task MarkAsRead() { return(ApiConnection.Put(ApiUrls.Notifications())); }
public Task Lock(long repositoryId, int number) { return(ApiConnection.Put <Issue>(ApiUrls.IssueLock(repositoryId, number), new object())); }
public Task MarkAsReadForRepository(long repositoryId) { return(ApiConnection.Put <object>(ApiUrls.Notifications(repositoryId), new object())); }
public Task MarkAsRead() { return(ApiConnection.Put <object>(ApiUrls.Notifications(), new object())); }
public Task Star(string id) { Ensure.ArgumentNotNullOrEmptyString(id, nameof(id)); return(ApiConnection.Put(ApiUrls.StarGist(id))); }
/// <summary> /// Marks the notifications for a given repository as read. /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository</remarks> public Task MarkAsReadForRepository(int repositoryId) { return(ApiConnection.Put(ApiUrls.Notifications(repositoryId))); }
/// <summary> /// Stars a gist /// </summary> /// <remarks> /// http://developer.github.com/v3/gists/#star-a-gist /// </remarks> /// <param name="id">The id of the gist</param> public Task Star(string id) { return(ApiConnection.Put(ApiUrls.StarGist(id))); }
/// <summary> /// Marks the notifications for a given repository as read. /// </summary> /// <param name="repositoryId">The Id of the repository</param> /// <param name="markAsReadRequest">The <see cref="MarkAsReadRequest"/> parameter which specifies which notifications to mark.</param> /// <remarks>http://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository</remarks> public Task MarkAsReadForRepository(int repositoryId, MarkAsReadRequest markAsReadRequest) { Ensure.ArgumentNotNull(markAsReadRequest, "markAsReadRequest"); return(ApiConnection.Put <object>(ApiUrls.Notifications(repositoryId), markAsReadRequest)); }
/// <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, nameof(user)); return(ApiConnection.Put <RepositoryInvitation>(ApiUrls.RepoCollaborator(repositoryId, user), new object(), null, AcceptHeaders.InvitationsApiPreview)); }
/// <summary> /// Replaces all topics for the specified repository. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/#replace-all-topics-for-a-repository">API documentation</a> for more details /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="topics">The topics list to be set</param> /// <returns>All topics for the repository.</returns> public async Task <RepositoryTopics> ReplaceAllTopics(long repositoryId, RepositoryTopics topics) { var endpoint = ApiUrls.RepositoryTopics(repositoryId); return(await ApiConnection.Put <RepositoryTopics>(endpoint, topics, null, AcceptHeaders.RepositoryTopicsPreview).ConfigureAwait(false)); }