{-# 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.Volume
-- 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.Batch.Types.Volume where

import Amazonka.Batch.Types.EFSVolumeConfiguration
import Amazonka.Batch.Types.Host
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

-- | A data volume that\'s used in a job\'s container properties.
--
-- /See:/ 'newVolume' smart constructor.
data Volume = Volume'
  { -- | This parameter is specified when you\'re using an Amazon Elastic File
    -- System file system for job storage. Jobs that are running on Fargate
    -- resources must specify a @platformVersion@ of at least @1.4.0@.
    Volume -> Maybe EFSVolumeConfiguration
efsVolumeConfiguration :: Prelude.Maybe EFSVolumeConfiguration,
    -- | The contents of the @host@ parameter determine whether your data volume
    -- persists on the host container instance and where it\'s stored. If the
    -- host parameter is empty, then the Docker daemon assigns a host path for
    -- your data volume. However, the data isn\'t guaranteed to persist after
    -- the containers that are associated with it stop running.
    --
    -- This parameter isn\'t applicable to jobs that are running on Fargate
    -- resources and shouldn\'t be provided.
    Volume -> Maybe Host
host :: Prelude.Maybe Host,
    -- | The name of the volume. It can be up to 255 characters long. It can
    -- contain uppercase and lowercase letters, numbers, hyphens (-), and
    -- underscores (_). This name is referenced in the @sourceVolume@ parameter
    -- of container definition @mountPoints@.
    Volume -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (Volume -> Volume -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Volume -> Volume -> Bool
$c/= :: Volume -> Volume -> Bool
== :: Volume -> Volume -> Bool
$c== :: Volume -> Volume -> Bool
Prelude.Eq, ReadPrec [Volume]
ReadPrec Volume
Int -> ReadS Volume
ReadS [Volume]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Volume]
$creadListPrec :: ReadPrec [Volume]
readPrec :: ReadPrec Volume
$creadPrec :: ReadPrec Volume
readList :: ReadS [Volume]
$creadList :: ReadS [Volume]
readsPrec :: Int -> ReadS Volume
$creadsPrec :: Int -> ReadS Volume
Prelude.Read, Int -> Volume -> ShowS
[Volume] -> ShowS
Volume -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Volume] -> ShowS
$cshowList :: [Volume] -> ShowS
show :: Volume -> String
$cshow :: Volume -> String
showsPrec :: Int -> Volume -> ShowS
$cshowsPrec :: Int -> Volume -> ShowS
Prelude.Show, forall x. Rep Volume x -> Volume
forall x. Volume -> Rep Volume x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Volume x -> Volume
$cfrom :: forall x. Volume -> Rep Volume x
Prelude.Generic)

-- |
-- Create a value of 'Volume' 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:
--
-- 'efsVolumeConfiguration', 'volume_efsVolumeConfiguration' - This parameter is specified when you\'re using an Amazon Elastic File
-- System file system for job storage. Jobs that are running on Fargate
-- resources must specify a @platformVersion@ of at least @1.4.0@.
--
-- 'host', 'volume_host' - The contents of the @host@ parameter determine whether your data volume
-- persists on the host container instance and where it\'s stored. If the
-- host parameter is empty, then the Docker daemon assigns a host path for
-- your data volume. However, the data isn\'t guaranteed to persist after
-- the containers that are associated with it stop running.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
--
-- 'name', 'volume_name' - The name of the volume. It can be up to 255 characters long. It can
-- contain uppercase and lowercase letters, numbers, hyphens (-), and
-- underscores (_). This name is referenced in the @sourceVolume@ parameter
-- of container definition @mountPoints@.
newVolume ::
  Volume
newVolume :: Volume
newVolume =
  Volume'
    { $sel:efsVolumeConfiguration:Volume' :: Maybe EFSVolumeConfiguration
efsVolumeConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:host:Volume' :: Maybe Host
host = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Volume' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | This parameter is specified when you\'re using an Amazon Elastic File
-- System file system for job storage. Jobs that are running on Fargate
-- resources must specify a @platformVersion@ of at least @1.4.0@.
volume_efsVolumeConfiguration :: Lens.Lens' Volume (Prelude.Maybe EFSVolumeConfiguration)
volume_efsVolumeConfiguration :: Lens' Volume (Maybe EFSVolumeConfiguration)
volume_efsVolumeConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Volume' {Maybe EFSVolumeConfiguration
efsVolumeConfiguration :: Maybe EFSVolumeConfiguration
$sel:efsVolumeConfiguration:Volume' :: Volume -> Maybe EFSVolumeConfiguration
efsVolumeConfiguration} -> Maybe EFSVolumeConfiguration
efsVolumeConfiguration) (\s :: Volume
s@Volume' {} Maybe EFSVolumeConfiguration
a -> Volume
s {$sel:efsVolumeConfiguration:Volume' :: Maybe EFSVolumeConfiguration
efsVolumeConfiguration = Maybe EFSVolumeConfiguration
a} :: Volume)

-- | The contents of the @host@ parameter determine whether your data volume
-- persists on the host container instance and where it\'s stored. If the
-- host parameter is empty, then the Docker daemon assigns a host path for
-- your data volume. However, the data isn\'t guaranteed to persist after
-- the containers that are associated with it stop running.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
volume_host :: Lens.Lens' Volume (Prelude.Maybe Host)
volume_host :: Lens' Volume (Maybe Host)
volume_host = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Volume' {Maybe Host
host :: Maybe Host
$sel:host:Volume' :: Volume -> Maybe Host
host} -> Maybe Host
host) (\s :: Volume
s@Volume' {} Maybe Host
a -> Volume
s {$sel:host:Volume' :: Maybe Host
host = Maybe Host
a} :: Volume)

-- | The name of the volume. It can be up to 255 characters long. It can
-- contain uppercase and lowercase letters, numbers, hyphens (-), and
-- underscores (_). This name is referenced in the @sourceVolume@ parameter
-- of container definition @mountPoints@.
volume_name :: Lens.Lens' Volume (Prelude.Maybe Prelude.Text)
volume_name :: Lens' Volume (Maybe Text)
volume_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Volume' {Maybe Text
name :: Maybe Text
$sel:name:Volume' :: Volume -> Maybe Text
name} -> Maybe Text
name) (\s :: Volume
s@Volume' {} Maybe Text
a -> Volume
s {$sel:name:Volume' :: Maybe Text
name = Maybe Text
a} :: Volume)

instance Data.FromJSON Volume where
  parseJSON :: Value -> Parser Volume
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Volume"
      ( \Object
x ->
          Maybe EFSVolumeConfiguration -> Maybe Host -> Maybe Text -> Volume
Volume'
            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
"efsVolumeConfiguration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"host")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"name")
      )

instance Prelude.Hashable Volume where
  hashWithSalt :: Int -> Volume -> Int
hashWithSalt Int
_salt Volume' {Maybe Text
Maybe EFSVolumeConfiguration
Maybe Host
name :: Maybe Text
host :: Maybe Host
efsVolumeConfiguration :: Maybe EFSVolumeConfiguration
$sel:name:Volume' :: Volume -> Maybe Text
$sel:host:Volume' :: Volume -> Maybe Host
$sel:efsVolumeConfiguration:Volume' :: Volume -> Maybe EFSVolumeConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EFSVolumeConfiguration
efsVolumeConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Host
host
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

instance Prelude.NFData Volume where
  rnf :: Volume -> ()
rnf Volume' {Maybe Text
Maybe EFSVolumeConfiguration
Maybe Host
name :: Maybe Text
host :: Maybe Host
efsVolumeConfiguration :: Maybe EFSVolumeConfiguration
$sel:name:Volume' :: Volume -> Maybe Text
$sel:host:Volume' :: Volume -> Maybe Host
$sel:efsVolumeConfiguration:Volume' :: Volume -> Maybe EFSVolumeConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EFSVolumeConfiguration
efsVolumeConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Host
host
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name

instance Data.ToJSON Volume where
  toJSON :: Volume -> Value
toJSON Volume' {Maybe Text
Maybe EFSVolumeConfiguration
Maybe Host
name :: Maybe Text
host :: Maybe Host
efsVolumeConfiguration :: Maybe EFSVolumeConfiguration
$sel:name:Volume' :: Volume -> Maybe Text
$sel:host:Volume' :: Volume -> Maybe Host
$sel:efsVolumeConfiguration:Volume' :: Volume -> Maybe EFSVolumeConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"efsVolumeConfiguration" 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 EFSVolumeConfiguration
efsVolumeConfiguration,
            (Key
"host" 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 Host
host,
            (Key
"name" 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
name
          ]
      )