From 97acb9c461a7ff210c03899dd041d36956ea962f Mon Sep 17 00:00:00 2001 From: Bob Eagan Date: Tue, 18 Apr 2017 10:33:55 -0700 Subject: [PATCH 1/2] add basic branch protection docs --- doc/README.md | 1 + doc/repo/protection.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 doc/repo/protection.md diff --git a/doc/README.md b/doc/README.md index 20abcd6373a..ebc64840d37 100644 --- a/doc/README.md +++ b/doc/README.md @@ -32,6 +32,7 @@ APIs: * [Repositories](repos.md) * [Contents](repo/contents.md) * [Deployments](repo/deployments.md) + * [Protection](repo/protection.md) * [Releases](repo/releases.md) * [Assets](repo/assets.md) * [Stargazers](repo/stargazers.md) diff --git a/doc/repo/protection.md b/doc/repo/protection.md new file mode 100644 index 00000000000..e6a0aa938a3 --- /dev/null +++ b/doc/repo/protection.md @@ -0,0 +1,25 @@ +## Repo / Protection API +[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md) + +The Protection API is currently available for developers to preview. +To access the API during the preview period, you must provide a custom media type in the Accept header: + +```php +$client->api('repo')->protection()->configure(); +``` + +### List all branch protection + +> Requires [authentication](../security.md). + +```php +$protection = $client->api('repo')->protection()->show('twbs', 'bootstrap', 'master'); +``` + +### Update branch protection + +> Requires [authentication](../security.md). + +```php +$protection = $client->api('repo')->protection()->show('twbs', 'bootstrap', 'master', $params); +``` From 3c426b7fdcfd45b4d0a9246997cc804998b0cf34 Mon Sep 17 00:00:00 2001 From: Bob Eagan Date: Tue, 18 Apr 2017 10:48:43 -0700 Subject: [PATCH 2/2] example params for branch protection --- doc/repo/protection.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/repo/protection.md b/doc/repo/protection.md index e6a0aa938a3..89a7fc550b3 100644 --- a/doc/repo/protection.md +++ b/doc/repo/protection.md @@ -20,6 +20,16 @@ $protection = $client->api('repo')->protection()->show('twbs', 'bootstrap', 'mas > Requires [authentication](../security.md). +For the full list of parameters see https://developer.github.com/v3/repos/branches/#parameters-1 + ```php +$params = [ + 'required_status_checks' => null, + 'required_pull_request_reviews' => [ + 'include_admins' => true, + ], + 'enforce_admins' => true, + 'restrictions' => null, +]; $protection = $client->api('repo')->protection()->show('twbs', 'bootstrap', 'master', $params); ```