// --- Input Variables --- // These variables should be updated by the user before running the script. // Product ID for ordering a new server or fetching product details. // Example: "AX41-NVMe" let SERVER_PRODUCT_ID = "YOUR_SERVER_PRODUCT_ID_HERE"; // SSH Key Fingerprint to be used for server deployment. // Example: "e0:73:80:26:80:46:f0:c8:bb:74:f4:d0:2d:10:2d:6f" let SSH_KEY_FINGERPRINT = "YOUR_SSH_KEY_FINGERPRINT_HERE"; // Transaction ID for fetching specific transaction details. // Example: "120000706572" or "B20250723-3204053-2775263" let TRANSACTION_ID = "YOUR_TRANSACTION_ID_HERE"; // Auction Product ID for fetching specific auction server product details or ordering. // Example: 2739642 let AUCTION_PRODUCT_ID = 0; // Replace with an actual auction product ID // Server Number for fetching server addon products or ordering addons. // Example: 1234567 let SERVER_NUMBER = 0; // Replace with an actual server number // Addon Transaction ID for fetching specific addon transaction details. // Example: "B20220210-1843193-S33055" let ADDON_TRANSACTION_ID = "YOUR_ADDON_TRANSACTION_ID_HERE"; // --- Server Ordering Operations --- // 1. Get all available server products // This section retrieves all available server products that can be ordered // and prints them in a human-readable table format. print("Fetching all available server products..."); try { let available_server_products = hetzner.get_server_products(); available_server_products.pretty_print(); print("All available server products fetched and displayed."); } catch (err) { print("Error fetching all available server products: " + err); } // 2. Get details of a specific server product by ID // This section demonstrates how to retrieve details for a single server product // using its product ID. // Uncomment the following lines and set SERVER_PRODUCT_ID to an actual product ID to use. /* print("\nAttempting to fetch specific server product with ID: " + SERVER_PRODUCT_ID); try { let example_server_product = hetzner.get_server_product_by_id(SERVER_PRODUCT_ID); print("Specific server product details:"); print(example_server_product); } catch (err) { print("Error fetching specific server product: " + err); } */ // 3. Order a new server // This section demonstrates how to order a new server. // Ensure SERVER_PRODUCT_ID and SSH_KEY_FINGERPRINT are set correctly. // Uncomment the following lines to order a server. /* print("\nAttempting to order a new server with product ID: " + SERVER_PRODUCT_ID); try { // First, grab the SSH key to pass to the deployment let ssh_key = hetzner.get_ssh_key(SSH_KEY_FINGERPRINT); // Use the builder to bundle the details on what to order let order_builder = new_server_builder(SERVER_PRODUCT_ID) .with_authorized_keys([ssh_key.fingerprint]) .with_test(true); // Set to 'false' for a real order let ordered_server_transaction = hetzner.order_server(order_builder); print("Server ordered successfully. Transaction details:"); print(ordered_server_transaction); } catch (err) { print("Error ordering server: " + err); } */ // 4. List all transactions from the past 30 days // This section retrieves all server order transactions from the past 30 days. // Uncomment the following lines to list transactions. /* print("\nFetching all server transactions from the past 30 days..."); try { let transactions_last_30 = hetzner.get_transactions(); transactions_last_30.pretty_print(); print("All transactions fetched and displayed."); } catch (err) { print("Error fetching transactions: " + err); } */ // 5. Fetch a specific transaction by ID // This section demonstrates how to fetch details for a specific transaction. // Uncomment the following lines and set TRANSACTION_ID to an actual transaction ID to use. /* print("\nAttempting to fetch transaction with ID: " + TRANSACTION_ID); try { let example_transaction = hetzner.get_transaction_by_id(TRANSACTION_ID); print("Specific transaction details:"); print(example_transaction); } catch (err) { print("Error fetching transaction by ID: " + err); } */ // 6. List all auction transactions from the past 30 days // This section retrieves all auction server transactions from the past 30 days. // Uncomment the following lines to list auction transactions. /* print("\nFetching all auction transactions from the past 30 days..."); try { let auction_transactions_last_30 = hetzner.get_auction_transactions(); auction_transactions_last_30.pretty_print(); print("All auction transactions fetched and displayed."); } catch (err) { print("Error fetching auction transactions: " + err); } */ // 7. Fetch a specific auction transaction by ID // This section demonstrates how to fetch details for a specific auction transaction. // Uncomment the following lines and set TRANSACTION_ID to an actual auction transaction ID to use. /* print("\nAttempting to fetch auction transaction with ID: " + TRANSACTION_ID); try { let example_auction_transaction = hetzner.get_auction_transaction_by_id(TRANSACTION_ID); print("Specific auction transaction details:"); print(example_auction_transaction); } catch (err) { print("Error fetching auction transaction by ID: " + err); } */ // 8. List all auctioned server products // This section retrieves all available auctioned server products. // Uncomment the following lines to list auctioned servers. /* print("\nFetching all auctioned server products..."); try { let auctioned_servers = hetzner.get_auction_server_products(); auctioned_servers.pretty_print(); print("All auctioned server products fetched and displayed."); } catch (err) { print("Error fetching auctioned server products: " + err); } */ // 9. Get information about one specific auctioned server by ID // This section demonstrates how to retrieve details for a specific auctioned server product. // Uncomment the following lines and set AUCTION_PRODUCT_ID to an actual auction product ID to use. /* print("\nAttempting to fetch specific auctioned server product with ID: " + AUCTION_PRODUCT_ID); try { let auctioned_server = hetzner.get_auction_server_product_by_id(AUCTION_PRODUCT_ID); print("Specific auctioned server product details:"); print(auctioned_server); } catch (err) { print("Error fetching specific auctioned server product: " + err); } */ // 10. Order an auction server // This section demonstrates how to order an auction server. // Ensure AUCTION_PRODUCT_ID and SSH_KEY_FINGERPRINT are set correctly. // Uncomment the following lines to order an auction server. /* print("\nAttempting to order an auction server with product ID: " + AUCTION_PRODUCT_ID); try { // First, grab the SSH key to pass to the deployment let ssh_key = hetzner.get_ssh_key(SSH_KEY_FINGERPRINT); // Use the builder to bundle the details on what to order let order_builder = new_auction_server_builder(AUCTION_PRODUCT_ID) .with_authorized_keys([ssh_key.fingerprint]) .with_lang("en") // Optional: language for the order confirmation .with_comment("test order") // Optional: comment for the order .with_test(true); // Set to 'false' for a real order let ordered_auction_server = hetzner.order_auction_server(order_builder); print("Auction server ordered successfully. Transaction details:"); print(ordered_auction_server); } catch (err) { print("Error ordering auction server: " + err); } */ // 11. Get all available server addon products // This section retrieves all available server addon products for a specific server // and prints them in a human-readable table format. // Uncomment the following lines and set SERVER_NUMBER to an actual server number to use. /* print("\nFetching all available server addon products for server: " + SERVER_NUMBER + "..."); try { let available_server_addons = hetzner.get_server_addon_products(SERVER_NUMBER); available_server_addons.pretty_print(); print("All available server addon products fetched and displayed."); } catch (err) { print("Error fetching all available server addon products: " + err); } */ // 12. List all addon transactions from the past 30 days // This section retrieves all server addon order transactions from the past 30 days. // Uncomment the following lines to list addon transactions. /* print("\nFetching all server addon transactions from the past 30 days..."); try { let addon_transactions_last_30 = hetzner.get_server_addon_transactions(); addon_transactions_last_30.pretty_print(); print("All addon transactions fetched and displayed."); } catch (err) { print("Error fetching addon transactions: " + err); } */ // 13. Order a server addon // This section demonstrates how to order a new server addon. // Ensure SERVER_NUMBER, PRODUCT_ID, and REASON are set correctly. // Uncomment the following lines to order a server addon. /* print("\nAttempting to order a server addon for server: " + SERVER_NUMBER + " with product ID: " + SERVER_PRODUCT_ID); try { let order_addon_builder = new_server_addon_builder(SERVER_NUMBER, SERVER_PRODUCT_ID) .with_reason("Test order") // Mandatory for some addon types, e.g., "ip_ipv4" .with_test(true); // Set to 'false' for a real order let ordered_addon_transaction = hetzner.order_server_addon(order_addon_builder); print("Server addon ordered successfully. Transaction details:"); print(ordered_addon_transaction); } catch (err) { print("Error ordering server addon: " + err); } */ // 14. Query a specific server addon transaction by ID // This section demonstrates how to fetch details for a specific server addon transaction. // Uncomment the following lines and set ADDON_TRANSACTION_ID to an actual transaction ID to use. /* print("\nAttempting to fetch specific server addon transaction with ID: " + ADDON_TRANSACTION_ID); try { let queried_addon_transaction = hetzner.get_server_addon_transaction_by_id(ADDON_TRANSACTION_ID); print("Specific server addon transaction details:"); print(queried_addon_transaction); } catch (err) { print("Error fetching specific server addon transaction: " + err); } */