twc_rs/cli/servers.rs
1// SPDX-FileCopyrightText: 2026 RAprogramm <andrey.rozanov.vl@gmail.com>
2// SPDX-License-Identifier: MIT
3
4//! Cloud server subcommands.
5
6use clap::Subcommand;
7
8/// Server-related subcommands.
9#[derive(Subcommand, Debug)]
10pub enum ServerCommands {
11 /// List all cloud servers.
12 List {
13 /// Maximum number of servers to return.
14 #[arg(long)]
15 limit: Option<i32>,
16
17 /// Number of servers to skip.
18 #[arg(long)]
19 offset: Option<i32>
20 },
21 /// Show detailed info for a server.
22 Info {
23 /// Server ID.
24 #[arg(long)]
25 id: i32
26 },
27 /// Delete a server by ID.
28 Delete {
29 /// Server ID.
30 #[arg(long)]
31 id: i32
32 },
33 /// Reboot a server by ID.
34 Reboot {
35 /// Server ID.
36 #[arg(long)]
37 id: i32
38 },
39 /// Power a server on.
40 Start {
41 /// Server ID.
42 #[arg(long)]
43 id: i32
44 },
45 /// Gracefully shut a server down.
46 Shutdown {
47 /// Server ID.
48 #[arg(long)]
49 id: i32
50 },
51 /// Clone a server by ID.
52 Clone {
53 /// Server ID.
54 #[arg(long)]
55 id: i32
56 },
57 /// Reset a server's root password.
58 ResetPassword {
59 /// Server ID.
60 #[arg(long)]
61 id: i32
62 },
63 /// List available server presets.
64 ListPresets,
65 /// List installable OS images.
66 ListOs,
67 /// List available pre-installable software.
68 ListSoftware,
69 /// List server configurators (custom builds).
70 ListConfigurators,
71 /// List the disks attached to a server.
72 Disk {
73 /// Server ID.
74 #[arg(long)]
75 id: i32
76 },
77 /// List the IP addresses of a server.
78 Ip {
79 /// Server ID.
80 #[arg(long)]
81 id: i32
82 },
83 /// Show the recent action history (logs) of a server.
84 History {
85 /// Server ID.
86 #[arg(long)]
87 id: i32
88 },
89 /// Set the NAT mode of a server's local network.
90 SetNatMode {
91 /// Server ID.
92 #[arg(long)]
93 id: i32,
94 /// One of: `dnat_and_snat`, `snat`, `no_nat`.
95 #[arg(long)]
96 nat_mode: String
97 },
98 /// Set the OS boot mode of a server (restarts the server).
99 SetBootMode {
100 /// Server ID.
101 #[arg(long)]
102 id: i32,
103 /// One of: `default`, `single`, `recovery_disk`.
104 #[arg(long)]
105 boot_mode: String
106 },
107 /// Resize a server to a different preset.
108 Resize {
109 /// Server ID.
110 #[arg(long)]
111 id: i32,
112 /// Target preset ID.
113 #[arg(long)]
114 preset_id: i32
115 },
116 /// Reinstall the OS of a server (wipes data).
117 Reinstall {
118 /// Server ID.
119 #[arg(long)]
120 id: i32,
121 /// OS image ID to install.
122 #[arg(long)]
123 os_id: i32
124 },
125 /// Create a new cloud server from a preset and OS image.
126 Create {
127 /// Server name (max 255 chars).
128 #[arg(long)]
129 name: String,
130 /// Preset (tariff) ID. Use `server list-presets` to list.
131 #[arg(long)]
132 preset_id: i32,
133 /// OS image ID. Use `server list-os` to list.
134 #[arg(long)]
135 os_id: i32,
136 /// Optional comment (max 255 chars).
137 #[arg(long)]
138 comment: Option<String>,
139 /// SSH key IDs to attach (repeatable).
140 #[arg(long = "ssh-key")]
141 ssh_key: Vec<i32>,
142 /// Project ID to place the server in.
143 #[arg(long)]
144 project_id: Option<i32>,
145 /// Availability zone (e.g. spb-1, msk-1, ams-1).
146 #[arg(long)]
147 availability_zone: Option<String>
148 },
149 /// Update a server's name and/or comment.
150 Set {
151 /// Server ID.
152 #[arg(long)]
153 id: i32,
154 /// New name.
155 #[arg(long)]
156 name: Option<String>,
157 /// New comment.
158 #[arg(long)]
159 comment: Option<String>
160 },
161 /// List disk backups of a server.
162 BackupList {
163 /// Server ID.
164 #[arg(long)]
165 id: i32
166 },
167 /// Create a disk backup of a server's system disk.
168 BackupCreate {
169 /// Server ID.
170 #[arg(long)]
171 id: i32,
172 /// Optional backup comment.
173 #[arg(long)]
174 comment: Option<String>
175 }
176}