{-# 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.MountPoint
-- 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.MountPoint where

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

-- | Details on a volume mount point that is used in a container definition.
--
-- /See:/ 'newMountPoint' smart constructor.
data MountPoint = MountPoint'
  { -- | The path on the container to mount the host volume at.
    MountPoint -> Maybe Text
containerPath :: Prelude.Maybe Prelude.Text,
    -- | The name of the volume to mount. Must be a volume name referenced in the
    -- @name@ parameter of task definition @volume@.
    MountPoint -> Maybe Text
sourceVolume :: Prelude.Maybe Prelude.Text,
    -- | If this value is @true@, the container has read-only access to the
    -- volume. If this value is @false@, then the container can write to the
    -- volume. The default value is @false@.
    MountPoint -> Maybe Bool
readOnly :: Prelude.Maybe Prelude.Bool
  }
  deriving (MountPoint -> MountPoint -> Bool
(MountPoint -> MountPoint -> Bool)
-> (MountPoint -> MountPoint -> Bool) -> Eq MountPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MountPoint -> MountPoint -> Bool
$c/= :: MountPoint -> MountPoint -> Bool
== :: MountPoint -> MountPoint -> Bool
$c== :: MountPoint -> MountPoint -> Bool
Prelude.Eq, ReadPrec [MountPoint]
ReadPrec MountPoint
Int -> ReadS MountPoint
ReadS [MountPoint]
(Int -> ReadS MountPoint)
-> ReadS [MountPoint]
-> ReadPrec MountPoint
-> ReadPrec [MountPoint]
-> Read MountPoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MountPoint]
$creadListPrec :: ReadPrec [MountPoint]
readPrec :: ReadPrec MountPoint
$creadPrec :: ReadPrec MountPoint
readList :: ReadS [MountPoint]
$creadList :: ReadS [MountPoint]
readsPrec :: Int -> ReadS MountPoint
$creadsPrec :: Int -> ReadS MountPoint
Prelude.Read, Int -> MountPoint -> ShowS
[MountPoint] -> ShowS
MountPoint -> String
(Int -> MountPoint -> ShowS)
-> (MountPoint -> String)
-> ([MountPoint] -> ShowS)
-> Show MountPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MountPoint] -> ShowS
$cshowList :: [MountPoint] -> ShowS
show :: MountPoint -> String
$cshow :: MountPoint -> String
showsPrec :: Int -> MountPoint -> ShowS
$cshowsPrec :: Int -> MountPoint -> ShowS
Prelude.Show, (forall x. MountPoint -> Rep MountPoint x)
-> (forall x. Rep MountPoint x -> MountPoint) -> Generic MountPoint
forall x. Rep MountPoint x -> MountPoint
forall x. MountPoint -> Rep MountPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MountPoint x -> MountPoint
$cfrom :: forall x. MountPoint -> Rep MountPoint x
Prelude.Generic)

-- |
-- Create a value of 'MountPoint' 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:
--
-- 'containerPath', 'mountPoint_containerPath' - The path on the container to mount the host volume at.
--
-- 'sourceVolume', 'mountPoint_sourceVolume' - The name of the volume to mount. Must be a volume name referenced in the
-- @name@ parameter of task definition @volume@.
--
-- 'readOnly', 'mountPoint_readOnly' - If this value is @true@, the container has read-only access to the
-- volume. If this value is @false@, then the container can write to the
-- volume. The default value is @false@.
newMountPoint ::
  MountPoint
newMountPoint :: MountPoint
newMountPoint =
  MountPoint' :: Maybe Text -> Maybe Text -> Maybe Bool -> MountPoint
MountPoint'
    { $sel:containerPath:MountPoint' :: Maybe Text
containerPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceVolume:MountPoint' :: Maybe Text
sourceVolume = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:readOnly:MountPoint' :: Maybe Bool
readOnly = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The path on the container to mount the host volume at.
mountPoint_containerPath :: Lens.Lens' MountPoint (Prelude.Maybe Prelude.Text)
mountPoint_containerPath :: (Maybe Text -> f (Maybe Text)) -> MountPoint -> f MountPoint
mountPoint_containerPath = (MountPoint -> Maybe Text)
-> (MountPoint -> Maybe Text -> MountPoint)
-> Lens MountPoint MountPoint (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MountPoint' {Maybe Text
containerPath :: Maybe Text
$sel:containerPath:MountPoint' :: MountPoint -> Maybe Text
containerPath} -> Maybe Text
containerPath) (\s :: MountPoint
s@MountPoint' {} Maybe Text
a -> MountPoint
s {$sel:containerPath:MountPoint' :: Maybe Text
containerPath = Maybe Text
a} :: MountPoint)

-- | The name of the volume to mount. Must be a volume name referenced in the
-- @name@ parameter of task definition @volume@.
mountPoint_sourceVolume :: Lens.Lens' MountPoint (Prelude.Maybe Prelude.Text)
mountPoint_sourceVolume :: (Maybe Text -> f (Maybe Text)) -> MountPoint -> f MountPoint
mountPoint_sourceVolume = (MountPoint -> Maybe Text)
-> (MountPoint -> Maybe Text -> MountPoint)
-> Lens MountPoint MountPoint (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MountPoint' {Maybe Text
sourceVolume :: Maybe Text
$sel:sourceVolume:MountPoint' :: MountPoint -> Maybe Text
sourceVolume} -> Maybe Text
sourceVolume) (\s :: MountPoint
s@MountPoint' {} Maybe Text
a -> MountPoint
s {$sel:sourceVolume:MountPoint' :: Maybe Text
sourceVolume = Maybe Text
a} :: MountPoint)

-- | If this value is @true@, the container has read-only access to the
-- volume. If this value is @false@, then the container can write to the
-- volume. The default value is @false@.
mountPoint_readOnly :: Lens.Lens' MountPoint (Prelude.Maybe Prelude.Bool)
mountPoint_readOnly :: (Maybe Bool -> f (Maybe Bool)) -> MountPoint -> f MountPoint
mountPoint_readOnly = (MountPoint -> Maybe Bool)
-> (MountPoint -> Maybe Bool -> MountPoint)
-> Lens MountPoint MountPoint (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MountPoint' {Maybe Bool
readOnly :: Maybe Bool
$sel:readOnly:MountPoint' :: MountPoint -> Maybe Bool
readOnly} -> Maybe Bool
readOnly) (\s :: MountPoint
s@MountPoint' {} Maybe Bool
a -> MountPoint
s {$sel:readOnly:MountPoint' :: Maybe Bool
readOnly = Maybe Bool
a} :: MountPoint)

instance Core.FromJSON MountPoint where
  parseJSON :: Value -> Parser MountPoint
parseJSON =
    String
-> (Object -> Parser MountPoint) -> Value -> Parser MountPoint
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MountPoint"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Bool -> MountPoint
MountPoint'
            (Maybe Text -> Maybe Text -> Maybe Bool -> MountPoint)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Bool -> MountPoint)
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
"containerPath")
            Parser (Maybe Text -> Maybe Bool -> MountPoint)
-> Parser (Maybe Text) -> Parser (Maybe Bool -> MountPoint)
forall (f :: * -> *) a b. Applicative f => 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
"sourceVolume")
            Parser (Maybe Bool -> MountPoint)
-> Parser (Maybe Bool) -> Parser MountPoint
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"readOnly")
      )

instance Prelude.Hashable MountPoint

instance Prelude.NFData MountPoint

instance Core.ToJSON MountPoint where
  toJSON :: MountPoint -> Value
toJSON MountPoint' {Maybe Bool
Maybe Text
readOnly :: Maybe Bool
sourceVolume :: Maybe Text
containerPath :: Maybe Text
$sel:readOnly:MountPoint' :: MountPoint -> Maybe Bool
$sel:sourceVolume:MountPoint' :: MountPoint -> Maybe Text
$sel:containerPath:MountPoint' :: MountPoint -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"containerPath" 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
containerPath,
            (Text
"sourceVolume" 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
sourceVolume,
            (Text
"readOnly" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
readOnly
          ]
      )