Back to the "Repos API" | Back to the navigation
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:
$client->api('repo')->protection()->configure();
Requires authentication.
$protection = $client->api('repo')->protection()->show('twbs', 'bootstrap', 'master');
Requires authentication.
For the full list of parameters see https://developer.github.com/v3/repos/branches/#parameters-1
$params = [
'required_status_checks' => null,
'required_pull_request_reviews' => [
'include_admins' => true,
],
'enforce_admins' => true,
'restrictions' => null,
];
$protection = $client->api('repo')->protection()->update('twbs', 'bootstrap', 'master', $params);
Requires authentication.
$protection = $client->api('repo')->protection()->remove('twbs', 'bootstrap', 'master');
Requires authentication.
$protection = $client->api('repo')->protection()->showStatusChecks('twbs', 'bootstrap', 'master');
Requires authentication.
$params = [
'strict' => true,
'contexts' => [
'continuous-integration/travis-ci',
],
];
$protection = $client->api('repo')->protection()->updateStatusChecks('twbs', 'bootstrap', 'master', $params);
Requires authentication.
$protection = $client->api('repo')->protection()->removeStatusChecks('twbs', 'bootstrap', 'master');
Requires authentication.
$protection = $client->api('repo')->protection()->showStatusChecksContexts('twbs', 'bootstrap', 'master');
Requires authentication.
$params = [
'continuous-integration/travis-ci',
];
$protection = $client->api('repo')->protection()->replaceStatusChecksContexts('twbs', 'bootstrap', 'master', $params);
Requires authentication.
$params = [
'continuous-integration/jenkins',
];
$protection = $client->api('repo')->protection()->addStatusChecksContexts('twbs', 'bootstrap', 'master', $params);
Requires authentication.
$params = [
'continuous-integration/jenkins',
];
$protection = $client->api('repo')->protection()->removeStatusChecksContexts('twbs', 'bootstrap', 'master', $params);
Requires authentication.
$protection = $client->api('repo')->protection()->showPullRequestReviewEnforcement('twbs', 'bootstrap', 'master');
Requires authentication with admin access and branch protection to be enabled.
$params = [
'dismissal_restrictions' => [
'users' => [
'octocat',
],
'teams' => [
'justice-league',
],
],
'dismiss_stale_reviews' => true,
'require_code_owner_reviews' => true,
];
$protection = $client->api('repo')->protection()->updatePullRequestReviewEnforcement('twbs', 'bootstrap', 'master', $params);
Requires authentication.
$protection = $client->api('repo')->protection()->removePullRequestReviewEnforcement('twbs', 'bootstrap', 'master');
Requires authentication.
$protection = $client->api('repo')->protection()->showAdminEnforcement('twbs', 'bootstrap', 'master');
Requires authentication with admin access and branch protection to be enabled.
$protection = $client->api('repo')->protection()->addAdminEnforcement('twbs', 'bootstrap', 'master');
Requires authentication with admin access and branch protection to be enabled.
$protection = $client->api('repo')->protection()->removeAdminEnforcement('twbs', 'bootstrap', 'master');
Requires authentication and is only available for organization-owned repositories.
$protection = $client->api('repo')->protection()->showRestrictions('twbs', 'bootstrap', 'master');
Requires authentication and is only available for organization-owned repositories.
$protection = $client->api('repo')->protection()->removeRestrictions('twbs', 'bootstrap', 'master');
Requires authentication and is only available for organization-owned repositories.
$protection = $client->api('repo')->protection()->showTeamRestrictions('twbs', 'bootstrap', 'master');
Requires authentication and is only available for organization-owned repositories.
$params = [
'justice-league',
];
$protection = $client->api('repo')->protection()->replaceTeamRestrictions('twbs', 'bootstrap', 'master', $params);
Requires authentication and is only available for organization-owned repositories.
$params = [
'justice-league',
];
$protection = $client->api('repo')->protection()->addTeamRestrictions('twbs', 'bootstrap', 'master', $params);
Requires authentication and is only available for organization-owned repositories.
$params = [
'octocats',
];
$protection = $client->api('repo')->protection()->removeTeamRestrictions('twbs', 'bootstrap', 'master', $params);
Requires authentication and is only available for organization-owned repositories.
$protection = $client->api('repo')->protection()->showUserRestrictions('twbs', 'bootstrap', 'master');
Requires authentication and is only available for organization-owned repositories.
$params = [
'octocat',
];
$protection = $client->api('repo')->protection()->replaceUserRestrictions('twbs', 'bootstrap', 'master', $params);
Requires authentication and is only available for organization-owned repositories.
$params = [
'octocat',
];
$protection = $client->api('repo')->protection()->addUserRestrictions('twbs', 'bootstrap', 'master', $params);
Requires authentication and is only available for organization-owned repositories.
$params = [
'defunkt',
];
$protection = $client->api('repo')->protection()->removeUserRestrictions('twbs', 'bootstrap', 'master', $params);