{-# 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.M2.Types.StorageConfiguration
-- 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.M2.Types.StorageConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.M2.Types.EfsStorageConfiguration
import Amazonka.M2.Types.FsxStorageConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Defines the storage configuration for a runtime environment.
--
-- /See:/ 'newStorageConfiguration' smart constructor.
data StorageConfiguration = StorageConfiguration'
  { -- | Defines the storage configuration for an Amazon EFS file system.
    StorageConfiguration -> Maybe EfsStorageConfiguration
efs :: Prelude.Maybe EfsStorageConfiguration,
    -- | Defines the storage configuration for an Amazon FSx file system.
    StorageConfiguration -> Maybe FsxStorageConfiguration
fsx :: Prelude.Maybe FsxStorageConfiguration
  }
  deriving (StorageConfiguration -> StorageConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StorageConfiguration -> StorageConfiguration -> Bool
$c/= :: StorageConfiguration -> StorageConfiguration -> Bool
== :: StorageConfiguration -> StorageConfiguration -> Bool
$c== :: StorageConfiguration -> StorageConfiguration -> Bool
Prelude.Eq, ReadPrec [StorageConfiguration]
ReadPrec StorageConfiguration
Int -> ReadS StorageConfiguration
ReadS [StorageConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StorageConfiguration]
$creadListPrec :: ReadPrec [StorageConfiguration]
readPrec :: ReadPrec StorageConfiguration
$creadPrec :: ReadPrec StorageConfiguration
readList :: ReadS [StorageConfiguration]
$creadList :: ReadS [StorageConfiguration]
readsPrec :: Int -> ReadS StorageConfiguration
$creadsPrec :: Int -> ReadS StorageConfiguration
Prelude.Read, Int -> StorageConfiguration -> ShowS
[StorageConfiguration] -> ShowS
StorageConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StorageConfiguration] -> ShowS
$cshowList :: [StorageConfiguration] -> ShowS
show :: StorageConfiguration -> String
$cshow :: StorageConfiguration -> String
showsPrec :: Int -> StorageConfiguration -> ShowS
$cshowsPrec :: Int -> StorageConfiguration -> ShowS
Prelude.Show, forall x. Rep StorageConfiguration x -> StorageConfiguration
forall x. StorageConfiguration -> Rep StorageConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StorageConfiguration x -> StorageConfiguration
$cfrom :: forall x. StorageConfiguration -> Rep StorageConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'StorageConfiguration' 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:
--
-- 'efs', 'storageConfiguration_efs' - Defines the storage configuration for an Amazon EFS file system.
--
-- 'fsx', 'storageConfiguration_fsx' - Defines the storage configuration for an Amazon FSx file system.
newStorageConfiguration ::
  StorageConfiguration
newStorageConfiguration :: StorageConfiguration
newStorageConfiguration =
  StorageConfiguration'
    { $sel:efs:StorageConfiguration' :: Maybe EfsStorageConfiguration
efs = forall a. Maybe a
Prelude.Nothing,
      $sel:fsx:StorageConfiguration' :: Maybe FsxStorageConfiguration
fsx = forall a. Maybe a
Prelude.Nothing
    }

-- | Defines the storage configuration for an Amazon EFS file system.
storageConfiguration_efs :: Lens.Lens' StorageConfiguration (Prelude.Maybe EfsStorageConfiguration)
storageConfiguration_efs :: Lens' StorageConfiguration (Maybe EfsStorageConfiguration)
storageConfiguration_efs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StorageConfiguration' {Maybe EfsStorageConfiguration
efs :: Maybe EfsStorageConfiguration
$sel:efs:StorageConfiguration' :: StorageConfiguration -> Maybe EfsStorageConfiguration
efs} -> Maybe EfsStorageConfiguration
efs) (\s :: StorageConfiguration
s@StorageConfiguration' {} Maybe EfsStorageConfiguration
a -> StorageConfiguration
s {$sel:efs:StorageConfiguration' :: Maybe EfsStorageConfiguration
efs = Maybe EfsStorageConfiguration
a} :: StorageConfiguration)

-- | Defines the storage configuration for an Amazon FSx file system.
storageConfiguration_fsx :: Lens.Lens' StorageConfiguration (Prelude.Maybe FsxStorageConfiguration)
storageConfiguration_fsx :: Lens' StorageConfiguration (Maybe FsxStorageConfiguration)
storageConfiguration_fsx = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StorageConfiguration' {Maybe FsxStorageConfiguration
fsx :: Maybe FsxStorageConfiguration
$sel:fsx:StorageConfiguration' :: StorageConfiguration -> Maybe FsxStorageConfiguration
fsx} -> Maybe FsxStorageConfiguration
fsx) (\s :: StorageConfiguration
s@StorageConfiguration' {} Maybe FsxStorageConfiguration
a -> StorageConfiguration
s {$sel:fsx:StorageConfiguration' :: Maybe FsxStorageConfiguration
fsx = Maybe FsxStorageConfiguration
a} :: StorageConfiguration)

instance Data.FromJSON StorageConfiguration where
  parseJSON :: Value -> Parser StorageConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StorageConfiguration"
      ( \Object
x ->
          Maybe EfsStorageConfiguration
-> Maybe FsxStorageConfiguration -> StorageConfiguration
StorageConfiguration'
            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
"efs")
            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
"fsx")
      )

instance Prelude.Hashable StorageConfiguration where
  hashWithSalt :: Int -> StorageConfiguration -> Int
hashWithSalt Int
_salt StorageConfiguration' {Maybe EfsStorageConfiguration
Maybe FsxStorageConfiguration
fsx :: Maybe FsxStorageConfiguration
efs :: Maybe EfsStorageConfiguration
$sel:fsx:StorageConfiguration' :: StorageConfiguration -> Maybe FsxStorageConfiguration
$sel:efs:StorageConfiguration' :: StorageConfiguration -> Maybe EfsStorageConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EfsStorageConfiguration
efs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FsxStorageConfiguration
fsx

instance Prelude.NFData StorageConfiguration where
  rnf :: StorageConfiguration -> ()
rnf StorageConfiguration' {Maybe EfsStorageConfiguration
Maybe FsxStorageConfiguration
fsx :: Maybe FsxStorageConfiguration
efs :: Maybe EfsStorageConfiguration
$sel:fsx:StorageConfiguration' :: StorageConfiguration -> Maybe FsxStorageConfiguration
$sel:efs:StorageConfiguration' :: StorageConfiguration -> Maybe EfsStorageConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EfsStorageConfiguration
efs seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FsxStorageConfiguration
fsx

instance Data.ToJSON StorageConfiguration where
  toJSON :: StorageConfiguration -> Value
toJSON StorageConfiguration' {Maybe EfsStorageConfiguration
Maybe FsxStorageConfiguration
fsx :: Maybe FsxStorageConfiguration
efs :: Maybe EfsStorageConfiguration
$sel:fsx:StorageConfiguration' :: StorageConfiguration -> Maybe FsxStorageConfiguration
$sel:efs:StorageConfiguration' :: StorageConfiguration -> Maybe EfsStorageConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"efs" 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 EfsStorageConfiguration
efs,
            (Key
"fsx" 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 FsxStorageConfiguration
fsx
          ]
      )