@@ -68,6 +68,8 @@ module Docker.Client.Types (
68 , UTSMode(..)
68 , UTSMode(..)
69 , HostConfig(..)
69 , HostConfig(..)
70 , defaultHostConfig
70 , defaultHostConfig
71+ , NetworkingConfig(..)
71 , Ulimit(..)
73 , Ulimit(..)
72 , ContainerResources(..)
74 , ContainerResources(..)
73 , defaultContainerResources
75 , defaultContainerResources
@@ -611,20 +613,45 @@ instance FromJSON Image where
611 return $ DockerImage imageId imageCreated imageParentId imageRepoTags imageRepoDigests imageSize imageVirtualSize imageLabels
613 return $ DockerImage imageId imageCreated imageParentId imageRepoTags imageRepoDigests imageSize imageVirtualSize imageLabels
612 parseJSON _ = fail "Failed to parse DockerImage."
614 parseJSON _ = fail "Failed to parse DockerImage."
616+-- | Alias for Aliases.
619+-- | EndpointsConfig is container configuration for a specific network
620+newtype EndpointConfig = EndpointConfig [Alias] deriving (Eq, Show)
622+instance ToJSON EndpointConfig where
623+ toJSON (EndpointConfig aliases) = JSON.object
624+ [ "Aliases" .= aliases
627+-- | Data type for the NetworkingConfig section of the container settings
628+newtype NetworkingConfig = NetworkingConfig
629+ { endpointsConfig :: HM.HashMap Text EndpointConfig
630+ } deriving (Eq, Show)
632+instance ToJSON NetworkingConfig where
633+ toJSON (NetworkingConfig endpointsConfig) = JSON.object
634+ [ "EndpointsConfig" .= endpointsConfig
615-- | Options used for creating a Container.
637-- | Options used for creating a Container.
616data CreateOpts = CreateOpts {
638data CreateOpts = CreateOpts {
617 containerConfig :: ContainerConfig
639 containerConfig :: ContainerConfig
618 , hostConfig :: HostConfig
640 , hostConfig :: HostConfig
641+ , networkingConfig :: Maybe NetworkingConfig
619 } deriving (Eq, Show)
642 } deriving (Eq, Show)
621instance ToJSON CreateOpts where
644instance ToJSON CreateOpts where
622− toJSON (CreateOpts cc hc) = do
645+ toJSON (CreateOpts cc hc nc) = do
623 let ccJSON = toJSON cc
646 let ccJSON = toJSON cc
624 let hcJSON = toJSON hc
647 let hcJSON = toJSON hc
625 case ccJSON of
648 case ccJSON of
626 JSON.Object (o :: HM.HashMap T.Text JSON.Value) -> do
649 JSON.Object (o :: HM.HashMap T.Text JSON.Value) -> do
627− JSON.Object $ HM.insert "HostConfig" hcJSON o
650+ let o1 = HM.insert "HostConfig" hcJSON o
653+ Just _ -> HM.insert "NetworkingConfig" (toJSON nc) o1
628 _ -> error "ContainerConfig is not an object." -- This should never happen.
655 _ -> error "ContainerConfig is not an object." -- This should never happen.
630-- | Container configuration used for creating a container with sensible
657-- | Container configuration used for creating a container with sensible
@@ -706,7 +733,11 @@ defaultContainerResources = ContainerResources {
706-- | Default create options when creating a container. You only need to
733-- | Default create options when creating a container. You only need to
707-- specify an image name and the rest is all sensible defaults.
734-- specify an image name and the rest is all sensible defaults.
708defaultCreateOpts :: T.Text -> CreateOpts
735defaultCreateOpts :: T.Text -> CreateOpts
736+defaultCreateOpts imageName = CreateOpts
709−defaultCreateOpts imageName = CreateOpts { containerConfig = defaultContainerConfig imageName, hostConfig = defaultHostConfig }
737+ { containerConfig = defaultContainerConfig imageName
738+ , hostConfig = defaultHostConfig
739+ , networkingConfig = Nothing
711-- | Override the key sequence for detaching a container.
742-- | Override the key sequence for detaching a container.
712-- Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _.
743-- Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _.