import hatchet.db.models as db from hatchet.resources.schemas.schemas import DivisionSchema from hatchet.apis.api_v1 import api_manager ns_divisions = api_manager.add_resource( name="divisions", resource=db.Division, schema=DivisionSchema, description="Sub-conference organizations of teams")
from flask_restplus import Resource import hatchet.db.models as models from hatchet.apis.api_v1 import api_manager from hatchet.apis.serializers import ranking import hatchet.resources.schemas.schemas as schemas from hatchet.errors import InvalidArgumentError ns_polls = api_manager.add_resource( name="polls", resource=models.Poll, schema=schemas.PollSchema, description="NCAA Football Polls / Rankings" ) @ns_polls.route("/<int:id>/rankings/season/<int:season>/week/<int:week>") @ns_polls.param("id", "the poll identifier") @ns_polls.param("season", "season") @ns_polls.param("week", "week") class ExternalTeamLookup(Resource): @ns_polls.doc("lookup rankings for a specific poll and week") @ns_polls.marshal_with(ranking) def get(self, id:int, season:int, week:int): wk = models.Week.query.filter_by(season=season, number=week).first() if not wk: raise InvalidArgumentError( f"you passed an invalid season {season} or week {week}" ) return models.Ranking.query\ .filter_by(poll_id=id)\
import hatchet.db.models as db from hatchet.apis.api_v1 import api_manager import hatchet.resources.schemas.schemas as schemas ns = api_manager.add_resource( name="players", resource=db.Player, schema=schemas.PlayerSchema, description="Football Player management endpoints")
import hatchet.db.models as db from hatchet.apis.api_v1 import api_manager import hatchet.resources.schemas.schemas as schemas ns_networks = api_manager.add_resource(name="networks", resource=db.Network, schema=schemas.NetworkSchema, description="Media Networks")
from flask_restplus import Resource, fields, inputs import logging import hatchet.db.models as db import hatchet.db.meta_models as mm import hatchet.db.crud.games as game_queries import hatchet.db.crud.base as queries from hatchet.apis.api_v1 import api_manager from hatchet.db.queries.lookups import lookup_team_by_external_id from hatchet.apis.serializers import game, player, team, record from hatchet.resources.schemas.schemas import TeamSchema from hatchet.util import default_list_parser logger = logging.getLogger(__name__) ns_teams = api_manager.add_resource( name="teams", resource=db.Team, schema=TeamSchema, description="NCAA Football Teams representing a University", parser_args=["code", "name", "short_name"]) parser = default_list_parser(namespace=ns_teams) parser.add_argument("code", type=str, required=False) team_games_args = ns_teams.parser() team_games_args.add_argument("season", type=int, required=False) team_games_args.add_argument("date", type=inputs.date_from_iso8601, required=False) season_arg = ns_teams.parser() season_arg.add_argument("season", type=int, required=False) record_arg = ns_teams.parser()
import hatchet.db.models as db from hatchet.apis.api_v1 import api_manager import hatchet.resources.schemas.schemas as schemas ns_coaches = api_manager.add_resource( name="coaches", resource=db.Coach, schema=schemas.CoachSchema, description="NCAA Football Coaches" )
import hatchet.db.models as db from hatchet.apis.api_v1 import api_manager import hatchet.resources.schemas.schemas as schemas ns = api_manager.add_resource( name="bookmakers", resource=db.Bookmaker, schema=schemas.BookmakerSchema, description="Sports Bookmaker management resources" )
import hatchet.db.models as db from hatchet.apis.api_v1 import api_manager import hatchet.resources.schemas.schemas as schemas ns = api_manager.add_resource(name="lines", resource=db.Line, schema=schemas.LineSchema, description="Sports Gambling lines", parser_args=["game_id", "team_id"])
import hatchet.db.models as db from hatchet.apis.api_v1 import api_manager import hatchet.resources.schemas.schemas as schemas ns = api_manager.add_resource(name="stadiums", resource=db.Stadium, schema=schemas.StadiumSchema, description="Football Stadium operations")
from flask_restplus import Resource import logging import hatchet.db.models as db import hatchet.db.crud.base as queries from hatchet.resources.schemas.schemas import ConferenceSchema, SubdivisionSchema, TeamSchema from hatchet.apis.api_v1 import api_manager from hatchet.apis.serializers import conference, team logger = logging.getLogger(__name__) ns_subdivisions = api_manager.add_resource(name="subdivisions", resource=db.Subdivision, schema=SubdivisionSchema, description="NCAA Subdivisions") @ns_subdivisions.route("/<int:id>/conferences") @ns_subdivisions.param("id", "the subdivision identifier") class SubdivisionConferences(Resource): @ns_subdivisions.doc("get subdivision conferences") @ns_subdivisions.marshal_with(conference) def get(self, id: int): subdiv = queries.get_resource(id, db.Subdivision) return subdiv.conferences @ns_subdivisions.route("/<int:id>/teams") @ns_subdivisions.param("id", "the subdivision identifier") class SubdivisionTeams(Resource): @ns_subdivisions.doc("get teams beloning to a subdivision") @ns_subdivisions.marshal_with(team) def get(self, id: int):
from flask_restplus import Resource from sqlalchemy import desc import hatchet.db.models as models from hatchet.apis.api_v1 import api_manager from hatchet.apis.serializers import ranking, game from hatchet.db.crud.games import list_week_games import hatchet.resources.schemas.schemas as schemas from hatchet.errors import InvalidArgumentError ns_weeks = api_manager.add_resource( name="weeks", resource=models.Week, schema=schemas.WeekSchema, description="NCAA Football Weeks / Rankings", parser_args=["season"]) @ns_weeks.route("/seasons") class SeasonCollection(Resource): @ns_weeks.doc("list available seasons") def get(self): return [ x.id for x in models.Season.query.order_by(desc( models.Season.id)).all() ] @ns_weeks.route("/<int:id>/games") @ns_weeks.param("id", "week identifier for game filtering") class WeeklyGameCollection(Resource): @ns_weeks.marshal_with(game)
from flask_restplus import Resource from hatchet.apis.serializers import team import hatchet.db.models as db import hatchet.db.crud.base as queries from hatchet.resources.schemas.schemas import ConferenceSchema from hatchet.apis.api_v1 import api_manager ns_conferences = api_manager.add_resource( name="conferences", resource=db.Conference, schema=ConferenceSchema, description="NCAA Football Conferences") @ns_conferences.route("/<int:id>/teams") @ns_conferences.param("id", "the conference identifier") class ConferenceTeams(Resource): @ns_conferences.doc("get conference teams") @ns_conferences.marshal_with(team) def get(self, id: int): conf = queries.get_resource(id, db.Conference) return conf.members
import hatchet.db.models as db from hatchet.apis.api_v1 import api_manager import hatchet.resources.schemas.schemas as schemas ns_ratings = api_manager.add_resource(name="ratings", resource=db.Rating, schema=schemas.RatingSchema, description="TV Ratings")
from flask_restplus import Namespace, Resource import hatchet.db.meta_models as db from hatchet.resources.schemas.schemas import DataSourceSchema from hatchet.apis.api_v1 import api_manager ns_data_sources = api_manager.add_resource(name="dataSources", resource=db.DataSource, schema=DataSourceSchema, description="External data sources")