-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Bindings to the Linode API -- -- Haskell bindings to the Linode API. Rent servers hourly or monthly. -- -- This package contains some helpers to create and configure Linode -- instances. The API key can be created on the Linode website. @package linode @version 0.3.0.0 module Network.Linode.Types type ApiKey = String data LinodeCreationOptions LinodeCreationOptions :: String -> String -> ([Kernel] -> Maybe Kernel) -> ([Distribution] -> Maybe Distribution) -> PaymentTerm -> Int -> String -> Maybe String -> String -> Maybe ConfigId -> LinodeCreationOptions [datacenterChoice] :: LinodeCreationOptions -> String [planChoice] :: LinodeCreationOptions -> String [kernelSelect] :: LinodeCreationOptions -> [Kernel] -> Maybe Kernel [distributionSelect] :: LinodeCreationOptions -> [Distribution] -> Maybe Distribution [paymentChoice] :: LinodeCreationOptions -> PaymentTerm [swapAmount] :: LinodeCreationOptions -> Int [password] :: LinodeCreationOptions -> String [sshKey] :: LinodeCreationOptions -> Maybe String [diskLabel] :: LinodeCreationOptions -> String [config] :: LinodeCreationOptions -> Maybe ConfigId newtype ConfigId ConfigId :: Int -> ConfigId [unConfigId] :: ConfigId -> Int newtype DatacenterId DatacenterId :: Int -> DatacenterId newtype DistributionId DistributionId :: Int -> DistributionId newtype DiskId DiskId :: Int -> DiskId [unDisk] :: DiskId -> Int newtype LinodeId LinodeId :: Int -> LinodeId [unLinodeId] :: LinodeId -> Int newtype JobId JobId :: Int -> JobId newtype KernelId KernelId :: Int -> KernelId newtype PlanId PlanId :: Int -> PlanId data DiskType Ext3 :: DiskType Ext4 :: DiskType Swap :: DiskType RawDisk :: DiskType data InstanceStatus BeingCreated :: InstanceStatus NewInstance :: InstanceStatus Running :: InstanceStatus PoweredOff :: InstanceStatus data PaymentTerm OneMonth :: PaymentTerm OneYear :: PaymentTerm TwoYears :: PaymentTerm data AccountInfo AccountInfo :: Int -> Int -> Int -> Bool -> Int -> Text -> AccountInfo [accountTransferPool] :: AccountInfo -> Int [accountTransferUsed] :: AccountInfo -> Int [accountTransferBillable] :: AccountInfo -> Int [accountManaged] :: AccountInfo -> Bool [accountBalance] :: AccountInfo -> Int [accountBillingMethod] :: AccountInfo -> Text data Address Address :: String -> String -> Bool -> Address [ip] :: Address -> String [rdnsName] :: Address -> String [isPublic] :: Address -> Bool data Datacenter Datacenter :: DatacenterId -> Text -> Text -> Datacenter [datacenterId] :: Datacenter -> DatacenterId [datacenterLocation] :: Datacenter -> Text [datacenterName] :: Datacenter -> Text data Distribution Distribution :: DistributionId -> Text -> Bool -> Int -> Bool -> Distribution [distributionId] :: Distribution -> DistributionId [distributionName] :: Distribution -> Text [is64Bit] :: Distribution -> Bool [minImageSize] :: Distribution -> Int [requiresPvopsKernel] :: Distribution -> Bool -- | Detailed info about a Linode instance. Memory and transfer are given -- in MB. data Instance Instance :: LinodeId -> Text -> DatacenterId -> PlanId -> Int -> Int -> Int -> Bool -> InstanceStatus -> Instance [instanceId] :: Instance -> LinodeId [instanceName] :: Instance -> Text [instanceDatacenterId] :: Instance -> DatacenterId [instancePlanId] :: Instance -> PlanId [instanceRAM] :: Instance -> Int [instanceHD] :: Instance -> Int [instanceTransfer] :: Instance -> Int [instanceBackupEnabled] :: Instance -> Bool [instanceStatus] :: Instance -> InstanceStatus data Kernel Kernel :: KernelId -> Text -> Bool -> Bool -> Bool -> Kernel [kernelId] :: Kernel -> KernelId [kernelName] :: Kernel -> Text [isXen] :: Kernel -> Bool [isKVM] :: Kernel -> Bool [isPVOPS] :: Kernel -> Bool data Plan Plan :: PlanId -> Text -> Int -> Int -> Int -> Double -> Map DatacenterId Int -> Plan [planId] :: Plan -> PlanId [planName] :: Plan -> Text [ram] :: Plan -> Int [disk] :: Plan -> Int [xfer] :: Plan -> Int [hourly] :: Plan -> Double [availabilities] :: Plan -> Map DatacenterId Int data BootedInstance BootedInstance :: JobId -> BootedInstance [bootJobId] :: BootedInstance -> JobId data CreatedConfig CreatedConfig :: ConfigId -> CreatedConfig [createdConfigId] :: CreatedConfig -> ConfigId data CreatedLinode CreatedLinode :: LinodeId -> CreatedLinode [createdLinodeId] :: CreatedLinode -> LinodeId data CreatedDisk CreatedDisk :: DiskId -> JobId -> CreatedDisk [diskCreationDiskId] :: CreatedDisk -> DiskId [diskCreationJobId] :: CreatedDisk -> JobId type DeletedLinode = CreatedLinode data WaitingJob WaitingJob :: JobId -> LinodeId -> Bool -> Text -> WaitingJob [waitingJobId] :: WaitingJob -> JobId [waitingJobLinodeId] :: WaitingJob -> LinodeId [waitingJobSuccess] :: WaitingJob -> Bool [waitingJobLabel] :: WaitingJob -> Text -- | Basic info about a linode instance. data Linode Linode :: LinodeId -> ConfigId -> Text -> String -> [Address] -> Linode [linodeId] :: Linode -> LinodeId [linodeConfigId] :: Linode -> ConfigId [linodeDatacenterName] :: Linode -> Text [linodePassword] :: Linode -> String [linodeAddresses] :: Linode -> [Address] type Cluster = [Linode] data Response a Response :: [LinodeError] -> Maybe a -> Response a [responseErrors] :: Response a -> [LinodeError] [responseContent] :: Response a -> Maybe a data LinodeError BadRequest :: LinodeError NoActionWasRequested :: LinodeError TheRequestedClassDoesNotExist :: LinodeError AuthenticationFailed :: LinodeError ObjectNotFound :: LinodeError ARequiredPropertyIsMissingForThisAction :: LinodeError PropertyIsInvalid :: LinodeError ADataValidationErrorHasOccurred :: LinodeError MethodNotImplemented :: LinodeError TooManyBatchedRequests :: LinodeError RequestArrayIsntValidJSONOrWDDX :: LinodeError BatchApproachingTimeout :: LinodeError PermissionDenied :: LinodeError APIRateLimitExceeded :: LinodeError ChargingTheCreditCardFailed :: LinodeError CreditCardIsExpired :: LinodeError LimitOfLinodesAddedPerHourReached :: LinodeError LinodeMustHaveNoDisksBeforeDelete :: LinodeError DeserializationError :: Text -> LinodeError NetworkError :: IOException -> LinodeError UnknownError :: Int -> LinodeError SelectionError :: String -> LinodeError linodeErrorFromCode :: Int -> LinodeError instanceStatusFromInt :: Int -> Maybe InstanceStatus instance GHC.Show.Show a => GHC.Show.Show (Network.Linode.Types.Response a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Network.Linode.Types.Response a) instance GHC.Show.Show Network.Linode.Types.LinodeError instance GHC.Classes.Eq Network.Linode.Types.LinodeError instance GHC.Generics.Generic Network.Linode.Types.Linode instance GHC.Show.Show Network.Linode.Types.Linode instance GHC.Classes.Eq Network.Linode.Types.Linode instance GHC.Show.Show Network.Linode.Types.WaitingJob instance GHC.Classes.Eq Network.Linode.Types.WaitingJob instance GHC.Show.Show Network.Linode.Types.CreatedDisk instance GHC.Classes.Eq Network.Linode.Types.CreatedDisk instance GHC.Show.Show Network.Linode.Types.CreatedLinode instance GHC.Classes.Eq Network.Linode.Types.CreatedLinode instance GHC.Show.Show Network.Linode.Types.CreatedConfig instance GHC.Classes.Eq Network.Linode.Types.CreatedConfig instance GHC.Show.Show Network.Linode.Types.BootedInstance instance GHC.Classes.Eq Network.Linode.Types.BootedInstance instance GHC.Show.Show Network.Linode.Types.Plan instance GHC.Classes.Eq Network.Linode.Types.Plan instance GHC.Show.Show Network.Linode.Types.Kernel instance GHC.Classes.Eq Network.Linode.Types.Kernel instance GHC.Show.Show Network.Linode.Types.Instance instance GHC.Classes.Eq Network.Linode.Types.Instance instance GHC.Show.Show Network.Linode.Types.Distribution instance GHC.Classes.Eq Network.Linode.Types.Distribution instance GHC.Show.Show Network.Linode.Types.Datacenter instance GHC.Classes.Eq Network.Linode.Types.Datacenter instance GHC.Generics.Generic Network.Linode.Types.Address instance GHC.Show.Show Network.Linode.Types.Address instance GHC.Classes.Eq Network.Linode.Types.Address instance GHC.Show.Show Network.Linode.Types.AccountInfo instance GHC.Classes.Eq Network.Linode.Types.AccountInfo instance GHC.Show.Show Network.Linode.Types.PaymentTerm instance GHC.Classes.Eq Network.Linode.Types.PaymentTerm instance GHC.Show.Show Network.Linode.Types.InstanceStatus instance GHC.Classes.Eq Network.Linode.Types.InstanceStatus instance GHC.Show.Show Network.Linode.Types.DiskType instance GHC.Classes.Eq Network.Linode.Types.DiskType instance GHC.Show.Show Network.Linode.Types.PlanId instance GHC.Classes.Ord Network.Linode.Types.PlanId instance GHC.Classes.Eq Network.Linode.Types.PlanId instance GHC.Show.Show Network.Linode.Types.KernelId instance GHC.Classes.Ord Network.Linode.Types.KernelId instance GHC.Classes.Eq Network.Linode.Types.KernelId instance GHC.Show.Show Network.Linode.Types.JobId instance GHC.Classes.Eq Network.Linode.Types.JobId instance GHC.Generics.Generic Network.Linode.Types.LinodeId instance GHC.Show.Show Network.Linode.Types.LinodeId instance GHC.Classes.Ord Network.Linode.Types.LinodeId instance GHC.Classes.Eq Network.Linode.Types.LinodeId instance GHC.Show.Show Network.Linode.Types.DiskId instance GHC.Classes.Eq Network.Linode.Types.DiskId instance GHC.Show.Show Network.Linode.Types.DistributionId instance GHC.Classes.Ord Network.Linode.Types.DistributionId instance GHC.Classes.Eq Network.Linode.Types.DistributionId instance GHC.Show.Show Network.Linode.Types.DatacenterId instance GHC.Classes.Ord Network.Linode.Types.DatacenterId instance GHC.Classes.Eq Network.Linode.Types.DatacenterId instance GHC.Generics.Generic Network.Linode.Types.ConfigId instance GHC.Show.Show Network.Linode.Types.ConfigId instance GHC.Classes.Eq Network.Linode.Types.ConfigId instance Data.Binary.Class.Binary Network.Linode.Types.ConfigId instance Data.Binary.Class.Binary Network.Linode.Types.LinodeId instance Data.Binary.Class.Binary Network.Linode.Types.Address instance Data.Binary.Class.Binary Network.Linode.Types.Linode instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.AccountInfo instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.BootedInstance instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.CreatedLinode instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.CreatedConfig instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.CreatedDisk instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.Datacenter instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.Distribution instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.Instance instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.Address instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.Kernel instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.LinodeError instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.Plan instance Data.Aeson.Types.FromJSON.FromJSON Network.Linode.Types.WaitingJob instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (Network.Linode.Types.Response a) module Network.Linode.Parsing parseResponse :: FromJSON a => ByteString -> Either LinodeError a -- | This package contains some helpers to create and configure -- Linode instances. They all require an API key, which can be -- created on the Linode website. -- -- Usage example. We want to create one Linode instance in Atlanta with -- 1GB of RAM: -- --
-- import Network.Linode
-- import Data.List (find)
-- import qualified System.Process as P
-- import Data.Foldable (traverse_)
-- import Data.Monoid ((<>))
--
-- main :: IO()
-- main = do
-- apiKey <- fmap (head . words) (readFile "apiKey")
-- sshPublicKey <- readFile "id_rsa.pub"
-- let options = defaultLinodeCreationOptions {
-- datacenterChoice = "atlanta",
-- planChoice = "Linode 1024",
-- sshKey = Just sshPublicKey
-- }
-- c <- createLinode apiKey True options
-- case c of
-- Left err -> print err
-- Right linode -> do
-- traverse_ (\a -> waitForSSH a >> setup a) (publicAddress linode)
-- print linode
--
-- setup address = P.callCommand $ "scp yourfile root@" <> ip address <> ":/root"
--
--
-- You should see something like this:
--
-- -- Creating empty linode (Linode 1024 at atlanta) -- Creating disk (24448 MB) -- .............. -- Creating swap (128 MB) -- ........ -- Creating config -- Booting -- ...................................... -- Booted linode 1481198 ---- -- And get something like that: -- --
-- Linode {
-- linodeId = LinodeId {unLinodeId = 1481198},
-- linodeConfigId = ConfigId {unConfigId = 2251152},
-- linodeDatacenterName = "atlanta",
-- linodePassword = "We4kP4ssw0rd",
-- linodeAddresses = [Address {ip = "45.79.194.121", rdnsName = "li1293-121.members.linode.com"}]}
--
module Network.Linode
-- | Create a Linode instance and boot it.
createLinode :: ApiKey -> Bool -> LinodeCreationOptions -> IO (Either LinodeError Linode)
-- | Create a Linode cluster.
createCluster :: ApiKey -> LinodeCreationOptions -> Int -> Bool -> IO (Either [LinodeError] [Linode])
-- | Default options to create an instance. Please customize the security
-- options.
defaultLinodeCreationOptions :: LinodeCreationOptions
-- | Wait until an ssh connexion is possible, then add the Linode's ip in
-- known_hosts.
--
-- A newly created Linode is unreachable during a few seconds.
waitForSSH :: Address -> IO ()
-- | Delete a Linode instance.
deleteInstance :: ApiKey -> LinodeId -> IO (Either LinodeError DeletedLinode)
-- | Delete a list of Linode instances.
deleteCluster :: ApiKey -> [LinodeId] -> IO ([LinodeError], [DeletedLinode])
-- | Read your global account information: network usage, billing state and
-- billing method.
getAccountInfo :: ApiKey -> ExceptT LinodeError IO AccountInfo
-- | Read all Linode datacenters: dallas, fremont, atlanta, newark, london,
-- tokyo, singapore, frankfurt
getDatacenters :: ApiKey -> ExceptT LinodeError IO [Datacenter]
-- | Read all available Linux distributions. For example, Debian 8.1 has id
-- 140.
getDistributions :: ApiKey -> ExceptT LinodeError IO [Distribution]
-- | Read detailed information about all your instances.
getInstances :: ApiKey -> ExceptT LinodeError IO [Instance]
-- | Read all available Linux kernels.
getKernels :: ApiKey -> ExceptT LinodeError IO [Kernel]
-- | Read all plans offered by Linode. A plan specifies the available CPU,
-- RAM, network usage and pricing of an instance. The smallest plan is
-- Linode 1024.
getPlans :: ApiKey -> ExceptT LinodeError IO [Plan]
-- | Read all IP addresses of an instance.
getIpList :: ApiKey -> LinodeId -> ExceptT LinodeError IO [Address]
-- | Create a Linode Config (a bag of instance options).
createConfig :: ApiKey -> LinodeId -> KernelId -> String -> [DiskId] -> ExceptT LinodeError IO CreatedConfig
-- | Create a disk from a supported Linux distribution. Size in MB.
createDiskFromDistribution :: ApiKey -> LinodeId -> DistributionId -> String -> Int -> String -> Maybe String -> ExceptT LinodeError IO CreatedDisk
-- | Create a Linode instance with no disk and no configuration. You
-- probably want createLinode instead.
createDisklessLinode :: ApiKey -> DatacenterId -> PlanId -> PaymentTerm -> ExceptT LinodeError IO CreatedLinode
-- | Create a swap partition.
createSwapDisk :: ApiKey -> LinodeId -> String -> Int -> ExceptT LinodeError IO CreatedDisk
-- | Create a partition.
createDisk :: ApiKey -> LinodeId -> String -> DiskType -> Int -> ExceptT LinodeError IO CreatedDisk
-- | Boot a Linode instance.
boot :: ApiKey -> LinodeId -> ConfigId -> ExceptT LinodeError IO BootedInstance
-- | List of pending jobs for this Linode instance.
jobList :: ApiKey -> LinodeId -> ExceptT LinodeError IO [WaitingJob]
-- | Wait until all operations on one instance are done.
waitUntilCompletion :: ApiKey -> LinodeId -> Bool -> IO ()
-- | Select a Datacenter, a Plan, a Linux distribution and kernel from all
-- Linode offering.
select :: ApiKey -> LinodeCreationOptions -> ExceptT LinodeError IO (Datacenter, Distribution, Plan, Kernel)
-- | Pick one public address of the Linode Instance
publicAddress :: Linode -> Maybe Address
-- | Example of Linode creation. It expects the apiKey and id_rsa.pub files
-- in the current directory.
exampleCreateOneLinode :: IO (Maybe Linode)
-- | Example of Linodes creation. It expects the apiKey and id_rsa.pub
-- files in the current directory.
exampleCreateTwoLinodes :: IO (Maybe [Linode])