func (loc *BackupLocator) Cleanup(keepLast string, lineage string, options rsapi.APIParams) error {
	if keepLast == "" {
		return fmt.Errorf("keepLast is required")
	}
	if lineage == "" {
		return fmt.Errorf("lineage is required")
	}
	var params rsapi.APIParams
	var p rsapi.APIParams
	p = rsapi.APIParams{
		"keep_last": keepLast,
		"lineage":   lineage,
	}
	var cloudHrefOpt = options["cloud_href"]
	if cloudHrefOpt != nil {
		p["cloud_href"] = cloudHrefOpt
	}
	var dailiesOpt = options["dailies"]
	if dailiesOpt != nil {
		p["dailies"] = dailiesOpt
	}
	var monthliesOpt = options["monthlies"]
	if monthliesOpt != nil {
		p["monthlies"] = monthliesOpt
	}
	var skipDeletionOpt = options["skip_deletion"]
	if skipDeletionOpt != nil {
		p["skip_deletion"] = skipDeletionOpt
	}
	var weekliesOpt = options["weeklies"]
	if weekliesOpt != nil {
		p["weeklies"] = weekliesOpt
	}
	var yearliesOpt = options["yearlies"]
	if yearliesOpt != nil {
		p["yearlies"] = yearliesOpt
	}
	uri, err := loc.ActionPath("Backup", "cleanup")
	if err != nil {
		return err
	}
	req, err := loc.api.BuildHTTPRequest(uri.HTTPMethod, uri.Path, APIVersion, params, p)
	if err != nil {
		return err
	}
	resp, err := loc.api.PerformRequest(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		respBody, _ := ioutil.ReadAll(resp.Body)
		sr := string(respBody)
		if sr != "" {
			sr = ": " + sr
		}
		return fmt.Errorf("invalid response %s%s", resp.Status, sr)
	}
	return nil
}
func (loc *BackupLocator) Cleanup(keepLast string, lineage string, options rsapi.APIParams) error {
	if keepLast == "" {
		return fmt.Errorf("keepLast is required")
	}
	if lineage == "" {
		return fmt.Errorf("lineage is required")
	}
	var params rsapi.APIParams
	var p rsapi.APIParams
	p = rsapi.APIParams{
		"keep_last": keepLast,
		"lineage":   lineage,
	}
	var cloudHrefOpt = options["cloud_href"]
	if cloudHrefOpt != nil {
		p["cloud_href"] = cloudHrefOpt
	}
	var dailiesOpt = options["dailies"]
	if dailiesOpt != nil {
		p["dailies"] = dailiesOpt
	}
	var monthliesOpt = options["monthlies"]
	if monthliesOpt != nil {
		p["monthlies"] = monthliesOpt
	}
	var skipDeletionOpt = options["skip_deletion"]
	if skipDeletionOpt != nil {
		p["skip_deletion"] = skipDeletionOpt
	}
	var weekliesOpt = options["weeklies"]
	if weekliesOpt != nil {
		p["weeklies"] = weekliesOpt
	}
	var yearliesOpt = options["yearlies"]
	if yearliesOpt != nil {
		p["yearlies"] = yearliesOpt
	}
	uri, err := loc.ActionPath("Backup", "cleanup")
	if err != nil {
		return err
	}
	req, err := loc.api.BuildHTTPRequest(uri.HTTPMethod, uri.Path, APIVersion, params, p)
	if err != nil {
		return err
	}
	resp, err := loc.api.PerformRequest(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		respBody, _ := ioutil.ReadAll(resp.Body)
		sr := string(respBody)
		if sr != "" {
			sr = ": " + sr
		}
		return fmt.Errorf("invalid response %s%s", resp.Status, sr)
	}
	return nil
}
//===== Actions
// POST /api/backups/cleanup
//
// Deletes old backups that meet the given criteria. For example, if a user calls cleanup with keep monthlies set to 12,
// then the latest backup for each month, for 12 months, will be kept.
// All backups belong to a particular 'lineage'. Backups are not constrained to a specific cloud or a specific deployment.
// A lineage is account-specific. Hence, backups having the same lineage but belonging to different clouds are still considered
// for cleanup.
// If backups specific to a single cloud should be cleaned up, see the cloud_href parameter.
// Definitions:
// A snapshot is completed if its status is "available"
// A snapshot is committed if it has a tag "rs_backup:committed=true"
// A snapshot belongs to a backup "X" if it has a tag "rs_backup:backup_id=X"
// A snapshot is part of a backup with size "Y" if it has a tag "rs_backup:count=Y"
// A snapshot's position in a backup is "Z" if it has a tag "rs_backup:position=Z"
// Backups are of 3 types:
// Perfect backup: A backup which is completed (all the snapshots are completed) and committed (all the snapshots are committed) and the number of snapshots it found is equal to the number
// in the "rs_backup:count=" tag on each of the Snapshots.
// Imperfect backup: A backup which is not committed or if the number of snapshots it found is not equal to the number in the "rs_backup:count=" tag on each of the snapshots.
// Partial Perfect backup: A snapshot which is neither perfect nor imperfect
// An imperfect backup is picked up for cleanup only if there exists a perfect backup with a newer created_at timestamp.
// No constraints will be applied on such imperfect backups and all of them will be destroyed.
// For all the perfect backups, the constraints of keep_last and dailies etc. will be applied.
// The algorithm for choosing the perfect backups to keep is simple. It is the union of those set of backups if each of those conditions are applied
// independently. i.e backups_to_keep = backups_to_keep(keep_last) U backups_to_keep(dailies) U backups_to_keep(weeklies) U backups_to_keep(monthlies) U backups_to_keep(yearlies)
// Hence, it is important to "commit" a backup to make it eligible for cleanup.
// Using skip_deletion='true' attribute will return an index of what will be deleted when the action is run.
// The status code returned is 200 when using this parameter instead of 204.
// Required parameters:
// keep_last: The number of backups that should be kept.
// lineage: The lineage of the backups that are to be cleaned-up.
// Optional parameters:
// cloud_href: Backups belonging to only this cloud are considered for cleanup. Otherwise, all backups in the account with the same lineage will be considered.
// dailies: The number of daily backups(the latest one in each day) that should be kept.
// monthlies: The number of monthly backups(the latest one in each month) that should be kept.
// skip_deletion: When set to 'true' return an index of what backups would be cleaned-up.  Otherwise, the backups will be removed.
// weeklies: The number of weekly backups(the latest one in each week) that should be kept.
// yearlies: The number of yearly backups(the latest one in each year) that should be kept.