def handle_get(): gid = get_param('id', type='uuid', required=True) include = get_param('include', type='enum+', container=ReleaseIncludes.parse) if include.artist and include.artists: abort(response_error(INCLUDE_DEPENDENCY_ERROR, 'include=artist and include=artists are mutually exclusive')) release = get_release_by_gid(query_release(g.db, include), gid) if release is None: abort(response_error(NOT_FOUND_ERROR, 'release not found')) if include.relationships: load_links(g.db, [release], include.relationships) return response_ok(release=serialize_release(release, include))
def get_search_params(): page_token = get_param('page_token', type='text') limit = get_param('results', type='int', default=5) if limit < 1 or limit > 50: raise abort(response_error(INVALID_PARAMETER_ERROR, 'results must be between 1 and 50')) page = parse_page_token(page_token, limit) if page is None: raise abort(response_error(INVALID_PARAMETER_ERROR, 'invalid page token')) if limit != page.limit: raise abort(response_error(INVALID_PARAMETER_ERROR, 'results does not match the page token')) return page
def get_plain_artist_by_gid_or_error(gid): query = g.db.query(Artist).\ options(load_only("id", "gid")) artist = get_artist_by_gid(query, gid) if artist is None: abort(response_error(NOT_FOUND_ERROR, 'artist not found')) return artist
def handle_get(): gid = get_param('id', type='uuid', required=True) include = get_param('include', type='enum+', container=ReleaseGroupIncludes.parse) release_group = get_release_group_by_gid(query_release_group(g.db, include), gid) if release_group is None: abort(response_error(NOT_FOUND_ERROR, 'release group not found')) return response_ok(release_group=serialize_release_group(release_group, include))
def handle_get(): gid = get_param('id', type='uuid', required=True) include = get_param('include', type='enum+', container=WorkIncludes.parse) work = get_work_by_gid(query_work(g.db, include), gid) if work is None: abort(response_error(NOT_FOUND_ERROR, 'work not found')) if include.relationships: load_links(g.db, [work], include.relationships) return response_ok(work=serialize_work(work, include))
def handle_get(): gid = get_param('id', type='uuid', required=True) include = get_param('include', type='enum+', container=PlaceIncludes.parse) place = get_place_by_gid(query_place(g.db, include), gid) if place is None: abort(response_error(NOT_FOUND_ERROR, 'place not found')) if include.area: load_areas(g.db, [place], include.area) if include.relationships: load_links(g.db, [place], include.relationships) return response_ok(place=serialize_place(place, include))
def handle_get(): gid = get_param('id', type='uuid', required=True) include = get_param('include', type='enum+', container=ArtistIncludes.parse) artist = get_artist_by_gid(query_artist(g.db, include), gid) if artist is None: abort(response_error(NOT_FOUND_ERROR, 'artist not found')) if include.areas: load_areas(g.db, [artist], include.areas) if include.relationships: load_links(g.db, [artist], include.relationships) return response_ok(artist=serialize_artist(artist, include))