{-# 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.SSMIncidents.Types.ChatChannel
-- 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.SSMIncidents.Types.ChatChannel 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
import Amazonka.SSMIncidents.Types.EmptyChatChannel

-- | The Chatbot chat channel used for collaboration during an incident.
--
-- /See:/ 'newChatChannel' smart constructor.
data ChatChannel = ChatChannel'
  { -- | The Amazon SNS targets that Chatbot uses to notify the chat channel of
    -- updates to an incident. You can also make updates to the incident
    -- through the chat channel by using the Amazon SNS topics.
    ChatChannel -> Maybe (NonEmpty Text)
chatbotSns :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | Used to remove the chat channel from an incident record or response
    -- plan.
    ChatChannel -> Maybe EmptyChatChannel
empty :: Prelude.Maybe EmptyChatChannel
  }
  deriving (ChatChannel -> ChatChannel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChatChannel -> ChatChannel -> Bool
$c/= :: ChatChannel -> ChatChannel -> Bool
== :: ChatChannel -> ChatChannel -> Bool
$c== :: ChatChannel -> ChatChannel -> Bool
Prelude.Eq, ReadPrec [ChatChannel]
ReadPrec ChatChannel
Int -> ReadS ChatChannel
ReadS [ChatChannel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChatChannel]
$creadListPrec :: ReadPrec [ChatChannel]
readPrec :: ReadPrec ChatChannel
$creadPrec :: ReadPrec ChatChannel
readList :: ReadS [ChatChannel]
$creadList :: ReadS [ChatChannel]
readsPrec :: Int -> ReadS ChatChannel
$creadsPrec :: Int -> ReadS ChatChannel
Prelude.Read, Int -> ChatChannel -> ShowS
[ChatChannel] -> ShowS
ChatChannel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChatChannel] -> ShowS
$cshowList :: [ChatChannel] -> ShowS
show :: ChatChannel -> String
$cshow :: ChatChannel -> String
showsPrec :: Int -> ChatChannel -> ShowS
$cshowsPrec :: Int -> ChatChannel -> ShowS
Prelude.Show, forall x. Rep ChatChannel x -> ChatChannel
forall x. ChatChannel -> Rep ChatChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChatChannel x -> ChatChannel
$cfrom :: forall x. ChatChannel -> Rep ChatChannel x
Prelude.Generic)

-- |
-- Create a value of 'ChatChannel' 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:
--
-- 'chatbotSns', 'chatChannel_chatbotSns' - The Amazon SNS targets that Chatbot uses to notify the chat channel of
-- updates to an incident. You can also make updates to the incident
-- through the chat channel by using the Amazon SNS topics.
--
-- 'empty', 'chatChannel_empty' - Used to remove the chat channel from an incident record or response
-- plan.
newChatChannel ::
  ChatChannel
newChatChannel :: ChatChannel
newChatChannel =
  ChatChannel'
    { $sel:chatbotSns:ChatChannel' :: Maybe (NonEmpty Text)
chatbotSns = forall a. Maybe a
Prelude.Nothing,
      $sel:empty:ChatChannel' :: Maybe EmptyChatChannel
empty = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon SNS targets that Chatbot uses to notify the chat channel of
-- updates to an incident. You can also make updates to the incident
-- through the chat channel by using the Amazon SNS topics.
chatChannel_chatbotSns :: Lens.Lens' ChatChannel (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
chatChannel_chatbotSns :: Lens' ChatChannel (Maybe (NonEmpty Text))
chatChannel_chatbotSns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChatChannel' {Maybe (NonEmpty Text)
chatbotSns :: Maybe (NonEmpty Text)
$sel:chatbotSns:ChatChannel' :: ChatChannel -> Maybe (NonEmpty Text)
chatbotSns} -> Maybe (NonEmpty Text)
chatbotSns) (\s :: ChatChannel
s@ChatChannel' {} Maybe (NonEmpty Text)
a -> ChatChannel
s {$sel:chatbotSns:ChatChannel' :: Maybe (NonEmpty Text)
chatbotSns = Maybe (NonEmpty Text)
a} :: ChatChannel) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Used to remove the chat channel from an incident record or response
-- plan.
chatChannel_empty :: Lens.Lens' ChatChannel (Prelude.Maybe EmptyChatChannel)
chatChannel_empty :: Lens' ChatChannel (Maybe EmptyChatChannel)
chatChannel_empty = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChatChannel' {Maybe EmptyChatChannel
empty :: Maybe EmptyChatChannel
$sel:empty:ChatChannel' :: ChatChannel -> Maybe EmptyChatChannel
empty} -> Maybe EmptyChatChannel
empty) (\s :: ChatChannel
s@ChatChannel' {} Maybe EmptyChatChannel
a -> ChatChannel
s {$sel:empty:ChatChannel' :: Maybe EmptyChatChannel
empty = Maybe EmptyChatChannel
a} :: ChatChannel)

instance Data.FromJSON ChatChannel where
  parseJSON :: Value -> Parser ChatChannel
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ChatChannel"
      ( \Object
x ->
          Maybe (NonEmpty Text) -> Maybe EmptyChatChannel -> ChatChannel
ChatChannel'
            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
"chatbotSns")
            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
"empty")
      )

instance Prelude.Hashable ChatChannel where
  hashWithSalt :: Int -> ChatChannel -> Int
hashWithSalt Int
_salt ChatChannel' {Maybe (NonEmpty Text)
Maybe EmptyChatChannel
empty :: Maybe EmptyChatChannel
chatbotSns :: Maybe (NonEmpty Text)
$sel:empty:ChatChannel' :: ChatChannel -> Maybe EmptyChatChannel
$sel:chatbotSns:ChatChannel' :: ChatChannel -> Maybe (NonEmpty Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
chatbotSns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EmptyChatChannel
empty

instance Prelude.NFData ChatChannel where
  rnf :: ChatChannel -> ()
rnf ChatChannel' {Maybe (NonEmpty Text)
Maybe EmptyChatChannel
empty :: Maybe EmptyChatChannel
chatbotSns :: Maybe (NonEmpty Text)
$sel:empty:ChatChannel' :: ChatChannel -> Maybe EmptyChatChannel
$sel:chatbotSns:ChatChannel' :: ChatChannel -> Maybe (NonEmpty Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
chatbotSns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EmptyChatChannel
empty

instance Data.ToJSON ChatChannel where
  toJSON :: ChatChannel -> Value
toJSON ChatChannel' {Maybe (NonEmpty Text)
Maybe EmptyChatChannel
empty :: Maybe EmptyChatChannel
chatbotSns :: Maybe (NonEmpty Text)
$sel:empty:ChatChannel' :: ChatChannel -> Maybe EmptyChatChannel
$sel:chatbotSns:ChatChannel' :: ChatChannel -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"chatbotSns" 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 (NonEmpty Text)
chatbotSns,
            (Key
"empty" 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 EmptyChatChannel
empty
          ]
      )