{-# 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.CodeCommit.Types.UserInfo
-- 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.CodeCommit.Types.UserInfo where

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

-- | Information about the user who made a specified commit.
--
-- /See:/ 'newUserInfo' smart constructor.
data UserInfo = UserInfo'
  { -- | The email address associated with the user who made the commit, if any.
    UserInfo -> Maybe Text
email :: Prelude.Maybe Prelude.Text,
    -- | The date when the specified commit was commited, in timestamp format
    -- with GMT offset.
    UserInfo -> Maybe Text
date :: Prelude.Maybe Prelude.Text,
    -- | The name of the user who made the specified commit.
    UserInfo -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (UserInfo -> UserInfo -> Bool
(UserInfo -> UserInfo -> Bool)
-> (UserInfo -> UserInfo -> Bool) -> Eq UserInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserInfo -> UserInfo -> Bool
$c/= :: UserInfo -> UserInfo -> Bool
== :: UserInfo -> UserInfo -> Bool
$c== :: UserInfo -> UserInfo -> Bool
Prelude.Eq, ReadPrec [UserInfo]
ReadPrec UserInfo
Int -> ReadS UserInfo
ReadS [UserInfo]
(Int -> ReadS UserInfo)
-> ReadS [UserInfo]
-> ReadPrec UserInfo
-> ReadPrec [UserInfo]
-> Read UserInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserInfo]
$creadListPrec :: ReadPrec [UserInfo]
readPrec :: ReadPrec UserInfo
$creadPrec :: ReadPrec UserInfo
readList :: ReadS [UserInfo]
$creadList :: ReadS [UserInfo]
readsPrec :: Int -> ReadS UserInfo
$creadsPrec :: Int -> ReadS UserInfo
Prelude.Read, Int -> UserInfo -> ShowS
[UserInfo] -> ShowS
UserInfo -> String
(Int -> UserInfo -> ShowS)
-> (UserInfo -> String) -> ([UserInfo] -> ShowS) -> Show UserInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserInfo] -> ShowS
$cshowList :: [UserInfo] -> ShowS
show :: UserInfo -> String
$cshow :: UserInfo -> String
showsPrec :: Int -> UserInfo -> ShowS
$cshowsPrec :: Int -> UserInfo -> ShowS
Prelude.Show, (forall x. UserInfo -> Rep UserInfo x)
-> (forall x. Rep UserInfo x -> UserInfo) -> Generic UserInfo
forall x. Rep UserInfo x -> UserInfo
forall x. UserInfo -> Rep UserInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserInfo x -> UserInfo
$cfrom :: forall x. UserInfo -> Rep UserInfo x
Prelude.Generic)

-- |
-- Create a value of 'UserInfo' 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:
--
-- 'email', 'userInfo_email' - The email address associated with the user who made the commit, if any.
--
-- 'date', 'userInfo_date' - The date when the specified commit was commited, in timestamp format
-- with GMT offset.
--
-- 'name', 'userInfo_name' - The name of the user who made the specified commit.
newUserInfo ::
  UserInfo
newUserInfo :: UserInfo
newUserInfo =
  UserInfo' :: Maybe Text -> Maybe Text -> Maybe Text -> UserInfo
UserInfo'
    { $sel:email:UserInfo' :: Maybe Text
email = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:date:UserInfo' :: Maybe Text
date = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UserInfo' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The email address associated with the user who made the commit, if any.
userInfo_email :: Lens.Lens' UserInfo (Prelude.Maybe Prelude.Text)
userInfo_email :: (Maybe Text -> f (Maybe Text)) -> UserInfo -> f UserInfo
userInfo_email = (UserInfo -> Maybe Text)
-> (UserInfo -> Maybe Text -> UserInfo)
-> Lens UserInfo UserInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserInfo' {Maybe Text
email :: Maybe Text
$sel:email:UserInfo' :: UserInfo -> Maybe Text
email} -> Maybe Text
email) (\s :: UserInfo
s@UserInfo' {} Maybe Text
a -> UserInfo
s {$sel:email:UserInfo' :: Maybe Text
email = Maybe Text
a} :: UserInfo)

-- | The date when the specified commit was commited, in timestamp format
-- with GMT offset.
userInfo_date :: Lens.Lens' UserInfo (Prelude.Maybe Prelude.Text)
userInfo_date :: (Maybe Text -> f (Maybe Text)) -> UserInfo -> f UserInfo
userInfo_date = (UserInfo -> Maybe Text)
-> (UserInfo -> Maybe Text -> UserInfo)
-> Lens UserInfo UserInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserInfo' {Maybe Text
date :: Maybe Text
$sel:date:UserInfo' :: UserInfo -> Maybe Text
date} -> Maybe Text
date) (\s :: UserInfo
s@UserInfo' {} Maybe Text
a -> UserInfo
s {$sel:date:UserInfo' :: Maybe Text
date = Maybe Text
a} :: UserInfo)

-- | The name of the user who made the specified commit.
userInfo_name :: Lens.Lens' UserInfo (Prelude.Maybe Prelude.Text)
userInfo_name :: (Maybe Text -> f (Maybe Text)) -> UserInfo -> f UserInfo
userInfo_name = (UserInfo -> Maybe Text)
-> (UserInfo -> Maybe Text -> UserInfo)
-> Lens UserInfo UserInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserInfo' {Maybe Text
name :: Maybe Text
$sel:name:UserInfo' :: UserInfo -> Maybe Text
name} -> Maybe Text
name) (\s :: UserInfo
s@UserInfo' {} Maybe Text
a -> UserInfo
s {$sel:name:UserInfo' :: Maybe Text
name = Maybe Text
a} :: UserInfo)

instance Core.FromJSON UserInfo where
  parseJSON :: Value -> Parser UserInfo
parseJSON =
    String -> (Object -> Parser UserInfo) -> Value -> Parser UserInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UserInfo"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> UserInfo
UserInfo'
            (Maybe Text -> Maybe Text -> Maybe Text -> UserInfo)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> UserInfo)
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
"email")
            Parser (Maybe Text -> Maybe Text -> UserInfo)
-> Parser (Maybe Text) -> Parser (Maybe Text -> UserInfo)
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
"date")
            Parser (Maybe Text -> UserInfo)
-> Parser (Maybe Text) -> Parser UserInfo
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
"name")
      )

instance Prelude.Hashable UserInfo

instance Prelude.NFData UserInfo