{-# 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.EFS.Types.PosixUser
-- 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.EFS.Types.PosixUser where

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

-- | The full POSIX identity, including the user ID, group ID, and any
-- secondary group IDs, on the access point that is used for all file
-- system operations performed by NFS clients using the access point.
--
-- /See:/ 'newPosixUser' smart constructor.
data PosixUser = PosixUser'
  { -- | Secondary POSIX group IDs used for all file system operations using this
    -- access point.
    PosixUser -> Maybe [Natural]
secondaryGids :: Prelude.Maybe [Prelude.Natural],
    -- | The POSIX user ID used for all file system operations using this access
    -- point.
    PosixUser -> Natural
uid :: Prelude.Natural,
    -- | The POSIX group ID used for all file system operations using this access
    -- point.
    PosixUser -> Natural
gid :: Prelude.Natural
  }
  deriving (PosixUser -> PosixUser -> Bool
(PosixUser -> PosixUser -> Bool)
-> (PosixUser -> PosixUser -> Bool) -> Eq PosixUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PosixUser -> PosixUser -> Bool
$c/= :: PosixUser -> PosixUser -> Bool
== :: PosixUser -> PosixUser -> Bool
$c== :: PosixUser -> PosixUser -> Bool
Prelude.Eq, ReadPrec [PosixUser]
ReadPrec PosixUser
Int -> ReadS PosixUser
ReadS [PosixUser]
(Int -> ReadS PosixUser)
-> ReadS [PosixUser]
-> ReadPrec PosixUser
-> ReadPrec [PosixUser]
-> Read PosixUser
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PosixUser]
$creadListPrec :: ReadPrec [PosixUser]
readPrec :: ReadPrec PosixUser
$creadPrec :: ReadPrec PosixUser
readList :: ReadS [PosixUser]
$creadList :: ReadS [PosixUser]
readsPrec :: Int -> ReadS PosixUser
$creadsPrec :: Int -> ReadS PosixUser
Prelude.Read, Int -> PosixUser -> ShowS
[PosixUser] -> ShowS
PosixUser -> String
(Int -> PosixUser -> ShowS)
-> (PosixUser -> String)
-> ([PosixUser] -> ShowS)
-> Show PosixUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PosixUser] -> ShowS
$cshowList :: [PosixUser] -> ShowS
show :: PosixUser -> String
$cshow :: PosixUser -> String
showsPrec :: Int -> PosixUser -> ShowS
$cshowsPrec :: Int -> PosixUser -> ShowS
Prelude.Show, (forall x. PosixUser -> Rep PosixUser x)
-> (forall x. Rep PosixUser x -> PosixUser) -> Generic PosixUser
forall x. Rep PosixUser x -> PosixUser
forall x. PosixUser -> Rep PosixUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PosixUser x -> PosixUser
$cfrom :: forall x. PosixUser -> Rep PosixUser x
Prelude.Generic)

-- |
-- Create a value of 'PosixUser' 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', 'posixUser_secondaryGids' - Secondary POSIX group IDs used for all file system operations using this
-- access point.
--
-- 'uid', 'posixUser_uid' - The POSIX user ID used for all file system operations using this access
-- point.
--
-- 'gid', 'posixUser_gid' - The POSIX group ID used for all file system operations using this access
-- point.
newPosixUser ::
  -- | 'uid'
  Prelude.Natural ->
  -- | 'gid'
  Prelude.Natural ->
  PosixUser
newPosixUser :: Natural -> Natural -> PosixUser
newPosixUser Natural
pUid_ Natural
pGid_ =
  PosixUser' :: Maybe [Natural] -> Natural -> Natural -> PosixUser
PosixUser'
    { $sel:secondaryGids:PosixUser' :: Maybe [Natural]
secondaryGids = Maybe [Natural]
forall a. Maybe a
Prelude.Nothing,
      $sel:uid:PosixUser' :: Natural
uid = Natural
pUid_,
      $sel:gid:PosixUser' :: Natural
gid = Natural
pGid_
    }

-- | Secondary POSIX group IDs used for all file system operations using this
-- access point.
posixUser_secondaryGids :: Lens.Lens' PosixUser (Prelude.Maybe [Prelude.Natural])
posixUser_secondaryGids :: (Maybe [Natural] -> f (Maybe [Natural]))
-> PosixUser -> f PosixUser
posixUser_secondaryGids = (PosixUser -> Maybe [Natural])
-> (PosixUser -> Maybe [Natural] -> PosixUser)
-> Lens PosixUser PosixUser (Maybe [Natural]) (Maybe [Natural])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PosixUser' {Maybe [Natural]
secondaryGids :: Maybe [Natural]
$sel:secondaryGids:PosixUser' :: PosixUser -> Maybe [Natural]
secondaryGids} -> Maybe [Natural]
secondaryGids) (\s :: PosixUser
s@PosixUser' {} Maybe [Natural]
a -> PosixUser
s {$sel:secondaryGids:PosixUser' :: Maybe [Natural]
secondaryGids = Maybe [Natural]
a} :: PosixUser) ((Maybe [Natural] -> f (Maybe [Natural]))
 -> PosixUser -> f PosixUser)
-> ((Maybe [Natural] -> f (Maybe [Natural]))
    -> Maybe [Natural] -> f (Maybe [Natural]))
-> (Maybe [Natural] -> f (Maybe [Natural]))
-> PosixUser
-> f PosixUser
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 file system operations using this access
-- point.
posixUser_uid :: Lens.Lens' PosixUser Prelude.Natural
posixUser_uid :: (Natural -> f Natural) -> PosixUser -> f PosixUser
posixUser_uid = (PosixUser -> Natural)
-> (PosixUser -> Natural -> PosixUser)
-> Lens PosixUser PosixUser Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PosixUser' {Natural
uid :: Natural
$sel:uid:PosixUser' :: PosixUser -> Natural
uid} -> Natural
uid) (\s :: PosixUser
s@PosixUser' {} Natural
a -> PosixUser
s {$sel:uid:PosixUser' :: Natural
uid = Natural
a} :: PosixUser)

-- | The POSIX group ID used for all file system operations using this access
-- point.
posixUser_gid :: Lens.Lens' PosixUser Prelude.Natural
posixUser_gid :: (Natural -> f Natural) -> PosixUser -> f PosixUser
posixUser_gid = (PosixUser -> Natural)
-> (PosixUser -> Natural -> PosixUser)
-> Lens PosixUser PosixUser Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PosixUser' {Natural
gid :: Natural
$sel:gid:PosixUser' :: PosixUser -> Natural
gid} -> Natural
gid) (\s :: PosixUser
s@PosixUser' {} Natural
a -> PosixUser
s {$sel:gid:PosixUser' :: Natural
gid = Natural
a} :: PosixUser)

instance Core.FromJSON PosixUser where
  parseJSON :: Value -> Parser PosixUser
parseJSON =
    String -> (Object -> Parser PosixUser) -> Value -> Parser PosixUser
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PosixUser"
      ( \Object
x ->
          Maybe [Natural] -> Natural -> Natural -> PosixUser
PosixUser'
            (Maybe [Natural] -> Natural -> Natural -> PosixUser)
-> Parser (Maybe [Natural])
-> Parser (Natural -> Natural -> PosixUser)
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 -> PosixUser)
-> Parser Natural -> Parser (Natural -> PosixUser)
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 -> PosixUser) -> Parser Natural -> Parser PosixUser
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 PosixUser

instance Prelude.NFData PosixUser

instance Core.ToJSON PosixUser where
  toJSON :: PosixUser -> Value
toJSON PosixUser' {Natural
Maybe [Natural]
gid :: Natural
uid :: Natural
secondaryGids :: Maybe [Natural]
$sel:gid:PosixUser' :: PosixUser -> Natural
$sel:uid:PosixUser' :: PosixUser -> Natural
$sel:secondaryGids:PosixUser' :: PosixUser -> 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)
          ]
      )