<s> import pecan <EOL> from pecan import core <EOL> from pecan import rest <EOL> from wsme import types as wtypes <EOL> import wsmeext . pecan as wsme_pecan <EOL> from solum . api . controllers . camp . v1_1 . datamodel import type_definitions as model <EOL> from solum . api . controllers . camp . v1_1 import uris <EOL> from solum . api . controllers import common_types <EOL> from solum . api . handlers . camp import type_definition_handler <EOL> from solum . common import exception <EOL> DESCRIPTION_STRING = "<STR_LIT>" <EOL> class TypeDefinitionsController ( rest . RestController ) : <EOL> """<STR_LIT>""" <EOL> @ exception . wrap_wsme_controller_exception <EOL> @ wsme_pecan . wsexpose ( model . TypeDefinition , wtypes . text ) <EOL> def get_one ( self , type_def_name ) : <EOL> handler = ( type_definition_handler . <EOL> TypeDefinitionHandler ( pecan . request . security_context ) ) <EOL> raw_def = handler . get ( type_def_name ) <EOL> if not raw_def : <EOL> core . abort ( <NUM_LIT> , <EOL> '<STR_LIT>' % <EOL> type_def_name ) <EOL> return raw_def . fix_uris ( pecan . request . host_url ) <EOL> @ exception . wrap_wsme_controller_exception <EOL> @ wsme_pecan . wsexpose ( model . TypeDefinitions ) <EOL> def get ( self ) : <EOL> links = [ ] <EOL> handler = ( type_definition_handler . <EOL> TypeDefinitionHandler ( pecan . request . security_context ) ) <EOL> def_list = handler . get_all ( ) <EOL> for tdef in def_list : <EOL> links . append ( common_types . Link ( href = uris . TYPE_DEF_URI_STR % <EOL> ( pecan . request . host_url , tdef . uri ) , <EOL> target_name = tdef . name ) ) <EOL> return model . TypeDefinitions ( uri = uris . TYPE_DEFS_URI_STR % <EOL> pecan . request . host_url , <EOL> name = '<STR_LIT>' , <EOL> type = '<STR_LIT>' , <EOL> description = DESCRIPTION_STRING , <EOL> type_definition_links = links ) </s>
