@@ -255,6 +255,28 @@ List languages for the specified repository. The value on the right of a languag
255
255
256
256
GET /repos/:owner/:repo/branches
257
257
258
+ ###Parameters
259
+
260
+ Name | Type | Description
261
+ -----|------|-------------
262
+ ` protected ` |` string ` | Set to` 1 ` or` true ` to only return protected branches.
263
+
264
+ {{#tip}}
265
+
266
+ <a name =" preview-period " ></a >
267
+
268
+ The` protected ` parameter is currently available for developers to preview.
269
+ During the preview period, the API may change without advance notice.
270
+ Please see the[ blog post] ( /changes/2015-11-11-protected-branches-api ) for full details.
271
+
272
+ To access the API during the preview period, you must provide a custom[ media type] ( /v3/media ) in the` Accept ` header:
273
+
274
+ application/vnd.github.loki-preview+json
275
+
276
+ The` protection ` key will only be present in branch payloads if this header is passed.
277
+
278
+ {{/tip}}
279
+
258
280
###Response
259
281
260
282
<%= headers 200,: pagination => default_pagination_rels %>
@@ -266,9 +288,81 @@ List languages for the specified repository. The value on the right of a languag
266
288
267
289
###Response
268
290
291
+ {{#tip}}
292
+
293
+ <a name =" preview-period " ></a >
294
+
295
+ The Protect Branch API is currently available for developers to preview.
296
+ During the preview period, the API may change without advance notice.
297
+ Please see the[ blog post] ( /changes/2015-11-11-protected-branches-api ) for full details.
298
+
299
+ To access the API during the preview period, you must provide a custom[ media type] ( /v3/media ) in the` Accept ` header:
300
+
301
+ application/vnd.github.loki-preview+json
302
+
303
+ The` protection ` key will only be present in branch payloads if this header is passed.
304
+
305
+ {{/tip}}
306
+
269
307
<%= headers 200 %>
270
308
<%= json(: branch ) %>
271
309
310
+ ##Enabling and disabling branch protection
311
+
312
+ {{#tip}}
313
+
314
+ <a name =" preview-period " ></a >
315
+
316
+ The Protect Branch API is currently available for developers to preview.
317
+ During the preview period, the API may change without advance notice.
318
+ Please see the[ blog post] ( /changes/2015-11-11-protected-branches-api ) for full details.
319
+
320
+ To access the API during the preview period, you must provide a custom[ media type] ( /v3/media ) in the` Accept ` header:
321
+
322
+ application/vnd.github.loki-preview+json
323
+
324
+ {{/tip}}
325
+
326
+ Protecting a branch requires admin access.
327
+
328
+ PATCH /repos/:owner/:repo/branches/:branch
329
+
330
+ ###Input
331
+
332
+ You need to pass a` protection ` object.
333
+
334
+ Name | Type | Description
335
+ -----|------|-------------
336
+ ` enabled ` |` boolean ` |** Required** . Should this branch be protected or not
337
+ ` required_status_checks ` |` object ` | Configure required status checks here
338
+
339
+ The` required_status_checks ` object must have the following keys:
340
+
341
+ Name | Type | Description
342
+ -----|------|-------------
343
+ ` enforcement_level ` |` string ` |** Required** . Who required status checks apply to. Options are` off ` ,` non_admins ` or` everyone ` .
344
+ ` contexts ` |` array ` |** Required** . The list of required status checks to require in order to merge into this branch
345
+
346
+ The` enforcement_level ` key can have the following values:
347
+
348
+ Name | Description
349
+ ------|------------
350
+ ` off ` | Turn off required status checks for this branch.
351
+ ` non_admins ` | Required status checks will be enforced for non-admins.
352
+ ` everyone ` | Required status checks will be enforced for everyone (including admins)
353
+
354
+ ####Example
355
+
356
+ <%= json\
357
+ "protection" => {
358
+ "enabled" => true,
359
+ "required_status_checks" => {
360
+ "enforcement_level" => "everyone",
361
+ "contexts" =>[ "continuous-integration/travis-ci"]
362
+ }
363
+ }
364
+ %>
365
+
272
366
##Delete a Repository
273
367
274
368
Deleting a repository requires admin access. If OAuth is used, the