hetzner-cli 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +907 -0
  3. package/dist/auction/client.d.ts +4 -0
  4. package/dist/auction/client.js +103 -0
  5. package/dist/auction/commands.d.ts +2 -0
  6. package/dist/auction/commands.js +138 -0
  7. package/dist/auction/formatter.d.ts +3 -0
  8. package/dist/auction/formatter.js +87 -0
  9. package/dist/cli.d.ts +2 -0
  10. package/dist/cli.js +39 -0
  11. package/dist/client.d.ts +2 -0
  12. package/dist/client.js +4 -0
  13. package/dist/cloud/client.d.ts +511 -0
  14. package/dist/cloud/client.js +706 -0
  15. package/dist/cloud/commands/certificate.d.ts +2 -0
  16. package/dist/cloud/commands/certificate.js +77 -0
  17. package/dist/cloud/commands/context.d.ts +2 -0
  18. package/dist/cloud/commands/context.js +78 -0
  19. package/dist/cloud/commands/datacenter.d.ts +2 -0
  20. package/dist/cloud/commands/datacenter.js +20 -0
  21. package/dist/cloud/commands/firewall.d.ts +2 -0
  22. package/dist/cloud/commands/firewall.js +77 -0
  23. package/dist/cloud/commands/floating-ip.d.ts +2 -0
  24. package/dist/cloud/commands/floating-ip.js +83 -0
  25. package/dist/cloud/commands/image.d.ts +2 -0
  26. package/dist/cloud/commands/image.js +60 -0
  27. package/dist/cloud/commands/index.d.ts +2 -0
  28. package/dist/cloud/commands/index.js +41 -0
  29. package/dist/cloud/commands/iso.d.ts +2 -0
  30. package/dist/cloud/commands/iso.js +22 -0
  31. package/dist/cloud/commands/load-balancer-type.d.ts +2 -0
  32. package/dist/cloud/commands/load-balancer-type.js +20 -0
  33. package/dist/cloud/commands/load-balancer.d.ts +2 -0
  34. package/dist/cloud/commands/load-balancer.js +177 -0
  35. package/dist/cloud/commands/location.d.ts +2 -0
  36. package/dist/cloud/commands/location.js +20 -0
  37. package/dist/cloud/commands/network.d.ts +2 -0
  38. package/dist/cloud/commands/network.js +96 -0
  39. package/dist/cloud/commands/placement-group.d.ts +2 -0
  40. package/dist/cloud/commands/placement-group.js +53 -0
  41. package/dist/cloud/commands/primary-ip.d.ts +2 -0
  42. package/dist/cloud/commands/primary-ip.js +83 -0
  43. package/dist/cloud/commands/server-type.d.ts +2 -0
  44. package/dist/cloud/commands/server-type.js +20 -0
  45. package/dist/cloud/commands/server.d.ts +2 -0
  46. package/dist/cloud/commands/server.js +260 -0
  47. package/dist/cloud/commands/ssh-key.d.ts +2 -0
  48. package/dist/cloud/commands/ssh-key.js +63 -0
  49. package/dist/cloud/commands/volume.d.ts +2 -0
  50. package/dist/cloud/commands/volume.js +92 -0
  51. package/dist/cloud/context.d.ts +28 -0
  52. package/dist/cloud/context.js +172 -0
  53. package/dist/cloud/formatter.d.ts +37 -0
  54. package/dist/cloud/formatter.js +413 -0
  55. package/dist/cloud/helpers.d.ts +18 -0
  56. package/dist/cloud/helpers.js +48 -0
  57. package/dist/cloud/types.d.ts +398 -0
  58. package/dist/cloud/types.js +5 -0
  59. package/dist/config.d.ts +1 -0
  60. package/dist/config.js +2 -0
  61. package/dist/formatter.d.ts +3 -0
  62. package/dist/formatter.js +6 -0
  63. package/dist/index.d.ts +10 -0
  64. package/dist/index.js +17 -0
  65. package/dist/robot/client.d.ts +256 -0
  66. package/dist/robot/client.js +656 -0
  67. package/dist/robot/commands/auth.d.ts +2 -0
  68. package/dist/robot/commands/auth.js +54 -0
  69. package/dist/robot/commands/boot.d.ts +2 -0
  70. package/dist/robot/commands/boot.js +72 -0
  71. package/dist/robot/commands/cancel.d.ts +2 -0
  72. package/dist/robot/commands/cancel.js +36 -0
  73. package/dist/robot/commands/failover.d.ts +2 -0
  74. package/dist/robot/commands/failover.js +42 -0
  75. package/dist/robot/commands/firewall.d.ts +2 -0
  76. package/dist/robot/commands/firewall.js +66 -0
  77. package/dist/robot/commands/index.d.ts +2 -0
  78. package/dist/robot/commands/index.js +36 -0
  79. package/dist/robot/commands/interactive.d.ts +2 -0
  80. package/dist/robot/commands/interactive.js +134 -0
  81. package/dist/robot/commands/ip.d.ts +2 -0
  82. package/dist/robot/commands/ip.js +52 -0
  83. package/dist/robot/commands/key.d.ts +2 -0
  84. package/dist/robot/commands/key.js +64 -0
  85. package/dist/robot/commands/order.d.ts +2 -0
  86. package/dist/robot/commands/order.js +33 -0
  87. package/dist/robot/commands/rdns.d.ts +2 -0
  88. package/dist/robot/commands/rdns.js +41 -0
  89. package/dist/robot/commands/reset.d.ts +2 -0
  90. package/dist/robot/commands/reset.js +77 -0
  91. package/dist/robot/commands/server.d.ts +2 -0
  92. package/dist/robot/commands/server.js +29 -0
  93. package/dist/robot/commands/storagebox.d.ts +2 -0
  94. package/dist/robot/commands/storagebox.js +116 -0
  95. package/dist/robot/commands/subnet.d.ts +2 -0
  96. package/dist/robot/commands/subnet.js +21 -0
  97. package/dist/robot/commands/traffic.d.ts +2 -0
  98. package/dist/robot/commands/traffic.js +20 -0
  99. package/dist/robot/commands/vswitch.d.ts +2 -0
  100. package/dist/robot/commands/vswitch.js +64 -0
  101. package/dist/robot/commands/wol.d.ts +2 -0
  102. package/dist/robot/commands/wol.js +20 -0
  103. package/dist/robot/formatter.d.ts +58 -0
  104. package/dist/robot/formatter.js +500 -0
  105. package/dist/robot/types.d.ts +352 -0
  106. package/dist/robot/types.js +5 -0
  107. package/dist/shared/config.d.ts +86 -0
  108. package/dist/shared/config.js +273 -0
  109. package/dist/shared/formatter.d.ts +29 -0
  110. package/dist/shared/formatter.js +118 -0
  111. package/dist/shared/helpers.d.ts +17 -0
  112. package/dist/shared/helpers.js +72 -0
  113. package/dist/shared/reference.d.ts +2 -0
  114. package/dist/shared/reference.js +626 -0
  115. package/dist/types.d.ts +75 -0
  116. package/dist/types.js +1 -0
  117. package/package.json +112 -0
@@ -0,0 +1,626 @@
1
+ // ============================================================================
2
+ // LLM-Optimized CLI Reference
3
+ // Outputs a structured, verbose plaintext document designed for easy parsing
4
+ // by language models (Claude, GPT, etc.) while remaining human-readable.
5
+ // ============================================================================
6
+ const PREAMBLE = `\
7
+ # HETZNER CLI — COMPLETE REFERENCE
8
+ # =================================
9
+ # Version: 2.0.0
10
+ # Binary: hetzner
11
+ # Install: npm install -g hetzner-cli
12
+ # Source: https://github.com/ytspar/hetzner-cli
13
+ #
14
+ # This CLI manages three Hetzner APIs:
15
+ # 1. Robot API — dedicated server management (requires Robot web service credentials)
16
+ # 2. Cloud API — cloud server/resource management (requires Cloud API token)
17
+ # 3. Auction API — public server auction browser (no authentication required)
18
+ #
19
+ # OUTPUT MODES:
20
+ # All commands default to human-readable formatted tables.
21
+ # Add --json to any command to get machine-readable JSON output.
22
+ # Example: hetzner server list --json | jq '.[].server.server_ip'
23
+ #
24
+ # SECTIONS: Use "hetzner reference --section robot|cloud|auction" to show only one section.
25
+
26
+ # ============================================================================
27
+ # AUTHENTICATION
28
+ # ============================================================================
29
+ #
30
+ # ROBOT API — Credential Resolution Order:
31
+ # 1. CLI flags: --user <username> --password <password>
32
+ # 2. Environment: HETZNER_ROBOT_USER and HETZNER_ROBOT_PASSWORD
33
+ # 3. System keychain: stored by "hetzner auth login" (uses keytar)
34
+ # 4. Config file: ~/.hetzner-cli/config.json
35
+ # 5. Interactive: prompts for username/password at runtime
36
+ #
37
+ # Password from stdin (keeps password out of shell history):
38
+ # echo "$PASSWORD" | hetzner server list -u myuser -p -
39
+ #
40
+ # With 1Password:
41
+ # op read "op://vault/item/password" | hetzner server list -u $(op read "op://vault/item/user") -p -
42
+ #
43
+ # CLOUD API — Token Resolution Order:
44
+ # 1. CLI flag: --token <token> (per command)
45
+ # 2. Environment: HETZNER_CLOUD_TOKEN
46
+ # 3. Active context: ~/.hetzner-cli/cloud-contexts.json (set via "hetzner cloud context use <name>")
47
+ #
48
+ # AUCTION API — No authentication required.
49
+
50
+ # ============================================================================
51
+ # GLOBAL OPTIONS (apply to all commands)
52
+ # ============================================================================
53
+
54
+ hetzner [command] [options]
55
+ -u, --user <username> Robot API username
56
+ -p, --password <password> Robot API password (use "-" to read from stdin)
57
+ --json Output raw JSON instead of formatted tables
58
+ -V, --version Show version number
59
+ -h, --help Show help for any command`;
60
+ const SECTION_ROBOT = `\
61
+ # ============================================================================
62
+ # ROBOT API COMMANDS — Dedicated Server Management
63
+ # ============================================================================
64
+ # All robot commands require Robot API credentials (see AUTHENTICATION above).
65
+ # Robot API docs: https://robot.hetzner.com/doc/webservice/en.html
66
+
67
+ # --- auth: Credential Management ---
68
+ hetzner auth login # Interactive login, saves credentials
69
+ hetzner auth logout # Clear saved credentials from keychain and config
70
+ hetzner auth status # Show current auth status (which credential source is active)
71
+ hetzner auth test # Test credentials against the API
72
+
73
+ # --- server: Dedicated Server Management ---
74
+ hetzner server list # List all servers (alias: ls)
75
+ hetzner server get <server> # Get server details by ID or IP (alias: show)
76
+ hetzner server rename <server> <name> # Rename a server
77
+
78
+ # --- reset: Server Reset Operations ---
79
+ hetzner reset options [server] # Show available reset types for server(s)
80
+ hetzner reset execute <servers...> # Reset one or more servers (alias: run)
81
+ -t, --type <type> # Reset type: sw (software, default), hw (hardware), man (manual), power, power_long
82
+ -i, --interactive # Interactively select reset type per server
83
+ -y, --yes # Skip confirmation prompt
84
+
85
+ # --- boot: Boot Configuration ---
86
+ hetzner boot status <server> # Show all boot configuration (rescue, linux, vnc, windows, etc.)
87
+
88
+ # boot rescue: Rescue System
89
+ hetzner boot rescue activate <server> # Activate rescue system
90
+ -o, --os <os> # OS: linux (default), linuxold, vkvm
91
+ -a, --arch <arch> # Architecture: 64 (default), 32
92
+ -k, --keys <fingerprints...> # SSH key fingerprints to authorize
93
+ hetzner boot rescue deactivate <server> # Deactivate rescue system
94
+ hetzner boot rescue last <server> # Show last rescue activation (including password if recent)
95
+
96
+ # boot linux: Linux Installation
97
+ hetzner boot linux activate <server> # Activate Linux installation
98
+ -d, --dist <dist> # Distribution name (required), e.g. "Debian-1210-bookworm-amd64-base"
99
+ -a, --arch <arch> # Architecture: 64 (default), 32
100
+ -l, --lang <lang> # Language: en (default)
101
+ -k, --keys <fingerprints...> # SSH key fingerprints to authorize
102
+ hetzner boot linux deactivate <server> # Deactivate pending Linux installation
103
+ hetzner boot linux options <server> # Show available Linux distributions for this server
104
+
105
+ # --- ip: IP Address Management ---
106
+ hetzner ip list # List all IP addresses (alias: ls)
107
+ hetzner ip get <ip> # Get IP details (alias: show)
108
+ hetzner ip update <ip> # Update IP traffic warning settings
109
+ --warnings <enabled> # Enable/disable warnings: true/false
110
+ --hourly <mb> # Hourly traffic warning threshold in MB
111
+ --daily <mb> # Daily traffic warning threshold in MB
112
+ --monthly <gb> # Monthly traffic warning threshold in GB
113
+
114
+ # ip mac: Separate MAC Addresses
115
+ hetzner ip mac get <ip> # Get separate MAC address for IP
116
+ hetzner ip mac generate <ip> # Generate a new separate MAC address
117
+ hetzner ip mac delete <ip> # Delete separate MAC address
118
+
119
+ # --- subnet: Subnet Management ---
120
+ hetzner subnet list # List all subnets (alias: ls)
121
+ hetzner subnet get <subnet> # Get subnet details (alias: show)
122
+
123
+ # --- failover: Failover IP Management ---
124
+ hetzner failover list # List all failover IPs (alias: ls)
125
+ hetzner failover get <ip> # Get failover IP details (alias: show)
126
+ hetzner failover switch <failover-ip> <target-server-ip> # Switch failover routing
127
+ -y, --yes # Skip confirmation
128
+ hetzner failover delete <ip> # Delete failover IP routing
129
+ -y, --yes # Skip confirmation
130
+
131
+ # --- rdns: Reverse DNS Management ---
132
+ hetzner rdns list # List all reverse DNS entries (alias: ls)
133
+ hetzner rdns get <ip> # Get reverse DNS for IP (alias: show)
134
+ hetzner rdns set <ip> <ptr> # Create or update reverse DNS entry
135
+ hetzner rdns delete <ip> # Delete reverse DNS entry
136
+
137
+ # --- key: SSH Key Management ---
138
+ hetzner key list # List all SSH keys (alias: ls)
139
+ hetzner key get <fingerprint> # Get SSH key details (alias: show)
140
+ hetzner key add <name> # Add new SSH key (prompts for key data if no flags)
141
+ -f, --file <path> # Path to public key file (e.g. ~/.ssh/id_rsa.pub)
142
+ -d, --data <key> # Public key data as string
143
+ hetzner key rename <fingerprint> <name> # Rename an SSH key
144
+ hetzner key delete <fingerprint> # Delete an SSH key (alias: rm)
145
+ -y, --yes # Skip confirmation
146
+
147
+ # --- firewall: Firewall Management ---
148
+ hetzner firewall get <server> # Get firewall configuration (alias: show)
149
+ hetzner firewall enable <server> # Enable firewall
150
+ hetzner firewall disable <server> # Disable firewall
151
+ hetzner firewall delete <server> # Delete all firewall rules
152
+ -y, --yes # Skip confirmation
153
+
154
+ # firewall template: Firewall Templates
155
+ hetzner firewall template list # List firewall templates (alias: ls)
156
+ hetzner firewall template get <id> # Get template details (alias: show)
157
+ hetzner firewall template delete <id> # Delete template (alias: rm)
158
+ -y, --yes # Skip confirmation
159
+
160
+ # --- vswitch: vSwitch Management ---
161
+ hetzner vswitch list # List all vSwitches (alias: ls)
162
+ hetzner vswitch get <id> # Get vSwitch details (alias: show)
163
+ hetzner vswitch create <name> <vlan> # Create a new vSwitch
164
+ hetzner vswitch update <id> # Update vSwitch
165
+ -n, --name <name> # New name
166
+ -v, --vlan <vlan> # New VLAN ID
167
+ hetzner vswitch delete <id> # Delete vSwitch (alias: rm)
168
+ -y, --yes # Skip confirmation
169
+ --date <date> # Cancellation date (YYYY-MM-DD format)
170
+ hetzner vswitch add-server <vswitch-id> <server> # Add server to vSwitch
171
+ hetzner vswitch remove-server <vswitch-id> <server> # Remove server from vSwitch
172
+
173
+ # --- storagebox: Storage Box Management (alias: storage) ---
174
+ hetzner storagebox list # List all storage boxes (alias: ls)
175
+ hetzner storagebox get <id> # Get storage box details (alias: show)
176
+ hetzner storagebox update <id> # Update storage box settings
177
+ -n, --name <name> # Storage box name
178
+ --webdav <enabled> # Enable/disable WebDAV: true/false
179
+ --samba <enabled> # Enable/disable Samba: true/false
180
+ --ssh <enabled> # Enable/disable SSH/SFTP: true/false
181
+ --external <enabled> # Enable/disable external reachability: true/false
182
+ --zfs <enabled> # Enable/disable ZFS: true/false
183
+ hetzner storagebox reset-password <id> # Reset storage box password
184
+
185
+ # storagebox snapshot: Snapshot Management
186
+ hetzner storagebox snapshot list <box-id> # List snapshots (alias: ls)
187
+ hetzner storagebox snapshot create <box-id> # Create a new snapshot
188
+ hetzner storagebox snapshot delete <box-id> <name> # Delete a snapshot (alias: rm)
189
+ -y, --yes # Skip confirmation
190
+ hetzner storagebox snapshot revert <box-id> <name> # Revert to a snapshot
191
+ -y, --yes # Skip confirmation
192
+
193
+ # storagebox subaccount: Subaccount Management
194
+ hetzner storagebox subaccount list <box-id> # List subaccounts (alias: ls)
195
+ hetzner storagebox subaccount create <box-id> <home-directory> # Create subaccount
196
+ --samba <enabled> # Enable Samba: true/false
197
+ --ssh <enabled> # Enable SSH: true/false
198
+ --webdav <enabled> # Enable WebDAV: true/false
199
+ --external <enabled> # Enable external access: true/false
200
+ --readonly <enabled> # Read-only mode: true/false
201
+ --comment <comment> # Comment
202
+ hetzner storagebox subaccount delete <box-id> <username> # Delete subaccount (alias: rm)
203
+ -y, --yes # Skip confirmation
204
+
205
+ # --- traffic: Traffic Analytics ---
206
+ hetzner traffic query # Query traffic data
207
+ -i, --ip <ips...> # IP addresses to query
208
+ -s, --subnet <subnets...> # Subnets to query
209
+ --from <date> # Start date (YYYY-MM-DD)
210
+ --to <date> # End date (YYYY-MM-DD)
211
+ -t, --type <type> # Query type: day, month (default), year
212
+
213
+ # --- wol: Wake on LAN ---
214
+ hetzner wol status <server> # Check WoL status for server
215
+ hetzner wol send <server> # Send Wake on LAN packet
216
+
217
+ # --- cancel: Server Cancellation ---
218
+ hetzner cancel status <server> # Get cancellation status
219
+ hetzner cancel request <server> # Request server cancellation
220
+ --date <date> # Cancellation date (YYYY-MM-DD)
221
+ --reason <reasons...> # Cancellation reasons
222
+ -y, --yes # Skip confirmation
223
+ hetzner cancel revoke <server> # Revoke pending cancellation
224
+
225
+ # --- order: Server Ordering ---
226
+ hetzner order products # List available server products
227
+ hetzner order market # List server market/auction products (authenticated API)
228
+ hetzner order transactions # List order transactions
229
+ hetzner order transaction <id> # Get order transaction details
230
+
231
+ # --- interactive: Interactive Mode (alias: i) ---
232
+ hetzner interactive # Launch menu-driven interface for common operations
233
+ hetzner i # Short alias
234
+
235
+ # --- Robot API Examples ---
236
+ # List all dedicated servers:
237
+ # hetzner server list
238
+ #
239
+ # Get server details as JSON:
240
+ # hetzner server get 123456 --json
241
+ #
242
+ # Hardware reset a server:
243
+ # hetzner reset execute 123456 -t hw -y
244
+ #
245
+ # Activate rescue mode with SSH key:
246
+ # hetzner boot rescue activate 123456 -k ab:cd:ef:12:34:56
247
+ #
248
+ # Switch failover IP:
249
+ # hetzner failover switch 1.2.3.4 5.6.7.8 -y
250
+ #
251
+ # Query monthly traffic:
252
+ # hetzner traffic query --ip 1.2.3.4 --from 2025-01-01 --to 2025-01-31`;
253
+ const SECTION_CLOUD = `\
254
+ # ============================================================================
255
+ # CLOUD API COMMANDS — hetzner cloud <resource> <action>
256
+ # ============================================================================
257
+ # All cloud commands require a Cloud API token (see AUTHENTICATION above).
258
+ # Cloud API docs: https://docs.hetzner.cloud/
259
+
260
+ # --- cloud context: Context/Token Management ---
261
+ hetzner cloud context create <name> # Create a new cloud context (saves token)
262
+ -t, --token <token> # API token (prompts interactively if omitted)
263
+ hetzner cloud context use <name> # Switch to a cloud context (sets it as active)
264
+ hetzner cloud context delete <name> # Delete a cloud context (alias: rm)
265
+ hetzner cloud context list # List all cloud contexts (alias: ls)
266
+ hetzner cloud context active # Show the currently active cloud context
267
+
268
+ # --- cloud server: Cloud Server Management ---
269
+ hetzner cloud server list # List all cloud servers (alias: ls)
270
+ -l, --label-selector <selector> # Filter by label (e.g. "env=prod")
271
+ -n, --name <name> # Filter by name
272
+ -s, --sort <field> # Sort by field (e.g. "name", "created")
273
+ --status <status> # Filter by status (e.g. "running", "off")
274
+ hetzner cloud server describe <id> # Show server details
275
+ hetzner cloud server create # Create a new server
276
+ --name <name> # Server name (REQUIRED)
277
+ --type <type> # Server type, e.g. cx22 (REQUIRED)
278
+ --image <image> # Image name or ID, e.g. ubuntu-22.04 (REQUIRED)
279
+ --location <location> # Location: fsn1, nbg1, hel1, ash, hil
280
+ --datacenter <dc> # Datacenter (alternative to location)
281
+ --ssh-key <keys...> # SSH key IDs or names
282
+ --user-data <data> # Cloud-init user data
283
+ --start-after-create # Start server immediately (default: true)
284
+ --no-start-after-create # Create without starting
285
+ hetzner cloud server delete <id> # Delete a server
286
+ -y, --yes # Skip confirmation
287
+ hetzner cloud server update <id> # Update server
288
+ --name <name> # New server name
289
+ hetzner cloud server poweron <id> # Power on a server
290
+ hetzner cloud server poweroff <id> # Power off a server (hard power off)
291
+ hetzner cloud server reboot <id> # Soft reboot a server (ACPI)
292
+ hetzner cloud server reset <id> # Hard reset a server
293
+ hetzner cloud server shutdown <id> # Graceful shutdown (ACPI signal)
294
+ hetzner cloud server rebuild <id> # Rebuild server with new image
295
+ --image <image> # Image to rebuild with (REQUIRED)
296
+ hetzner cloud server change-type <id> # Change server type (resize)
297
+ --type <type> # New server type (REQUIRED)
298
+ --upgrade-disk # Also upgrade disk (irreversible)
299
+ hetzner cloud server enable-rescue <id> # Enable rescue mode
300
+ --type <type> # Rescue type: linux64 (default)
301
+ --ssh-key <keys...> # SSH key IDs
302
+ hetzner cloud server disable-rescue <id> # Disable rescue mode
303
+ hetzner cloud server enable-backup <id> # Enable automatic backups
304
+ hetzner cloud server disable-backup <id> # Disable automatic backups
305
+ hetzner cloud server create-image <id> # Create snapshot from server
306
+ --description <desc> # Image description
307
+ --type <type> # Image type: snapshot (default), backup
308
+ hetzner cloud server attach-iso <id> # Attach ISO to server
309
+ --iso <iso> # ISO name or ID (REQUIRED)
310
+ hetzner cloud server detach-iso <id> # Detach ISO from server
311
+ hetzner cloud server reset-password <id> # Reset root password
312
+ hetzner cloud server set-rdns <id> # Set reverse DNS
313
+ --ip <ip> # IP address (REQUIRED)
314
+ --dns-ptr <ptr> # DNS pointer record (REQUIRED)
315
+ hetzner cloud server enable-protection <id> # Enable protection
316
+ --delete # Delete protection (default: true)
317
+ --rebuild # Rebuild protection (default: false)
318
+ hetzner cloud server disable-protection <id> # Disable all protection
319
+ hetzner cloud server request-console <id> # Get WebSocket VNC console URL + password
320
+ hetzner cloud server attach-to-network <id> # Attach to network
321
+ --network <network> # Network ID (REQUIRED)
322
+ --ip <ip> # IP address in network (optional)
323
+ hetzner cloud server detach-from-network <id> # Detach from network
324
+ --network <network> # Network ID (REQUIRED)
325
+ hetzner cloud server add-label <id> <label> # Add label (format: key=value)
326
+ hetzner cloud server remove-label <id> <key> # Remove label by key
327
+
328
+ # --- cloud network: Network Management ---
329
+ hetzner cloud network list # List all networks (alias: ls)
330
+ hetzner cloud network describe <id> # Show network details
331
+ hetzner cloud network create # Create a network
332
+ --name <name> # Network name (REQUIRED)
333
+ --ip-range <cidr> # IP range in CIDR notation (REQUIRED)
334
+ hetzner cloud network delete <id> # Delete a network
335
+ -y, --yes # Skip confirmation
336
+
337
+ # --- cloud firewall: Cloud Firewall Management ---
338
+ hetzner cloud firewall list # List all firewalls (alias: ls)
339
+ hetzner cloud firewall describe <id> # Show firewall details
340
+ hetzner cloud firewall create # Create a firewall
341
+ --name <name> # Firewall name (REQUIRED)
342
+ hetzner cloud firewall delete <id> # Delete a firewall
343
+ -y, --yes # Skip confirmation
344
+
345
+ # --- cloud floating-ip: Floating IP Management ---
346
+ hetzner cloud floating-ip list # List all floating IPs (alias: ls)
347
+ hetzner cloud floating-ip describe <id> # Show floating IP details
348
+ hetzner cloud floating-ip create # Create a floating IP
349
+ --type <type> # IP type: ipv4, ipv6 (REQUIRED)
350
+ --home-location <location> # Home location (REQUIRED)
351
+ --description <desc> # Description
352
+ hetzner cloud floating-ip delete <id> # Delete a floating IP
353
+ -y, --yes # Skip confirmation
354
+
355
+ # --- cloud primary-ip: Primary IP Management ---
356
+ hetzner cloud primary-ip list # List all primary IPs (alias: ls)
357
+ hetzner cloud primary-ip describe <id> # Show primary IP details
358
+ hetzner cloud primary-ip create # Create a primary IP
359
+ --type <type> # IP type: ipv4, ipv6 (REQUIRED)
360
+ --assignee-type <type> # Assignee type: server (REQUIRED)
361
+ --datacenter <dc> # Datacenter (REQUIRED)
362
+ --name <name> # Name
363
+ hetzner cloud primary-ip delete <id> # Delete a primary IP
364
+ -y, --yes # Skip confirmation
365
+
366
+ # --- cloud volume: Volume Management ---
367
+ hetzner cloud volume list # List all volumes (alias: ls)
368
+ hetzner cloud volume describe <id> # Show volume details
369
+ hetzner cloud volume create # Create a volume
370
+ --name <name> # Volume name (REQUIRED)
371
+ --size <gb> # Size in GB (REQUIRED)
372
+ --location <location> # Location
373
+ --server <id> # Attach to server immediately
374
+ hetzner cloud volume delete <id> # Delete a volume
375
+ -y, --yes # Skip confirmation
376
+
377
+ # --- cloud load-balancer: Load Balancer Management ---
378
+ hetzner cloud load-balancer list # List all load balancers (alias: ls)
379
+ hetzner cloud load-balancer describe <id> # Show load balancer details
380
+ hetzner cloud load-balancer create # Create a load balancer
381
+ --name <name> # Load balancer name (REQUIRED)
382
+ --type <type> # Load balancer type (REQUIRED)
383
+ --location <location> # Location
384
+ hetzner cloud load-balancer delete <id> # Delete a load balancer
385
+ -y, --yes # Skip confirmation
386
+
387
+ # --- cloud image: Image Management ---
388
+ hetzner cloud image list # List all images (alias: ls)
389
+ -l, --label-selector <selector> # Filter by label
390
+ -s, --sort <field> # Sort by field
391
+ --type <type> # Filter: system, snapshot, backup, app
392
+ --architecture <arch> # Filter: x86, arm
393
+ --status <status> # Filter by status
394
+ hetzner cloud image describe <id> # Show image details
395
+ hetzner cloud image update <id> # Update image
396
+ --description <desc> # New description
397
+ --type <type> # New type
398
+ hetzner cloud image delete <id> # Delete an image
399
+ -y, --yes # Skip confirmation
400
+
401
+ # --- cloud ssh-key: Cloud SSH Key Management ---
402
+ hetzner cloud ssh-key list # List all SSH keys (alias: ls)
403
+ hetzner cloud ssh-key describe <id> # Show SSH key details
404
+ hetzner cloud ssh-key create # Create an SSH key
405
+ --name <name> # Key name (REQUIRED)
406
+ --public-key <key> # Public key data (REQUIRED)
407
+ hetzner cloud ssh-key delete <id> # Delete an SSH key
408
+ -y, --yes # Skip confirmation
409
+
410
+ # --- cloud certificate: TLS Certificate Management ---
411
+ hetzner cloud certificate list # List all certificates (alias: ls)
412
+ hetzner cloud certificate describe <id> # Show certificate details
413
+ hetzner cloud certificate create # Create/upload a certificate
414
+ --name <name> # Certificate name (REQUIRED)
415
+ --certificate <cert> # PEM certificate data
416
+ --private-key <key> # PEM private key data
417
+ hetzner cloud certificate delete <id> # Delete a certificate
418
+ -y, --yes # Skip confirmation
419
+
420
+ # --- cloud placement-group: Placement Group Management ---
421
+ hetzner cloud placement-group list # List all placement groups (alias: ls)
422
+ hetzner cloud placement-group describe <id> # Show placement group details
423
+ hetzner cloud placement-group create # Create a placement group
424
+ --name <name> # Group name (REQUIRED)
425
+ --type <type> # Type: spread (REQUIRED)
426
+ hetzner cloud placement-group delete <id> # Delete a placement group
427
+ -y, --yes # Skip confirmation
428
+
429
+ # --- cloud datacenter: Datacenter Information (read-only) ---
430
+ hetzner cloud datacenter list # List all datacenters (alias: ls)
431
+ hetzner cloud datacenter describe <id> # Show datacenter details
432
+
433
+ # --- cloud location: Location Information (read-only) ---
434
+ hetzner cloud location list # List all locations (alias: ls)
435
+ hetzner cloud location describe <id> # Show location details
436
+
437
+ # --- cloud server-type: Server Type Information (read-only) ---
438
+ hetzner cloud server-type list # List all server types (alias: ls)
439
+ hetzner cloud server-type describe <id> # Show server type details
440
+
441
+ # --- cloud load-balancer-type: Load Balancer Type Information (read-only) ---
442
+ hetzner cloud load-balancer-type list # List all load balancer types (alias: ls)
443
+ hetzner cloud load-balancer-type describe <id> # Show load balancer type details
444
+
445
+ # --- cloud iso: ISO Image Information ---
446
+ hetzner cloud iso list # List all ISO images (alias: ls)
447
+ -n, --name <name> # Filter by name
448
+ -a, --architecture <arch> # Filter by architecture
449
+ hetzner cloud iso describe <id> # Show ISO details
450
+
451
+ # --- Cloud API Examples ---
452
+ # Set up cloud authentication:
453
+ # hetzner cloud context create production -t hcloud_xxxxx
454
+ # hetzner cloud context use production
455
+ #
456
+ # Create a cloud server:
457
+ # hetzner cloud server create --name web1 --type cx22 --image ubuntu-22.04 --location fsn1 --ssh-key my-key
458
+ #
459
+ # List cloud servers filtered by label:
460
+ # hetzner cloud server list -l "env=prod" --json
461
+ #
462
+ # Snapshot a server:
463
+ # hetzner cloud server create-image 12345 --description "before upgrade"
464
+ #
465
+ # Resize a server:
466
+ # hetzner cloud server change-type 12345 --type cx32`;
467
+ const SECTION_AUCTION = `\
468
+ # ============================================================================
469
+ # AUCTION COMMANDS — Public Server Auction Browser
470
+ # ============================================================================
471
+ # No authentication required. Data from: https://www.hetzner.com/_resources/app/data/app/live_data_sb_EUR.json
472
+ # Returns ~1000+ servers. All filtering and sorting is done client-side.
473
+ #
474
+ # TYPICAL DATA RANGES (approximate, changes continuously):
475
+ # Price: 30 - 450 EUR/month
476
+ # Hourly: 0.04 - 0.72 EUR/hour
477
+ # RAM: 32 - 1024 GB
478
+ # Disk total: 240 - 230,000+ GB
479
+ # Disk count: 1 - 16 drives
480
+ # CPU models: Intel (i7, Xeon) and AMD (Ryzen, EPYC)
481
+ # Datacenters: FSN1-DC* (Falkenstein), HEL1-DC* (Helsinki), NBG1-DC* (Nuremberg)
482
+ # Specials: ECC, GPU, IPv4, iNIC (Intel NIC)
483
+
484
+ # --- auction list: List and Filter Auction Servers ---
485
+ hetzner auction list # List all auction servers (alias: ls)
486
+
487
+ # PRICE FILTERS:
488
+ --min-price <n> # Minimum monthly price (EUR/USD)
489
+ --max-price <n> # Maximum monthly price
490
+ --max-hourly-price <n> # Maximum hourly price
491
+ --max-setup-price <n> # Maximum setup fee
492
+ --no-setup-fee # Only servers with zero setup fee (shorthand for --max-setup-price 0)
493
+ --fixed-price # Only fixed-price servers (price won't change)
494
+ --auction-only # Only auction servers (price decreases over time)
495
+
496
+ # HARDWARE FILTERS:
497
+ --cpu <text> # CPU model substring match, case-insensitive
498
+ # Examples: "Ryzen", "EPYC", "i7-6700", "Xeon"
499
+ --min-cpu-count <n> # Minimum CPU/socket count
500
+ --max-cpu-count <n> # Maximum CPU/socket count
501
+ --min-ram <gb> # Minimum RAM in GB
502
+ --max-ram <gb> # Maximum RAM in GB
503
+ --ecc # Only ECC RAM servers
504
+
505
+ # DISK FILTERS:
506
+ --min-disk-size <gb> # Minimum total disk capacity in GB (sum across all drives)
507
+ --max-disk-size <gb> # Maximum total disk capacity in GB
508
+ --min-disk-count <n> # Minimum number of physical drives
509
+ --max-disk-count <n> # Maximum number of physical drives
510
+ --disk-type <type> # Only servers with this disk type: nvme, sata, hdd
511
+ # Note: server may have OTHER types too; this checks presence
512
+
513
+ # NETWORK FILTERS:
514
+ --datacenter <text> # Datacenter substring match, case-insensitive
515
+ # Examples: "FSN" (all Falkenstein), "HEL1-DC2" (specific), "NBG"
516
+ --min-bandwidth <mbit> # Minimum bandwidth in Mbit/s
517
+
518
+ # FEATURE FILTERS:
519
+ --gpu # Only GPU servers
520
+ --inic # Only servers with Intel NIC
521
+ --highio # Only high I/O servers
522
+ --specials <text> # Filter by any special feature, substring match
523
+ # Examples: "GPU", "ECC", "iNIC", "IPv4"
524
+
525
+ # TEXT SEARCH:
526
+ --search <text> # Free-text search across server description lines
527
+ # Searches the description array (CPU, RAM, disk details, NIC info)
528
+
529
+ # SORTING:
530
+ --sort <field> # Sort field (default: price). Choices:
531
+ # price — monthly price
532
+ # hourly — hourly price
533
+ # setup — setup fee
534
+ # ram — RAM size in GB
535
+ # disk — total disk capacity (sum of all drives)
536
+ # disk_count — number of physical drives
537
+ # cpu — CPU model name (alphabetical)
538
+ # cpu_count — number of CPU sockets
539
+ # datacenter — datacenter name (alphabetical)
540
+ # bandwidth — bandwidth in Mbit/s
541
+ # next_reduce — minutes until next price reduction (auction servers only)
542
+ --desc # Sort in descending order (default: ascending)
543
+
544
+ # OUTPUT:
545
+ --currency <currency> # EUR (default) or USD
546
+ --limit <n> # Limit number of results shown
547
+ --json # Output raw JSON array
548
+
549
+ # --- auction show: Show Auction Server Details ---
550
+ hetzner auction show <id> # Show full details for a specific auction server
551
+ --currency <currency> # EUR (default) or USD
552
+ --json # Output raw JSON object
553
+
554
+ # --- Auction API Examples ---
555
+ # Browse all auction servers sorted by price:
556
+ # hetzner auction list
557
+ #
558
+ # Find cheap AMD EPYC servers with NVMe and ECC in Helsinki:
559
+ # hetzner auction list --cpu epyc --disk-type nvme --ecc --datacenter HEL --sort price
560
+ #
561
+ # Find GPU servers under 150 EUR:
562
+ # hetzner auction list --gpu --max-price 150
563
+ #
564
+ # Find servers with at least 256 GB RAM and 4+ drives:
565
+ # hetzner auction list --min-ram 256 --min-disk-count 4 --sort ram --desc
566
+ #
567
+ # Find the cheapest fixed-price servers with NVMe:
568
+ # hetzner auction list --fixed-price --disk-type nvme --sort price --limit 10
569
+ #
570
+ # Find auction servers about to drop in price (sorted by nearest reduction):
571
+ # hetzner auction list --auction-only --sort next_reduce --limit 20
572
+ #
573
+ # Get full details for a specific auction server:
574
+ # hetzner auction show 2919866
575
+ #
576
+ # Export filtered results as JSON for scripting:
577
+ # hetzner auction list --max-price 60 --ecc --json | jq '.[].id'
578
+ #
579
+ # Compare EUR vs USD pricing:
580
+ # hetzner auction list --currency USD --max-price 50`;
581
+ const POSTAMBLE = `\
582
+ # ============================================================================
583
+ # CONFIGURATION FILES
584
+ # ============================================================================
585
+ # ~/.hetzner-cli/config.json Robot API credentials (file-based fallback)
586
+ # ~/.hetzner-cli/cloud-contexts.json Cloud API contexts and tokens
587
+ #
588
+ # System keychain (via keytar): Robot API credentials (preferred, secure)
589
+ # Service name: "hetzner-cli"
590
+ # Account key: "credentials"
591
+ #
592
+ # Environment variables:
593
+ # HETZNER_ROBOT_USER Robot API username
594
+ # HETZNER_ROBOT_PASSWORD Robot API password
595
+ # HETZNER_CLOUD_TOKEN Cloud API token (overrides context)
596
+
597
+ # ============================================================================
598
+ # PROGRAMMATIC (LIBRARY) USAGE
599
+ # ============================================================================
600
+ # This package can also be imported as a Node.js/TypeScript library:
601
+ #
602
+ # import { HetznerRobotClient } from 'hetzner-cli';
603
+ # import { fetchAuctionServers, filterAuctionServers, sortAuctionServers } from 'hetzner-cli';
604
+ #
605
+ # Robot Client:
606
+ # const client = new HetznerRobotClient(username, password);
607
+ # const servers = await client.listServers();
608
+ # const details = await client.getServer(123456);
609
+ # await client.resetServer(123456, 'sw');
610
+ #
611
+ # Auction Client (no auth):
612
+ # const { server: servers } = await fetchAuctionServers('EUR');
613
+ # const filtered = filterAuctionServers(servers, { maxPrice: 50, ecc: true });
614
+ # const sorted = sortAuctionServers(filtered, 'price', false);`;
615
+ const SECTIONS = {
616
+ robot: SECTION_ROBOT,
617
+ cloud: SECTION_CLOUD,
618
+ auction: SECTION_AUCTION,
619
+ };
620
+ export function generateReference(section) {
621
+ if (section) {
622
+ const body = SECTIONS[section];
623
+ return `${PREAMBLE}\n\n${body}`;
624
+ }
625
+ return `${PREAMBLE}\n\n${SECTION_ROBOT}\n\n${SECTION_CLOUD}\n\n${SECTION_AUCTION}\n\n${POSTAMBLE}`;
626
+ }