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

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

-- | Information about the Chatbot topics or Chatbot clients associated with
-- a notification rule.
--
-- /See:/ 'newTarget' smart constructor.
data Target = Target'
  { -- | The Amazon Resource Name (ARN) of the Chatbot topic or Chatbot client.
    Target -> Maybe (Sensitive Text)
targetAddress :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The target type. Can be an Chatbot topic or Chatbot client.
    --
    -- -   Chatbot topics are specified as @SNS@.
    --
    -- -   Chatbot clients are specified as @AWSChatbotSlack@.
    Target -> Maybe Text
targetType :: Prelude.Maybe Prelude.Text
  }
  deriving (Target -> Target -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Target -> Target -> Bool
$c/= :: Target -> Target -> Bool
== :: Target -> Target -> Bool
$c== :: Target -> Target -> Bool
Prelude.Eq, Int -> Target -> ShowS
[Target] -> ShowS
Target -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Target] -> ShowS
$cshowList :: [Target] -> ShowS
show :: Target -> String
$cshow :: Target -> String
showsPrec :: Int -> Target -> ShowS
$cshowsPrec :: Int -> Target -> ShowS
Prelude.Show, forall x. Rep Target x -> Target
forall x. Target -> Rep Target x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Target x -> Target
$cfrom :: forall x. Target -> Rep Target x
Prelude.Generic)

-- |
-- Create a value of 'Target' 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:
--
-- 'targetAddress', 'target_targetAddress' - The Amazon Resource Name (ARN) of the Chatbot topic or Chatbot client.
--
-- 'targetType', 'target_targetType' - The target type. Can be an Chatbot topic or Chatbot client.
--
-- -   Chatbot topics are specified as @SNS@.
--
-- -   Chatbot clients are specified as @AWSChatbotSlack@.
newTarget ::
  Target
newTarget :: Target
newTarget =
  Target'
    { $sel:targetAddress:Target' :: Maybe (Sensitive Text)
targetAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:targetType:Target' :: Maybe Text
targetType = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the Chatbot topic or Chatbot client.
target_targetAddress :: Lens.Lens' Target (Prelude.Maybe Prelude.Text)
target_targetAddress :: Lens' Target (Maybe Text)
target_targetAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Target' {Maybe (Sensitive Text)
targetAddress :: Maybe (Sensitive Text)
$sel:targetAddress:Target' :: Target -> Maybe (Sensitive Text)
targetAddress} -> Maybe (Sensitive Text)
targetAddress) (\s :: Target
s@Target' {} Maybe (Sensitive Text)
a -> Target
s {$sel:targetAddress:Target' :: Maybe (Sensitive Text)
targetAddress = Maybe (Sensitive Text)
a} :: Target) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The target type. Can be an Chatbot topic or Chatbot client.
--
-- -   Chatbot topics are specified as @SNS@.
--
-- -   Chatbot clients are specified as @AWSChatbotSlack@.
target_targetType :: Lens.Lens' Target (Prelude.Maybe Prelude.Text)
target_targetType :: Lens' Target (Maybe Text)
target_targetType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Target' {Maybe Text
targetType :: Maybe Text
$sel:targetType:Target' :: Target -> Maybe Text
targetType} -> Maybe Text
targetType) (\s :: Target
s@Target' {} Maybe Text
a -> Target
s {$sel:targetType:Target' :: Maybe Text
targetType = Maybe Text
a} :: Target)

instance Prelude.Hashable Target where
  hashWithSalt :: Int -> Target -> Int
hashWithSalt Int
_salt Target' {Maybe Text
Maybe (Sensitive Text)
targetType :: Maybe Text
targetAddress :: Maybe (Sensitive Text)
$sel:targetType:Target' :: Target -> Maybe Text
$sel:targetAddress:Target' :: Target -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
targetAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetType

instance Prelude.NFData Target where
  rnf :: Target -> ()
rnf Target' {Maybe Text
Maybe (Sensitive Text)
targetType :: Maybe Text
targetAddress :: Maybe (Sensitive Text)
$sel:targetType:Target' :: Target -> Maybe Text
$sel:targetAddress:Target' :: Target -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
targetAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetType

instance Data.ToJSON Target where
  toJSON :: Target -> Value
toJSON Target' {Maybe Text
Maybe (Sensitive Text)
targetType :: Maybe Text
targetAddress :: Maybe (Sensitive Text)
$sel:targetType:Target' :: Target -> Maybe Text
$sel:targetAddress:Target' :: Target -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TargetAddress" 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 (Sensitive Text)
targetAddress,
            (Key
"TargetType" 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
targetType
          ]
      )