MyNixOS website logo
Description

Complete API bindings for DigitalOcean API V2

Complete API bindings for DigitalOcean API V2

To get started, see Network.DigitalOcean module below.

DOH

Complete API bindings for DigitalOcean API V2

Getting Started

Here is an example usage of the API:

{-# LANGUAGE OverloadedStrings #-}

module Main where

-----------------------------------------------------------------
import Network.DigitalOcean
import Network.DigitalOcean.Types
import Network.DigitalOcean.Services
-----------------------------------------------------------------
import Control.Monad.Except
import Control.Monad.Reader
-----------------------------------------------------------------

client :: Client
client = Client "your api key"

main :: IO ()
main = do
  result <- runExceptT $ (runReaderT $ runDO createViaSshKeys) 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 api 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"))

For full documentation and reference, see: http://hackage.haskell.org/package/DOH-0.1.2.0

Contributing

What can you do?

  • You can open an issue for unexpected / needed behaviors
  • Better, you can send a Pull Request

Any kind of contributions are welcome, even if it's updating docs / improving commenting / improving tests.

Metadata

Version

0.1.4.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows