public async Task <bool> Delete(int id) { var endpoint = ApiUrls.ProjectCard(id); try { var httpStatusCode = await Connection.Delete(endpoint, new object(), AcceptHeaders.ProjectsApiPreview).ConfigureAwait(false); return(httpStatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Deletes a repository invitation. /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/invitations/#delete-a-repository-invitation">API documentation</a> for more information. /// </remarks> /// <param name="repositoryId">The id of the repository</param> /// <param name="invitationId">The id of the invitation</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> public async Task <bool> Delete(int repositoryId, int invitationId) { var endpoint = ApiUrls.RepositoryInvitations(repositoryId, invitationId); try { var httpStatusCode = await Connection.Delete(endpoint, new object(), AcceptHeaders.InvitationsApiPreview).ConfigureAwait(false); return(httpStatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Deletes an impersonation OAuth token (must be Site Admin user). /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/enterprise/2.5/v3/users/administration/#delete-an-impersonation-oauth-token">API documentation</a> /// for more information. /// </remarks> /// <param name="login">The user to remove impersonation token from</param> /// <returns></returns> public async Task DeleteImpersonationToken(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); var endpoint = ApiUrls.UserAdministrationAuthorization(login); var response = await Connection.Delete(endpoint).ConfigureAwait(false); if (response != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response); } return; }
public async Task <bool> Delete(long repositoryId, int invitationId) { var endpoint = ApiUrls.RepositoryInvitations(repositoryId, invitationId); try { var httpStatusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return(httpStatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Unstars a repository for the authenticated user. /// </summary> /// <param name="owner">The owner of the repository to unstar</param> /// <param name="name">The name of the repository to unstar</param> /// <returns>A <c>bool</c> representing the success of the operation</returns> public async Task <bool> RemoveStarFromRepo(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); try { var statusCode = await Connection.Delete(ApiUrls.Starred(owner, name)).ConfigureAwait(false); return(statusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Unwatches a repository for the authenticated user. /// </summary> /// <param name="owner">The owner of the repository to unstar</param> /// <param name="name">The name of the repository to unstar</param> public async Task <bool> UnwatchRepo(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); try { var endpoint = ApiUrls.Watched(owner, name); var statusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return(statusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Remove the branch protection settings for the specified branch /> /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/branches/#remove-branch-protection">API documentation</a> for more details /// </remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="branch">The name of the branch</param> public async Task <bool> DeleteBranchProtection(int repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); var endpoint = ApiUrls.RepoBranchProtection(repositoryId, branch); try { var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); return(httpStatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Remove restrictions for the specified branch (applies only to Organization owned repositories) /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/branches/#remove-restrictions-of-protected-branch">API documentation</a> for more details /// </remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="branch">The name of the branch</param> public async Task <bool> DeleteProtectedBranchRestrictions(string owner, string name, string branch) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); var endpoint = ApiUrls.RepoRestrictions(owner, name, branch); try { var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); return(httpStatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }