def check_status_code(response, codes=None):
codes = codes or [httplib.OK]<EOL>checker = (<EOL>codes<EOL>if callable(codes)<EOL>else lambda resp: resp.status_code in codes<EOL>)<EOL>if not checker(response):<EOL><INDENT>raise exceptions.ApiError(response, response.json())<EOL><DEDENT>
Check HTTP status code and raise exception if incorrect.

    :param Response response: HTTP response
    :param codes: List of accepted codes or callable
    :raises: ApiError if code invalid