{-# 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.ReactionForComment
-- 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.ReactionForComment where

import Amazonka.CodeCommit.Types.ReactionValueFormats
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the reaction values provided by users on a comment.
--
-- /See:/ 'newReactionForComment' smart constructor.
data ReactionForComment = ReactionForComment'
  { -- | The Amazon Resource Names (ARNs) of users who have provided reactions to
    -- the comment.
    ReactionForComment -> Maybe [Text]
reactionUsers :: Prelude.Maybe [Prelude.Text],
    -- | A numerical count of users who reacted with the specified emoji whose
    -- identities have been subsequently deleted from IAM. While these IAM
    -- users or roles no longer exist, the reactions might still appear in
    -- total reaction counts.
    ReactionForComment -> Maybe Int
reactionsFromDeletedUsersCount :: Prelude.Maybe Prelude.Int,
    -- | The reaction for a specified comment.
    ReactionForComment -> Maybe ReactionValueFormats
reaction :: Prelude.Maybe ReactionValueFormats
  }
  deriving (ReactionForComment -> ReactionForComment -> Bool
(ReactionForComment -> ReactionForComment -> Bool)
-> (ReactionForComment -> ReactionForComment -> Bool)
-> Eq ReactionForComment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReactionForComment -> ReactionForComment -> Bool
$c/= :: ReactionForComment -> ReactionForComment -> Bool
== :: ReactionForComment -> ReactionForComment -> Bool
$c== :: ReactionForComment -> ReactionForComment -> Bool
Prelude.Eq, ReadPrec [ReactionForComment]
ReadPrec ReactionForComment
Int -> ReadS ReactionForComment
ReadS [ReactionForComment]
(Int -> ReadS ReactionForComment)
-> ReadS [ReactionForComment]
-> ReadPrec ReactionForComment
-> ReadPrec [ReactionForComment]
-> Read ReactionForComment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReactionForComment]
$creadListPrec :: ReadPrec [ReactionForComment]
readPrec :: ReadPrec ReactionForComment
$creadPrec :: ReadPrec ReactionForComment
readList :: ReadS [ReactionForComment]
$creadList :: ReadS [ReactionForComment]
readsPrec :: Int -> ReadS ReactionForComment
$creadsPrec :: Int -> ReadS ReactionForComment
Prelude.Read, Int -> ReactionForComment -> ShowS
[ReactionForComment] -> ShowS
ReactionForComment -> String
(Int -> ReactionForComment -> ShowS)
-> (ReactionForComment -> String)
-> ([ReactionForComment] -> ShowS)
-> Show ReactionForComment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReactionForComment] -> ShowS
$cshowList :: [ReactionForComment] -> ShowS
show :: ReactionForComment -> String
$cshow :: ReactionForComment -> String
showsPrec :: Int -> ReactionForComment -> ShowS
$cshowsPrec :: Int -> ReactionForComment -> ShowS
Prelude.Show, (forall x. ReactionForComment -> Rep ReactionForComment x)
-> (forall x. Rep ReactionForComment x -> ReactionForComment)
-> Generic ReactionForComment
forall x. Rep ReactionForComment x -> ReactionForComment
forall x. ReactionForComment -> Rep ReactionForComment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReactionForComment x -> ReactionForComment
$cfrom :: forall x. ReactionForComment -> Rep ReactionForComment x
Prelude.Generic)

-- |
-- Create a value of 'ReactionForComment' 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:
--
-- 'reactionUsers', 'reactionForComment_reactionUsers' - The Amazon Resource Names (ARNs) of users who have provided reactions to
-- the comment.
--
-- 'reactionsFromDeletedUsersCount', 'reactionForComment_reactionsFromDeletedUsersCount' - A numerical count of users who reacted with the specified emoji whose
-- identities have been subsequently deleted from IAM. While these IAM
-- users or roles no longer exist, the reactions might still appear in
-- total reaction counts.
--
-- 'reaction', 'reactionForComment_reaction' - The reaction for a specified comment.
newReactionForComment ::
  ReactionForComment
newReactionForComment :: ReactionForComment
newReactionForComment =
  ReactionForComment' :: Maybe [Text]
-> Maybe Int -> Maybe ReactionValueFormats -> ReactionForComment
ReactionForComment'
    { $sel:reactionUsers:ReactionForComment' :: Maybe [Text]
reactionUsers =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:reactionsFromDeletedUsersCount:ReactionForComment' :: Maybe Int
reactionsFromDeletedUsersCount = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:reaction:ReactionForComment' :: Maybe ReactionValueFormats
reaction = Maybe ReactionValueFormats
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Names (ARNs) of users who have provided reactions to
-- the comment.
reactionForComment_reactionUsers :: Lens.Lens' ReactionForComment (Prelude.Maybe [Prelude.Text])
reactionForComment_reactionUsers :: (Maybe [Text] -> f (Maybe [Text]))
-> ReactionForComment -> f ReactionForComment
reactionForComment_reactionUsers = (ReactionForComment -> Maybe [Text])
-> (ReactionForComment -> Maybe [Text] -> ReactionForComment)
-> Lens
     ReactionForComment ReactionForComment (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReactionForComment' {Maybe [Text]
reactionUsers :: Maybe [Text]
$sel:reactionUsers:ReactionForComment' :: ReactionForComment -> Maybe [Text]
reactionUsers} -> Maybe [Text]
reactionUsers) (\s :: ReactionForComment
s@ReactionForComment' {} Maybe [Text]
a -> ReactionForComment
s {$sel:reactionUsers:ReactionForComment' :: Maybe [Text]
reactionUsers = Maybe [Text]
a} :: ReactionForComment) ((Maybe [Text] -> f (Maybe [Text]))
 -> ReactionForComment -> f ReactionForComment)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ReactionForComment
-> f ReactionForComment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A numerical count of users who reacted with the specified emoji whose
-- identities have been subsequently deleted from IAM. While these IAM
-- users or roles no longer exist, the reactions might still appear in
-- total reaction counts.
reactionForComment_reactionsFromDeletedUsersCount :: Lens.Lens' ReactionForComment (Prelude.Maybe Prelude.Int)
reactionForComment_reactionsFromDeletedUsersCount :: (Maybe Int -> f (Maybe Int))
-> ReactionForComment -> f ReactionForComment
reactionForComment_reactionsFromDeletedUsersCount = (ReactionForComment -> Maybe Int)
-> (ReactionForComment -> Maybe Int -> ReactionForComment)
-> Lens
     ReactionForComment ReactionForComment (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReactionForComment' {Maybe Int
reactionsFromDeletedUsersCount :: Maybe Int
$sel:reactionsFromDeletedUsersCount:ReactionForComment' :: ReactionForComment -> Maybe Int
reactionsFromDeletedUsersCount} -> Maybe Int
reactionsFromDeletedUsersCount) (\s :: ReactionForComment
s@ReactionForComment' {} Maybe Int
a -> ReactionForComment
s {$sel:reactionsFromDeletedUsersCount:ReactionForComment' :: Maybe Int
reactionsFromDeletedUsersCount = Maybe Int
a} :: ReactionForComment)

-- | The reaction for a specified comment.
reactionForComment_reaction :: Lens.Lens' ReactionForComment (Prelude.Maybe ReactionValueFormats)
reactionForComment_reaction :: (Maybe ReactionValueFormats -> f (Maybe ReactionValueFormats))
-> ReactionForComment -> f ReactionForComment
reactionForComment_reaction = (ReactionForComment -> Maybe ReactionValueFormats)
-> (ReactionForComment
    -> Maybe ReactionValueFormats -> ReactionForComment)
-> Lens
     ReactionForComment
     ReactionForComment
     (Maybe ReactionValueFormats)
     (Maybe ReactionValueFormats)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReactionForComment' {Maybe ReactionValueFormats
reaction :: Maybe ReactionValueFormats
$sel:reaction:ReactionForComment' :: ReactionForComment -> Maybe ReactionValueFormats
reaction} -> Maybe ReactionValueFormats
reaction) (\s :: ReactionForComment
s@ReactionForComment' {} Maybe ReactionValueFormats
a -> ReactionForComment
s {$sel:reaction:ReactionForComment' :: Maybe ReactionValueFormats
reaction = Maybe ReactionValueFormats
a} :: ReactionForComment)

instance Core.FromJSON ReactionForComment where
  parseJSON :: Value -> Parser ReactionForComment
parseJSON =
    String
-> (Object -> Parser ReactionForComment)
-> Value
-> Parser ReactionForComment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReactionForComment"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Int -> Maybe ReactionValueFormats -> ReactionForComment
ReactionForComment'
            (Maybe [Text]
 -> Maybe Int -> Maybe ReactionValueFormats -> ReactionForComment)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Int -> Maybe ReactionValueFormats -> ReactionForComment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"reactionUsers" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Int -> Maybe ReactionValueFormats -> ReactionForComment)
-> Parser (Maybe Int)
-> Parser (Maybe ReactionValueFormats -> ReactionForComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"reactionsFromDeletedUsersCount")
            Parser (Maybe ReactionValueFormats -> ReactionForComment)
-> Parser (Maybe ReactionValueFormats) -> Parser ReactionForComment
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ReactionValueFormats)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"reaction")
      )

instance Prelude.Hashable ReactionForComment

instance Prelude.NFData ReactionForComment