{-# 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.Shield.Types.EmergencyContact
-- 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.Shield.Types.EmergencyContact where

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

-- | Contact information that the SRT can use to contact you if you have
-- proactive engagement enabled, for escalations to the SRT and to initiate
-- proactive customer support.
--
-- /See:/ 'newEmergencyContact' smart constructor.
data EmergencyContact = EmergencyContact'
  { -- | The phone number for the contact.
    EmergencyContact -> Maybe Text
phoneNumber :: Prelude.Maybe Prelude.Text,
    -- | Additional notes regarding the contact.
    EmergencyContact -> Maybe Text
contactNotes :: Prelude.Maybe Prelude.Text,
    -- | The email address for the contact.
    EmergencyContact -> Text
emailAddress :: Prelude.Text
  }
  deriving (EmergencyContact -> EmergencyContact -> Bool
(EmergencyContact -> EmergencyContact -> Bool)
-> (EmergencyContact -> EmergencyContact -> Bool)
-> Eq EmergencyContact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EmergencyContact -> EmergencyContact -> Bool
$c/= :: EmergencyContact -> EmergencyContact -> Bool
== :: EmergencyContact -> EmergencyContact -> Bool
$c== :: EmergencyContact -> EmergencyContact -> Bool
Prelude.Eq, ReadPrec [EmergencyContact]
ReadPrec EmergencyContact
Int -> ReadS EmergencyContact
ReadS [EmergencyContact]
(Int -> ReadS EmergencyContact)
-> ReadS [EmergencyContact]
-> ReadPrec EmergencyContact
-> ReadPrec [EmergencyContact]
-> Read EmergencyContact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EmergencyContact]
$creadListPrec :: ReadPrec [EmergencyContact]
readPrec :: ReadPrec EmergencyContact
$creadPrec :: ReadPrec EmergencyContact
readList :: ReadS [EmergencyContact]
$creadList :: ReadS [EmergencyContact]
readsPrec :: Int -> ReadS EmergencyContact
$creadsPrec :: Int -> ReadS EmergencyContact
Prelude.Read, Int -> EmergencyContact -> ShowS
[EmergencyContact] -> ShowS
EmergencyContact -> String
(Int -> EmergencyContact -> ShowS)
-> (EmergencyContact -> String)
-> ([EmergencyContact] -> ShowS)
-> Show EmergencyContact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmergencyContact] -> ShowS
$cshowList :: [EmergencyContact] -> ShowS
show :: EmergencyContact -> String
$cshow :: EmergencyContact -> String
showsPrec :: Int -> EmergencyContact -> ShowS
$cshowsPrec :: Int -> EmergencyContact -> ShowS
Prelude.Show, (forall x. EmergencyContact -> Rep EmergencyContact x)
-> (forall x. Rep EmergencyContact x -> EmergencyContact)
-> Generic EmergencyContact
forall x. Rep EmergencyContact x -> EmergencyContact
forall x. EmergencyContact -> Rep EmergencyContact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EmergencyContact x -> EmergencyContact
$cfrom :: forall x. EmergencyContact -> Rep EmergencyContact x
Prelude.Generic)

-- |
-- Create a value of 'EmergencyContact' 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:
--
-- 'phoneNumber', 'emergencyContact_phoneNumber' - The phone number for the contact.
--
-- 'contactNotes', 'emergencyContact_contactNotes' - Additional notes regarding the contact.
--
-- 'emailAddress', 'emergencyContact_emailAddress' - The email address for the contact.
newEmergencyContact ::
  -- | 'emailAddress'
  Prelude.Text ->
  EmergencyContact
newEmergencyContact :: Text -> EmergencyContact
newEmergencyContact Text
pEmailAddress_ =
  EmergencyContact' :: Maybe Text -> Maybe Text -> Text -> EmergencyContact
EmergencyContact'
    { $sel:phoneNumber:EmergencyContact' :: Maybe Text
phoneNumber = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contactNotes:EmergencyContact' :: Maybe Text
contactNotes = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:emailAddress:EmergencyContact' :: Text
emailAddress = Text
pEmailAddress_
    }

-- | The phone number for the contact.
emergencyContact_phoneNumber :: Lens.Lens' EmergencyContact (Prelude.Maybe Prelude.Text)
emergencyContact_phoneNumber :: (Maybe Text -> f (Maybe Text))
-> EmergencyContact -> f EmergencyContact
emergencyContact_phoneNumber = (EmergencyContact -> Maybe Text)
-> (EmergencyContact -> Maybe Text -> EmergencyContact)
-> Lens EmergencyContact EmergencyContact (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmergencyContact' {Maybe Text
phoneNumber :: Maybe Text
$sel:phoneNumber:EmergencyContact' :: EmergencyContact -> Maybe Text
phoneNumber} -> Maybe Text
phoneNumber) (\s :: EmergencyContact
s@EmergencyContact' {} Maybe Text
a -> EmergencyContact
s {$sel:phoneNumber:EmergencyContact' :: Maybe Text
phoneNumber = Maybe Text
a} :: EmergencyContact)

-- | Additional notes regarding the contact.
emergencyContact_contactNotes :: Lens.Lens' EmergencyContact (Prelude.Maybe Prelude.Text)
emergencyContact_contactNotes :: (Maybe Text -> f (Maybe Text))
-> EmergencyContact -> f EmergencyContact
emergencyContact_contactNotes = (EmergencyContact -> Maybe Text)
-> (EmergencyContact -> Maybe Text -> EmergencyContact)
-> Lens EmergencyContact EmergencyContact (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmergencyContact' {Maybe Text
contactNotes :: Maybe Text
$sel:contactNotes:EmergencyContact' :: EmergencyContact -> Maybe Text
contactNotes} -> Maybe Text
contactNotes) (\s :: EmergencyContact
s@EmergencyContact' {} Maybe Text
a -> EmergencyContact
s {$sel:contactNotes:EmergencyContact' :: Maybe Text
contactNotes = Maybe Text
a} :: EmergencyContact)

-- | The email address for the contact.
emergencyContact_emailAddress :: Lens.Lens' EmergencyContact Prelude.Text
emergencyContact_emailAddress :: (Text -> f Text) -> EmergencyContact -> f EmergencyContact
emergencyContact_emailAddress = (EmergencyContact -> Text)
-> (EmergencyContact -> Text -> EmergencyContact)
-> Lens EmergencyContact EmergencyContact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmergencyContact' {Text
emailAddress :: Text
$sel:emailAddress:EmergencyContact' :: EmergencyContact -> Text
emailAddress} -> Text
emailAddress) (\s :: EmergencyContact
s@EmergencyContact' {} Text
a -> EmergencyContact
s {$sel:emailAddress:EmergencyContact' :: Text
emailAddress = Text
a} :: EmergencyContact)

instance Core.FromJSON EmergencyContact where
  parseJSON :: Value -> Parser EmergencyContact
parseJSON =
    String
-> (Object -> Parser EmergencyContact)
-> Value
-> Parser EmergencyContact
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EmergencyContact"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> EmergencyContact
EmergencyContact'
            (Maybe Text -> Maybe Text -> Text -> EmergencyContact)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> EmergencyContact)
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
"PhoneNumber")
            Parser (Maybe Text -> Text -> EmergencyContact)
-> Parser (Maybe Text) -> Parser (Text -> EmergencyContact)
forall (f :: * -> *) a b. Applicative f => 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
"ContactNotes")
            Parser (Text -> EmergencyContact)
-> Parser Text -> Parser EmergencyContact
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
"EmailAddress")
      )

instance Prelude.Hashable EmergencyContact

instance Prelude.NFData EmergencyContact

instance Core.ToJSON EmergencyContact where
  toJSON :: EmergencyContact -> Value
toJSON EmergencyContact' {Maybe Text
Text
emailAddress :: Text
contactNotes :: Maybe Text
phoneNumber :: Maybe Text
$sel:emailAddress:EmergencyContact' :: EmergencyContact -> Text
$sel:contactNotes:EmergencyContact' :: EmergencyContact -> Maybe Text
$sel:phoneNumber:EmergencyContact' :: EmergencyContact -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PhoneNumber" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
phoneNumber,
            (Text
"ContactNotes" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
contactNotes,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EmailAddress" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
emailAddress)
          ]
      )