{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECS.Types.HostVolumeProperties where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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\'s 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 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.
    --
    -- If you\'re using the Fargate launch type, the @sourcePath@ parameter is
    -- not supported.
    HostVolumeProperties -> Maybe Text
sourcePath :: Prelude.Maybe Prelude.Text
  }
  deriving (HostVolumeProperties -> HostVolumeProperties -> Bool
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]
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
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. 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\'s 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 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.
--
-- If you\'re using the Fargate launch type, the @sourcePath@ parameter is
-- not supported.
newHostVolumeProperties ::
  HostVolumeProperties
newHostVolumeProperties :: HostVolumeProperties
newHostVolumeProperties =
  HostVolumeProperties' {$sel:sourcePath:HostVolumeProperties' :: Maybe Text
sourcePath = 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\'s 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 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.
--
-- If you\'re using the Fargate launch type, the @sourcePath@ parameter is
-- not supported.
hostVolumeProperties_sourcePath :: Lens.Lens' HostVolumeProperties (Prelude.Maybe Prelude.Text)
hostVolumeProperties_sourcePath :: Lens' HostVolumeProperties (Maybe Text)
hostVolumeProperties_sourcePath = 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 Data.FromJSON HostVolumeProperties where
  parseJSON :: Value -> Parser HostVolumeProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HostVolumeProperties"
      ( \Object
x ->
          Maybe Text -> HostVolumeProperties
HostVolumeProperties'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sourcePath")
      )

instance Prelude.Hashable HostVolumeProperties where
  hashWithSalt :: Int -> HostVolumeProperties -> Int
hashWithSalt Int
_salt HostVolumeProperties' {Maybe Text
sourcePath :: Maybe Text
$sel:sourcePath:HostVolumeProperties' :: HostVolumeProperties -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourcePath

instance Prelude.NFData HostVolumeProperties where
  rnf :: HostVolumeProperties -> ()
rnf HostVolumeProperties' {Maybe Text
sourcePath :: Maybe Text
$sel:sourcePath:HostVolumeProperties' :: HostVolumeProperties -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourcePath

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