public static RepoBranchProtection ( long repositoryId, string branchName ) : |
||
repositoryId | long | The Id of the repository |
branchName | string | The name of the branch |
Результат |
/// <summary> /// Update the branch protection settings for the specified branch /> /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/branches/#update-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> /// <param name="update">Branch protection settings</param> public Task <BranchProtectionSettings> UpdateBranchProtection(int repositoryId, string branch, BranchProtectionSettingsUpdate update) { Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); Ensure.ArgumentNotNull(update, "update"); return(ApiConnection.Put <BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null, AcceptHeaders.ProtectedBranchesApiPreview)); }
/// <summary> /// Get the branch protection settings for the specified branch /> /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/branches/#get-branch-protection">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 Task <BranchProtectionSettings> GetBranchProtection(string owner, string name, string branch) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); return(ApiConnection.Get <BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview)); }
/// <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> /// Get the branch protection settings for the specified branch /> /// </summary> /// <remarks> /// See the <a href="https://developer.github.com/v3/repos/branches/#get-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 Task <BranchProtectionSettings> GetBranchProtection(int repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); return(ApiConnection.Get <BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview)); }