hetzner 0.7.0.0 → 0.7.1.0
raw patch · 5 files changed
+53/−6 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Hetzner.Cloud: actionsOf :: HasActions a => a -> [ActionID]
+ Hetzner.Cloud: class HasActions a
+ Hetzner.Cloud: instance Hetzner.Cloud.HasActions Hetzner.Cloud.Action
+ Hetzner.Cloud: instance Hetzner.Cloud.HasActions Hetzner.Cloud.ActionID
+ Hetzner.Cloud: instance Hetzner.Cloud.HasActions Hetzner.Cloud.CreatedFirewall
+ Hetzner.Cloud: instance Hetzner.Cloud.HasActions Hetzner.Cloud.CreatedServer
+ Hetzner.Cloud: instance Hetzner.Cloud.HasActions Hetzner.Cloud.CreatedVolume
+ Hetzner.Cloud: instance Hetzner.Cloud.HasActions a => Hetzner.Cloud.HasActions [a]
+ Hetzner.Cloud: waitForActions :: HasActions a => Token -> a -> IO ()
Files
- apps/Docs.hs +0/−1
- changelog.md +3/−0
- hetzner.cabal +1/−1
- readme.md +9/−4
- src/Hetzner/Cloud.hs +40/−0
apps/Docs.hs view
@@ -48,7 +48,6 @@ H.th "Cores" H.th "Memory" H.th "Disk"- H.th "Included Traffic" H.th "CPU Type" H.th "Max Monthly Price" forM_ serverTypes $ \serverType -> H.tr $ do
changelog.md view
@@ -1,3 +1,6 @@+## 0.7.1.0+* Introduce `HasActions` typeclass.+ ## 0.7.0.0 * base-19 and base-20 support. * Make hetzner-test executable.
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.0.0+version: 0.7.1.0 cabal-version: 1.18 build-type: Simple author: Daniel Casanueva (daniel.casanueva `at` proton.me)
readme.md view
@@ -6,12 +6,17 @@ and the [Hetzner DNS API](https://dns.hetzner.com/api-docs), written in the [Haskell](https://www.haskell.org) programming language. -## Status+## Completeness -This library is still in development, so expect missing funcionality.-If there's anything you would like to see added, feel free to+This library doesn't cover (at least, not yet) the enterity of Hetzner's API.+However, if there's anything you would like to see added, feel free to [open an issue](https://gitlab.com/daniel-casanueva/haskell/hetzner/-/issues/new).-Some breaking changes might also be introduced as the library matures.+If it's urgent, send me an email.+I mainly add features only when I myself need them, but I'd be happy to extend the+library upon request. Of course, if you can contribute with a merge request,+that'd be greatly appreciated. The only ask I have if you decide to contribute+is to follow more or less the naming and styling already used in the rest of+the library. Thanks! ## Documentation
src/Hetzner/Cloud.hs view
@@ -53,6 +53,8 @@ , Action (..) , getAction , waitForAction+ , HasActions (..)+ , waitForActions -- ** Datacenters , DatacenterID (..) , DatacenterServers (..)@@ -858,6 +860,31 @@ ActionSuccess t -> pure t ActionError _ err -> throwIO $ CloudError err +-- | This class provides a method to get all actions related to the given+-- argument. If a type is instance of 'HasActions', 'waitForActions' can+-- be used to wait for all related actions.+class HasActions a where+ -- | Return all related actions.+ actionsOf :: a -> [ActionID]++-- | Wait for all actions to be finished. If any of the actions throws an+-- error, a 'CloudException' will be thrown. For more control over individual+-- actions, use 'waitForAction'.+--+-- Check instances of 'HasActions' to learn on what types this can be used.+--+waitForActions :: HasActions a => Token -> a -> IO ()+waitForActions token = mapM_ (waitForAction token) . actionsOf++instance HasActions ActionID where+ actionsOf = pure++instance HasActions Action where+ actionsOf = pure . actionID++instance HasActions a => HasActions [a] where+ actionsOf = foldMap actionsOf+ ---------------------------------------------------------------------------------------------------- -- Datacenters ----------------------------------------------------------------------------------------------------@@ -1141,6 +1168,9 @@ , createdFirewall :: Firewall } deriving Show +instance HasActions CreatedFirewall where+ actionsOf = fmap actionID . createdFirewallActions+ instance FromJSON CreatedFirewall where parseJSON = JSON.withObject "CreatedFirewall" $ \o -> CreatedFirewall <$> o .: "actions" <*> o .: "firewall"@@ -1821,6 +1851,11 @@ , createdServer :: Server } deriving Show +instance HasActions CreatedServer where+ actionsOf cserver =+ actionID (createdServerAction cserver) :+ fmap actionID (createdServerNextActions cserver)+ instance FromJSON CreatedServer where parseJSON = JSON.withObject "CreatedServer" $ \o -> CreatedServer <$> o .: "action"@@ -2133,6 +2168,11 @@ , createdVolumeNextActions :: [Action] , createdVolume :: Volume } deriving Show++instance HasActions CreatedVolume where+ actionsOf cvolume =+ actionID (createdVolumeAction cvolume) :+ fmap actionID (createdVolumeNextActions cvolume) instance FromJSON CreatedVolume where parseJSON = JSON.withObject "CreatedVolume" $ \o -> CreatedVolume