@@ -282,11 +282,8 @@ instance FromJSON DockerVersion where
282282 parseJSON = genericParseJSON defaultOptions {
283283 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
284284
285−-- instance ToJSON ContainerDetails where
286−-- toJSON = error "TODO"
287−
288285instance FromJSON ContainerDetails where
289− parseJSON (JSON.Object o) = do
286+ parseJSON v@(JSON.Object o) = do
290287 appArmor <- o .: "AppArmorProfile"
291288 args <- o .: "Args"
292289 config <- o .: "Config"
@@ -296,7 +293,7 @@ instance FromJSON ContainerDetails where
296293 hostnamePath <- o .: "HostnamePath"
297294 hostsPath <- o .: "HostsPath"
298295 logPath <- o .: "LogPath"
299− id <- o .: "Id"
296+ id <- parseJSON v
300297 image <- o .: "Image"
301298 mountLabel <- o .: "MountLabel"
302299 name <- o .: "Name"
@@ -401,7 +398,7 @@ data NetworkSettings = NetworkSettings {
401398 , networkSettingsHairpinMode :: Bool
402399 , networkSettingsLinkLocalIPv6Address :: Text
403400 , networkSettingsLinkLocalIPv6PrefixLen :: Int
404− , networkSettingsPorts :: [Port] -- TODO: 1.24 spec is unclear
401+ , networkSettingsPorts :: PortBindings
405402 , networkSettingsSandboxKey :: Text
406403 , networkSettingsSecondaryIPAddresses :: Maybe [Text] -- TODO: 1.24 spec is unclear
407404 , networkSettingsSecondaryIPv6Addresses :: Maybe [Text] -- TODO: 1.24 spec is unclear
@@ -424,7 +421,7 @@ instance FromJSON NetworkSettings where
424421 hairpin <- o .: "HairpinMode"
425422 localIP6 <- o .: "LinkLocalIPv6Address"
426423 localIP6Len <- o .: "LinkLocalIPv6PrefixLen"
427− ports <- o .:? "Ports" .!= []
424+ ports <- o .: "Ports" -- .!= []
428425 sandboxKey <- o .: "SandboxKey"
429426 secondaryIP <- o .: "SecondaryIPAddresses"
430427 secondayIP6 <- o .: "SecondaryIPv6Addresses"
@@ -438,7 +435,7 @@ instance FromJSON NetworkSettings where
438435 mac <- o .: "MacAddress"
439436 networks <- o .: "Networks"
440437 return $ NetworkSettings bridge sandbox hairpin localIP6 localIP6Len ports sandboxKey secondaryIP secondayIP6 endpointID gateway globalIP6 globalIP6Len ip ipLen ip6Gateway mac networks
441− parseJSON _ = fail "NetworkSettings is not an Object"
438+ parseJSON _ = fail "NetworkSettings is not an object."
442439
443440data Container = Container
444441 { containerId :: ContainerID
@@ -824,7 +821,7 @@ newtype PortBindings = PortBindings [PortBinding]
824821data PortBinding = PortBinding {
825822 containerPort :: Port
826823 , portType :: PortType
827− , hostPorts :: HostPorts
824+ , hostPorts :: [HostPort]
828825 } deriving (Eq, Show)
829826
830827
@@ -862,29 +859,28 @@ instance ToJSON HostPort where
862859
863860instance FromJSON HostPort where
864861 parseJSON (JSON.Object o) = do
865− p <- o .: "HostPort"
866− i <- o .: "HostIP"
862+ p <- o .: "HostPort" >>= parseIntegerText
863+ i <- o .: "HostIp"
867864 return $ HostPort i p
868865 parseJSON _ = fail "HostPort is not an object."
869866
870−newtype HostPorts = HostPorts [HostPort]
871− deriving (Eq, Show)
872−
873−
874−instance ToJSON HostPorts where
875− toJSON (HostPorts hps) = toJSON hps
876−
877−instance FromJSON HostPorts where
878− parseJSON (JSON.Object o) = do
879− HostPorts <$> HM.foldlWithKey' f (return []) o
880−
881− where
882− f accM k v = do
883− acc <- accM
884− p' <- parseJSON v
885− p <- parseIntegerText p'
886− return $ (HostPort (NetworkInterface k) p):acc
887− parseJSON _ = fail "HostPorts is not an object"
867+-- newtype HostPorts = HostPorts [HostPort]
868+-- deriving (Eq, Show)
869+--
870+-- instance ToJSON HostPorts where
871+-- toJSON (HostPorts hps) = toJSON hps
872+--
873+-- instance FromJSON HostPorts where
874+-- parseJSON (JSON.Object o) = do
875+-- HostPorts <$> HM.foldlWithKey' f (return []) o
876+--
877+-- where
878+-- f accM k v = do
879+-- acc <- accM
880+-- p' <- parseJSON v
881+-- p <- parseIntegerText p'
882+-- return $ (HostPort (NetworkInterface k) p):acc
883+-- parseJSON _ = fail $ "HostPorts is not an object"
888884
889885-- { "Name": "on-failure" , "MaximumRetryCount": 2}
890886type RetryCount = Integer
@@ -1047,12 +1043,12 @@ instance ToJSON Ulimit where
10471043data ContainerResources = ContainerResources {
10481044 cpuShares :: Maybe Integer
10491045 -- , cgroupParent :: Text -- 1.24: Missing from inspecting container details... Going to omit for now.
1050− , blkioWeight :: Maybe Text
1051− , blkioWeightDevice :: Maybe Text
1052− , blkioDeviceReadBps :: Maybe Text
1053− , blkioDeviceWriteBps :: Maybe Text
1054− , blkioDeviceReadIOps :: Maybe Text
1055− , blkioDeviceWriteIOps :: Maybe Text
1046+ , blkioWeight :: Maybe Integer
1047+ , blkioWeightDevice :: Maybe Text -- TODO: Not Text
1048+ , blkioDeviceReadBps :: Maybe Text -- TODO: Not Text
1049+ , blkioDeviceWriteBps :: Maybe Text -- TODO: Not Text
1050+ , blkioDeviceReadIOps :: Maybe Text -- TODO: Not Text
1051+ , blkioDeviceWriteIOps :: Maybe Text -- TODO: Not Text
10561052 , cpuPeriod :: Maybe Integer
10571053 -- , cpuQuota :: Integer -- 1.24: Missing from inspecting container details... Going to omit for now.
10581054 , cpusetCpus :: Maybe Text
@@ -1173,7 +1169,7 @@ instance FromJSON ContainerConfig where
11731169 parseJSON = genericParseJSON defaultOptions {
11741170 fieldLabelModifier = (\(x:xs) -> toUpper x : xs)}
11751171
1176−parseIntegerText :: (Monad m) =>Text -> m Integer
1172+parseIntegerText :: (Monad m) => Text -> m Integer
11771173parseIntegerText t = case readMaybe $ T.unpack t of
11781174 Nothing ->
11791175 fail "Could not parse Integer"