@@ -399,18 +399,27 @@ def branch(self, name):
399
399
json = self ._json (self ._get (url ), 200 )
400
400
return self ._instance_or_null (Branch , json )
401
401
402
- def branches (self , number = - 1 , etag = None ):
402
+ def branches (self , number = - 1 , protected = False , etag = None ):
403
403
r"""Iterate over the branches in this repository.
404
404
405
405
:param int number: (optional), number of branches to return. Default:
406
406
-1 returns all branches
407
+ :param bool protected: (optional), True lists only protected branches.
408
+ Default: False
407
409
:param str etag: (optional), ETag from a previous request to the same
408
410
endpoint
409
411
:returns: generator of
410
412
:class:`Branch <github3.repos.branch.Branch>`\ es
411
413
"""
412
414
url = self ._build_url ('branches' , base_url = self ._api )
413
- return self ._iter (int (number ), url , Branch , etag = etag )
415
+
416
+ # The Accept header will likely be removable once the feature is out of
417
+ # preview mode. See: http://git.io/v4O1e
418
+ headers = {'Accept' : 'application/vnd.github.loki-preview+json' }
419
+
420
+ params = {'protected' : '1' } if protected else None
421
+ return self ._iter (int (number ), url , Branch , params , etag = etag ,
422
+ headers = headers )
414
423
415
424
def code_frequency (self , number = - 1 , etag = None ):
416
425
"""Iterate over the code frequency per week.
0 commit comments