<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def RebootInstance(r, instance, reboot_type=None, ignore_secondaries=False, dry_run=False):
 """ Reboots an instance. @type instance: str @param instance: instance to rebot @type reboot_type: str @param reboot_type: one of: hard, soft, full @type ignore_secondaries: bool @param ignore_secondaries: if True, ignores errors for the secondary node while re-assembling disks (in hard-reboot mode only) @type dry_run: bool @param dry_run: whether to perform a dry run """


    query = {
        "ignore_secondaries": ignore_secondaries,
        "dry-run": dry_run,
    }

    if reboot_type:
        if reboot_type not in ("hard", "soft", "full"):
            raise GanetiApiError("reboot_type must be one of 'hard',"
                                 " 'soft', or 'full'")
        query["type"] = reboot_type

    return r.request("post", "/2/instances/%s/reboot" % instance, query=query)