{-# 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.CognitoIdentityProvider.Types.SmsConfigurationType
-- 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.CognitoIdentityProvider.Types.SmsConfigurationType where

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

-- | The SMS configuration type that includes the settings the Cognito User
-- Pool needs to call for the Amazon SNS service to send an SMS message
-- from your account. The Cognito User Pool makes the request to the Amazon
-- SNS Service by using an IAM role that you provide for your account.
--
-- /See:/ 'newSmsConfigurationType' smart constructor.
data SmsConfigurationType = SmsConfigurationType'
  { -- | The external ID is a value that we recommend you use to add security to
    -- your IAM role which is used to call Amazon SNS to send SMS messages for
    -- your user pool. If you provide an @ExternalId@, the Cognito User Pool
    -- will include it when attempting to assume your IAM role, so that you can
    -- set your roles trust policy to require the @ExternalID@. If you use the
    -- Cognito Management Console to create a role for SMS MFA, Cognito will
    -- create a role with the required permissions and a trust policy that
    -- demonstrates use of the @ExternalId@.
    --
    -- For more information about the @ExternalId@ of a role, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html How to use an external ID when granting access to your Amazon Web Services resources to a third party>
    SmsConfigurationType -> Maybe Text
externalId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Amazon Simple Notification Service
    -- (SNS) caller. This is the ARN of the IAM role in your account which
    -- Cognito will use to send SMS messages. SMS messages are subject to a
    -- <https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-email-phone-verification.html spending limit>.
    SmsConfigurationType -> Text
snsCallerArn :: Prelude.Text
  }
  deriving (SmsConfigurationType -> SmsConfigurationType -> Bool
(SmsConfigurationType -> SmsConfigurationType -> Bool)
-> (SmsConfigurationType -> SmsConfigurationType -> Bool)
-> Eq SmsConfigurationType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SmsConfigurationType -> SmsConfigurationType -> Bool
$c/= :: SmsConfigurationType -> SmsConfigurationType -> Bool
== :: SmsConfigurationType -> SmsConfigurationType -> Bool
$c== :: SmsConfigurationType -> SmsConfigurationType -> Bool
Prelude.Eq, ReadPrec [SmsConfigurationType]
ReadPrec SmsConfigurationType
Int -> ReadS SmsConfigurationType
ReadS [SmsConfigurationType]
(Int -> ReadS SmsConfigurationType)
-> ReadS [SmsConfigurationType]
-> ReadPrec SmsConfigurationType
-> ReadPrec [SmsConfigurationType]
-> Read SmsConfigurationType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SmsConfigurationType]
$creadListPrec :: ReadPrec [SmsConfigurationType]
readPrec :: ReadPrec SmsConfigurationType
$creadPrec :: ReadPrec SmsConfigurationType
readList :: ReadS [SmsConfigurationType]
$creadList :: ReadS [SmsConfigurationType]
readsPrec :: Int -> ReadS SmsConfigurationType
$creadsPrec :: Int -> ReadS SmsConfigurationType
Prelude.Read, Int -> SmsConfigurationType -> ShowS
[SmsConfigurationType] -> ShowS
SmsConfigurationType -> String
(Int -> SmsConfigurationType -> ShowS)
-> (SmsConfigurationType -> String)
-> ([SmsConfigurationType] -> ShowS)
-> Show SmsConfigurationType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SmsConfigurationType] -> ShowS
$cshowList :: [SmsConfigurationType] -> ShowS
show :: SmsConfigurationType -> String
$cshow :: SmsConfigurationType -> String
showsPrec :: Int -> SmsConfigurationType -> ShowS
$cshowsPrec :: Int -> SmsConfigurationType -> ShowS
Prelude.Show, (forall x. SmsConfigurationType -> Rep SmsConfigurationType x)
-> (forall x. Rep SmsConfigurationType x -> SmsConfigurationType)
-> Generic SmsConfigurationType
forall x. Rep SmsConfigurationType x -> SmsConfigurationType
forall x. SmsConfigurationType -> Rep SmsConfigurationType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SmsConfigurationType x -> SmsConfigurationType
$cfrom :: forall x. SmsConfigurationType -> Rep SmsConfigurationType x
Prelude.Generic)

-- |
-- Create a value of 'SmsConfigurationType' 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:
--
-- 'externalId', 'smsConfigurationType_externalId' - The external ID is a value that we recommend you use to add security to
-- your IAM role which is used to call Amazon SNS to send SMS messages for
-- your user pool. If you provide an @ExternalId@, the Cognito User Pool
-- will include it when attempting to assume your IAM role, so that you can
-- set your roles trust policy to require the @ExternalID@. If you use the
-- Cognito Management Console to create a role for SMS MFA, Cognito will
-- create a role with the required permissions and a trust policy that
-- demonstrates use of the @ExternalId@.
--
-- For more information about the @ExternalId@ of a role, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html How to use an external ID when granting access to your Amazon Web Services resources to a third party>
--
-- 'snsCallerArn', 'smsConfigurationType_snsCallerArn' - The Amazon Resource Name (ARN) of the Amazon Simple Notification Service
-- (SNS) caller. This is the ARN of the IAM role in your account which
-- Cognito will use to send SMS messages. SMS messages are subject to a
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-email-phone-verification.html spending limit>.
newSmsConfigurationType ::
  -- | 'snsCallerArn'
  Prelude.Text ->
  SmsConfigurationType
newSmsConfigurationType :: Text -> SmsConfigurationType
newSmsConfigurationType Text
pSnsCallerArn_ =
  SmsConfigurationType' :: Maybe Text -> Text -> SmsConfigurationType
SmsConfigurationType'
    { $sel:externalId:SmsConfigurationType' :: Maybe Text
externalId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:snsCallerArn:SmsConfigurationType' :: Text
snsCallerArn = Text
pSnsCallerArn_
    }

-- | The external ID is a value that we recommend you use to add security to
-- your IAM role which is used to call Amazon SNS to send SMS messages for
-- your user pool. If you provide an @ExternalId@, the Cognito User Pool
-- will include it when attempting to assume your IAM role, so that you can
-- set your roles trust policy to require the @ExternalID@. If you use the
-- Cognito Management Console to create a role for SMS MFA, Cognito will
-- create a role with the required permissions and a trust policy that
-- demonstrates use of the @ExternalId@.
--
-- For more information about the @ExternalId@ of a role, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html How to use an external ID when granting access to your Amazon Web Services resources to a third party>
smsConfigurationType_externalId :: Lens.Lens' SmsConfigurationType (Prelude.Maybe Prelude.Text)
smsConfigurationType_externalId :: (Maybe Text -> f (Maybe Text))
-> SmsConfigurationType -> f SmsConfigurationType
smsConfigurationType_externalId = (SmsConfigurationType -> Maybe Text)
-> (SmsConfigurationType -> Maybe Text -> SmsConfigurationType)
-> Lens
     SmsConfigurationType SmsConfigurationType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SmsConfigurationType' {Maybe Text
externalId :: Maybe Text
$sel:externalId:SmsConfigurationType' :: SmsConfigurationType -> Maybe Text
externalId} -> Maybe Text
externalId) (\s :: SmsConfigurationType
s@SmsConfigurationType' {} Maybe Text
a -> SmsConfigurationType
s {$sel:externalId:SmsConfigurationType' :: Maybe Text
externalId = Maybe Text
a} :: SmsConfigurationType)

-- | The Amazon Resource Name (ARN) of the Amazon Simple Notification Service
-- (SNS) caller. This is the ARN of the IAM role in your account which
-- Cognito will use to send SMS messages. SMS messages are subject to a
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-email-phone-verification.html spending limit>.
smsConfigurationType_snsCallerArn :: Lens.Lens' SmsConfigurationType Prelude.Text
smsConfigurationType_snsCallerArn :: (Text -> f Text) -> SmsConfigurationType -> f SmsConfigurationType
smsConfigurationType_snsCallerArn = (SmsConfigurationType -> Text)
-> (SmsConfigurationType -> Text -> SmsConfigurationType)
-> Lens SmsConfigurationType SmsConfigurationType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SmsConfigurationType' {Text
snsCallerArn :: Text
$sel:snsCallerArn:SmsConfigurationType' :: SmsConfigurationType -> Text
snsCallerArn} -> Text
snsCallerArn) (\s :: SmsConfigurationType
s@SmsConfigurationType' {} Text
a -> SmsConfigurationType
s {$sel:snsCallerArn:SmsConfigurationType' :: Text
snsCallerArn = Text
a} :: SmsConfigurationType)

instance Core.FromJSON SmsConfigurationType where
  parseJSON :: Value -> Parser SmsConfigurationType
parseJSON =
    String
-> (Object -> Parser SmsConfigurationType)
-> Value
-> Parser SmsConfigurationType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SmsConfigurationType"
      ( \Object
x ->
          Maybe Text -> Text -> SmsConfigurationType
SmsConfigurationType'
            (Maybe Text -> Text -> SmsConfigurationType)
-> Parser (Maybe Text) -> Parser (Text -> SmsConfigurationType)
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
"ExternalId")
            Parser (Text -> SmsConfigurationType)
-> Parser Text -> Parser SmsConfigurationType
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
"SnsCallerArn")
      )

instance Prelude.Hashable SmsConfigurationType

instance Prelude.NFData SmsConfigurationType

instance Core.ToJSON SmsConfigurationType where
  toJSON :: SmsConfigurationType -> Value
toJSON SmsConfigurationType' {Maybe Text
Text
snsCallerArn :: Text
externalId :: Maybe Text
$sel:snsCallerArn:SmsConfigurationType' :: SmsConfigurationType -> Text
$sel:externalId:SmsConfigurationType' :: SmsConfigurationType -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ExternalId" 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
externalId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SnsCallerArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
snsCallerArn)
          ]
      )