hetzner 0.7.2.1 → 0.7.3.0
raw patch · 5 files changed
+50/−7 lines, 5 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Hetzner.Cloud: ResourceImageID :: ImageID -> ResourceID
+ Hetzner.Cloud: instance GHC.Classes.Eq Hetzner.Cloud.OSFlavor
+ Hetzner.Cloud: isSystemImage :: ImageType -> Bool
+ Hetzner.Cloud: withTempServer :: Token -> NewServer -> (Maybe Text -> Server -> IO a) -> IO a
Files
- changelog.md +6/−0
- hetzner.cabal +1/−1
- license +1/−1
- src/Hetzner/Cloud.hs +37/−4
- src/Hetzner/DNS.hs +5/−1
changelog.md view
@@ -1,3 +1,9 @@+## 0.7.3.0+* `Eq` instance for `OSFlavor`.+* New function: `isSystemImage`.+* New function: `withTempServer`.+* Updated value of `defaultNewServer`.+ ## 0.7.2.1 * Update default server type for new servers. The previous value became obsolete.
hetzner.cabal view
@@ -2,7 +2,7 @@ category: Cloud synopsis: Hetzner Cloud and DNS library. description: Hetzner Cloud and DNS library. Check the readme and documentation for more details.-version: 0.7.2.1+version: 0.7.3.0 cabal-version: 1.18 build-type: Simple author: Daniel Casanueva (coding `at` danielcasanueva.eu)
license view
@@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 Daniel Díaz Casanueva+Copyright (c) 2026 Daniel Díaz Casanueva Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
src/Hetzner/Cloud.hs view
@@ -88,6 +88,7 @@ -- ** Images , OSFlavor (..) , ImageType (..)+ , isSystemImage , ImageID (..) , Image (..) , getImages@@ -133,6 +134,7 @@ , getServer , createServer , deleteServer+ , withTempServer -- *** Server actions , setServerReverseDNS , powerOnServer@@ -205,7 +207,7 @@ import Hetzner.Cloud.Fingerprint (Fingerprint, fingerprint) -- base-import Control.Exception (Exception, throwIO)+import Control.Exception (Exception, throwIO, bracket) import Control.Concurrent (threadDelay) import GHC.TypeLits (Symbol, KnownSymbol, symbolVal) import Data.Proxy@@ -815,6 +817,8 @@ | ResourcePrimaryIPID PrimaryIPID -- | Firewall ID. | ResourceFirewallID FirewallID+ -- | Image ID.+ | ResourceImageID ImageID deriving Show instance FromJSON ResourceID where@@ -825,6 +829,7 @@ "volume" -> ResourceVolumeID <$> o .: "id" "primary_ip" -> ResourcePrimaryIPID <$> o .: "id" "firewall" -> ResourceFirewallID <$> o .: "id"+ "image" -> ResourceImageID <$> o .: "id" _ -> fail $ "Unknown resource type: " ++ Text.unpack t -- | Action.@@ -1291,7 +1296,7 @@ -- | Flavor of operative system. data OSFlavor = Ubuntu | CentOS | Debian | Fedora | Rocky | Alma | OpenSUSE | UnknownOS- deriving Show+ deriving (Eq, Show) instance FromJSON OSFlavor where parseJSON = JSON.withText "OSFlavor" $ \t -> case t of@@ -1316,6 +1321,13 @@ | Temporary deriving Show +-- | Check whether an image type uses the 'SystemImage' constructor.+--+-- @since 0.7.3.0+isSystemImage :: ImageType -> Bool+isSystemImage (SystemImage _) = True+isSystemImage _ = False+ -- | An image that can be mounted to a server. data Image = Image { -- | Image identifier.@@ -1831,13 +1843,13 @@ { newServerAutomount = True , newServerLocation = Nothing , newServerFirewalls = []- , newServerImage = ImageID 67794396+ , newServerImage = ImageID 387894169 -- ubuntu-26.04 , newServerLabels = [] , newServerName = name , newServerNetworks = [] , newServerEnableIPv4 = True , newServerEnableIPv6 = True- , newServerType = ServerTypeID 22+ , newServerType = ServerTypeID 114 -- CX23 , newServerSSHKeys = [] , newServerStart = True , newServerVolumes = []@@ -1890,6 +1902,27 @@ deleteServer :: Token -> ServerID -> IO Action deleteServer token (ServerID i) = withoutKey @"action" <$> cloudQuery "DELETE" ("/servers/" <> fromString (show i)) noBody token Nothing++-- | Create a temporary server. Once the server finishes its creation, it's+-- passed to the provided continuation function. When the continuation finishes+-- (either normally or by exception) the created server is deleted.+-- If no SSH keys are assigned to the server on creation (see 'newServerSSHKeys'),+-- the root password is passed as 'Text'.+--+-- Note that the 'Server' value passed to the continuation is the value at+-- the server creation's time. Any changes made to the server after that are+-- not reflected in it.+--+-- @since 0.7.3.0+withTempServer :: Token -> NewServer -> (Maybe Text -> Server -> IO a) -> IO a+withTempServer token nserver f =+ bracket+ (createServer token nserver)+ (\cserver ->+ deleteServer token (serverID $ createdServer cserver)+ >>= waitForAction token . actionID)+ $ \cserver -> waitForActions token cserver+ >> f (createdServerPassword cserver) (createdServer cserver) -- | Set reverse DNS entry for a server. setServerReverseDNS :: Token -> ServerID -> PublicIPInfo Text (Either IPv4 IPv6) -> IO Action
src/Hetzner/DNS.hs view
@@ -1,7 +1,11 @@ ---------------------------------------------------------------------------------------------------- -- | Client for the Hetzner DNS API.-module Hetzner.DNS (+--+-- /This module is currently outdated. Hetzner deprecated this API./+-- /Its replacement has not been implemented in this library as of yet./+-- /Contributions are welcome./+module Hetzner.DNS {-# DEPRECATED "DNS functionality moved to Cloud." #-} ( -- * Tokens Token (..) , getTokenFromEnv