3 @qhc! @sddlmZddlmZddlmZmZmZddlm Z m Z ddddgZ Gd dde eZ Gd dde eZ Gd dde eZGd dde eZd S))cli) exceptions)RequiredOptional RESTManager RESTObject) NoUpdateMixinObjectDeleteMixin ProjectBranchProjectBranchManagerProjectProtectedBranchProjectProtectedBranchManagerc@sTeZdZdZejded ejej d ddZ ejdejej ddZ d S) r namedevelopers_can_pushdevelopers_can_mergeFcKsR|jjdd}d|jj|f}||d}|jjj|fd|i|d|jd<dS) a*Protect the branch. Args: developers_can_push (bool): Set to True if developers are allowed to push to the branch developers_can_merge (bool): Set to True if developers are allowed to merge to the branch **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabProtectError: If the branch could not be protected /z%2Fz %s/%s/protect)rr post_dataT protectedN)get_idreplacemanagerpathgitlabhttp_put_attrs)selfrrkwargsidrrrY/home/ec2-user/environment/venv/lib/python3.6/dist-packages/gitlab/v4/objects/branches.pyprotects zProjectBranch.protectcKs@|jjdd}d|jj|f}|jjj|f|d|jd<dS)aUnprotect the branch. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabProtectError: If the branch could not be unprotected rz%2Fz%s/%s/unprotectFrN)rrrrrrr)rrrrrrr unprotect,s zProjectBranch.unprotectN)rr)FF) __name__ __module__ __qualname___id_attrrZregister_custom_actiontupleexcZ on_http_errorZGitlabProtectErrorrr rrrrr s  c@s&eZdZdZeZddiZeddZdS) r z,/projects/%(project_id)s/repository/branches project_idrbranchref)requiredN)r(r)) r!r"r#_pathr _obj_cls_from_parent_attrsr _create_attrsrrrrr >sc@seZdZdZdS)r r N)r!r"r#r$rrrrr Esc @s(eZdZdZeZddiZeddd Zd S)r z+/projects/%(project_id)s/protected_branchesr'rr push_access_levelmerge_access_levelunprotect_access_levelallowed_to_pushallowed_to_mergeallowed_to_unprotectcode_owner_approval_required)r*optionalN)r )r/r0r1r2r3r4r5) r!r"r#r+r r,r-rr.rrrrr IsN)rrrr&Z gitlab.baserrrZ gitlab.mixinsrr__all__r r r r rrrrs  0