@@ -2,8 +2,9 @@ module Docker.Types where
22
33import Control.Monad.Except (ExceptT, runExceptT)
44import Control.Monad.Reader (ReaderT, runReaderT)
5−import Data.Aeson (FromJSON, ToJSON, genericParseJSON,
6− genericToJSON, parseJSON, toJSON)
5+import Data.Aeson (FromJSON, ToJSON, encode,
6+ genericParseJSON, genericToJSON,
7+ parseJSON, toJSON)
78import Data.Aeson.Types (defaultOptions, fieldLabelModifier)
89import qualified Data.ByteString.Lazy as BL
910import Data.Char (toUpper)
@@ -15,10 +16,15 @@ import qualified Network.HTTP.Client as HTTP
1516type Endpoint = Text
1617type URL = Text
1718type ApiVersion = Text
19+type ContainerID = Text
20+type ImageID = Text
21+type Timeout = Integer
1822
1923type Request = HTTP.Request
2024type Response = HTTP.Response BL.ByteString
2125
26+data Signal = SIGINT | SIGKILL deriving (Eq, Show)
27+
2228data DockerClientOpts m = DockerClientOpts {
2329 http :: Request -> m Response
2430 , apiVersion :: ApiVersion
@@ -31,22 +37,17 @@ runDockerT :: (Monad m) => DockerClientOpts m -> DockerT m a -> m (Either String
3137runDockerT opts a = runExceptT $ runReaderT a opts
3238-- runDockerT opts a = (runExceptT .) . flip runReaderT opts a
3339
34−data ListOpts = ListOpts
35− { all :: Bool
36− } deriving (Eq, Show, Generic)
37−
38−instance ToJSON ListOpts
39−instance FromJSON ListOpts
40+data ListOpts = ListOpts { all :: Bool } deriving (Eq, Show)
4041
4142defaultClientOpts :: DockerClientOpts IO
42−defaultClientOpts = DockerClientOpts
43− { http = undefined
43+defaultClientOpts = DockerClientOpts {
44+ http = undefined
4445 , apiVersion = "v1.22"
4546 , baseUrl = "http://127.0.0.1:2375/"
4647 }
4748
48−data DockerVersion = DockerVersion
49− { version :: Text
49+data DockerVersion = DockerVersion {
50+ version :: Text
5051 , gitCommit :: Text
5152 , goVersion :: Text
5253 , arch :: Text
@@ -67,4 +68,22 @@ data Container = Container
6768
6869data Image = Image
6970
70−
71+data CreateOpts = CreateOpts
72+data StartOpts = StartOpts
73+
74+data DeleteOpts = DeleteOpts {
75+ v :: Bool
76+ , force :: Bool
77+ } deriving (Eq, Show)
78+
79+type Timestamp = Integer
80+data Tail = Integer | All deriving (Eq, Show)
81+
82+data LogOpts = LogOpts {
83+ follow :: Bool
84+ , stdout :: Bool
85+ , stderr :: Bool
86+ , since :: Timestamp
87+ , timestamps :: Bool
88+ , tail :: Tail
89+ } deriving (Eq, Show)