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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GuardDuty.Types.HostPath
import qualified Amazonka.Prelude as Prelude

-- | Volume used by the Kubernetes workload.
--
-- /See:/ 'newVolume' smart constructor.
data Volume = Volume'
  { -- | Represents a pre-existing file or directory on the host machine that the
    -- volume maps to.
    Volume -> Maybe HostPath
hostPath :: Prelude.Maybe HostPath,
    -- | Volume name.
    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:
--
-- 'hostPath', 'volume_hostPath' - Represents a pre-existing file or directory on the host machine that the
-- volume maps to.
--
-- 'name', 'volume_name' - Volume name.
newVolume ::
  Volume
newVolume :: Volume
newVolume =
  Volume'
    { $sel:hostPath:Volume' :: Maybe HostPath
hostPath = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Volume' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing
    }

-- | Represents a pre-existing file or directory on the host machine that the
-- volume maps to.
volume_hostPath :: Lens.Lens' Volume (Prelude.Maybe HostPath)
volume_hostPath :: Lens' Volume (Maybe HostPath)
volume_hostPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Volume' {Maybe HostPath
hostPath :: Maybe HostPath
$sel:hostPath:Volume' :: Volume -> Maybe HostPath
hostPath} -> Maybe HostPath
hostPath) (\s :: Volume
s@Volume' {} Maybe HostPath
a -> Volume
s {$sel:hostPath:Volume' :: Maybe HostPath
hostPath = Maybe HostPath
a} :: Volume)

-- | Volume name.
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 HostPath -> 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
"hostPath")
            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 HostPath
name :: Maybe Text
hostPath :: Maybe HostPath
$sel:name:Volume' :: Volume -> Maybe Text
$sel:hostPath:Volume' :: Volume -> Maybe HostPath
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HostPath
hostPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name

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