DOH-0.1.4.0: Complete API bindings for DigitalOcean API V2

Copyright(c) Yiğit Özkavcı 2017
LicenseMIT
Maintaineryigitozkavci8@gmail.com
Stabilitybeta
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Network.DigitalOcean

Contents

Description

Every computation within this module should be assessed via DO monad.

An example usage:

{-# LANGUAGE OverloadedStrings #-}

module Main where

import Network.DigitalOcean
import Control.Monad.Except
import Control.Monad.Reader

client :: Client
client = Client "my api key"

main :: IO ()
main = do
  result <- runExceptT $ (runReaderT $ "runDO" doActions) client
  case result of
    Left err -> print err
    Right _ -> return ()

createViaSshKeys :: DO ()
createViaSshKeys = do
  -- Read a public key from a key pair and create ssh keys on DigitalOcean with it
  pubKey <- liftIO $ readFile "/Users/yigitozkavci/.ssh/do_api_rsa.pub"
  sshKey <- createSSHKey (SSHKeyPayload "my ssh key" pubKey) 
  
  -- Create 2 droplets with our newly uploaded ssh keys
  let dropletPayload = IDropletPayload "nyc3" "512mb" Ubuntu1404x64 (Just [sshkeyFingerprint sshKey]) Nothing Nothing Nothing Nothing Nothing Nothing Nothing
  droplets <- map dropletId <$> createDroplets ["droplet-1", "droplet-2"] dropletPayload

  -- Take snapshot of our newly created droplets
  forM_ droplets $ dropletId -> performDropletAction dropletId (TakeSnapshot (Just "bulk snapshot"))

Synopsis

Account

Actions

Regions

Volumes

Snapshots

Certificates

Domains

Domain Records

Images

Sizes

Droplets

Floating IPs

Firewalls

Load Balancers

SSH Keys