{-# 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.WorkDocs.Types.PermissionInfo
-- 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.WorkDocs.Types.PermissionInfo where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkDocs.Types.RolePermissionType
import Amazonka.WorkDocs.Types.RoleType

-- | Describes the permissions.
--
-- /See:/ 'newPermissionInfo' smart constructor.
data PermissionInfo = PermissionInfo'
  { -- | The role of the user.
    PermissionInfo -> Maybe RoleType
role' :: Prelude.Maybe RoleType,
    -- | The type of permissions.
    PermissionInfo -> Maybe RolePermissionType
type' :: Prelude.Maybe RolePermissionType
  }
  deriving (PermissionInfo -> PermissionInfo -> Bool
(PermissionInfo -> PermissionInfo -> Bool)
-> (PermissionInfo -> PermissionInfo -> Bool) -> Eq PermissionInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PermissionInfo -> PermissionInfo -> Bool
$c/= :: PermissionInfo -> PermissionInfo -> Bool
== :: PermissionInfo -> PermissionInfo -> Bool
$c== :: PermissionInfo -> PermissionInfo -> Bool
Prelude.Eq, ReadPrec [PermissionInfo]
ReadPrec PermissionInfo
Int -> ReadS PermissionInfo
ReadS [PermissionInfo]
(Int -> ReadS PermissionInfo)
-> ReadS [PermissionInfo]
-> ReadPrec PermissionInfo
-> ReadPrec [PermissionInfo]
-> Read PermissionInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PermissionInfo]
$creadListPrec :: ReadPrec [PermissionInfo]
readPrec :: ReadPrec PermissionInfo
$creadPrec :: ReadPrec PermissionInfo
readList :: ReadS [PermissionInfo]
$creadList :: ReadS [PermissionInfo]
readsPrec :: Int -> ReadS PermissionInfo
$creadsPrec :: Int -> ReadS PermissionInfo
Prelude.Read, Int -> PermissionInfo -> ShowS
[PermissionInfo] -> ShowS
PermissionInfo -> String
(Int -> PermissionInfo -> ShowS)
-> (PermissionInfo -> String)
-> ([PermissionInfo] -> ShowS)
-> Show PermissionInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PermissionInfo] -> ShowS
$cshowList :: [PermissionInfo] -> ShowS
show :: PermissionInfo -> String
$cshow :: PermissionInfo -> String
showsPrec :: Int -> PermissionInfo -> ShowS
$cshowsPrec :: Int -> PermissionInfo -> ShowS
Prelude.Show, (forall x. PermissionInfo -> Rep PermissionInfo x)
-> (forall x. Rep PermissionInfo x -> PermissionInfo)
-> Generic PermissionInfo
forall x. Rep PermissionInfo x -> PermissionInfo
forall x. PermissionInfo -> Rep PermissionInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PermissionInfo x -> PermissionInfo
$cfrom :: forall x. PermissionInfo -> Rep PermissionInfo x
Prelude.Generic)

-- |
-- Create a value of 'PermissionInfo' 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:
--
-- 'role'', 'permissionInfo_role' - The role of the user.
--
-- 'type'', 'permissionInfo_type' - The type of permissions.
newPermissionInfo ::
  PermissionInfo
newPermissionInfo :: PermissionInfo
newPermissionInfo =
  PermissionInfo' :: Maybe RoleType -> Maybe RolePermissionType -> PermissionInfo
PermissionInfo'
    { $sel:role':PermissionInfo' :: Maybe RoleType
role' = Maybe RoleType
forall a. Maybe a
Prelude.Nothing,
      $sel:type':PermissionInfo' :: Maybe RolePermissionType
type' = Maybe RolePermissionType
forall a. Maybe a
Prelude.Nothing
    }

-- | The role of the user.
permissionInfo_role :: Lens.Lens' PermissionInfo (Prelude.Maybe RoleType)
permissionInfo_role :: (Maybe RoleType -> f (Maybe RoleType))
-> PermissionInfo -> f PermissionInfo
permissionInfo_role = (PermissionInfo -> Maybe RoleType)
-> (PermissionInfo -> Maybe RoleType -> PermissionInfo)
-> Lens
     PermissionInfo PermissionInfo (Maybe RoleType) (Maybe RoleType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PermissionInfo' {Maybe RoleType
role' :: Maybe RoleType
$sel:role':PermissionInfo' :: PermissionInfo -> Maybe RoleType
role'} -> Maybe RoleType
role') (\s :: PermissionInfo
s@PermissionInfo' {} Maybe RoleType
a -> PermissionInfo
s {$sel:role':PermissionInfo' :: Maybe RoleType
role' = Maybe RoleType
a} :: PermissionInfo)

-- | The type of permissions.
permissionInfo_type :: Lens.Lens' PermissionInfo (Prelude.Maybe RolePermissionType)
permissionInfo_type :: (Maybe RolePermissionType -> f (Maybe RolePermissionType))
-> PermissionInfo -> f PermissionInfo
permissionInfo_type = (PermissionInfo -> Maybe RolePermissionType)
-> (PermissionInfo -> Maybe RolePermissionType -> PermissionInfo)
-> Lens
     PermissionInfo
     PermissionInfo
     (Maybe RolePermissionType)
     (Maybe RolePermissionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PermissionInfo' {Maybe RolePermissionType
type' :: Maybe RolePermissionType
$sel:type':PermissionInfo' :: PermissionInfo -> Maybe RolePermissionType
type'} -> Maybe RolePermissionType
type') (\s :: PermissionInfo
s@PermissionInfo' {} Maybe RolePermissionType
a -> PermissionInfo
s {$sel:type':PermissionInfo' :: Maybe RolePermissionType
type' = Maybe RolePermissionType
a} :: PermissionInfo)

instance Core.FromJSON PermissionInfo where
  parseJSON :: Value -> Parser PermissionInfo
parseJSON =
    String
-> (Object -> Parser PermissionInfo)
-> Value
-> Parser PermissionInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PermissionInfo"
      ( \Object
x ->
          Maybe RoleType -> Maybe RolePermissionType -> PermissionInfo
PermissionInfo'
            (Maybe RoleType -> Maybe RolePermissionType -> PermissionInfo)
-> Parser (Maybe RoleType)
-> Parser (Maybe RolePermissionType -> PermissionInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RoleType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Role") Parser (Maybe RolePermissionType -> PermissionInfo)
-> Parser (Maybe RolePermissionType) -> Parser PermissionInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RolePermissionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable PermissionInfo

instance Prelude.NFData PermissionInfo