Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BranchProtection.EnforceAdmins object #1598

63 changes: 63 additions & 0 deletions Octokit.Reactive/Clients/IObservableRepositoryBranchesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,69 @@ public interface IObservableRepositoryBranchesClient
/// <param name="contexts">The contexts to remove</param>
IObservable<string> DeleteRequiredStatusChecksContexts(long repositoryId, string branch, IReadOnlyList<string> contexts);

/// <summary>
/// Get admin enforcement of protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#get-admin-enforcement-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>
IObservable<EnforceAdmins> GetAdminEnforcement(string owner, string name, string branch);

/// <summary>
/// Get admin enforcement of protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#get-admin-enforcement-of-protected-branch">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<EnforceAdmins> GetAdminEnforcement(long repositoryId, string branch);

/// <summary>
/// Add admin enforcement to protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#add-admin-enforcement-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>
IObservable<EnforceAdmins> AddAdminEnforcement(string owner, string name, string branch);

/// <summary>
/// Add admin enforcement to protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#add-admin-enforcement-of-protected-branch">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<EnforceAdmins> AddAdminEnforcement(long repositoryId, string branch);

/// <summary>
/// Remove admin enforcement on protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#remove-admin-enforcement-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>
IObservable<bool> RemoveAdminEnforcement(string owner, string name, string branch);

/// <summary>
/// Remove admin enforcement on protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#remove-admin-enforcement-of-protected-branch">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> RemoveAdminEnforcement(long repositoryId, string branch);

/// <summary>
/// Get the restrictions for the specified branch (applies only to Organization owned repositories)
/// </summary>
Expand Down
91 changes: 91 additions & 0 deletions Octokit.Reactive/Clients/ObservableRepositoryBranchesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,97 @@ public IObservable<string> DeleteRequiredStatusChecksContexts(long repositoryId,
return _client.DeleteRequiredStatusChecksContexts(repositoryId, branch, contexts).ToObservable().SelectMany(x => x);
}

/// <summary>
/// Get admin enforcement of protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#get-admin-enforcement-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 IObservable<EnforceAdmins> GetAdminEnforcement(string owner, string name, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

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

/// <summary>
/// Get admin enforcement of protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#get-admin-enforcement-of-protected-branch">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<EnforceAdmins> GetAdminEnforcement(long repositoryId, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

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

/// <summary>
/// Add admin enforcement to protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#add-admin-enforcement-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 IObservable<EnforceAdmins> AddAdminEnforcement(string owner, string name, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

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

public IObservable<EnforceAdmins> AddAdminEnforcement(long repositoryId, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

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

/// <summary>
/// Remove admin enforcement on protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#remove-admin-enforcement-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 IObservable<bool> RemoveAdminEnforcement(string owner, string name, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

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

/// <summary>
/// Remove admin enforcement on protected branch
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/branches/#remove-admin-enforcement-of-protected-branch">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> RemoveAdminEnforcement(long repositoryId, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(branch, "branch");

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

/// <summary>
/// Get the restrictions for the specified branch (applies only to Organization owned repositories)
/// </summary>
Expand Down
Loading