{-# 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.Glacier.Types.Grantee
-- 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.Glacier.Types.Grantee where

import qualified Amazonka.Core as Core
import Amazonka.Glacier.Types.Type
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the grantee.
--
-- /See:/ 'newGrantee' smart constructor.
data Grantee = Grantee'
  { -- | URI of the grantee group.
    Grantee -> Maybe Text
uri :: Prelude.Maybe Prelude.Text,
    -- | Email address of the grantee.
    Grantee -> Maybe Text
emailAddress :: Prelude.Maybe Prelude.Text,
    -- | Screen name of the grantee.
    Grantee -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The canonical user ID of the grantee.
    Grantee -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | Type of grantee
    Grantee -> Type
type' :: Type
  }
  deriving (Grantee -> Grantee -> Bool
(Grantee -> Grantee -> Bool)
-> (Grantee -> Grantee -> Bool) -> Eq Grantee
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Grantee -> Grantee -> Bool
$c/= :: Grantee -> Grantee -> Bool
== :: Grantee -> Grantee -> Bool
$c== :: Grantee -> Grantee -> Bool
Prelude.Eq, ReadPrec [Grantee]
ReadPrec Grantee
Int -> ReadS Grantee
ReadS [Grantee]
(Int -> ReadS Grantee)
-> ReadS [Grantee]
-> ReadPrec Grantee
-> ReadPrec [Grantee]
-> Read Grantee
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Grantee]
$creadListPrec :: ReadPrec [Grantee]
readPrec :: ReadPrec Grantee
$creadPrec :: ReadPrec Grantee
readList :: ReadS [Grantee]
$creadList :: ReadS [Grantee]
readsPrec :: Int -> ReadS Grantee
$creadsPrec :: Int -> ReadS Grantee
Prelude.Read, Int -> Grantee -> ShowS
[Grantee] -> ShowS
Grantee -> String
(Int -> Grantee -> ShowS)
-> (Grantee -> String) -> ([Grantee] -> ShowS) -> Show Grantee
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Grantee] -> ShowS
$cshowList :: [Grantee] -> ShowS
show :: Grantee -> String
$cshow :: Grantee -> String
showsPrec :: Int -> Grantee -> ShowS
$cshowsPrec :: Int -> Grantee -> ShowS
Prelude.Show, (forall x. Grantee -> Rep Grantee x)
-> (forall x. Rep Grantee x -> Grantee) -> Generic Grantee
forall x. Rep Grantee x -> Grantee
forall x. Grantee -> Rep Grantee x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Grantee x -> Grantee
$cfrom :: forall x. Grantee -> Rep Grantee x
Prelude.Generic)

-- |
-- Create a value of 'Grantee' 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', 'grantee_uri' - URI of the grantee group.
--
-- 'emailAddress', 'grantee_emailAddress' - Email address of the grantee.
--
-- 'displayName', 'grantee_displayName' - Screen name of the grantee.
--
-- 'id', 'grantee_id' - The canonical user ID of the grantee.
--
-- 'type'', 'grantee_type' - Type of grantee
newGrantee ::
  -- | 'type''
  Type ->
  Grantee
newGrantee :: Type -> Grantee
newGrantee Type
pType_ =
  Grantee' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> Type -> Grantee
Grantee'
    { $sel:uri:Grantee' :: Maybe Text
uri = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:emailAddress:Grantee' :: Maybe Text
emailAddress = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:Grantee' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Grantee' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Grantee' :: Type
type' = Type
pType_
    }

-- | URI of the grantee group.
grantee_uri :: Lens.Lens' Grantee (Prelude.Maybe Prelude.Text)
grantee_uri :: (Maybe Text -> f (Maybe Text)) -> Grantee -> f Grantee
grantee_uri = (Grantee -> Maybe Text)
-> (Grantee -> Maybe Text -> Grantee)
-> Lens Grantee Grantee (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grantee' {Maybe Text
uri :: Maybe Text
$sel:uri:Grantee' :: Grantee -> Maybe Text
uri} -> Maybe Text
uri) (\s :: Grantee
s@Grantee' {} Maybe Text
a -> Grantee
s {$sel:uri:Grantee' :: Maybe Text
uri = Maybe Text
a} :: Grantee)

-- | Email address of the grantee.
grantee_emailAddress :: Lens.Lens' Grantee (Prelude.Maybe Prelude.Text)
grantee_emailAddress :: (Maybe Text -> f (Maybe Text)) -> Grantee -> f Grantee
grantee_emailAddress = (Grantee -> Maybe Text)
-> (Grantee -> Maybe Text -> Grantee)
-> Lens Grantee Grantee (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grantee' {Maybe Text
emailAddress :: Maybe Text
$sel:emailAddress:Grantee' :: Grantee -> Maybe Text
emailAddress} -> Maybe Text
emailAddress) (\s :: Grantee
s@Grantee' {} Maybe Text
a -> Grantee
s {$sel:emailAddress:Grantee' :: Maybe Text
emailAddress = Maybe Text
a} :: Grantee)

-- | Screen name of the grantee.
grantee_displayName :: Lens.Lens' Grantee (Prelude.Maybe Prelude.Text)
grantee_displayName :: (Maybe Text -> f (Maybe Text)) -> Grantee -> f Grantee
grantee_displayName = (Grantee -> Maybe Text)
-> (Grantee -> Maybe Text -> Grantee)
-> Lens Grantee Grantee (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grantee' {Maybe Text
displayName :: Maybe Text
$sel:displayName:Grantee' :: Grantee -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: Grantee
s@Grantee' {} Maybe Text
a -> Grantee
s {$sel:displayName:Grantee' :: Maybe Text
displayName = Maybe Text
a} :: Grantee)

-- | The canonical user ID of the grantee.
grantee_id :: Lens.Lens' Grantee (Prelude.Maybe Prelude.Text)
grantee_id :: (Maybe Text -> f (Maybe Text)) -> Grantee -> f Grantee
grantee_id = (Grantee -> Maybe Text)
-> (Grantee -> Maybe Text -> Grantee)
-> Lens Grantee Grantee (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grantee' {Maybe Text
id :: Maybe Text
$sel:id:Grantee' :: Grantee -> Maybe Text
id} -> Maybe Text
id) (\s :: Grantee
s@Grantee' {} Maybe Text
a -> Grantee
s {$sel:id:Grantee' :: Maybe Text
id = Maybe Text
a} :: Grantee)

-- | Type of grantee
grantee_type :: Lens.Lens' Grantee Type
grantee_type :: (Type -> f Type) -> Grantee -> f Grantee
grantee_type = (Grantee -> Type)
-> (Grantee -> Type -> Grantee) -> Lens Grantee Grantee Type Type
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Grantee' {Type
type' :: Type
$sel:type':Grantee' :: Grantee -> Type
type'} -> Type
type') (\s :: Grantee
s@Grantee' {} Type
a -> Grantee
s {$sel:type':Grantee' :: Type
type' = Type
a} :: Grantee)

instance Core.FromJSON Grantee where
  parseJSON :: Value -> Parser Grantee
parseJSON =
    String -> (Object -> Parser Grantee) -> Value -> Parser Grantee
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Grantee"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> Type -> Grantee
Grantee'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> Type -> Grantee)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> Type -> Grantee)
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 -> Maybe Text -> Maybe Text -> Type -> Grantee)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Type -> Grantee)
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
"EmailAddress")
            Parser (Maybe Text -> Maybe Text -> Type -> Grantee)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Type -> Grantee)
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
"DisplayName")
            Parser (Maybe Text -> Type -> Grantee)
-> Parser (Maybe Text) -> Parser (Type -> Grantee)
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")
            Parser (Type -> Grantee) -> Parser Type -> Parser Grantee
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Type
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
      )

instance Prelude.Hashable Grantee

instance Prelude.NFData Grantee

instance Core.ToJSON Grantee where
  toJSON :: Grantee -> Value
toJSON Grantee' {Maybe Text
Type
type' :: Type
id :: Maybe Text
displayName :: Maybe Text
emailAddress :: Maybe Text
uri :: Maybe Text
$sel:type':Grantee' :: Grantee -> Type
$sel:id:Grantee' :: Grantee -> Maybe Text
$sel:displayName:Grantee' :: Grantee -> Maybe Text
$sel:emailAddress:Grantee' :: Grantee -> Maybe Text
$sel:uri:Grantee' :: Grantee -> 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
"EmailAddress" 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
emailAddress,
            (Text
"DisplayName" 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
displayName,
            (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> Type -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Type
type')
          ]
      )