ts / src / transfers.ts
317 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
 * 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 } });

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/ts.git