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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | The default POSIX user ID (UID). If not specified, defaults to @1000@.
    FileSystemConfig -> Maybe Natural
defaultUid :: Prelude.Maybe Prelude.Natural
  }
  deriving (FileSystemConfig -> FileSystemConfig -> Bool
(FileSystemConfig -> FileSystemConfig -> Bool)
-> (FileSystemConfig -> FileSystemConfig -> Bool)
-> Eq FileSystemConfig
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]
(Int -> ReadS FileSystemConfig)
-> ReadS [FileSystemConfig]
-> ReadPrec FileSystemConfig
-> ReadPrec [FileSystemConfig]
-> Read 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
(Int -> FileSystemConfig -> ShowS)
-> (FileSystemConfig -> String)
-> ([FileSystemConfig] -> ShowS)
-> Show FileSystemConfig
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. FileSystemConfig -> Rep FileSystemConfig x)
-> (forall x. Rep FileSystemConfig x -> FileSystemConfig)
-> Generic FileSystemConfig
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@.
--
-- '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/.
--
-- 'defaultUid', 'fileSystemConfig_defaultUid' - The default POSIX user ID (UID). If not specified, defaults to @1000@.
newFileSystemConfig ::
  FileSystemConfig
newFileSystemConfig :: FileSystemConfig
newFileSystemConfig =
  FileSystemConfig' :: Maybe Natural -> Maybe Text -> Maybe Natural -> FileSystemConfig
FileSystemConfig'
    { $sel:defaultGid:FileSystemConfig' :: Maybe Natural
defaultGid = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:mountPath:FileSystemConfig' :: Maybe Text
mountPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultUid:FileSystemConfig' :: Maybe Natural
defaultUid = Maybe Natural
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 :: (Maybe Natural -> f (Maybe Natural))
-> FileSystemConfig -> f FileSystemConfig
fileSystemConfig_defaultGid = (FileSystemConfig -> Maybe Natural)
-> (FileSystemConfig -> Maybe Natural -> FileSystemConfig)
-> Lens
     FileSystemConfig FileSystemConfig (Maybe Natural) (Maybe Natural)
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 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 :: (Maybe Text -> f (Maybe Text))
-> FileSystemConfig -> f FileSystemConfig
fileSystemConfig_mountPath = (FileSystemConfig -> Maybe Text)
-> (FileSystemConfig -> Maybe Text -> FileSystemConfig)
-> Lens FileSystemConfig FileSystemConfig (Maybe Text) (Maybe Text)
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)

-- | The default POSIX user ID (UID). If not specified, defaults to @1000@.
fileSystemConfig_defaultUid :: Lens.Lens' FileSystemConfig (Prelude.Maybe Prelude.Natural)
fileSystemConfig_defaultUid :: (Maybe Natural -> f (Maybe Natural))
-> FileSystemConfig -> f FileSystemConfig
fileSystemConfig_defaultUid = (FileSystemConfig -> Maybe Natural)
-> (FileSystemConfig -> Maybe Natural -> FileSystemConfig)
-> Lens
     FileSystemConfig FileSystemConfig (Maybe Natural) (Maybe Natural)
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)

instance Core.FromJSON FileSystemConfig where
  parseJSON :: Value -> Parser FileSystemConfig
parseJSON =
    String
-> (Object -> Parser FileSystemConfig)
-> Value
-> Parser FileSystemConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FileSystemConfig"
      ( \Object
x ->
          Maybe Natural -> Maybe Text -> Maybe Natural -> FileSystemConfig
FileSystemConfig'
            (Maybe Natural -> Maybe Text -> Maybe Natural -> FileSystemConfig)
-> Parser (Maybe Natural)
-> Parser (Maybe Text -> Maybe Natural -> FileSystemConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DefaultGid")
            Parser (Maybe Text -> Maybe Natural -> FileSystemConfig)
-> Parser (Maybe Text)
-> Parser (Maybe Natural -> FileSystemConfig)
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
"MountPath")
            Parser (Maybe Natural -> FileSystemConfig)
-> Parser (Maybe Natural) -> Parser FileSystemConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DefaultUid")
      )

instance Prelude.Hashable FileSystemConfig

instance Prelude.NFData FileSystemConfig

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