{-# 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.SageMaker.Types.FileSystemConfig
-- 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.SageMaker.Types.FileSystemConfig 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

-- | The Amazon Elastic File System (EFS) storage configuration for a
-- SageMaker image.
--
-- /See:/ 'newFileSystemConfig' smart constructor.
data FileSystemConfig = FileSystemConfig'
  { -- | The default POSIX group ID (GID). If not specified, defaults to @100@.
    FileSystemConfig -> Maybe Natural
defaultGid :: Prelude.Maybe Prelude.Natural,
    -- | The default POSIX user ID (UID). If not specified, defaults to @1000@.
    FileSystemConfig -> Maybe Natural
defaultUid :: Prelude.Maybe Prelude.Natural,
    -- | The path within the image to mount the user\'s EFS home directory. The
    -- directory should be empty. If not specified, defaults to
    -- /\/home\/sagemaker-user/.
    FileSystemConfig -> Maybe Text
mountPath :: Prelude.Maybe Prelude.Text
  }
  deriving (FileSystemConfig -> FileSystemConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileSystemConfig -> FileSystemConfig -> Bool
$c/= :: FileSystemConfig -> FileSystemConfig -> Bool
== :: FileSystemConfig -> FileSystemConfig -> Bool
$c== :: FileSystemConfig -> FileSystemConfig -> Bool
Prelude.Eq, ReadPrec [FileSystemConfig]
ReadPrec FileSystemConfig
Int -> ReadS FileSystemConfig
ReadS [FileSystemConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileSystemConfig]
$creadListPrec :: ReadPrec [FileSystemConfig]
readPrec :: ReadPrec FileSystemConfig
$creadPrec :: ReadPrec FileSystemConfig
readList :: ReadS [FileSystemConfig]
$creadList :: ReadS [FileSystemConfig]
readsPrec :: Int -> ReadS FileSystemConfig
$creadsPrec :: Int -> ReadS FileSystemConfig
Prelude.Read, Int -> FileSystemConfig -> ShowS
[FileSystemConfig] -> ShowS
FileSystemConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileSystemConfig] -> ShowS
$cshowList :: [FileSystemConfig] -> ShowS
show :: FileSystemConfig -> String
$cshow :: FileSystemConfig -> String
showsPrec :: Int -> FileSystemConfig -> ShowS
$cshowsPrec :: Int -> FileSystemConfig -> ShowS
Prelude.Show, forall x. Rep FileSystemConfig x -> FileSystemConfig
forall x. FileSystemConfig -> Rep FileSystemConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FileSystemConfig x -> FileSystemConfig
$cfrom :: forall x. FileSystemConfig -> Rep FileSystemConfig x
Prelude.Generic)

-- |
-- Create a value of 'FileSystemConfig' 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:
--
-- 'defaultGid', 'fileSystemConfig_defaultGid' - The default POSIX group ID (GID). If not specified, defaults to @100@.
--
-- 'defaultUid', 'fileSystemConfig_defaultUid' - The default POSIX user ID (UID). If not specified, defaults to @1000@.
--
-- 'mountPath', 'fileSystemConfig_mountPath' - The path within the image to mount the user\'s EFS home directory. The
-- directory should be empty. If not specified, defaults to
-- /\/home\/sagemaker-user/.
newFileSystemConfig ::
  FileSystemConfig
newFileSystemConfig :: FileSystemConfig
newFileSystemConfig =
  FileSystemConfig'
    { $sel:defaultGid:FileSystemConfig' :: Maybe Natural
defaultGid = forall a. Maybe a
Prelude.Nothing,
      $sel:defaultUid:FileSystemConfig' :: Maybe Natural
defaultUid = forall a. Maybe a
Prelude.Nothing,
      $sel:mountPath:FileSystemConfig' :: Maybe Text
mountPath = forall a. Maybe a
Prelude.Nothing
    }

-- | The default POSIX group ID (GID). If not specified, defaults to @100@.
fileSystemConfig_defaultGid :: Lens.Lens' FileSystemConfig (Prelude.Maybe Prelude.Natural)
fileSystemConfig_defaultGid :: Lens' FileSystemConfig (Maybe Natural)
fileSystemConfig_defaultGid = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileSystemConfig' {Maybe Natural
defaultGid :: Maybe Natural
$sel:defaultGid:FileSystemConfig' :: FileSystemConfig -> Maybe Natural
defaultGid} -> Maybe Natural
defaultGid) (\s :: FileSystemConfig
s@FileSystemConfig' {} Maybe Natural
a -> FileSystemConfig
s {$sel:defaultGid:FileSystemConfig' :: Maybe Natural
defaultGid = Maybe Natural
a} :: FileSystemConfig)

-- | The default POSIX user ID (UID). If not specified, defaults to @1000@.
fileSystemConfig_defaultUid :: Lens.Lens' FileSystemConfig (Prelude.Maybe Prelude.Natural)
fileSystemConfig_defaultUid :: Lens' FileSystemConfig (Maybe Natural)
fileSystemConfig_defaultUid = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileSystemConfig' {Maybe Natural
defaultUid :: Maybe Natural
$sel:defaultUid:FileSystemConfig' :: FileSystemConfig -> Maybe Natural
defaultUid} -> Maybe Natural
defaultUid) (\s :: FileSystemConfig
s@FileSystemConfig' {} Maybe Natural
a -> FileSystemConfig
s {$sel:defaultUid:FileSystemConfig' :: Maybe Natural
defaultUid = Maybe Natural
a} :: FileSystemConfig)

-- | The path within the image to mount the user\'s EFS home directory. The
-- directory should be empty. If not specified, defaults to
-- /\/home\/sagemaker-user/.
fileSystemConfig_mountPath :: Lens.Lens' FileSystemConfig (Prelude.Maybe Prelude.Text)
fileSystemConfig_mountPath :: Lens' FileSystemConfig (Maybe Text)
fileSystemConfig_mountPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileSystemConfig' {Maybe Text
mountPath :: Maybe Text
$sel:mountPath:FileSystemConfig' :: FileSystemConfig -> Maybe Text
mountPath} -> Maybe Text
mountPath) (\s :: FileSystemConfig
s@FileSystemConfig' {} Maybe Text
a -> FileSystemConfig
s {$sel:mountPath:FileSystemConfig' :: Maybe Text
mountPath = Maybe Text
a} :: FileSystemConfig)

instance Data.FromJSON FileSystemConfig where
  parseJSON :: Value -> Parser FileSystemConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FileSystemConfig"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> Maybe Text -> FileSystemConfig
FileSystemConfig'
            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
"DefaultGid")
            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
"DefaultUid")
            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
"MountPath")
      )

instance Prelude.Hashable FileSystemConfig where
  hashWithSalt :: Int -> FileSystemConfig -> Int
hashWithSalt Int
_salt FileSystemConfig' {Maybe Natural
Maybe Text
mountPath :: Maybe Text
defaultUid :: Maybe Natural
defaultGid :: Maybe Natural
$sel:mountPath:FileSystemConfig' :: FileSystemConfig -> Maybe Text
$sel:defaultUid:FileSystemConfig' :: FileSystemConfig -> Maybe Natural
$sel:defaultGid:FileSystemConfig' :: FileSystemConfig -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
defaultGid
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
defaultUid
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
mountPath

instance Prelude.NFData FileSystemConfig where
  rnf :: FileSystemConfig -> ()
rnf FileSystemConfig' {Maybe Natural
Maybe Text
mountPath :: Maybe Text
defaultUid :: Maybe Natural
defaultGid :: Maybe Natural
$sel:mountPath:FileSystemConfig' :: FileSystemConfig -> Maybe Text
$sel:defaultUid:FileSystemConfig' :: FileSystemConfig -> Maybe Natural
$sel:defaultGid:FileSystemConfig' :: FileSystemConfig -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
defaultGid
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
defaultUid
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
mountPath

instance Data.ToJSON FileSystemConfig where
  toJSON :: FileSystemConfig -> Value
toJSON FileSystemConfig' {Maybe Natural
Maybe Text
mountPath :: Maybe Text
defaultUid :: Maybe Natural
defaultGid :: Maybe Natural
$sel:mountPath:FileSystemConfig' :: FileSystemConfig -> Maybe Text
$sel:defaultUid:FileSystemConfig' :: FileSystemConfig -> Maybe Natural
$sel:defaultGid:FileSystemConfig' :: FileSystemConfig -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DefaultGid" 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 Natural
defaultGid,
            (Key
"DefaultUid" 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 Natural
defaultUid,
            (Key
"MountPath" 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
mountPath
          ]
      )