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..89a7fc550b3 --- /dev/null +++ b/doc/repo/protection.md @@ -0,0 +1,35 @@ +## 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). + +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); +```