Added methods to protect and unprotect branches in from the API

Fixes #1947