{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Batch.Types.Host
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Batch.Types.Host where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Determine whether your data volume persists on the host container
-- instance and where it is stored. If this parameter is empty, then the
-- Docker daemon assigns a host path for your data volume, but the data
-- isn\'t guaranteed to persist after the containers associated with it
-- stop running.
--
-- /See:/ 'newHost' smart constructor.
data Host = Host'
  { -- | The path on the host container instance that\'s presented to the
    -- container. If this parameter is empty, then the Docker daemon has
    -- assigned a host path for you. If this parameter contains a file
    -- location, then the data volume persists at the specified location on the
    -- host container instance until you delete it manually. If the source path
    -- location doesn\'t exist on the host container instance, the Docker
    -- daemon creates it. If the location does exist, the contents of the
    -- source path folder are exported.
    --
    -- This parameter isn\'t applicable to jobs that run on Fargate resources
    -- and shouldn\'t be provided.
    Host -> Maybe Text
sourcePath :: Prelude.Maybe Prelude.Text
  }
  deriving (Host -> Host -> Bool
(Host -> Host -> Bool) -> (Host -> Host -> Bool) -> Eq Host
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Host -> Host -> Bool
$c/= :: Host -> Host -> Bool
== :: Host -> Host -> Bool
$c== :: Host -> Host -> Bool
Prelude.Eq, ReadPrec [Host]
ReadPrec Host
Int -> ReadS Host
ReadS [Host]
(Int -> ReadS Host)
-> ReadS [Host] -> ReadPrec Host -> ReadPrec [Host] -> Read Host
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Host]
$creadListPrec :: ReadPrec [Host]
readPrec :: ReadPrec Host
$creadPrec :: ReadPrec Host
readList :: ReadS [Host]
$creadList :: ReadS [Host]
readsPrec :: Int -> ReadS Host
$creadsPrec :: Int -> ReadS Host
Prelude.Read, Int -> Host -> ShowS
[Host] -> ShowS
Host -> String
(Int -> Host -> ShowS)
-> (Host -> String) -> ([Host] -> ShowS) -> Show Host
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Host] -> ShowS
$cshowList :: [Host] -> ShowS
show :: Host -> String
$cshow :: Host -> String
showsPrec :: Int -> Host -> ShowS
$cshowsPrec :: Int -> Host -> ShowS
Prelude.Show, (forall x. Host -> Rep Host x)
-> (forall x. Rep Host x -> Host) -> Generic Host
forall x. Rep Host x -> Host
forall x. Host -> Rep Host x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Host x -> Host
$cfrom :: forall x. Host -> Rep Host x
Prelude.Generic)

-- |
-- Create a value of 'Host' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'sourcePath', 'host_sourcePath' - The path on the host container instance that\'s presented to the
-- container. If this parameter is empty, then the Docker daemon has
-- assigned a host path for you. If this parameter contains a file
-- location, then the data volume persists at the specified location on the
-- host container instance until you delete it manually. If the source path
-- location doesn\'t exist on the host container instance, the Docker
-- daemon creates it. If the location does exist, the contents of the
-- source path folder are exported.
--
-- This parameter isn\'t applicable to jobs that run on Fargate resources
-- and shouldn\'t be provided.
newHost ::
  Host
newHost :: Host
newHost = Host' :: Maybe Text -> Host
Host' {$sel:sourcePath:Host' :: Maybe Text
sourcePath = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The path on the host container instance that\'s presented to the
-- container. If this parameter is empty, then the Docker daemon has
-- assigned a host path for you. If this parameter contains a file
-- location, then the data volume persists at the specified location on the
-- host container instance until you delete it manually. If the source path
-- location doesn\'t exist on the host container instance, the Docker
-- daemon creates it. If the location does exist, the contents of the
-- source path folder are exported.
--
-- This parameter isn\'t applicable to jobs that run on Fargate resources
-- and shouldn\'t be provided.
host_sourcePath :: Lens.Lens' Host (Prelude.Maybe Prelude.Text)
host_sourcePath :: (Maybe Text -> f (Maybe Text)) -> Host -> f Host
host_sourcePath = (Host -> Maybe Text)
-> (Host -> Maybe Text -> Host)
-> Lens Host Host (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Host' {Maybe Text
sourcePath :: Maybe Text
$sel:sourcePath:Host' :: Host -> Maybe Text
sourcePath} -> Maybe Text
sourcePath) (\s :: Host
s@Host' {} Maybe Text
a -> Host
s {$sel:sourcePath:Host' :: Maybe Text
sourcePath = Maybe Text
a} :: Host)

instance Core.FromJSON Host where
  parseJSON :: Value -> Parser Host
parseJSON =
    String -> (Object -> Parser Host) -> Value -> Parser Host
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Host"
      (\Object
x -> Maybe Text -> Host
Host' (Maybe Text -> Host) -> Parser (Maybe Text) -> Parser Host
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sourcePath"))

instance Prelude.Hashable Host

instance Prelude.NFData Host

instance Core.ToJSON Host where
  toJSON :: Host -> Value
toJSON Host' {Maybe Text
sourcePath :: Maybe Text
$sel:sourcePath:Host' :: Host -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"sourcePath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sourcePath]
      )