{-# 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.Transfer.Types.PosixProfile
-- 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.Transfer.Types.PosixProfile where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The full POSIX identity, including user ID (@Uid@), group ID (@Gid@),
-- and any secondary groups IDs (@SecondaryGids@), that controls your
-- users\' access to your Amazon EFS file systems. The POSIX permissions
-- that are set on files and directories in your file system determine the
-- level of access your users get when transferring files into and out of
-- your Amazon EFS file systems.
--
-- /See:/ 'newPosixProfile' smart constructor.
data PosixProfile = PosixProfile'
  { -- | The secondary POSIX group IDs used for all EFS operations by this user.
    PosixProfile -> Maybe [Natural]
secondaryGids :: Prelude.Maybe [Prelude.Natural],
    -- | The POSIX user ID used for all EFS operations by this user.
    PosixProfile -> Natural
uid :: Prelude.Natural,
    -- | The POSIX group ID used for all EFS operations by this user.
    PosixProfile -> Natural
gid :: Prelude.Natural
  }
  deriving (PosixProfile -> PosixProfile -> Bool
(PosixProfile -> PosixProfile -> Bool)
-> (PosixProfile -> PosixProfile -> Bool) -> Eq PosixProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PosixProfile -> PosixProfile -> Bool
$c/= :: PosixProfile -> PosixProfile -> Bool
== :: PosixProfile -> PosixProfile -> Bool
$c== :: PosixProfile -> PosixProfile -> Bool
Prelude.Eq, ReadPrec [PosixProfile]
ReadPrec PosixProfile
Int -> ReadS PosixProfile
ReadS [PosixProfile]
(Int -> ReadS PosixProfile)
-> ReadS [PosixProfile]
-> ReadPrec PosixProfile
-> ReadPrec [PosixProfile]
-> Read PosixProfile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PosixProfile]
$creadListPrec :: ReadPrec [PosixProfile]
readPrec :: ReadPrec PosixProfile
$creadPrec :: ReadPrec PosixProfile
readList :: ReadS [PosixProfile]
$creadList :: ReadS [PosixProfile]
readsPrec :: Int -> ReadS PosixProfile
$creadsPrec :: Int -> ReadS PosixProfile
Prelude.Read, Int -> PosixProfile -> ShowS
[PosixProfile] -> ShowS
PosixProfile -> String
(Int -> PosixProfile -> ShowS)
-> (PosixProfile -> String)
-> ([PosixProfile] -> ShowS)
-> Show PosixProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PosixProfile] -> ShowS
$cshowList :: [PosixProfile] -> ShowS
show :: PosixProfile -> String
$cshow :: PosixProfile -> String
showsPrec :: Int -> PosixProfile -> ShowS
$cshowsPrec :: Int -> PosixProfile -> ShowS
Prelude.Show, (forall x. PosixProfile -> Rep PosixProfile x)
-> (forall x. Rep PosixProfile x -> PosixProfile)
-> Generic PosixProfile
forall x. Rep PosixProfile x -> PosixProfile
forall x. PosixProfile -> Rep PosixProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PosixProfile x -> PosixProfile
$cfrom :: forall x. PosixProfile -> Rep PosixProfile x
Prelude.Generic)

-- |
-- Create a value of 'PosixProfile' 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:
--
-- 'secondaryGids', 'posixProfile_secondaryGids' - The secondary POSIX group IDs used for all EFS operations by this user.
--
-- 'uid', 'posixProfile_uid' - The POSIX user ID used for all EFS operations by this user.
--
-- 'gid', 'posixProfile_gid' - The POSIX group ID used for all EFS operations by this user.
newPosixProfile ::
  -- | 'uid'
  Prelude.Natural ->
  -- | 'gid'
  Prelude.Natural ->
  PosixProfile
newPosixProfile :: Natural -> Natural -> PosixProfile
newPosixProfile Natural
pUid_ Natural
pGid_ =
  PosixProfile' :: Maybe [Natural] -> Natural -> Natural -> PosixProfile
PosixProfile'
    { $sel:secondaryGids:PosixProfile' :: Maybe [Natural]
secondaryGids = Maybe [Natural]
forall a. Maybe a
Prelude.Nothing,
      $sel:uid:PosixProfile' :: Natural
uid = Natural
pUid_,
      $sel:gid:PosixProfile' :: Natural
gid = Natural
pGid_
    }

-- | The secondary POSIX group IDs used for all EFS operations by this user.
posixProfile_secondaryGids :: Lens.Lens' PosixProfile (Prelude.Maybe [Prelude.Natural])
posixProfile_secondaryGids :: (Maybe [Natural] -> f (Maybe [Natural]))
-> PosixProfile -> f PosixProfile
posixProfile_secondaryGids = (PosixProfile -> Maybe [Natural])
-> (PosixProfile -> Maybe [Natural] -> PosixProfile)
-> Lens
     PosixProfile PosixProfile (Maybe [Natural]) (Maybe [Natural])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PosixProfile' {Maybe [Natural]
secondaryGids :: Maybe [Natural]
$sel:secondaryGids:PosixProfile' :: PosixProfile -> Maybe [Natural]
secondaryGids} -> Maybe [Natural]
secondaryGids) (\s :: PosixProfile
s@PosixProfile' {} Maybe [Natural]
a -> PosixProfile
s {$sel:secondaryGids:PosixProfile' :: Maybe [Natural]
secondaryGids = Maybe [Natural]
a} :: PosixProfile) ((Maybe [Natural] -> f (Maybe [Natural]))
 -> PosixProfile -> f PosixProfile)
-> ((Maybe [Natural] -> f (Maybe [Natural]))
    -> Maybe [Natural] -> f (Maybe [Natural]))
-> (Maybe [Natural] -> f (Maybe [Natural]))
-> PosixProfile
-> f PosixProfile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Natural] [Natural] [Natural] [Natural]
-> Iso
     (Maybe [Natural])
     (Maybe [Natural])
     (Maybe [Natural])
     (Maybe [Natural])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Natural] [Natural] [Natural] [Natural]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The POSIX user ID used for all EFS operations by this user.
posixProfile_uid :: Lens.Lens' PosixProfile Prelude.Natural
posixProfile_uid :: (Natural -> f Natural) -> PosixProfile -> f PosixProfile
posixProfile_uid = (PosixProfile -> Natural)
-> (PosixProfile -> Natural -> PosixProfile)
-> Lens PosixProfile PosixProfile Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PosixProfile' {Natural
uid :: Natural
$sel:uid:PosixProfile' :: PosixProfile -> Natural
uid} -> Natural
uid) (\s :: PosixProfile
s@PosixProfile' {} Natural
a -> PosixProfile
s {$sel:uid:PosixProfile' :: Natural
uid = Natural
a} :: PosixProfile)

-- | The POSIX group ID used for all EFS operations by this user.
posixProfile_gid :: Lens.Lens' PosixProfile Prelude.Natural
posixProfile_gid :: (Natural -> f Natural) -> PosixProfile -> f PosixProfile
posixProfile_gid = (PosixProfile -> Natural)
-> (PosixProfile -> Natural -> PosixProfile)
-> Lens PosixProfile PosixProfile Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PosixProfile' {Natural
gid :: Natural
$sel:gid:PosixProfile' :: PosixProfile -> Natural
gid} -> Natural
gid) (\s :: PosixProfile
s@PosixProfile' {} Natural
a -> PosixProfile
s {$sel:gid:PosixProfile' :: Natural
gid = Natural
a} :: PosixProfile)

instance Core.FromJSON PosixProfile where
  parseJSON :: Value -> Parser PosixProfile
parseJSON =
    String
-> (Object -> Parser PosixProfile) -> Value -> Parser PosixProfile
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PosixProfile"
      ( \Object
x ->
          Maybe [Natural] -> Natural -> Natural -> PosixProfile
PosixProfile'
            (Maybe [Natural] -> Natural -> Natural -> PosixProfile)
-> Parser (Maybe [Natural])
-> Parser (Natural -> Natural -> PosixProfile)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Natural]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SecondaryGids" Parser (Maybe (Maybe [Natural]))
-> Maybe [Natural] -> Parser (Maybe [Natural])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Natural]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Natural -> Natural -> PosixProfile)
-> Parser Natural -> Parser (Natural -> PosixProfile)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Uid")
            Parser (Natural -> PosixProfile)
-> Parser Natural -> Parser PosixProfile
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Gid")
      )

instance Prelude.Hashable PosixProfile

instance Prelude.NFData PosixProfile

instance Core.ToJSON PosixProfile where
  toJSON :: PosixProfile -> Value
toJSON PosixProfile' {Natural
Maybe [Natural]
gid :: Natural
uid :: Natural
secondaryGids :: Maybe [Natural]
$sel:gid:PosixProfile' :: PosixProfile -> Natural
$sel:uid:PosixProfile' :: PosixProfile -> Natural
$sel:secondaryGids:PosixProfile' :: PosixProfile -> Maybe [Natural]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SecondaryGids" 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]
secondaryGids,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Uid" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
uid),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Gid" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
gid)
          ]
      )