Skip to content

Commit

Permalink
change tests to comments #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ryotaro612 committed Jun 25, 2015
1 parent 503ea8b commit 5894cae
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 59 deletions.
14 changes: 8 additions & 6 deletions src/DigitalOcean/Account.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ instance FromJSON Account where
parseJSON _ = mzero

-- | Get User Information
-- >>> :{
-- Example:
--
-- @
-- do
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- mayBeAcnt <- account $ Authentication tkn
-- print $ show $ isJust mayBeAcnt
-- :}
-- "True"
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- mayBeAcnt <- account $ Authentication tkn
-- print $ show $ isJust mayBeAcnt
-- @
--
account :: Authentication -> (MonadIO m) => m (Maybe Account)
account a = liftM toAccount $ liftM decode (requestGet "account" a)

Expand Down
13 changes: 7 additions & 6 deletions src/DigitalOcean/Droplet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ instance FromJSON Droplet where


-- | List all Droplets
-- :{
--
-- @
-- do
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeDroplets <- droplets $ Authentication tkn
-- print $ show $ isJust maybeDroplets
-- :}
-- "True"
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeDroplets <- droplets $ Authentication tkn
-- print $ show $ isJust maybeDroplets
-- @
--
droplets :: Authentication -> (MonadIO m) => m (Maybe [Droplet])
droplets a = liftM toList $ liftM decode (requestGet "droplets?page=1&per_page=100" a)

Expand Down
26 changes: 14 additions & 12 deletions src/DigitalOcean/Image.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,26 @@ data Image = Image {
} deriving(Show, Read)

-- | List all Images
-- >>> :{
--
-- @
-- do
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeImages <- images $ Authentication tkn
-- print $ show $ isJust maybeImages
-- :}
-- "True"
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeImages <- images $ Authentication tkn
-- print $ show $ isJust maybeImages
-- @
--
images :: Authentication -> (MonadIO m) => m (Maybe [Image])
images a = liftM toList $ liftM decode (requestGet "images?page=1&per_page=1" a)

-- | List all Distribution Images
-- >>> :{
--
-- @
-- do
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeImages <- listAllDistributionImages $ Authentication tkn
-- print $ show $ isJust maybeImages
-- :}
-- "True"
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeImages <- listAllDistributionImages $ Authentication tkn
-- print $ show $ isJust maybeImages
-- @
--
listAllDistributionImages :: Authentication -> (MonadIO m) => m (Maybe [Image])
listAllDistributionImages a = liftM toList $ liftM decode (requestGet "images?page=1&per_page=100&type=distribution" a)

Expand Down
34 changes: 17 additions & 17 deletions src/DigitalOcean/NewDroplet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@ instance FromJSON OuterDroplet where


-- | create new Droplet
-- :{
--
-- @
-- do
-- let d = NewDropletRequest {
-- ndname="hoge",
-- region="nyc3",
-- size="512mb",
-- image=12241402,
-- ndsshKeys=[],
-- backups = False,
-- ipv6=True,
-- userData = Nothing,
-- privateNetworking=False
-- }
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeNewDroplet <- newDroplet ( Authentication tkn) d
-- print $ show $ isJust maybeNewDroplet
-- :}
-- "True"
-- let d = NewDropletRequest {
-- ndname="hoge",
-- region="nyc3",
-- size="512mb",
-- image=12241402,
-- ndsshKeys=[],
-- backups = False,
-- ipv6=True,
-- userData = Nothing,
-- privateNetworking=False
-- }
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeNewDroplet <- newDroplet ( Authentication tkn) d
-- @
--
newDroplet :: Authentication -> NewDropletRequest -> (MonadIO m) => m (Maybe Droplet)
newDroplet a d = liftM toDroplet $ liftM decode (requestPost "droplets" a d)

Expand Down
13 changes: 7 additions & 6 deletions src/DigitalOcean/Region.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ data Region = Region {


-- | List all Regions
-- >>> :{
--
-- @
-- do
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeRegions <- regions $ Authentication tkn
-- print $ show $ isJust maybeRegions
-- :}
-- "True"
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeRegions <- regions $ Authentication tkn
-- print $ show $ isJust maybeRegions
-- @
--
regions :: Authentication -> (MonadIO m) => m (Maybe [Region])
regions a = liftM toList $ liftM decode (requestGet "regions" a)

Expand Down
13 changes: 7 additions & 6 deletions src/DigitalOcean/SSHKey.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ instance FromJSON SSHKey where
parseJSON _ = mzero

-- | List all Keys
-- >>> :{
--
-- @
-- do
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeKeys <- listAllKeys $ Authentication tkn
-- print $ show $ isJust maybeKeys
-- :}
-- "True"
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeKeys <- listAllKeys $ Authentication tkn
-- print $ show $ isJust maybeKeys
-- @
--
listAllKeys :: Authentication -> (MonadIO m) => m (Maybe [SSHKey])
listAllKeys a = liftM toList $ liftM decode (requestGet "account/keys" a)

Expand Down
13 changes: 7 additions & 6 deletions src/DigitalOcean/Size.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ instance FromJSON Sizes where
parseJSON _ = mzero

-- | List all Sizes
-- >>> :{
--
-- @
-- do
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeSizes <- sizes $ Authentication tkn
-- print $ show $ isJust maybeSizes
-- :}
-- "True"
-- tkn <- getEnv "DIGITAL_OCEAN_PERSONAL_ACCESS_TOKEN"
-- maybeSizes <- sizes $ Authentication tkn
-- print $ show $ isJust maybeSizes
-- @
--
sizes :: Authentication -> (MonadIO m) => m (Maybe [Size])
sizes a = liftM toList $ liftM decode (requestGet "sizes" a)

Expand Down

0 comments on commit 5894cae

Please sign in to comment.