Skip to content

Commit

Permalink
Merge pull request #1441 from TattsGroup/protected-branches-v2
Browse files Browse the repository at this point in the history
Protected Branches updates - main methods
  • Loading branch information
shiftkey authored Aug 29, 2016
2 parents bee5e9f + 0334730 commit 4808941
Show file tree
Hide file tree
Showing 21 changed files with 1,370 additions and 15 deletions.
65 changes: 65 additions & 0 deletions Octokit.Reactive/Clients/IObservableRepositoryBranchesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,70 @@ public interface IObservableRepositoryBranchesClient
/// <param name="update">New values to update the branch with</param>
[Obsolete("BranchProtection preview functionality in the GitHub API has had breaking changes. This existing implementation will cease to work when the preview period ends.")]
IObservable<Branch> Edit(int repositoryId, string branch, BranchUpdate update);

/// <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>
IObservable<BranchProtectionSettings> GetBranchProtection(string owner, string name, string branch);

/// <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>
IObservable<BranchProtectionSettings> GetBranchProtection(int repositoryId, string 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="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>
/// <param name="update">Branch protection settings</param>
IObservable<BranchProtectionSettings> UpdateBranchProtection(string owner, string name, string branch, BranchProtectionSettingsUpdate update);

/// <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>
IObservable<BranchProtectionSettings> UpdateBranchProtection(int repositoryId, string branch, BranchProtectionSettingsUpdate update);

/// <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="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>
IObservable<bool> DeleteBranchProtection(string owner, string name, string branch);

/// <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>
IObservable<bool> DeleteBranchProtection(int repositoryId, string branch);
}
}
103 changes: 103 additions & 0 deletions Octokit.Reactive/Clients/ObservableRepositoryBranchesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,108 @@ public IObservable<Branch> Edit(int repositoryId, string branch, BranchUpdate up

return _client.Edit(repositoryId, branch, update).ToObservable();
}

/// <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 IObservable<BranchProtectionSettings> GetBranchProtection(string owner, string name, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

return _client.GetBranchProtection(owner, name, branch).ToObservable();
}

/// <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 IObservable<BranchProtectionSettings> GetBranchProtection(int repositoryId, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

return _client.GetBranchProtection(repositoryId, branch).ToObservable();
}

/// <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="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>
/// <param name="update">Branch protection settings</param>
public IObservable<BranchProtectionSettings> UpdateBranchProtection(string owner, string name, string branch, BranchProtectionSettingsUpdate update)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");
Ensure.ArgumentNotNull(update, "update");

return _client.UpdateBranchProtection(owner, name, branch, update).ToObservable();
}

/// <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 IObservable<BranchProtectionSettings> UpdateBranchProtection(int repositoryId, string branch, BranchProtectionSettingsUpdate update)
{
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");
Ensure.ArgumentNotNull(update, "update");

return _client.UpdateBranchProtection(repositoryId, branch, update).ToObservable();
}

/// <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="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 IObservable<bool> DeleteBranchProtection(string owner, string name, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

return _client.DeleteBranchProtection(owner, name, branch).ToObservable();
}

/// <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 IObservable<bool> DeleteBranchProtection(int repositoryId, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

return _client.DeleteBranchProtection(repositoryId, branch).ToObservable();
}
}
}
Loading

0 comments on commit 4808941

Please sign in to comment.