How to use the oncall.bin.scheduler.load_scheduler function in oncall

To help you get started, we’ve selected a few oncall examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linkedin / oncall / src / oncall / api / v0 / preview.py View on Github external
def on_get(req, resp, schedule_id):
    """
    Run the scheduler on demand from a given point in time. Unlike populate it doen't permanently delete or insert anything.
    """
    start_time = float(req.get_param('start', required=True))

    connection = db.connect()
    cursor = connection.cursor(db.DictCursor)
    cursor.execute('''SELECT `scheduler`.`name` FROM `schedule`
                      JOIN `scheduler` ON `schedule`.`scheduler_id` = `scheduler`.`id`
                      WHERE `schedule`.`id` = %s''',
                   schedule_id)
    if cursor.rowcount == 0:
        raise HTTPNotFound()
    scheduler_name = cursor.fetchone()['name']
    scheduler = load_scheduler(scheduler_name)
    schedule = get_schedules({'id': schedule_id})[0]
    check_team_auth(schedule['team'], req)
    scheduler.preview(schedule, start_time, (connection, cursor), req, resp)
    cursor.close()
    connection.close()
github linkedin / oncall / src / oncall / api / v0 / populate.py View on Github external
:statuscode 400: Validation checks failed
    """
    # TODO: add images to docstring because it doesn't make sense
    data = load_json_body(req)
    start_time = data['start']

    connection = db.connect()
    cursor = connection.cursor(db.DictCursor)
    cursor.execute('''SELECT `scheduler`.`name` FROM `schedule`
                      JOIN `scheduler` ON `schedule`.`scheduler_id` = `scheduler`.`id`
                      WHERE `schedule`.`id` = %s''',
                   schedule_id)
    if cursor.rowcount == 0:
        raise HTTPNotFound()
    scheduler_name = cursor.fetchone()['name']
    scheduler = load_scheduler(scheduler_name)
    schedule = get_schedules({'id': schedule_id})[0]
    check_team_auth(schedule['team'], req)
    scheduler.populate(schedule, start_time, (connection, cursor))
    cursor.close()
    connection.close()