<s> from . helpers import ResourceBase , IterableResource , Nested <EOL> from . errors import ok_or_error , response_or_error <EOL> from . compat import update_doc <EOL> API_NAME = '<STR_LIT>' <EOL> API_VERSION = '<STR_LIT:1.0>' <EOL> API_OVERRIDE_PATH = '<STR_LIT>' . format ( API_NAME , API_VERSION ) <EOL> class Permitted ( ResourceBase , IterableResource ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , url , client , parent ) : <EOL> ResourceBase . __init__ ( self , url , client , parent , API_OVERRIDE_PATH ) <EOL> update_doc ( Permitted . all , """<STR_LIT>""" ) <EOL> class Restriction ( ResourceBase ) : <EOL> def __init__ ( self , id , url , client , parent ) : <EOL> super ( Restriction , self ) . __init__ ( url , client , parent , API_OVERRIDE_PATH ) <EOL> self . _id = id <EOL> @ response_or_error <EOL> def get ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _client . get ( self . url ( ) ) <EOL> @ ok_or_error <EOL> def delete ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _client . delete ( self . url ( ) ) <EOL> @ response_or_error <EOL> def update ( self , value , users = None , groups = None , pattern = False ) : <EOL> """<STR_LIT>""" <EOL> data = dict ( type = ( '<STR_LIT>' if pattern else '<STR_LIT>' ) , value = value ) <EOL> if users is not None : <EOL> data [ '<STR_LIT>' ] = users <EOL> if groups is not None : <EOL> data [ '<STR_LIT>' ] = groups <EOL> return self . _client . put ( self . url ( "<STR_LIT>" ) , data = data ) <EOL> class Restricted ( ResourceBase , IterableResource ) : <EOL> def __init__ ( self , url , client , parent ) : <EOL> ResourceBase . __init__ ( self , url , client , parent , API_OVERRIDE_PATH ) <EOL> def __getitem__ ( self , item ) : <EOL> return Restriction ( item , self . url ( item ) , self . _client , self ) <EOL> @ response_or_error <EOL> def create ( self , value , users = None , groups = None , pattern = False ) : <EOL> """<STR_LIT>""" <EOL> data = dict ( type = ( '<STR_LIT>' if pattern else '<STR_LIT>' ) , value = value ) <EOL> if users is not None : <EOL> data [ '<STR_LIT>' ] = users <EOL> if groups is not None : <EOL> data [ '<STR_LIT>' ] = groups <EOL> return self . _client . post ( self . url ( "<STR_LIT>" ) , data = data ) <EOL> update_doc ( Restricted . all , """<STR_LIT>""" ) <EOL> class BranchPermissions ( ResourceBase ) : <EOL> """<STR_LIT>""" <EOL> permitted = Nested ( Permitted ) <EOL> restricted = Nested ( Restricted ) </s>
