{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CognitoIdentityProvider.Types.SmsConfigurationType where

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

-- | The SMS configuration type is the settings that your Amazon Cognito user
-- pool must use to send an SMS message from your Amazon Web Services
-- account through Amazon Simple Notification Service. To send SMS messages
-- with Amazon SNS in the Amazon Web Services Region that you want, the
-- Amazon Cognito user pool uses an Identity and Access Management (IAM)
-- role in your Amazon Web Services account.
--
-- /See:/ 'newSmsConfigurationType' smart constructor.
data SmsConfigurationType = SmsConfigurationType'
  { -- | The external ID provides additional security for your IAM role. You can
    -- use an @ExternalId@ with the IAM role that you use with Amazon SNS to
    -- send SMS messages for your user pool. If you provide an @ExternalId@,
    -- your Amazon Cognito user pool includes it in the request to assume your
    -- IAM role. You can configure the role trust policy to require that Amazon
    -- Cognito, and any principal, provide the @ExternalID@. If you use the
    -- Amazon Cognito Management Console to create a role for SMS multi-factor
    -- authentication (MFA), Amazon Cognito creates 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 Web Services Region to use with Amazon SNS integration. You
    -- can choose the same Region as your user pool, or a supported __Legacy
    -- Amazon SNS alternate Region__.
    --
    -- Amazon Cognito resources in the Asia Pacific (Seoul) Amazon Web Services
    -- Region must use your Amazon SNS configuration in the Asia Pacific
    -- (Tokyo) Region. For more information, see
    -- <https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html SMS message settings for Amazon Cognito user pools>.
    SmsConfigurationType -> Maybe Text
snsRegion :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Amazon SNS caller. This is the ARN
    -- of the IAM role in your Amazon Web Services account that Amazon 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
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]
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
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. 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 provides additional security for your IAM role. You can
-- use an @ExternalId@ with the IAM role that you use with Amazon SNS to
-- send SMS messages for your user pool. If you provide an @ExternalId@,
-- your Amazon Cognito user pool includes it in the request to assume your
-- IAM role. You can configure the role trust policy to require that Amazon
-- Cognito, and any principal, provide the @ExternalID@. If you use the
-- Amazon Cognito Management Console to create a role for SMS multi-factor
-- authentication (MFA), Amazon Cognito creates 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>
--
-- 'snsRegion', 'smsConfigurationType_snsRegion' - The Amazon Web Services Region to use with Amazon SNS integration. You
-- can choose the same Region as your user pool, or a supported __Legacy
-- Amazon SNS alternate Region__.
--
-- Amazon Cognito resources in the Asia Pacific (Seoul) Amazon Web Services
-- Region must use your Amazon SNS configuration in the Asia Pacific
-- (Tokyo) Region. For more information, see
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html SMS message settings for Amazon Cognito user pools>.
--
-- 'snsCallerArn', 'smsConfigurationType_snsCallerArn' - The Amazon Resource Name (ARN) of the Amazon SNS caller. This is the ARN
-- of the IAM role in your Amazon Web Services account that Amazon 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'
    { $sel:externalId:SmsConfigurationType' :: Maybe Text
externalId = forall a. Maybe a
Prelude.Nothing,
      $sel:snsRegion:SmsConfigurationType' :: Maybe Text
snsRegion = forall a. Maybe a
Prelude.Nothing,
      $sel:snsCallerArn:SmsConfigurationType' :: Text
snsCallerArn = Text
pSnsCallerArn_
    }

-- | The external ID provides additional security for your IAM role. You can
-- use an @ExternalId@ with the IAM role that you use with Amazon SNS to
-- send SMS messages for your user pool. If you provide an @ExternalId@,
-- your Amazon Cognito user pool includes it in the request to assume your
-- IAM role. You can configure the role trust policy to require that Amazon
-- Cognito, and any principal, provide the @ExternalID@. If you use the
-- Amazon Cognito Management Console to create a role for SMS multi-factor
-- authentication (MFA), Amazon Cognito creates 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 :: Lens' SmsConfigurationType (Maybe Text)
smsConfigurationType_externalId = 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 Web Services Region to use with Amazon SNS integration. You
-- can choose the same Region as your user pool, or a supported __Legacy
-- Amazon SNS alternate Region__.
--
-- Amazon Cognito resources in the Asia Pacific (Seoul) Amazon Web Services
-- Region must use your Amazon SNS configuration in the Asia Pacific
-- (Tokyo) Region. For more information, see
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html SMS message settings for Amazon Cognito user pools>.
smsConfigurationType_snsRegion :: Lens.Lens' SmsConfigurationType (Prelude.Maybe Prelude.Text)
smsConfigurationType_snsRegion :: Lens' SmsConfigurationType (Maybe Text)
smsConfigurationType_snsRegion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SmsConfigurationType' {Maybe Text
snsRegion :: Maybe Text
$sel:snsRegion:SmsConfigurationType' :: SmsConfigurationType -> Maybe Text
snsRegion} -> Maybe Text
snsRegion) (\s :: SmsConfigurationType
s@SmsConfigurationType' {} Maybe Text
a -> SmsConfigurationType
s {$sel:snsRegion:SmsConfigurationType' :: Maybe Text
snsRegion = Maybe Text
a} :: SmsConfigurationType)

-- | The Amazon Resource Name (ARN) of the Amazon SNS caller. This is the ARN
-- of the IAM role in your Amazon Web Services account that Amazon 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 :: Lens' SmsConfigurationType Text
smsConfigurationType_snsCallerArn = 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 Data.FromJSON SmsConfigurationType where
  parseJSON :: Value -> Parser SmsConfigurationType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SmsConfigurationType"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> SmsConfigurationType
SmsConfigurationType'
            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
"ExternalId")
            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
"SnsRegion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SnsCallerArn")
      )

instance Prelude.Hashable SmsConfigurationType where
  hashWithSalt :: Int -> SmsConfigurationType -> Int
hashWithSalt Int
_salt SmsConfigurationType' {Maybe Text
Text
snsCallerArn :: Text
snsRegion :: Maybe Text
externalId :: Maybe Text
$sel:snsCallerArn:SmsConfigurationType' :: SmsConfigurationType -> Text
$sel:snsRegion:SmsConfigurationType' :: SmsConfigurationType -> Maybe Text
$sel:externalId:SmsConfigurationType' :: SmsConfigurationType -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
externalId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
snsRegion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
snsCallerArn

instance Prelude.NFData SmsConfigurationType where
  rnf :: SmsConfigurationType -> ()
rnf SmsConfigurationType' {Maybe Text
Text
snsCallerArn :: Text
snsRegion :: Maybe Text
externalId :: Maybe Text
$sel:snsCallerArn:SmsConfigurationType' :: SmsConfigurationType -> Text
$sel:snsRegion:SmsConfigurationType' :: SmsConfigurationType -> Maybe Text
$sel:externalId:SmsConfigurationType' :: SmsConfigurationType -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
externalId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
snsRegion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
snsCallerArn

instance Data.ToJSON SmsConfigurationType where
  toJSON :: SmsConfigurationType -> Value
toJSON SmsConfigurationType' {Maybe Text
Text
snsCallerArn :: Text
snsRegion :: Maybe Text
externalId :: Maybe Text
$sel:snsCallerArn:SmsConfigurationType' :: SmsConfigurationType -> Text
$sel:snsRegion:SmsConfigurationType' :: SmsConfigurationType -> Maybe Text
$sel:externalId:SmsConfigurationType' :: SmsConfigurationType -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ExternalId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
externalId,
            (Key
"SnsRegion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
snsRegion,
            forall a. a -> Maybe a
Prelude.Just (Key
"SnsCallerArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
snsCallerArn)
          ]
      )