<s> from sahara . api import acl <EOL> from sahara . service . api . v2 import images as api <EOL> from sahara . service import validation as v <EOL> from sahara . service . validations import images as v_images <EOL> import sahara . utils . api as u <EOL> rest = u . RestV2 ( '<STR_LIT>' , __name__ ) <EOL> @ rest . get ( '<STR_LIT>' ) <EOL> @ acl . enforce ( "<STR_LIT>" ) <EOL> def images_list ( ) : <EOL> tags = u . get_request_args ( ) . getlist ( '<STR_LIT>' ) <EOL> name = u . get_request_args ( ) . get ( '<STR_LIT:name>' , None ) <EOL> return u . render ( images = [ i . dict for i in api . get_images ( name , tags ) ] ) <EOL> @ rest . get ( '<STR_LIT>' ) <EOL> @ acl . enforce ( "<STR_LIT>" ) <EOL> @ v . check_exists ( api . get_image , id = '<STR_LIT>' ) <EOL> def images_get ( image_id ) : <EOL> return u . render ( api . get_registered_image ( id = image_id ) . wrapped_dict ) <EOL> @ rest . post ( '<STR_LIT>' ) <EOL> @ acl . enforce ( "<STR_LIT>" ) <EOL> @ v . check_exists ( api . get_image , id = '<STR_LIT>' ) <EOL> @ v . validate ( v_images . image_register_schema , v_images . check_image_register ) <EOL> def images_set ( image_id , data ) : <EOL> return u . render ( api . register_image ( image_id , ** data ) . wrapped_dict ) <EOL> @ rest . delete ( '<STR_LIT>' ) <EOL> @ acl . enforce ( "<STR_LIT>" ) <EOL> @ v . check_exists ( api . get_image , id = '<STR_LIT>' ) <EOL> def images_unset ( image_id ) : <EOL> api . unregister_image ( image_id ) <EOL> return u . render ( ) <EOL> @ rest . post ( '<STR_LIT>' ) <EOL> @ acl . enforce ( "<STR_LIT>" ) <EOL> @ v . check_exists ( api . get_image , id = '<STR_LIT>' ) <EOL> @ v . validate ( v_images . image_tags_schema , v_images . check_tags ) <EOL> def image_tags_add ( image_id , data ) : <EOL> return u . render ( api . add_image_tags ( image_id , ** data ) . wrapped_dict ) <EOL> @ rest . post ( '<STR_LIT>' ) <EOL> @ acl . enforce ( "<STR_LIT>" ) <EOL> @ v . check_exists ( api . get_image , id = '<STR_LIT>' ) <EOL> @ v . validate ( v_images . image_tags_schema ) <EOL> def image_tags_delete ( image_id , data ) : <EOL> return u . render ( api . remove_image_tags ( image_id , ** data ) . wrapped_dict ) </s>
