hetzner 0.2.1.1 → 0.3.0.0
raw patch · 5 files changed
+73/−14 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Hetzner.Cloud: getActions :: Token -> Maybe Int -> IO (WithMeta "actions" [Action])
+ Hetzner.Cloud: RebootServer :: ActionCommand
+ Hetzner.Cloud: ShutdownServer :: ActionCommand
+ Hetzner.Cloud: changeServerType :: Token -> ServerID -> ServerTypeID -> Bool -> IO Action
+ Hetzner.Cloud: powerOffServer :: Token -> ServerID -> IO Action
+ Hetzner.Cloud: powerOnServer :: Token -> ServerID -> IO Action
+ Hetzner.Cloud: rebootServer :: Token -> ServerID -> IO Action
+ Hetzner.Cloud: setServerReverseDNS :: Token -> ServerID -> PublicIPInfo Text (Either IPv4 IPv6) -> IO Action
+ Hetzner.Cloud: shutdownServer :: Token -> ServerID -> IO Action
Files
- changelog.md +6/−0
- hetzner.cabal +4/−4
- readme.md +5/−2
- src/Hetzner/Cloud.hs +57/−8
- src/Hetzner/Cloud/Fingerprint.hs +1/−0
changelog.md view
@@ -1,3 +1,9 @@+## 0.3.0.0+* Added support for the following server actions:+ `setServerReverseDNS`, `powerOnServer`, `powerOffServer`, `shutdownServer`,+ `rebootServer`, `changeServerType`.+* Removed `getActions`, as it has been discontinued by Hetzner.+ ## 0.2.1.1 * base-4.18 support.
hetzner.cabal view
@@ -2,15 +2,15 @@ category: Cloud synopsis: Hetzner Cloud and DNS library. description: Hetzner Cloud and DNS library. Check the readme and documentation for more details.-version: 0.2.1.1-cabal-version: >= 1.10+version: 0.3.0.0+cabal-version: 1.18 build-type: Simple author: Daniel Casanueva (daniel.casanueva `at` proton.me) maintainer: Daniel Casanueva (daniel.casanueva `at` proton.me)-bug-reports: https://github.com/Daniel-Diaz/hetzner/issues+bug-reports: https://gitlab.com/daniel-casanueva/hetzner/-/issues license: MIT license-file: license-extra-source-files: readme.md, changelog.md+extra-doc-files: readme.md, changelog.md library default-language: Haskell2010
readme.md view
@@ -1,7 +1,5 @@ # Hetzner Haskell Library -[](https://github.com/Daniel-Diaz/hetzner/actions/workflows/build.yml)- ## Distribution [](https://hackage.haskell.org/package/hetzner)@@ -20,3 +18,8 @@ If there's anything you would like to see added, feel free to [open an issue](https://github.com/Daniel-Diaz/hetzner/issues/new). Some breaking changes might also be introduced as the library matures.++## Documentation++Access documentation from the main (potentially unreleased) branch+[here](https://daniel-casanueva.gitlab.io/hetzner/doc).
src/Hetzner/Cloud.hs view
@@ -51,7 +51,6 @@ , ActionCommand (..) , ActionID (..) , Action (..)- , getActions , getAction , waitForAction -- ** Datacenters@@ -113,6 +112,13 @@ , getServer , createServer , deleteServer+ -- *** Server actions+ , setServerReverseDNS+ , powerOnServer+ , powerOffServer+ , shutdownServer+ , rebootServer+ , changeServerType -- ** Server types , Architecture (..) , StorageType (..)@@ -640,6 +646,8 @@ | DeleteServer | StartServer | StopServer+ | ShutdownServer+ | RebootServer | SetFirewallRules | ApplyFirewall | CreateVolume@@ -653,6 +661,8 @@ "delete_server" -> pure DeleteServer "start_server" -> pure StartServer "stop_server" -> pure StopServer+ "shutdown_server" -> pure ShutdownServer+ "reboot_server" -> pure RebootServer "set_firewall_rules" -> pure SetFirewallRules "apply_firewall" -> pure ApplyFirewall "create_volume" -> pure CreateVolume@@ -707,13 +717,6 @@ <*> o .: "started" <*> o .: "resources" --- | Get actions.-getActions- :: Token- -> Maybe Int -- ^ Page.- -> IO (WithMeta "actions" [Action])-getActions = cloudQuery "GET" "/actions" noBody- -- | Get a single action. getAction :: Token -> ActionID -> IO Action getAction token (ActionID i) = withoutKey @"action" <$>@@ -1396,6 +1399,52 @@ deleteServer :: Token -> ServerID -> IO Action deleteServer token (ServerID i) = withoutKey @"action" <$> cloudQuery "DELETE" ("/servers/" <> fromString (show i)) noBody token Nothing++-- | Set reverse DNS entry for a server.+setServerReverseDNS :: Token -> ServerID -> PublicIPInfo Text (Either IPv4 IPv6) -> IO Action+setServerReverseDNS token (ServerID i) ipinfo = withoutKey @"action" <$>+ let ip = either JSON.toJSON JSON.toJSON $ publicIP ipinfo+ in cloudQuery "POST"+ ("/servers/" <> fromString (show i) <> "/actions/change_dns_ptr") + (Just $ ipinfo { publicIP = ip }) token Nothing++-- | Turn server on.+powerOnServer :: Token -> ServerID -> IO Action+powerOnServer token (ServerID i) = withoutKey @"action" <$>+ cloudQuery "POST" ("/servers/" <> fromString (show i) <> "/actions/poweron") noBody token Nothing++-- | Turn server off. This is not a graceful shutdown.+powerOffServer :: Token -> ServerID -> IO Action+powerOffServer token (ServerID i) = withoutKey @"action" <$>+ cloudQuery "POST" ("/servers/" <> fromString (show i) <> "/actions/poweroff") noBody token Nothing++-- | Send ACPI shutdown request to a server. Use this instead of 'powerOffServer' if you+-- wish for a graceful shutdown. However, the returned action finishes when the+-- shutdown request is sent, so 'waitForAction' won't help you to tell whether the+-- server is actually off.+shutdownServer :: Token -> ServerID -> IO Action+shutdownServer token (ServerID i) = withoutKey @"action" <$>+ cloudQuery "POST" ("/servers/" <> fromString (show i) <> "/actions/shutdown") noBody token Nothing++-- | Send ACPI reboot request to a server.+rebootServer :: Token -> ServerID -> IO Action+rebootServer token (ServerID i) = withoutKey @"action" <$>+ cloudQuery "POST" ("/servers/" <> fromString (show i) <> "/actions/reboot") noBody token Nothing++-- | Change a server's type. The target type must have equal or larger disk.+-- The server needs to be turned off before changing its type.+changeServerType+ :: Token -> ServerID -> ServerTypeID+ -> Bool -- ^ Should the disk also be upgraded? If not, it will stay the same size.+ -> IO Action+changeServerType token (ServerID i) stype upgrade = withoutKey @"action" <$>+ let body = JSON.object+ [ "server_type" .= stype+ , "upgrade_disk" .= upgrade+ ]+ in cloudQuery "POST"+ ("/servers/" <> fromString (show i) <> "/actions/change_type")+ (Just body) token Nothing ---------------------------------------------------------------------------------------------------- -- Server Types
src/Hetzner/Cloud/Fingerprint.hs view
@@ -1,5 +1,6 @@ {-# OPTIONS_GHC -Wno-orphans #-} +-- | Parsers for the 'Fingerprint' type. module Hetzner.Cloud.Fingerprint ( Fingerprint , fingerprintParser