<s> """<STR_LIT>""" <EOL> from consulate . api import base <EOL> from consulate import exceptions <EOL> class ACL ( base . Endpoint ) : <EOL> """<STR_LIT>""" <EOL> def create ( self , name , acl_type = '<STR_LIT>' , rules = None ) : <EOL> """<STR_LIT>""" <EOL> payload = { '<STR_LIT:Name>' : name , '<STR_LIT>' : acl_type } <EOL> if rules : <EOL> payload [ '<STR_LIT>' ] = rules <EOL> response = self . _adapter . put ( self . _build_uri ( [ '<STR_LIT>' ] ) , payload ) <EOL> if response . status_code == <NUM_LIT> : <EOL> raise exceptions . Forbidden ( response . body ) <EOL> return response . body . get ( '<STR_LIT>' ) or None <EOL> def clone ( self , acl_id ) : <EOL> """<STR_LIT>""" <EOL> response = self . _adapter . put ( self . _build_uri ( [ '<STR_LIT>' , acl_id ] ) ) <EOL> if response . status_code == <NUM_LIT> : <EOL> raise exceptions . NotFound ( response . body ) <EOL> return response . body . get ( '<STR_LIT>' ) <EOL> def destroy ( self , acl_id ) : <EOL> """<STR_LIT>""" <EOL> response = self . _adapter . put ( self . _build_uri ( [ '<STR_LIT>' , acl_id ] ) ) <EOL> if response . status_code == <NUM_LIT> : <EOL> raise exceptions . Forbidden ( response . body ) <EOL> return response . status_code == <NUM_LIT:200> <EOL> def info ( self , acl_id ) : <EOL> """<STR_LIT>""" <EOL> result = self . _get ( [ '<STR_LIT:info>' , acl_id ] , raise_on_404 = True ) <EOL> if result is None : <EOL> raise exceptions . NotFound ( ) <EOL> return result <EOL> def list ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _get ( [ '<STR_LIT:list>' ] ) <EOL> def update ( self , acl_id , name , acl_type = '<STR_LIT>' , rules = None ) : <EOL> """<STR_LIT>""" <EOL> payload = { '<STR_LIT>' : acl_id , '<STR_LIT:Name>' : name , '<STR_LIT>' : acl_type } <EOL> if rules : <EOL> payload [ '<STR_LIT>' ] = rules <EOL> response = self . _adapter . put ( self . _build_uri ( [ '<STR_LIT>' ] ) , payload ) <EOL> if response . status_code == <NUM_LIT> : <EOL> raise exceptions . Forbidden ( response . body ) <EOL> return response . status_code == <NUM_LIT:200> </s>
