def METHOD_NAME(user, job_id):
    """Get all jobstates."""
    args = check_and_get_args(flask.request.args.to_dict())
    job = base.get_resource_orm(models2.Job, job_id)
    if user.is_not_super_admin() and user.is_not_read_only_user() and user.is_not_epm():
        if job.team_id not in user.teams_ids:
            raise dci_exc.Unauthorized()
    query = flask.g.session.query(models2.Jobstate)
    query = query.filter(models2.Jobstate.job_id == job_id).options(
        sa_orm.selectinload("files")
    )
    query = declarative.handle_args(query, models2.Jobstate, args)
    nb_jobstates = query.count()
    query = declarative.handle_pagination(query, args)
    jobstates = [js.serialize() for js in query.all()]
    return flask.jsonify({"jobstates": jobstates, "_meta": {"count": nb_jobstates}})