{-# 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.ECS.Types.HostVolumeProperties
-- 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.ECS.Types.HostVolumeProperties where

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

-- | Details on a container instance bind mount host volume.
--
-- /See:/ 'newHostVolumeProperties' smart constructor.
data HostVolumeProperties = HostVolumeProperties'
  { -- | When the @host@ parameter is used, specify a @sourcePath@ to declare the
    -- path on the host container instance that is presented to the container.
    -- If this parameter is empty, then the Docker daemon has assigned a host
    -- path for you. If the @host@ parameter contains a @sourcePath@ file
    -- location, then the data volume persists at the specified location on the
    -- host container instance until you delete it manually. If the
    -- @sourcePath@ value does not 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.
    --
    -- If you are using the Fargate launch type, the @sourcePath@ parameter is
    -- not supported.
    HostVolumeProperties -> Maybe Text
sourcePath :: Prelude.Maybe Prelude.Text
  }
  deriving (HostVolumeProperties -> HostVolumeProperties -> Bool
(HostVolumeProperties -> HostVolumeProperties -> Bool)
-> (HostVolumeProperties -> HostVolumeProperties -> Bool)
-> Eq HostVolumeProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HostVolumeProperties -> HostVolumeProperties -> Bool
$c/= :: HostVolumeProperties -> HostVolumeProperties -> Bool
== :: HostVolumeProperties -> HostVolumeProperties -> Bool
$c== :: HostVolumeProperties -> HostVolumeProperties -> Bool
Prelude.Eq, ReadPrec [HostVolumeProperties]
ReadPrec HostVolumeProperties
Int -> ReadS HostVolumeProperties
ReadS [HostVolumeProperties]
(Int -> ReadS HostVolumeProperties)
-> ReadS [HostVolumeProperties]
-> ReadPrec HostVolumeProperties
-> ReadPrec [HostVolumeProperties]
-> Read HostVolumeProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HostVolumeProperties]
$creadListPrec :: ReadPrec [HostVolumeProperties]
readPrec :: ReadPrec HostVolumeProperties
$creadPrec :: ReadPrec HostVolumeProperties
readList :: ReadS [HostVolumeProperties]
$creadList :: ReadS [HostVolumeProperties]
readsPrec :: Int -> ReadS HostVolumeProperties
$creadsPrec :: Int -> ReadS HostVolumeProperties
Prelude.Read, Int -> HostVolumeProperties -> ShowS
[HostVolumeProperties] -> ShowS
HostVolumeProperties -> String
(Int -> HostVolumeProperties -> ShowS)
-> (HostVolumeProperties -> String)
-> ([HostVolumeProperties] -> ShowS)
-> Show HostVolumeProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HostVolumeProperties] -> ShowS
$cshowList :: [HostVolumeProperties] -> ShowS
show :: HostVolumeProperties -> String
$cshow :: HostVolumeProperties -> String
showsPrec :: Int -> HostVolumeProperties -> ShowS
$cshowsPrec :: Int -> HostVolumeProperties -> ShowS
Prelude.Show, (forall x. HostVolumeProperties -> Rep HostVolumeProperties x)
-> (forall x. Rep HostVolumeProperties x -> HostVolumeProperties)
-> Generic HostVolumeProperties
forall x. Rep HostVolumeProperties x -> HostVolumeProperties
forall x. HostVolumeProperties -> Rep HostVolumeProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HostVolumeProperties x -> HostVolumeProperties
$cfrom :: forall x. HostVolumeProperties -> Rep HostVolumeProperties x
Prelude.Generic)

-- |
-- Create a value of 'HostVolumeProperties' 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', 'hostVolumeProperties_sourcePath' - When the @host@ parameter is used, specify a @sourcePath@ to declare the
-- path on the host container instance that is presented to the container.
-- If this parameter is empty, then the Docker daemon has assigned a host
-- path for you. If the @host@ parameter contains a @sourcePath@ file
-- location, then the data volume persists at the specified location on the
-- host container instance until you delete it manually. If the
-- @sourcePath@ value does not 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.
--
-- If you are using the Fargate launch type, the @sourcePath@ parameter is
-- not supported.
newHostVolumeProperties ::
  HostVolumeProperties
newHostVolumeProperties :: HostVolumeProperties
newHostVolumeProperties =
  HostVolumeProperties' :: Maybe Text -> HostVolumeProperties
HostVolumeProperties' {$sel:sourcePath:HostVolumeProperties' :: Maybe Text
sourcePath = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | When the @host@ parameter is used, specify a @sourcePath@ to declare the
-- path on the host container instance that is presented to the container.
-- If this parameter is empty, then the Docker daemon has assigned a host
-- path for you. If the @host@ parameter contains a @sourcePath@ file
-- location, then the data volume persists at the specified location on the
-- host container instance until you delete it manually. If the
-- @sourcePath@ value does not 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.
--
-- If you are using the Fargate launch type, the @sourcePath@ parameter is
-- not supported.
hostVolumeProperties_sourcePath :: Lens.Lens' HostVolumeProperties (Prelude.Maybe Prelude.Text)
hostVolumeProperties_sourcePath :: (Maybe Text -> f (Maybe Text))
-> HostVolumeProperties -> f HostVolumeProperties
hostVolumeProperties_sourcePath = (HostVolumeProperties -> Maybe Text)
-> (HostVolumeProperties -> Maybe Text -> HostVolumeProperties)
-> Lens
     HostVolumeProperties HostVolumeProperties (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HostVolumeProperties' {Maybe Text
sourcePath :: Maybe Text
$sel:sourcePath:HostVolumeProperties' :: HostVolumeProperties -> Maybe Text
sourcePath} -> Maybe Text
sourcePath) (\s :: HostVolumeProperties
s@HostVolumeProperties' {} Maybe Text
a -> HostVolumeProperties
s {$sel:sourcePath:HostVolumeProperties' :: Maybe Text
sourcePath = Maybe Text
a} :: HostVolumeProperties)

instance Core.FromJSON HostVolumeProperties where
  parseJSON :: Value -> Parser HostVolumeProperties
parseJSON =
    String
-> (Object -> Parser HostVolumeProperties)
-> Value
-> Parser HostVolumeProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HostVolumeProperties"
      ( \Object
x ->
          Maybe Text -> HostVolumeProperties
HostVolumeProperties'
            (Maybe Text -> HostVolumeProperties)
-> Parser (Maybe Text) -> Parser HostVolumeProperties
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 HostVolumeProperties

instance Prelude.NFData HostVolumeProperties

instance Core.ToJSON HostVolumeProperties where
  toJSON :: HostVolumeProperties -> Value
toJSON HostVolumeProperties' {Maybe Text
sourcePath :: Maybe Text
$sel:sourcePath:HostVolumeProperties' :: HostVolumeProperties -> 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]
      )