{-# 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.Lightsail.Types.ContactMethod
-- 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.Lightsail.Types.ContactMethod where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lightsail.Types.ContactMethodStatus
import Amazonka.Lightsail.Types.ContactProtocol
import Amazonka.Lightsail.Types.ResourceLocation
import Amazonka.Lightsail.Types.ResourceType
import qualified Amazonka.Prelude as Prelude

-- | Describes a contact method.
--
-- A contact method is a way to send you notifications. For more
-- information, see
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-notifications Notifications in Amazon Lightsail>.
--
-- /See:/ 'newContactMethod' smart constructor.
data ContactMethod = ContactMethod'
  { -- | The Amazon Resource Name (ARN) of the contact method.
    ContactMethod -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The destination of the contact method, such as an email address or a
    -- mobile phone number.
    ContactMethod -> Maybe Text
contactEndpoint :: Prelude.Maybe Prelude.Text,
    -- | The timestamp when the contact method was created.
    ContactMethod -> Maybe POSIX
createdAt :: Prelude.Maybe Data.POSIX,
    -- | An object that describes the location of the contact method, such as the
    -- Amazon Web Services Region and Availability Zone.
    ContactMethod -> Maybe ResourceLocation
location :: Prelude.Maybe ResourceLocation,
    -- | The name of the contact method.
    ContactMethod -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The protocol of the contact method, such as email or SMS (text
    -- messaging).
    ContactMethod -> Maybe ContactProtocol
protocol :: Prelude.Maybe ContactProtocol,
    -- | The Lightsail resource type (e.g., @ContactMethod@).
    ContactMethod -> Maybe ResourceType
resourceType :: Prelude.Maybe ResourceType,
    -- | The current status of the contact method.
    --
    -- A contact method has the following possible status:
    --
    -- -   @PendingVerification@ - The contact method has not yet been
    --     verified, and the verification has not yet expired.
    --
    -- -   @Valid@ - The contact method has been verified.
    --
    -- -   @InValid@ - An attempt was made to verify the contact method, but
    --     the verification has expired.
    ContactMethod -> Maybe ContactMethodStatus
status :: Prelude.Maybe ContactMethodStatus,
    -- | The support code. Include this code in your email to support when you
    -- have questions about your Lightsail contact method. This code enables
    -- our support team to look up your Lightsail information more easily.
    ContactMethod -> Maybe Text
supportCode :: Prelude.Maybe Prelude.Text
  }
  deriving (ContactMethod -> ContactMethod -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContactMethod -> ContactMethod -> Bool
$c/= :: ContactMethod -> ContactMethod -> Bool
== :: ContactMethod -> ContactMethod -> Bool
$c== :: ContactMethod -> ContactMethod -> Bool
Prelude.Eq, ReadPrec [ContactMethod]
ReadPrec ContactMethod
Int -> ReadS ContactMethod
ReadS [ContactMethod]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContactMethod]
$creadListPrec :: ReadPrec [ContactMethod]
readPrec :: ReadPrec ContactMethod
$creadPrec :: ReadPrec ContactMethod
readList :: ReadS [ContactMethod]
$creadList :: ReadS [ContactMethod]
readsPrec :: Int -> ReadS ContactMethod
$creadsPrec :: Int -> ReadS ContactMethod
Prelude.Read, Int -> ContactMethod -> ShowS
[ContactMethod] -> ShowS
ContactMethod -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContactMethod] -> ShowS
$cshowList :: [ContactMethod] -> ShowS
show :: ContactMethod -> String
$cshow :: ContactMethod -> String
showsPrec :: Int -> ContactMethod -> ShowS
$cshowsPrec :: Int -> ContactMethod -> ShowS
Prelude.Show, forall x. Rep ContactMethod x -> ContactMethod
forall x. ContactMethod -> Rep ContactMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContactMethod x -> ContactMethod
$cfrom :: forall x. ContactMethod -> Rep ContactMethod x
Prelude.Generic)

-- |
-- Create a value of 'ContactMethod' 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:
--
-- 'arn', 'contactMethod_arn' - The Amazon Resource Name (ARN) of the contact method.
--
-- 'contactEndpoint', 'contactMethod_contactEndpoint' - The destination of the contact method, such as an email address or a
-- mobile phone number.
--
-- 'createdAt', 'contactMethod_createdAt' - The timestamp when the contact method was created.
--
-- 'location', 'contactMethod_location' - An object that describes the location of the contact method, such as the
-- Amazon Web Services Region and Availability Zone.
--
-- 'name', 'contactMethod_name' - The name of the contact method.
--
-- 'protocol', 'contactMethod_protocol' - The protocol of the contact method, such as email or SMS (text
-- messaging).
--
-- 'resourceType', 'contactMethod_resourceType' - The Lightsail resource type (e.g., @ContactMethod@).
--
-- 'status', 'contactMethod_status' - The current status of the contact method.
--
-- A contact method has the following possible status:
--
-- -   @PendingVerification@ - The contact method has not yet been
--     verified, and the verification has not yet expired.
--
-- -   @Valid@ - The contact method has been verified.
--
-- -   @InValid@ - An attempt was made to verify the contact method, but
--     the verification has expired.
--
-- 'supportCode', 'contactMethod_supportCode' - The support code. Include this code in your email to support when you
-- have questions about your Lightsail contact method. This code enables
-- our support team to look up your Lightsail information more easily.
newContactMethod ::
  ContactMethod
newContactMethod :: ContactMethod
newContactMethod =
  ContactMethod'
    { $sel:arn:ContactMethod' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:contactEndpoint:ContactMethod' :: Maybe Text
contactEndpoint = forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:ContactMethod' :: Maybe POSIX
createdAt = forall a. Maybe a
Prelude.Nothing,
      $sel:location:ContactMethod' :: Maybe ResourceLocation
location = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ContactMethod' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:ContactMethod' :: Maybe ContactProtocol
protocol = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ContactMethod' :: Maybe ResourceType
resourceType = forall a. Maybe a
Prelude.Nothing,
      $sel:status:ContactMethod' :: Maybe ContactMethodStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:supportCode:ContactMethod' :: Maybe Text
supportCode = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the contact method.
contactMethod_arn :: Lens.Lens' ContactMethod (Prelude.Maybe Prelude.Text)
contactMethod_arn :: Lens' ContactMethod (Maybe Text)
contactMethod_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactMethod' {Maybe Text
arn :: Maybe Text
$sel:arn:ContactMethod' :: ContactMethod -> Maybe Text
arn} -> Maybe Text
arn) (\s :: ContactMethod
s@ContactMethod' {} Maybe Text
a -> ContactMethod
s {$sel:arn:ContactMethod' :: Maybe Text
arn = Maybe Text
a} :: ContactMethod)

-- | The destination of the contact method, such as an email address or a
-- mobile phone number.
contactMethod_contactEndpoint :: Lens.Lens' ContactMethod (Prelude.Maybe Prelude.Text)
contactMethod_contactEndpoint :: Lens' ContactMethod (Maybe Text)
contactMethod_contactEndpoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactMethod' {Maybe Text
contactEndpoint :: Maybe Text
$sel:contactEndpoint:ContactMethod' :: ContactMethod -> Maybe Text
contactEndpoint} -> Maybe Text
contactEndpoint) (\s :: ContactMethod
s@ContactMethod' {} Maybe Text
a -> ContactMethod
s {$sel:contactEndpoint:ContactMethod' :: Maybe Text
contactEndpoint = Maybe Text
a} :: ContactMethod)

-- | The timestamp when the contact method was created.
contactMethod_createdAt :: Lens.Lens' ContactMethod (Prelude.Maybe Prelude.UTCTime)
contactMethod_createdAt :: Lens' ContactMethod (Maybe UTCTime)
contactMethod_createdAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactMethod' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:ContactMethod' :: ContactMethod -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: ContactMethod
s@ContactMethod' {} Maybe POSIX
a -> ContactMethod
s {$sel:createdAt:ContactMethod' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: ContactMethod) 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 :: Format). Iso' (Time a) UTCTime
Data._Time

-- | An object that describes the location of the contact method, such as the
-- Amazon Web Services Region and Availability Zone.
contactMethod_location :: Lens.Lens' ContactMethod (Prelude.Maybe ResourceLocation)
contactMethod_location :: Lens' ContactMethod (Maybe ResourceLocation)
contactMethod_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactMethod' {Maybe ResourceLocation
location :: Maybe ResourceLocation
$sel:location:ContactMethod' :: ContactMethod -> Maybe ResourceLocation
location} -> Maybe ResourceLocation
location) (\s :: ContactMethod
s@ContactMethod' {} Maybe ResourceLocation
a -> ContactMethod
s {$sel:location:ContactMethod' :: Maybe ResourceLocation
location = Maybe ResourceLocation
a} :: ContactMethod)

-- | The name of the contact method.
contactMethod_name :: Lens.Lens' ContactMethod (Prelude.Maybe Prelude.Text)
contactMethod_name :: Lens' ContactMethod (Maybe Text)
contactMethod_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactMethod' {Maybe Text
name :: Maybe Text
$sel:name:ContactMethod' :: ContactMethod -> Maybe Text
name} -> Maybe Text
name) (\s :: ContactMethod
s@ContactMethod' {} Maybe Text
a -> ContactMethod
s {$sel:name:ContactMethod' :: Maybe Text
name = Maybe Text
a} :: ContactMethod)

-- | The protocol of the contact method, such as email or SMS (text
-- messaging).
contactMethod_protocol :: Lens.Lens' ContactMethod (Prelude.Maybe ContactProtocol)
contactMethod_protocol :: Lens' ContactMethod (Maybe ContactProtocol)
contactMethod_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactMethod' {Maybe ContactProtocol
protocol :: Maybe ContactProtocol
$sel:protocol:ContactMethod' :: ContactMethod -> Maybe ContactProtocol
protocol} -> Maybe ContactProtocol
protocol) (\s :: ContactMethod
s@ContactMethod' {} Maybe ContactProtocol
a -> ContactMethod
s {$sel:protocol:ContactMethod' :: Maybe ContactProtocol
protocol = Maybe ContactProtocol
a} :: ContactMethod)

-- | The Lightsail resource type (e.g., @ContactMethod@).
contactMethod_resourceType :: Lens.Lens' ContactMethod (Prelude.Maybe ResourceType)
contactMethod_resourceType :: Lens' ContactMethod (Maybe ResourceType)
contactMethod_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactMethod' {Maybe ResourceType
resourceType :: Maybe ResourceType
$sel:resourceType:ContactMethod' :: ContactMethod -> Maybe ResourceType
resourceType} -> Maybe ResourceType
resourceType) (\s :: ContactMethod
s@ContactMethod' {} Maybe ResourceType
a -> ContactMethod
s {$sel:resourceType:ContactMethod' :: Maybe ResourceType
resourceType = Maybe ResourceType
a} :: ContactMethod)

-- | The current status of the contact method.
--
-- A contact method has the following possible status:
--
-- -   @PendingVerification@ - The contact method has not yet been
--     verified, and the verification has not yet expired.
--
-- -   @Valid@ - The contact method has been verified.
--
-- -   @InValid@ - An attempt was made to verify the contact method, but
--     the verification has expired.
contactMethod_status :: Lens.Lens' ContactMethod (Prelude.Maybe ContactMethodStatus)
contactMethod_status :: Lens' ContactMethod (Maybe ContactMethodStatus)
contactMethod_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactMethod' {Maybe ContactMethodStatus
status :: Maybe ContactMethodStatus
$sel:status:ContactMethod' :: ContactMethod -> Maybe ContactMethodStatus
status} -> Maybe ContactMethodStatus
status) (\s :: ContactMethod
s@ContactMethod' {} Maybe ContactMethodStatus
a -> ContactMethod
s {$sel:status:ContactMethod' :: Maybe ContactMethodStatus
status = Maybe ContactMethodStatus
a} :: ContactMethod)

-- | The support code. Include this code in your email to support when you
-- have questions about your Lightsail contact method. This code enables
-- our support team to look up your Lightsail information more easily.
contactMethod_supportCode :: Lens.Lens' ContactMethod (Prelude.Maybe Prelude.Text)
contactMethod_supportCode :: Lens' ContactMethod (Maybe Text)
contactMethod_supportCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactMethod' {Maybe Text
supportCode :: Maybe Text
$sel:supportCode:ContactMethod' :: ContactMethod -> Maybe Text
supportCode} -> Maybe Text
supportCode) (\s :: ContactMethod
s@ContactMethod' {} Maybe Text
a -> ContactMethod
s {$sel:supportCode:ContactMethod' :: Maybe Text
supportCode = Maybe Text
a} :: ContactMethod)

instance Data.FromJSON ContactMethod where
  parseJSON :: Value -> Parser ContactMethod
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ContactMethod"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe ResourceLocation
-> Maybe Text
-> Maybe ContactProtocol
-> Maybe ResourceType
-> Maybe ContactMethodStatus
-> Maybe Text
-> ContactMethod
ContactMethod'
            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
"arn")
            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
"contactEndpoint")
            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
"createdAt")
            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
"location")
            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
"name")
            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
"protocol")
            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
"resourceType")
            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
"status")
            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
"supportCode")
      )

instance Prelude.Hashable ContactMethod where
  hashWithSalt :: Int -> ContactMethod -> Int
hashWithSalt Int
_salt ContactMethod' {Maybe Text
Maybe POSIX
Maybe ContactMethodStatus
Maybe ContactProtocol
Maybe ResourceLocation
Maybe ResourceType
supportCode :: Maybe Text
status :: Maybe ContactMethodStatus
resourceType :: Maybe ResourceType
protocol :: Maybe ContactProtocol
name :: Maybe Text
location :: Maybe ResourceLocation
createdAt :: Maybe POSIX
contactEndpoint :: Maybe Text
arn :: Maybe Text
$sel:supportCode:ContactMethod' :: ContactMethod -> Maybe Text
$sel:status:ContactMethod' :: ContactMethod -> Maybe ContactMethodStatus
$sel:resourceType:ContactMethod' :: ContactMethod -> Maybe ResourceType
$sel:protocol:ContactMethod' :: ContactMethod -> Maybe ContactProtocol
$sel:name:ContactMethod' :: ContactMethod -> Maybe Text
$sel:location:ContactMethod' :: ContactMethod -> Maybe ResourceLocation
$sel:createdAt:ContactMethod' :: ContactMethod -> Maybe POSIX
$sel:contactEndpoint:ContactMethod' :: ContactMethod -> Maybe Text
$sel:arn:ContactMethod' :: ContactMethod -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contactEndpoint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceLocation
location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ContactProtocol
protocol
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceType
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ContactMethodStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
supportCode

instance Prelude.NFData ContactMethod where
  rnf :: ContactMethod -> ()
rnf ContactMethod' {Maybe Text
Maybe POSIX
Maybe ContactMethodStatus
Maybe ContactProtocol
Maybe ResourceLocation
Maybe ResourceType
supportCode :: Maybe Text
status :: Maybe ContactMethodStatus
resourceType :: Maybe ResourceType
protocol :: Maybe ContactProtocol
name :: Maybe Text
location :: Maybe ResourceLocation
createdAt :: Maybe POSIX
contactEndpoint :: Maybe Text
arn :: Maybe Text
$sel:supportCode:ContactMethod' :: ContactMethod -> Maybe Text
$sel:status:ContactMethod' :: ContactMethod -> Maybe ContactMethodStatus
$sel:resourceType:ContactMethod' :: ContactMethod -> Maybe ResourceType
$sel:protocol:ContactMethod' :: ContactMethod -> Maybe ContactProtocol
$sel:name:ContactMethod' :: ContactMethod -> Maybe Text
$sel:location:ContactMethod' :: ContactMethod -> Maybe ResourceLocation
$sel:createdAt:ContactMethod' :: ContactMethod -> Maybe POSIX
$sel:contactEndpoint:ContactMethod' :: ContactMethod -> Maybe Text
$sel:arn:ContactMethod' :: ContactMethod -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contactEndpoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceLocation
location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ContactProtocol
protocol
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceType
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ContactMethodStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
supportCode