{-# 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.LexModels.Types.SlotTypeConfiguration
-- 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.LexModels.Types.SlotTypeConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LexModels.Types.SlotTypeRegexConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Provides configuration information for a slot type.
--
-- /See:/ 'newSlotTypeConfiguration' smart constructor.
data SlotTypeConfiguration = SlotTypeConfiguration'
  { -- | A regular expression used to validate the value of a slot.
    SlotTypeConfiguration -> Maybe SlotTypeRegexConfiguration
regexConfiguration :: Prelude.Maybe SlotTypeRegexConfiguration
  }
  deriving (SlotTypeConfiguration -> SlotTypeConfiguration -> Bool
(SlotTypeConfiguration -> SlotTypeConfiguration -> Bool)
-> (SlotTypeConfiguration -> SlotTypeConfiguration -> Bool)
-> Eq SlotTypeConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotTypeConfiguration -> SlotTypeConfiguration -> Bool
$c/= :: SlotTypeConfiguration -> SlotTypeConfiguration -> Bool
== :: SlotTypeConfiguration -> SlotTypeConfiguration -> Bool
$c== :: SlotTypeConfiguration -> SlotTypeConfiguration -> Bool
Prelude.Eq, ReadPrec [SlotTypeConfiguration]
ReadPrec SlotTypeConfiguration
Int -> ReadS SlotTypeConfiguration
ReadS [SlotTypeConfiguration]
(Int -> ReadS SlotTypeConfiguration)
-> ReadS [SlotTypeConfiguration]
-> ReadPrec SlotTypeConfiguration
-> ReadPrec [SlotTypeConfiguration]
-> Read SlotTypeConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotTypeConfiguration]
$creadListPrec :: ReadPrec [SlotTypeConfiguration]
readPrec :: ReadPrec SlotTypeConfiguration
$creadPrec :: ReadPrec SlotTypeConfiguration
readList :: ReadS [SlotTypeConfiguration]
$creadList :: ReadS [SlotTypeConfiguration]
readsPrec :: Int -> ReadS SlotTypeConfiguration
$creadsPrec :: Int -> ReadS SlotTypeConfiguration
Prelude.Read, Int -> SlotTypeConfiguration -> ShowS
[SlotTypeConfiguration] -> ShowS
SlotTypeConfiguration -> String
(Int -> SlotTypeConfiguration -> ShowS)
-> (SlotTypeConfiguration -> String)
-> ([SlotTypeConfiguration] -> ShowS)
-> Show SlotTypeConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotTypeConfiguration] -> ShowS
$cshowList :: [SlotTypeConfiguration] -> ShowS
show :: SlotTypeConfiguration -> String
$cshow :: SlotTypeConfiguration -> String
showsPrec :: Int -> SlotTypeConfiguration -> ShowS
$cshowsPrec :: Int -> SlotTypeConfiguration -> ShowS
Prelude.Show, (forall x. SlotTypeConfiguration -> Rep SlotTypeConfiguration x)
-> (forall x. Rep SlotTypeConfiguration x -> SlotTypeConfiguration)
-> Generic SlotTypeConfiguration
forall x. Rep SlotTypeConfiguration x -> SlotTypeConfiguration
forall x. SlotTypeConfiguration -> Rep SlotTypeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotTypeConfiguration x -> SlotTypeConfiguration
$cfrom :: forall x. SlotTypeConfiguration -> Rep SlotTypeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SlotTypeConfiguration' 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:
--
-- 'regexConfiguration', 'slotTypeConfiguration_regexConfiguration' - A regular expression used to validate the value of a slot.
newSlotTypeConfiguration ::
  SlotTypeConfiguration
newSlotTypeConfiguration :: SlotTypeConfiguration
newSlotTypeConfiguration =
  SlotTypeConfiguration' :: Maybe SlotTypeRegexConfiguration -> SlotTypeConfiguration
SlotTypeConfiguration'
    { $sel:regexConfiguration:SlotTypeConfiguration' :: Maybe SlotTypeRegexConfiguration
regexConfiguration =
        Maybe SlotTypeRegexConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | A regular expression used to validate the value of a slot.
slotTypeConfiguration_regexConfiguration :: Lens.Lens' SlotTypeConfiguration (Prelude.Maybe SlotTypeRegexConfiguration)
slotTypeConfiguration_regexConfiguration :: (Maybe SlotTypeRegexConfiguration
 -> f (Maybe SlotTypeRegexConfiguration))
-> SlotTypeConfiguration -> f SlotTypeConfiguration
slotTypeConfiguration_regexConfiguration = (SlotTypeConfiguration -> Maybe SlotTypeRegexConfiguration)
-> (SlotTypeConfiguration
    -> Maybe SlotTypeRegexConfiguration -> SlotTypeConfiguration)
-> Lens
     SlotTypeConfiguration
     SlotTypeConfiguration
     (Maybe SlotTypeRegexConfiguration)
     (Maybe SlotTypeRegexConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotTypeConfiguration' {Maybe SlotTypeRegexConfiguration
regexConfiguration :: Maybe SlotTypeRegexConfiguration
$sel:regexConfiguration:SlotTypeConfiguration' :: SlotTypeConfiguration -> Maybe SlotTypeRegexConfiguration
regexConfiguration} -> Maybe SlotTypeRegexConfiguration
regexConfiguration) (\s :: SlotTypeConfiguration
s@SlotTypeConfiguration' {} Maybe SlotTypeRegexConfiguration
a -> SlotTypeConfiguration
s {$sel:regexConfiguration:SlotTypeConfiguration' :: Maybe SlotTypeRegexConfiguration
regexConfiguration = Maybe SlotTypeRegexConfiguration
a} :: SlotTypeConfiguration)

instance Core.FromJSON SlotTypeConfiguration where
  parseJSON :: Value -> Parser SlotTypeConfiguration
parseJSON =
    String
-> (Object -> Parser SlotTypeConfiguration)
-> Value
-> Parser SlotTypeConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SlotTypeConfiguration"
      ( \Object
x ->
          Maybe SlotTypeRegexConfiguration -> SlotTypeConfiguration
SlotTypeConfiguration'
            (Maybe SlotTypeRegexConfiguration -> SlotTypeConfiguration)
-> Parser (Maybe SlotTypeRegexConfiguration)
-> Parser SlotTypeConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SlotTypeRegexConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"regexConfiguration")
      )

instance Prelude.Hashable SlotTypeConfiguration

instance Prelude.NFData SlotTypeConfiguration

instance Core.ToJSON SlotTypeConfiguration where
  toJSON :: SlotTypeConfiguration -> Value
toJSON SlotTypeConfiguration' {Maybe SlotTypeRegexConfiguration
regexConfiguration :: Maybe SlotTypeRegexConfiguration
$sel:regexConfiguration:SlotTypeConfiguration' :: SlotTypeConfiguration -> Maybe SlotTypeRegexConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"regexConfiguration" Text -> SlotTypeRegexConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SlotTypeRegexConfiguration -> Pair)
-> Maybe SlotTypeRegexConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SlotTypeRegexConfiguration
regexConfiguration
          ]
      )