

def modify(name, **kwargs):
    "\n    Modify an existing job in the schedule\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' schedule.modify job1 function='test.ping' seconds=3600\n    "
    ret = {
        'comment': '',
        'changes': {
            
        },
        'result': True,
    }
    time_conflict = False
    for item in ['seconds', 'minutes', 'hours', 'days']:
        if ((item in kwargs) and ('when' in kwargs)):
            time_conflict = True
        if ((item in kwargs) and ('cron' in kwargs)):
            time_conflict = True
    if time_conflict:
        ret['result'] = False
        ret['comment'] = 'Error: Unable to use "seconds", "minutes", "hours", or "days" with "when" option.'
        return ret
    if (('when' in kwargs) and ('cron' in kwargs)):
        ret['result'] = False
        ret['comment'] = 'Unable to use "when" and "cron" options together.  Ignoring.'
        return ret
    current_schedule = list_(show_all=True, return_yaml=False)
    if (name not in current_schedule):
        ret['comment'] = 'Job {0} does not exist in schedule.'.format(name)
        ret['result'] = False
        return ret
    _current = current_schedule[name]
    if ('_seconds' in _current):
        _current['seconds'] = _current['_seconds']
        del _current['_seconds']
    _new = build_schedule_item(name, **kwargs)
    if (_new == _current):
        ret['comment'] = 'Job {0} in correct state'.format(name)
        return ret
    _current_lines = ['{0}:{1}\n'.format(key, value) for (key, value) in sorted(_current.items())]
    _new_lines = ['{0}:{1}\n'.format(key, value) for (key, value) in sorted(_new.items())]
    _diff = difflib.unified_diff(_current_lines, _new_lines)
    ret['changes']['diff'] = ''.join(_diff)
    if (('test' in kwargs) and kwargs['test']):
        ret['comment'] = 'Job: {0} would be modified in schedule.'.format(name)
    else:
        persist = True
        if ('persist' in kwargs):
            persist = kwargs['persist']
        if (name in list_(show_all=True, where='opts', return_yaml=False)):
            event_data = {
                'name': name,
                'schedule': _new,
                'func': 'modify',
                'persist': persist,
            }
        elif (name in list_(show_all=True, where='pillar', return_yaml=False)):
            event_data = {
                'name': name,
                'schedule': _new,
                'where': 'pillar',
                'func': 'modify',
                'persist': False,
            }
        out = __salt__['event.fire'](event_data, 'manage_schedule')
        if out:
            ret['comment'] = 'Modified job: {0} in schedule.'.format(name)
        else:
            ret['comment'] = 'Failed to modify job {0} in schedule.'.format(name)
            ret['result'] = False
    return ret

dataset/ETHPy150Open saltstack/salt/salt/modules/schedule.py modify/original