{-# 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.Chime.Types.PhoneNumberAssociation
-- 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.Chime.Types.PhoneNumberAssociation where

import Amazonka.Chime.Types.PhoneNumberAssociationName
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The phone number associations, such as Amazon Chime account ID, Amazon
-- Chime user ID, Amazon Chime Voice Connector ID, or Amazon Chime Voice
-- Connector group ID.
--
-- /See:/ 'newPhoneNumberAssociation' smart constructor.
data PhoneNumberAssociation = PhoneNumberAssociation'
  { -- | Contains the ID for the entity specified in Name.
    PhoneNumberAssociation -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The timestamp of the phone number association, in ISO 8601 format.
    PhoneNumberAssociation -> Maybe POSIX
associatedTimestamp :: Prelude.Maybe Core.POSIX,
    -- | Defines the association with an Amazon Chime account ID, user ID, Amazon
    -- Chime Voice Connector ID, or Amazon Chime Voice Connector group ID.
    PhoneNumberAssociation -> Maybe PhoneNumberAssociationName
name :: Prelude.Maybe PhoneNumberAssociationName
  }
  deriving (PhoneNumberAssociation -> PhoneNumberAssociation -> Bool
(PhoneNumberAssociation -> PhoneNumberAssociation -> Bool)
-> (PhoneNumberAssociation -> PhoneNumberAssociation -> Bool)
-> Eq PhoneNumberAssociation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhoneNumberAssociation -> PhoneNumberAssociation -> Bool
$c/= :: PhoneNumberAssociation -> PhoneNumberAssociation -> Bool
== :: PhoneNumberAssociation -> PhoneNumberAssociation -> Bool
$c== :: PhoneNumberAssociation -> PhoneNumberAssociation -> Bool
Prelude.Eq, ReadPrec [PhoneNumberAssociation]
ReadPrec PhoneNumberAssociation
Int -> ReadS PhoneNumberAssociation
ReadS [PhoneNumberAssociation]
(Int -> ReadS PhoneNumberAssociation)
-> ReadS [PhoneNumberAssociation]
-> ReadPrec PhoneNumberAssociation
-> ReadPrec [PhoneNumberAssociation]
-> Read PhoneNumberAssociation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PhoneNumberAssociation]
$creadListPrec :: ReadPrec [PhoneNumberAssociation]
readPrec :: ReadPrec PhoneNumberAssociation
$creadPrec :: ReadPrec PhoneNumberAssociation
readList :: ReadS [PhoneNumberAssociation]
$creadList :: ReadS [PhoneNumberAssociation]
readsPrec :: Int -> ReadS PhoneNumberAssociation
$creadsPrec :: Int -> ReadS PhoneNumberAssociation
Prelude.Read, Int -> PhoneNumberAssociation -> ShowS
[PhoneNumberAssociation] -> ShowS
PhoneNumberAssociation -> String
(Int -> PhoneNumberAssociation -> ShowS)
-> (PhoneNumberAssociation -> String)
-> ([PhoneNumberAssociation] -> ShowS)
-> Show PhoneNumberAssociation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhoneNumberAssociation] -> ShowS
$cshowList :: [PhoneNumberAssociation] -> ShowS
show :: PhoneNumberAssociation -> String
$cshow :: PhoneNumberAssociation -> String
showsPrec :: Int -> PhoneNumberAssociation -> ShowS
$cshowsPrec :: Int -> PhoneNumberAssociation -> ShowS
Prelude.Show, (forall x. PhoneNumberAssociation -> Rep PhoneNumberAssociation x)
-> (forall x.
    Rep PhoneNumberAssociation x -> PhoneNumberAssociation)
-> Generic PhoneNumberAssociation
forall x. Rep PhoneNumberAssociation x -> PhoneNumberAssociation
forall x. PhoneNumberAssociation -> Rep PhoneNumberAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhoneNumberAssociation x -> PhoneNumberAssociation
$cfrom :: forall x. PhoneNumberAssociation -> Rep PhoneNumberAssociation x
Prelude.Generic)

-- |
-- Create a value of 'PhoneNumberAssociation' 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:
--
-- 'value', 'phoneNumberAssociation_value' - Contains the ID for the entity specified in Name.
--
-- 'associatedTimestamp', 'phoneNumberAssociation_associatedTimestamp' - The timestamp of the phone number association, in ISO 8601 format.
--
-- 'name', 'phoneNumberAssociation_name' - Defines the association with an Amazon Chime account ID, user ID, Amazon
-- Chime Voice Connector ID, or Amazon Chime Voice Connector group ID.
newPhoneNumberAssociation ::
  PhoneNumberAssociation
newPhoneNumberAssociation :: PhoneNumberAssociation
newPhoneNumberAssociation =
  PhoneNumberAssociation' :: Maybe Text
-> Maybe POSIX
-> Maybe PhoneNumberAssociationName
-> PhoneNumberAssociation
PhoneNumberAssociation'
    { $sel:value:PhoneNumberAssociation' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:associatedTimestamp:PhoneNumberAssociation' :: Maybe POSIX
associatedTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:PhoneNumberAssociation' :: Maybe PhoneNumberAssociationName
name = Maybe PhoneNumberAssociationName
forall a. Maybe a
Prelude.Nothing
    }

-- | Contains the ID for the entity specified in Name.
phoneNumberAssociation_value :: Lens.Lens' PhoneNumberAssociation (Prelude.Maybe Prelude.Text)
phoneNumberAssociation_value :: (Maybe Text -> f (Maybe Text))
-> PhoneNumberAssociation -> f PhoneNumberAssociation
phoneNumberAssociation_value = (PhoneNumberAssociation -> Maybe Text)
-> (PhoneNumberAssociation -> Maybe Text -> PhoneNumberAssociation)
-> Lens
     PhoneNumberAssociation
     PhoneNumberAssociation
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberAssociation' {Maybe Text
value :: Maybe Text
$sel:value:PhoneNumberAssociation' :: PhoneNumberAssociation -> Maybe Text
value} -> Maybe Text
value) (\s :: PhoneNumberAssociation
s@PhoneNumberAssociation' {} Maybe Text
a -> PhoneNumberAssociation
s {$sel:value:PhoneNumberAssociation' :: Maybe Text
value = Maybe Text
a} :: PhoneNumberAssociation)

-- | The timestamp of the phone number association, in ISO 8601 format.
phoneNumberAssociation_associatedTimestamp :: Lens.Lens' PhoneNumberAssociation (Prelude.Maybe Prelude.UTCTime)
phoneNumberAssociation_associatedTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> PhoneNumberAssociation -> f PhoneNumberAssociation
phoneNumberAssociation_associatedTimestamp = (PhoneNumberAssociation -> Maybe POSIX)
-> (PhoneNumberAssociation
    -> Maybe POSIX -> PhoneNumberAssociation)
-> Lens
     PhoneNumberAssociation
     PhoneNumberAssociation
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberAssociation' {Maybe POSIX
associatedTimestamp :: Maybe POSIX
$sel:associatedTimestamp:PhoneNumberAssociation' :: PhoneNumberAssociation -> Maybe POSIX
associatedTimestamp} -> Maybe POSIX
associatedTimestamp) (\s :: PhoneNumberAssociation
s@PhoneNumberAssociation' {} Maybe POSIX
a -> PhoneNumberAssociation
s {$sel:associatedTimestamp:PhoneNumberAssociation' :: Maybe POSIX
associatedTimestamp = Maybe POSIX
a} :: PhoneNumberAssociation) ((Maybe POSIX -> f (Maybe POSIX))
 -> PhoneNumberAssociation -> f PhoneNumberAssociation)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> PhoneNumberAssociation
-> f PhoneNumberAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Defines the association with an Amazon Chime account ID, user ID, Amazon
-- Chime Voice Connector ID, or Amazon Chime Voice Connector group ID.
phoneNumberAssociation_name :: Lens.Lens' PhoneNumberAssociation (Prelude.Maybe PhoneNumberAssociationName)
phoneNumberAssociation_name :: (Maybe PhoneNumberAssociationName
 -> f (Maybe PhoneNumberAssociationName))
-> PhoneNumberAssociation -> f PhoneNumberAssociation
phoneNumberAssociation_name = (PhoneNumberAssociation -> Maybe PhoneNumberAssociationName)
-> (PhoneNumberAssociation
    -> Maybe PhoneNumberAssociationName -> PhoneNumberAssociation)
-> Lens
     PhoneNumberAssociation
     PhoneNumberAssociation
     (Maybe PhoneNumberAssociationName)
     (Maybe PhoneNumberAssociationName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberAssociation' {Maybe PhoneNumberAssociationName
name :: Maybe PhoneNumberAssociationName
$sel:name:PhoneNumberAssociation' :: PhoneNumberAssociation -> Maybe PhoneNumberAssociationName
name} -> Maybe PhoneNumberAssociationName
name) (\s :: PhoneNumberAssociation
s@PhoneNumberAssociation' {} Maybe PhoneNumberAssociationName
a -> PhoneNumberAssociation
s {$sel:name:PhoneNumberAssociation' :: Maybe PhoneNumberAssociationName
name = Maybe PhoneNumberAssociationName
a} :: PhoneNumberAssociation)

instance Core.FromJSON PhoneNumberAssociation where
  parseJSON :: Value -> Parser PhoneNumberAssociation
parseJSON =
    String
-> (Object -> Parser PhoneNumberAssociation)
-> Value
-> Parser PhoneNumberAssociation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PhoneNumberAssociation"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe PhoneNumberAssociationName
-> PhoneNumberAssociation
PhoneNumberAssociation'
            (Maybe Text
 -> Maybe POSIX
 -> Maybe PhoneNumberAssociationName
 -> PhoneNumberAssociation)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe PhoneNumberAssociationName -> PhoneNumberAssociation)
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
"Value")
            Parser
  (Maybe POSIX
   -> Maybe PhoneNumberAssociationName -> PhoneNumberAssociation)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe PhoneNumberAssociationName -> PhoneNumberAssociation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AssociatedTimestamp")
            Parser (Maybe PhoneNumberAssociationName -> PhoneNumberAssociation)
-> Parser (Maybe PhoneNumberAssociationName)
-> Parser PhoneNumberAssociation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe PhoneNumberAssociationName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
      )

instance Prelude.Hashable PhoneNumberAssociation

instance Prelude.NFData PhoneNumberAssociation