{-# 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.CodeStarNotifications.Types.TargetSummary
-- 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.CodeStarNotifications.Types.TargetSummary where

import Amazonka.CodeStarNotifications.Types.TargetStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the targets specified for a notification rule.
--
-- /See:/ 'newTargetSummary' smart constructor.
data TargetSummary = TargetSummary'
  { -- | The type of the target (for example, SNS).
    TargetSummary -> Maybe Text
targetType :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the SNS topic.
    TargetSummary -> Maybe (Sensitive Text)
targetAddress :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The status of the target.
    TargetSummary -> Maybe TargetStatus
targetStatus :: Prelude.Maybe TargetStatus
  }
  deriving (TargetSummary -> TargetSummary -> Bool
(TargetSummary -> TargetSummary -> Bool)
-> (TargetSummary -> TargetSummary -> Bool) -> Eq TargetSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetSummary -> TargetSummary -> Bool
$c/= :: TargetSummary -> TargetSummary -> Bool
== :: TargetSummary -> TargetSummary -> Bool
$c== :: TargetSummary -> TargetSummary -> Bool
Prelude.Eq, Int -> TargetSummary -> ShowS
[TargetSummary] -> ShowS
TargetSummary -> String
(Int -> TargetSummary -> ShowS)
-> (TargetSummary -> String)
-> ([TargetSummary] -> ShowS)
-> Show TargetSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetSummary] -> ShowS
$cshowList :: [TargetSummary] -> ShowS
show :: TargetSummary -> String
$cshow :: TargetSummary -> String
showsPrec :: Int -> TargetSummary -> ShowS
$cshowsPrec :: Int -> TargetSummary -> ShowS
Prelude.Show, (forall x. TargetSummary -> Rep TargetSummary x)
-> (forall x. Rep TargetSummary x -> TargetSummary)
-> Generic TargetSummary
forall x. Rep TargetSummary x -> TargetSummary
forall x. TargetSummary -> Rep TargetSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetSummary x -> TargetSummary
$cfrom :: forall x. TargetSummary -> Rep TargetSummary x
Prelude.Generic)

-- |
-- Create a value of 'TargetSummary' 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:
--
-- 'targetType', 'targetSummary_targetType' - The type of the target (for example, SNS).
--
-- 'targetAddress', 'targetSummary_targetAddress' - The Amazon Resource Name (ARN) of the SNS topic.
--
-- 'targetStatus', 'targetSummary_targetStatus' - The status of the target.
newTargetSummary ::
  TargetSummary
newTargetSummary :: TargetSummary
newTargetSummary =
  TargetSummary' :: Maybe Text
-> Maybe (Sensitive Text) -> Maybe TargetStatus -> TargetSummary
TargetSummary'
    { $sel:targetType:TargetSummary' :: Maybe Text
targetType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetAddress:TargetSummary' :: Maybe (Sensitive Text)
targetAddress = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:targetStatus:TargetSummary' :: Maybe TargetStatus
targetStatus = Maybe TargetStatus
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of the target (for example, SNS).
targetSummary_targetType :: Lens.Lens' TargetSummary (Prelude.Maybe Prelude.Text)
targetSummary_targetType :: (Maybe Text -> f (Maybe Text)) -> TargetSummary -> f TargetSummary
targetSummary_targetType = (TargetSummary -> Maybe Text)
-> (TargetSummary -> Maybe Text -> TargetSummary)
-> Lens TargetSummary TargetSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetSummary' {Maybe Text
targetType :: Maybe Text
$sel:targetType:TargetSummary' :: TargetSummary -> Maybe Text
targetType} -> Maybe Text
targetType) (\s :: TargetSummary
s@TargetSummary' {} Maybe Text
a -> TargetSummary
s {$sel:targetType:TargetSummary' :: Maybe Text
targetType = Maybe Text
a} :: TargetSummary)

-- | The Amazon Resource Name (ARN) of the SNS topic.
targetSummary_targetAddress :: Lens.Lens' TargetSummary (Prelude.Maybe Prelude.Text)
targetSummary_targetAddress :: (Maybe Text -> f (Maybe Text)) -> TargetSummary -> f TargetSummary
targetSummary_targetAddress = (TargetSummary -> Maybe (Sensitive Text))
-> (TargetSummary -> Maybe (Sensitive Text) -> TargetSummary)
-> Lens
     TargetSummary
     TargetSummary
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetSummary' {Maybe (Sensitive Text)
targetAddress :: Maybe (Sensitive Text)
$sel:targetAddress:TargetSummary' :: TargetSummary -> Maybe (Sensitive Text)
targetAddress} -> Maybe (Sensitive Text)
targetAddress) (\s :: TargetSummary
s@TargetSummary' {} Maybe (Sensitive Text)
a -> TargetSummary
s {$sel:targetAddress:TargetSummary' :: Maybe (Sensitive Text)
targetAddress = Maybe (Sensitive Text)
a} :: TargetSummary) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> TargetSummary -> f TargetSummary)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> TargetSummary
-> f TargetSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The status of the target.
targetSummary_targetStatus :: Lens.Lens' TargetSummary (Prelude.Maybe TargetStatus)
targetSummary_targetStatus :: (Maybe TargetStatus -> f (Maybe TargetStatus))
-> TargetSummary -> f TargetSummary
targetSummary_targetStatus = (TargetSummary -> Maybe TargetStatus)
-> (TargetSummary -> Maybe TargetStatus -> TargetSummary)
-> Lens
     TargetSummary
     TargetSummary
     (Maybe TargetStatus)
     (Maybe TargetStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetSummary' {Maybe TargetStatus
targetStatus :: Maybe TargetStatus
$sel:targetStatus:TargetSummary' :: TargetSummary -> Maybe TargetStatus
targetStatus} -> Maybe TargetStatus
targetStatus) (\s :: TargetSummary
s@TargetSummary' {} Maybe TargetStatus
a -> TargetSummary
s {$sel:targetStatus:TargetSummary' :: Maybe TargetStatus
targetStatus = Maybe TargetStatus
a} :: TargetSummary)

instance Core.FromJSON TargetSummary where
  parseJSON :: Value -> Parser TargetSummary
parseJSON =
    String
-> (Object -> Parser TargetSummary)
-> Value
-> Parser TargetSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TargetSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe (Sensitive Text) -> Maybe TargetStatus -> TargetSummary
TargetSummary'
            (Maybe Text
 -> Maybe (Sensitive Text) -> Maybe TargetStatus -> TargetSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe (Sensitive Text) -> Maybe TargetStatus -> TargetSummary)
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
"TargetType")
            Parser
  (Maybe (Sensitive Text) -> Maybe TargetStatus -> TargetSummary)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe TargetStatus -> TargetSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetAddress")
            Parser (Maybe TargetStatus -> TargetSummary)
-> Parser (Maybe TargetStatus) -> Parser TargetSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TargetStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetStatus")
      )

instance Prelude.Hashable TargetSummary

instance Prelude.NFData TargetSummary