{-# 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.SSMContacts.Types.Contact
-- 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.SSMContacts.Types.Contact where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSMContacts.Types.ContactType

-- | A personal contact or escalation plan that Incident Manager engages
-- during an incident.
--
-- /See:/ 'newContact' smart constructor.
data Contact = Contact'
  { -- | The full name of the contact or escalation plan.
    Contact -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the contact or escalation plan.
    Contact -> Text
contactArn :: Prelude.Text,
    -- | The unique and identifiable alias of the contact or escalation plan.
    Contact -> Text
alias :: Prelude.Text,
    -- | Refers to the type of contact. A single contact is type @PERSONAL@ and
    -- an escalation plan is type @ESCALATION@.
    Contact -> ContactType
type' :: ContactType
  }
  deriving (Contact -> Contact -> Bool
(Contact -> Contact -> Bool)
-> (Contact -> Contact -> Bool) -> Eq Contact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Contact -> Contact -> Bool
$c/= :: Contact -> Contact -> Bool
== :: Contact -> Contact -> Bool
$c== :: Contact -> Contact -> Bool
Prelude.Eq, ReadPrec [Contact]
ReadPrec Contact
Int -> ReadS Contact
ReadS [Contact]
(Int -> ReadS Contact)
-> ReadS [Contact]
-> ReadPrec Contact
-> ReadPrec [Contact]
-> Read Contact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Contact]
$creadListPrec :: ReadPrec [Contact]
readPrec :: ReadPrec Contact
$creadPrec :: ReadPrec Contact
readList :: ReadS [Contact]
$creadList :: ReadS [Contact]
readsPrec :: Int -> ReadS Contact
$creadsPrec :: Int -> ReadS Contact
Prelude.Read, Int -> Contact -> ShowS
[Contact] -> ShowS
Contact -> String
(Int -> Contact -> ShowS)
-> (Contact -> String) -> ([Contact] -> ShowS) -> Show Contact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Contact] -> ShowS
$cshowList :: [Contact] -> ShowS
show :: Contact -> String
$cshow :: Contact -> String
showsPrec :: Int -> Contact -> ShowS
$cshowsPrec :: Int -> Contact -> ShowS
Prelude.Show, (forall x. Contact -> Rep Contact x)
-> (forall x. Rep Contact x -> Contact) -> Generic Contact
forall x. Rep Contact x -> Contact
forall x. Contact -> Rep Contact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Contact x -> Contact
$cfrom :: forall x. Contact -> Rep Contact x
Prelude.Generic)

-- |
-- Create a value of 'Contact' 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:
--
-- 'displayName', 'contact_displayName' - The full name of the contact or escalation plan.
--
-- 'contactArn', 'contact_contactArn' - The Amazon Resource Name (ARN) of the contact or escalation plan.
--
-- 'alias', 'contact_alias' - The unique and identifiable alias of the contact or escalation plan.
--
-- 'type'', 'contact_type' - Refers to the type of contact. A single contact is type @PERSONAL@ and
-- an escalation plan is type @ESCALATION@.
newContact ::
  -- | 'contactArn'
  Prelude.Text ->
  -- | 'alias'
  Prelude.Text ->
  -- | 'type''
  ContactType ->
  Contact
newContact :: Text -> Text -> ContactType -> Contact
newContact Text
pContactArn_ Text
pAlias_ ContactType
pType_ =
  Contact' :: Maybe Text -> Text -> Text -> ContactType -> Contact
Contact'
    { $sel:displayName:Contact' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contactArn:Contact' :: Text
contactArn = Text
pContactArn_,
      $sel:alias:Contact' :: Text
alias = Text
pAlias_,
      $sel:type':Contact' :: ContactType
type' = ContactType
pType_
    }

-- | The full name of the contact or escalation plan.
contact_displayName :: Lens.Lens' Contact (Prelude.Maybe Prelude.Text)
contact_displayName :: (Maybe Text -> f (Maybe Text)) -> Contact -> f Contact
contact_displayName = (Contact -> Maybe Text)
-> (Contact -> Maybe Text -> Contact)
-> Lens Contact Contact (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {Maybe Text
displayName :: Maybe Text
$sel:displayName:Contact' :: Contact -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: Contact
s@Contact' {} Maybe Text
a -> Contact
s {$sel:displayName:Contact' :: Maybe Text
displayName = Maybe Text
a} :: Contact)

-- | The Amazon Resource Name (ARN) of the contact or escalation plan.
contact_contactArn :: Lens.Lens' Contact Prelude.Text
contact_contactArn :: (Text -> f Text) -> Contact -> f Contact
contact_contactArn = (Contact -> Text)
-> (Contact -> Text -> Contact) -> Lens Contact Contact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {Text
contactArn :: Text
$sel:contactArn:Contact' :: Contact -> Text
contactArn} -> Text
contactArn) (\s :: Contact
s@Contact' {} Text
a -> Contact
s {$sel:contactArn:Contact' :: Text
contactArn = Text
a} :: Contact)

-- | The unique and identifiable alias of the contact or escalation plan.
contact_alias :: Lens.Lens' Contact Prelude.Text
contact_alias :: (Text -> f Text) -> Contact -> f Contact
contact_alias = (Contact -> Text)
-> (Contact -> Text -> Contact) -> Lens Contact Contact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {Text
alias :: Text
$sel:alias:Contact' :: Contact -> Text
alias} -> Text
alias) (\s :: Contact
s@Contact' {} Text
a -> Contact
s {$sel:alias:Contact' :: Text
alias = Text
a} :: Contact)

-- | Refers to the type of contact. A single contact is type @PERSONAL@ and
-- an escalation plan is type @ESCALATION@.
contact_type :: Lens.Lens' Contact ContactType
contact_type :: (ContactType -> f ContactType) -> Contact -> f Contact
contact_type = (Contact -> ContactType)
-> (Contact -> ContactType -> Contact)
-> Lens Contact Contact ContactType ContactType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {ContactType
type' :: ContactType
$sel:type':Contact' :: Contact -> ContactType
type'} -> ContactType
type') (\s :: Contact
s@Contact' {} ContactType
a -> Contact
s {$sel:type':Contact' :: ContactType
type' = ContactType
a} :: Contact)

instance Core.FromJSON Contact where
  parseJSON :: Value -> Parser Contact
parseJSON =
    String -> (Object -> Parser Contact) -> Value -> Parser Contact
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Contact"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> ContactType -> Contact
Contact'
            (Maybe Text -> Text -> Text -> ContactType -> Contact)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> ContactType -> Contact)
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
"DisplayName")
            Parser (Text -> Text -> ContactType -> Contact)
-> Parser Text -> Parser (Text -> ContactType -> Contact)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ContactArn")
            Parser (Text -> ContactType -> Contact)
-> Parser Text -> Parser (ContactType -> Contact)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Alias")
            Parser (ContactType -> Contact)
-> Parser ContactType -> Parser Contact
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ContactType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
      )

instance Prelude.Hashable Contact

instance Prelude.NFData Contact