linode 0.1.0.4 → 0.2.0.0
raw patch · 3 files changed
+15/−16 lines, 3 files
Files
- linode.cabal +1/−1
- src/Network/Linode.hs +12/−13
- src/Network/Linode/Types.hs +2/−2
linode.cabal view
@@ -1,5 +1,5 @@ name: linode-version: 0.1.0.4+version: 0.2.0.0 synopsis: Bindings to the Linode API description: Haskell bindings to the Linode API. Rent servers hourly or monthly. .
src/Network/Linode.hs view
@@ -10,7 +10,6 @@ Usage example. We want to create one Linode instance in Atlanta with 1GB of RAM: -> {-# LANGUAGE OverloadedStrings #-} > import Network.Linode > import Data.List (find) > import qualified System.Process as P@@ -22,8 +21,8 @@ > apiKey <- fmap (head . words) (readFile "apiKey") > sshPublicKey <- readFile "id_rsa.pub" > let options = defaultLinodeCreationOptions {-> datacenterSelect = find ((=="atlanta") . datacenterName),-> planSelect = find ((=="Linode 1024") . planName),+> datacenterChoice = "atlanta",+> planChoice = "Linode 1024", > sshKey = Just sshPublicKey > } > c <- createLinode apiKey True options@@ -171,10 +170,10 @@ -} defaultLinodeCreationOptions :: LinodeCreationOptions defaultLinodeCreationOptions = LinodeCreationOptions {- datacenterSelect = find ((=="london") . datacenterName),- planSelect = find ((=="Linode 1024") . planName),- kernelSelect = find (("Latest 64 bit" `T.isPrefixOf`) . kernelName),- distributionSelect = find ((=="Debian 8.1") . distributionName),+ datacenterChoice = "london",+ planChoice = "Linode 1024",+ kernelSelect = find (("Latest 64 bit" `T.isPrefixOf`) . kernelName), -- Most recent 64 bits kernel+ distributionSelect = lastMay . sortBy (comparing distributionName) . filter ((T.pack "Debian" `T.isPrefixOf`) . distributionName), -- Most recent Debian paymentChoice = OneMonth, swapAmount = 128, password = "We4kP4ssw0rd",@@ -361,9 +360,9 @@ -} select :: ApiKey -> LinodeCreationOptions -> ExceptT LinodeError IO (Datacenter, Distribution, Plan, Kernel) select apiKey options = (,,,) <$>- fetchAndSelect (runExceptT $ getDatacenters apiKey) (datacenterSelect options) "datacenter" <*>+ fetchAndSelect (runExceptT $ getDatacenters apiKey) (find ((== T.pack (datacenterChoice options)) . datacenterName)) "datacenter" <*> fetchAndSelect (runExceptT $ getDistributions apiKey) (distributionSelect options) "distribution" <*>- fetchAndSelect (runExceptT $ getPlans apiKey) (planSelect options . sortBy (comparing hourly)) "plan" <*>+ fetchAndSelect (runExceptT $ getPlans apiKey) (find ((== T.pack (planChoice options)) . planName)) "plan" <*> fetchAndSelect (runExceptT $ getKernels apiKey) (kernelSelect options) "kernel" @@ -381,8 +380,8 @@ apiKey <- fmap (head . words) (readFile "apiKey") sshPublicKey <- readFile "id_rsa.pub" let options = defaultLinodeCreationOptions {- datacenterSelect = find ((=="atlanta") . datacenterName),- planSelect = find ((=="Linode 1024") . planName),+ datacenterChoice = "atlanta",+ planChoice = "Linode 1024", sshKey = Just sshPublicKey } c <- createLinode apiKey True options@@ -403,8 +402,8 @@ sshPublicKey <- readFile "id_rsa.pub" apiKey <- fmap (head . words) (readFile "apiKey") let options = defaultLinodeCreationOptions {- datacenterSelect = find ((=="atlanta") . datacenterName),- planSelect = find ((=="Linode 1024") . planName),+ datacenterChoice = "atlanta",+ planChoice = "Linode 1024", sshKey = Just sshPublicKey } c <- createCluster apiKey options 2 True
src/Network/Linode/Types.hs view
@@ -18,8 +18,8 @@ type ApiKey = String data LinodeCreationOptions = LinodeCreationOptions {- datacenterSelect :: [Datacenter] -> Maybe Datacenter,- planSelect :: [Plan] -> Maybe Plan,+ datacenterChoice :: String,+ planChoice :: String, kernelSelect :: [Kernel] -> Maybe Kernel, distributionSelect :: [Distribution] -> Maybe Distribution, paymentChoice :: PaymentTerm,