{-# 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.AccessAnalyzer.Types.AclGrantee
-- 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.AccessAnalyzer.Types.AclGrantee where

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

-- | You specify each grantee as a type-value pair using one of these types.
-- You can specify only one type of grantee. For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketAcl.html PutBucketAcl>.
--
-- /See:/ 'newAclGrantee' smart constructor.
data AclGrantee = AclGrantee'
  { -- | Used for granting permissions to a predefined group.
    AclGrantee -> Maybe Text
uri :: Prelude.Maybe Prelude.Text,
    -- | The value specified is the canonical user ID of an Amazon Web Services
    -- account.
    AclGrantee -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (AclGrantee -> AclGrantee -> Bool
(AclGrantee -> AclGrantee -> Bool)
-> (AclGrantee -> AclGrantee -> Bool) -> Eq AclGrantee
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AclGrantee -> AclGrantee -> Bool
$c/= :: AclGrantee -> AclGrantee -> Bool
== :: AclGrantee -> AclGrantee -> Bool
$c== :: AclGrantee -> AclGrantee -> Bool
Prelude.Eq, ReadPrec [AclGrantee]
ReadPrec AclGrantee
Int -> ReadS AclGrantee
ReadS [AclGrantee]
(Int -> ReadS AclGrantee)
-> ReadS [AclGrantee]
-> ReadPrec AclGrantee
-> ReadPrec [AclGrantee]
-> Read AclGrantee
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AclGrantee]
$creadListPrec :: ReadPrec [AclGrantee]
readPrec :: ReadPrec AclGrantee
$creadPrec :: ReadPrec AclGrantee
readList :: ReadS [AclGrantee]
$creadList :: ReadS [AclGrantee]
readsPrec :: Int -> ReadS AclGrantee
$creadsPrec :: Int -> ReadS AclGrantee
Prelude.Read, Int -> AclGrantee -> ShowS
[AclGrantee] -> ShowS
AclGrantee -> String
(Int -> AclGrantee -> ShowS)
-> (AclGrantee -> String)
-> ([AclGrantee] -> ShowS)
-> Show AclGrantee
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AclGrantee] -> ShowS
$cshowList :: [AclGrantee] -> ShowS
show :: AclGrantee -> String
$cshow :: AclGrantee -> String
showsPrec :: Int -> AclGrantee -> ShowS
$cshowsPrec :: Int -> AclGrantee -> ShowS
Prelude.Show, (forall x. AclGrantee -> Rep AclGrantee x)
-> (forall x. Rep AclGrantee x -> AclGrantee) -> Generic AclGrantee
forall x. Rep AclGrantee x -> AclGrantee
forall x. AclGrantee -> Rep AclGrantee x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AclGrantee x -> AclGrantee
$cfrom :: forall x. AclGrantee -> Rep AclGrantee x
Prelude.Generic)

-- |
-- Create a value of 'AclGrantee' 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:
--
-- 'uri', 'aclGrantee_uri' - Used for granting permissions to a predefined group.
--
-- 'id', 'aclGrantee_id' - The value specified is the canonical user ID of an Amazon Web Services
-- account.
newAclGrantee ::
  AclGrantee
newAclGrantee :: AclGrantee
newAclGrantee =
  AclGrantee' :: Maybe Text -> Maybe Text -> AclGrantee
AclGrantee'
    { $sel:uri:AclGrantee' :: Maybe Text
uri = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:AclGrantee' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Used for granting permissions to a predefined group.
aclGrantee_uri :: Lens.Lens' AclGrantee (Prelude.Maybe Prelude.Text)
aclGrantee_uri :: (Maybe Text -> f (Maybe Text)) -> AclGrantee -> f AclGrantee
aclGrantee_uri = (AclGrantee -> Maybe Text)
-> (AclGrantee -> Maybe Text -> AclGrantee)
-> Lens AclGrantee AclGrantee (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AclGrantee' {Maybe Text
uri :: Maybe Text
$sel:uri:AclGrantee' :: AclGrantee -> Maybe Text
uri} -> Maybe Text
uri) (\s :: AclGrantee
s@AclGrantee' {} Maybe Text
a -> AclGrantee
s {$sel:uri:AclGrantee' :: Maybe Text
uri = Maybe Text
a} :: AclGrantee)

-- | The value specified is the canonical user ID of an Amazon Web Services
-- account.
aclGrantee_id :: Lens.Lens' AclGrantee (Prelude.Maybe Prelude.Text)
aclGrantee_id :: (Maybe Text -> f (Maybe Text)) -> AclGrantee -> f AclGrantee
aclGrantee_id = (AclGrantee -> Maybe Text)
-> (AclGrantee -> Maybe Text -> AclGrantee)
-> Lens AclGrantee AclGrantee (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AclGrantee' {Maybe Text
id :: Maybe Text
$sel:id:AclGrantee' :: AclGrantee -> Maybe Text
id} -> Maybe Text
id) (\s :: AclGrantee
s@AclGrantee' {} Maybe Text
a -> AclGrantee
s {$sel:id:AclGrantee' :: Maybe Text
id = Maybe Text
a} :: AclGrantee)

instance Core.FromJSON AclGrantee where
  parseJSON :: Value -> Parser AclGrantee
parseJSON =
    String
-> (Object -> Parser AclGrantee) -> Value -> Parser AclGrantee
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AclGrantee"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> AclGrantee
AclGrantee'
            (Maybe Text -> Maybe Text -> AclGrantee)
-> Parser (Maybe Text) -> Parser (Maybe Text -> AclGrantee)
forall (f :: * -> *) a b. Functor 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
"uri") Parser (Maybe Text -> AclGrantee)
-> Parser (Maybe Text) -> Parser AclGrantee
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
"id")
      )

instance Prelude.Hashable AclGrantee

instance Prelude.NFData AclGrantee

instance Core.ToJSON AclGrantee where
  toJSON :: AclGrantee -> Value
toJSON AclGrantee' {Maybe Text
id :: Maybe Text
uri :: Maybe Text
$sel:id:AclGrantee' :: AclGrantee -> Maybe Text
$sel:uri:AclGrantee' :: AclGrantee -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"uri" 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
uri,
            (Text
"id" 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
id
          ]
      )