{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glacier.Types.Grantee where

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

-- | Contains information about the grantee.
--
-- /See:/ 'newGrantee' smart constructor.
data Grantee = Grantee'
  { -- | Screen name of the grantee.
    Grantee -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | Email address of the grantee.
    Grantee -> Maybe Text
emailAddress :: Prelude.Maybe Prelude.Text,
    -- | The canonical user ID of the grantee.
    Grantee -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | URI of the grantee group.
    Grantee -> Maybe Text
uri :: Prelude.Maybe Prelude.Text,
    -- | Type of grantee
    Grantee -> Type
type' :: Type
  }
  deriving (Grantee -> Grantee -> Bool
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]
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
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. 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:
--
-- 'displayName', 'grantee_displayName' - Screen name of the grantee.
--
-- 'emailAddress', 'grantee_emailAddress' - Email address of the grantee.
--
-- 'id', 'grantee_id' - The canonical user ID of the grantee.
--
-- 'uri', 'grantee_uri' - URI of the grantee group.
--
-- 'type'', 'grantee_type' - Type of grantee
newGrantee ::
  -- | 'type''
  Type ->
  Grantee
newGrantee :: Type -> Grantee
newGrantee Type
pType_ =
  Grantee'
    { $sel:displayName:Grantee' :: Maybe Text
displayName = forall a. Maybe a
Prelude.Nothing,
      $sel:emailAddress:Grantee' :: Maybe Text
emailAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Grantee' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:uri:Grantee' :: Maybe Text
uri = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Grantee' :: Type
type' = Type
pType_
    }

-- | Screen name of the grantee.
grantee_displayName :: Lens.Lens' Grantee (Prelude.Maybe Prelude.Text)
grantee_displayName :: Lens' Grantee (Maybe Text)
grantee_displayName = 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)

-- | Email address of the grantee.
grantee_emailAddress :: Lens.Lens' Grantee (Prelude.Maybe Prelude.Text)
grantee_emailAddress :: Lens' Grantee (Maybe Text)
grantee_emailAddress = 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)

-- | The canonical user ID of the grantee.
grantee_id :: Lens.Lens' Grantee (Prelude.Maybe Prelude.Text)
grantee_id :: Lens' Grantee (Maybe Text)
grantee_id = 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)

-- | URI of the grantee group.
grantee_uri :: Lens.Lens' Grantee (Prelude.Maybe Prelude.Text)
grantee_uri :: Lens' Grantee (Maybe Text)
grantee_uri = 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)

-- | Type of grantee
grantee_type :: Lens.Lens' Grantee Type
grantee_type :: Lens' Grantee Type
grantee_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 Data.FromJSON Grantee where
  parseJSON :: Value -> Parser Grantee
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Grantee"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> Type -> Grantee
Grantee'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DisplayName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EmailAddress")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ID")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"URI")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
      )

instance Prelude.Hashable Grantee where
  hashWithSalt :: Int -> Grantee -> Int
hashWithSalt Int
_salt Grantee' {Maybe Text
Type
type' :: Type
uri :: Maybe Text
id :: Maybe Text
emailAddress :: Maybe Text
displayName :: Maybe Text
$sel:type':Grantee' :: Grantee -> Type
$sel:uri:Grantee' :: Grantee -> Maybe Text
$sel:id:Grantee' :: Grantee -> Maybe Text
$sel:emailAddress:Grantee' :: Grantee -> Maybe Text
$sel:displayName:Grantee' :: Grantee -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
displayName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
emailAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
uri
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Type
type'

instance Prelude.NFData Grantee where
  rnf :: Grantee -> ()
rnf Grantee' {Maybe Text
Type
type' :: Type
uri :: Maybe Text
id :: Maybe Text
emailAddress :: Maybe Text
displayName :: Maybe Text
$sel:type':Grantee' :: Grantee -> Type
$sel:uri:Grantee' :: Grantee -> Maybe Text
$sel:id:Grantee' :: Grantee -> Maybe Text
$sel:emailAddress:Grantee' :: Grantee -> Maybe Text
$sel:displayName:Grantee' :: Grantee -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
displayName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
emailAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
uri
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Type
type'

instance Data.ToJSON Grantee where
  toJSON :: Grantee -> Value
toJSON Grantee' {Maybe Text
Type
type' :: Type
uri :: Maybe Text
id :: Maybe Text
emailAddress :: Maybe Text
displayName :: Maybe Text
$sel:type':Grantee' :: Grantee -> Type
$sel:uri:Grantee' :: Grantee -> Maybe Text
$sel:id:Grantee' :: Grantee -> Maybe Text
$sel:emailAddress:Grantee' :: Grantee -> Maybe Text
$sel:displayName:Grantee' :: Grantee -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DisplayName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
displayName,
            (Key
"EmailAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
emailAddress,
            (Key
"ID" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
id,
            (Key
"URI" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
uri,
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Type
type')
          ]
      )