/**
* Cross-account handover of VPS resources (servers, volumes, snapshots):
* offer to another account by email, they accept or decline.
*
* NOTE: every operation here requires an account JWT (see
* `auth.deviceLogin`); API keys are not accepted.
*/
import type { Client } from './client.js';
import * as http from './http.js';
import type { Body } from './types.js';
/** POST /vps/instances/{id}/transfer — Offer this server to another account. */
export const offerInstance = (client: Client, id: string, body: Body<'/vps/instances/{id}/transfer', 'post'>) =>
http.post(client, '/vps/instances/{id}/transfer', { params: { id }, body });
/** DELETE /vps/instances/{id}/transfer — Withdraw the pending server transfer offer. */
export const withdrawInstanceOffer = (client: Client, id: string) =>
http.del(client, '/vps/instances/{id}/transfer', { params: { id } });
/** POST /vps/volumes/{id}/transfer — Offer this volume to another account. */
export const offerVolume = (client: Client, id: string, body: Body<'/vps/volumes/{id}/transfer', 'post'>) =>
http.post(client, '/vps/volumes/{id}/transfer', { params: { id }, body });
/** DELETE /vps/volumes/{id}/transfer — Withdraw the pending volume transfer offer. */
export const withdrawVolumeOffer = (client: Client, id: string) =>
http.del(client, '/vps/volumes/{id}/transfer', { params: { id } });
/** POST /vps/images/{id}/transfer — Offer this image to another account. */
export const offerImage = (client: Client, id: string, body: Body<'/vps/images/{id}/transfer', 'post'>) =>
http.post(client, '/vps/images/{id}/transfer', { params: { id }, body });
/** DELETE /vps/images/{id}/transfer — Withdraw the pending image transfer offer. */
export const withdrawImageOffer = (client: Client, id: string) =>
http.del(client, '/vps/images/{id}/transfer', { params: { id } });
/** GET /vps/transfers — Pending handover offers, both directions. */
export const list = (client: Client) => http.get(client, '/vps/transfers');
/** POST /vps/transfers/{id}/accept — Take over the offered resource. */
export const accept = (client: Client, id: string, body?: Body<'/vps/transfers/{id}/accept', 'post'>) =>
http.post(client, '/vps/transfers/{id}/accept', { params: { id }, body });
/** POST /vps/transfers/{id}/decline — Decline an incoming transfer offer. */
export const decline = (client: Client, id: string) =>
http.post(client, '/vps/transfers/{id}/decline', { params: { id } });