{-# 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.SMS.Types.ServerValidationConfiguration
-- 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.SMS.Types.ServerValidationConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SMS.Types.Server
import Amazonka.SMS.Types.ServerValidationStrategy
import Amazonka.SMS.Types.UserDataValidationParameters

-- | Configuration for validating an instance.
--
-- /See:/ 'newServerValidationConfiguration' smart constructor.
data ServerValidationConfiguration = ServerValidationConfiguration'
  { -- | The validation strategy.
    ServerValidationConfiguration -> Maybe ServerValidationStrategy
serverValidationStrategy :: Prelude.Maybe ServerValidationStrategy,
    -- | The validation parameters.
    ServerValidationConfiguration -> Maybe UserDataValidationParameters
userDataValidationParameters :: Prelude.Maybe UserDataValidationParameters,
    -- | The name of the configuration.
    ServerValidationConfiguration -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    ServerValidationConfiguration -> Maybe Server
server :: Prelude.Maybe Server,
    -- | The ID of the validation.
    ServerValidationConfiguration -> Maybe Text
validationId :: Prelude.Maybe Prelude.Text
  }
  deriving (ServerValidationConfiguration
-> ServerValidationConfiguration -> Bool
(ServerValidationConfiguration
 -> ServerValidationConfiguration -> Bool)
-> (ServerValidationConfiguration
    -> ServerValidationConfiguration -> Bool)
-> Eq ServerValidationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServerValidationConfiguration
-> ServerValidationConfiguration -> Bool
$c/= :: ServerValidationConfiguration
-> ServerValidationConfiguration -> Bool
== :: ServerValidationConfiguration
-> ServerValidationConfiguration -> Bool
$c== :: ServerValidationConfiguration
-> ServerValidationConfiguration -> Bool
Prelude.Eq, ReadPrec [ServerValidationConfiguration]
ReadPrec ServerValidationConfiguration
Int -> ReadS ServerValidationConfiguration
ReadS [ServerValidationConfiguration]
(Int -> ReadS ServerValidationConfiguration)
-> ReadS [ServerValidationConfiguration]
-> ReadPrec ServerValidationConfiguration
-> ReadPrec [ServerValidationConfiguration]
-> Read ServerValidationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServerValidationConfiguration]
$creadListPrec :: ReadPrec [ServerValidationConfiguration]
readPrec :: ReadPrec ServerValidationConfiguration
$creadPrec :: ReadPrec ServerValidationConfiguration
readList :: ReadS [ServerValidationConfiguration]
$creadList :: ReadS [ServerValidationConfiguration]
readsPrec :: Int -> ReadS ServerValidationConfiguration
$creadsPrec :: Int -> ReadS ServerValidationConfiguration
Prelude.Read, Int -> ServerValidationConfiguration -> ShowS
[ServerValidationConfiguration] -> ShowS
ServerValidationConfiguration -> String
(Int -> ServerValidationConfiguration -> ShowS)
-> (ServerValidationConfiguration -> String)
-> ([ServerValidationConfiguration] -> ShowS)
-> Show ServerValidationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServerValidationConfiguration] -> ShowS
$cshowList :: [ServerValidationConfiguration] -> ShowS
show :: ServerValidationConfiguration -> String
$cshow :: ServerValidationConfiguration -> String
showsPrec :: Int -> ServerValidationConfiguration -> ShowS
$cshowsPrec :: Int -> ServerValidationConfiguration -> ShowS
Prelude.Show, (forall x.
 ServerValidationConfiguration
 -> Rep ServerValidationConfiguration x)
-> (forall x.
    Rep ServerValidationConfiguration x
    -> ServerValidationConfiguration)
-> Generic ServerValidationConfiguration
forall x.
Rep ServerValidationConfiguration x
-> ServerValidationConfiguration
forall x.
ServerValidationConfiguration
-> Rep ServerValidationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ServerValidationConfiguration x
-> ServerValidationConfiguration
$cfrom :: forall x.
ServerValidationConfiguration
-> Rep ServerValidationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ServerValidationConfiguration' 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:
--
-- 'serverValidationStrategy', 'serverValidationConfiguration_serverValidationStrategy' - The validation strategy.
--
-- 'userDataValidationParameters', 'serverValidationConfiguration_userDataValidationParameters' - The validation parameters.
--
-- 'name', 'serverValidationConfiguration_name' - The name of the configuration.
--
-- 'server', 'serverValidationConfiguration_server' - Undocumented member.
--
-- 'validationId', 'serverValidationConfiguration_validationId' - The ID of the validation.
newServerValidationConfiguration ::
  ServerValidationConfiguration
newServerValidationConfiguration :: ServerValidationConfiguration
newServerValidationConfiguration =
  ServerValidationConfiguration' :: Maybe ServerValidationStrategy
-> Maybe UserDataValidationParameters
-> Maybe Text
-> Maybe Server
-> Maybe Text
-> ServerValidationConfiguration
ServerValidationConfiguration'
    { $sel:serverValidationStrategy:ServerValidationConfiguration' :: Maybe ServerValidationStrategy
serverValidationStrategy =
        Maybe ServerValidationStrategy
forall a. Maybe a
Prelude.Nothing,
      $sel:userDataValidationParameters:ServerValidationConfiguration' :: Maybe UserDataValidationParameters
userDataValidationParameters =
        Maybe UserDataValidationParameters
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ServerValidationConfiguration' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:server:ServerValidationConfiguration' :: Maybe Server
server = Maybe Server
forall a. Maybe a
Prelude.Nothing,
      $sel:validationId:ServerValidationConfiguration' :: Maybe Text
validationId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The validation strategy.
serverValidationConfiguration_serverValidationStrategy :: Lens.Lens' ServerValidationConfiguration (Prelude.Maybe ServerValidationStrategy)
serverValidationConfiguration_serverValidationStrategy :: (Maybe ServerValidationStrategy
 -> f (Maybe ServerValidationStrategy))
-> ServerValidationConfiguration -> f ServerValidationConfiguration
serverValidationConfiguration_serverValidationStrategy = (ServerValidationConfiguration -> Maybe ServerValidationStrategy)
-> (ServerValidationConfiguration
    -> Maybe ServerValidationStrategy -> ServerValidationConfiguration)
-> Lens
     ServerValidationConfiguration
     ServerValidationConfiguration
     (Maybe ServerValidationStrategy)
     (Maybe ServerValidationStrategy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerValidationConfiguration' {Maybe ServerValidationStrategy
serverValidationStrategy :: Maybe ServerValidationStrategy
$sel:serverValidationStrategy:ServerValidationConfiguration' :: ServerValidationConfiguration -> Maybe ServerValidationStrategy
serverValidationStrategy} -> Maybe ServerValidationStrategy
serverValidationStrategy) (\s :: ServerValidationConfiguration
s@ServerValidationConfiguration' {} Maybe ServerValidationStrategy
a -> ServerValidationConfiguration
s {$sel:serverValidationStrategy:ServerValidationConfiguration' :: Maybe ServerValidationStrategy
serverValidationStrategy = Maybe ServerValidationStrategy
a} :: ServerValidationConfiguration)

-- | The validation parameters.
serverValidationConfiguration_userDataValidationParameters :: Lens.Lens' ServerValidationConfiguration (Prelude.Maybe UserDataValidationParameters)
serverValidationConfiguration_userDataValidationParameters :: (Maybe UserDataValidationParameters
 -> f (Maybe UserDataValidationParameters))
-> ServerValidationConfiguration -> f ServerValidationConfiguration
serverValidationConfiguration_userDataValidationParameters = (ServerValidationConfiguration
 -> Maybe UserDataValidationParameters)
-> (ServerValidationConfiguration
    -> Maybe UserDataValidationParameters
    -> ServerValidationConfiguration)
-> Lens
     ServerValidationConfiguration
     ServerValidationConfiguration
     (Maybe UserDataValidationParameters)
     (Maybe UserDataValidationParameters)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerValidationConfiguration' {Maybe UserDataValidationParameters
userDataValidationParameters :: Maybe UserDataValidationParameters
$sel:userDataValidationParameters:ServerValidationConfiguration' :: ServerValidationConfiguration -> Maybe UserDataValidationParameters
userDataValidationParameters} -> Maybe UserDataValidationParameters
userDataValidationParameters) (\s :: ServerValidationConfiguration
s@ServerValidationConfiguration' {} Maybe UserDataValidationParameters
a -> ServerValidationConfiguration
s {$sel:userDataValidationParameters:ServerValidationConfiguration' :: Maybe UserDataValidationParameters
userDataValidationParameters = Maybe UserDataValidationParameters
a} :: ServerValidationConfiguration)

-- | The name of the configuration.
serverValidationConfiguration_name :: Lens.Lens' ServerValidationConfiguration (Prelude.Maybe Prelude.Text)
serverValidationConfiguration_name :: (Maybe Text -> f (Maybe Text))
-> ServerValidationConfiguration -> f ServerValidationConfiguration
serverValidationConfiguration_name = (ServerValidationConfiguration -> Maybe Text)
-> (ServerValidationConfiguration
    -> Maybe Text -> ServerValidationConfiguration)
-> Lens
     ServerValidationConfiguration
     ServerValidationConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerValidationConfiguration' {Maybe Text
name :: Maybe Text
$sel:name:ServerValidationConfiguration' :: ServerValidationConfiguration -> Maybe Text
name} -> Maybe Text
name) (\s :: ServerValidationConfiguration
s@ServerValidationConfiguration' {} Maybe Text
a -> ServerValidationConfiguration
s {$sel:name:ServerValidationConfiguration' :: Maybe Text
name = Maybe Text
a} :: ServerValidationConfiguration)

-- | Undocumented member.
serverValidationConfiguration_server :: Lens.Lens' ServerValidationConfiguration (Prelude.Maybe Server)
serverValidationConfiguration_server :: (Maybe Server -> f (Maybe Server))
-> ServerValidationConfiguration -> f ServerValidationConfiguration
serverValidationConfiguration_server = (ServerValidationConfiguration -> Maybe Server)
-> (ServerValidationConfiguration
    -> Maybe Server -> ServerValidationConfiguration)
-> Lens
     ServerValidationConfiguration
     ServerValidationConfiguration
     (Maybe Server)
     (Maybe Server)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerValidationConfiguration' {Maybe Server
server :: Maybe Server
$sel:server:ServerValidationConfiguration' :: ServerValidationConfiguration -> Maybe Server
server} -> Maybe Server
server) (\s :: ServerValidationConfiguration
s@ServerValidationConfiguration' {} Maybe Server
a -> ServerValidationConfiguration
s {$sel:server:ServerValidationConfiguration' :: Maybe Server
server = Maybe Server
a} :: ServerValidationConfiguration)

-- | The ID of the validation.
serverValidationConfiguration_validationId :: Lens.Lens' ServerValidationConfiguration (Prelude.Maybe Prelude.Text)
serverValidationConfiguration_validationId :: (Maybe Text -> f (Maybe Text))
-> ServerValidationConfiguration -> f ServerValidationConfiguration
serverValidationConfiguration_validationId = (ServerValidationConfiguration -> Maybe Text)
-> (ServerValidationConfiguration
    -> Maybe Text -> ServerValidationConfiguration)
-> Lens
     ServerValidationConfiguration
     ServerValidationConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerValidationConfiguration' {Maybe Text
validationId :: Maybe Text
$sel:validationId:ServerValidationConfiguration' :: ServerValidationConfiguration -> Maybe Text
validationId} -> Maybe Text
validationId) (\s :: ServerValidationConfiguration
s@ServerValidationConfiguration' {} Maybe Text
a -> ServerValidationConfiguration
s {$sel:validationId:ServerValidationConfiguration' :: Maybe Text
validationId = Maybe Text
a} :: ServerValidationConfiguration)

instance Core.FromJSON ServerValidationConfiguration where
  parseJSON :: Value -> Parser ServerValidationConfiguration
parseJSON =
    String
-> (Object -> Parser ServerValidationConfiguration)
-> Value
-> Parser ServerValidationConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ServerValidationConfiguration"
      ( \Object
x ->
          Maybe ServerValidationStrategy
-> Maybe UserDataValidationParameters
-> Maybe Text
-> Maybe Server
-> Maybe Text
-> ServerValidationConfiguration
ServerValidationConfiguration'
            (Maybe ServerValidationStrategy
 -> Maybe UserDataValidationParameters
 -> Maybe Text
 -> Maybe Server
 -> Maybe Text
 -> ServerValidationConfiguration)
-> Parser (Maybe ServerValidationStrategy)
-> Parser
     (Maybe UserDataValidationParameters
      -> Maybe Text
      -> Maybe Server
      -> Maybe Text
      -> ServerValidationConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ServerValidationStrategy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"serverValidationStrategy")
            Parser
  (Maybe UserDataValidationParameters
   -> Maybe Text
   -> Maybe Server
   -> Maybe Text
   -> ServerValidationConfiguration)
-> Parser (Maybe UserDataValidationParameters)
-> Parser
     (Maybe Text
      -> Maybe Server -> Maybe Text -> ServerValidationConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UserDataValidationParameters)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"userDataValidationParameters")
            Parser
  (Maybe Text
   -> Maybe Server -> Maybe Text -> ServerValidationConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe Server -> Maybe Text -> ServerValidationConfiguration)
forall (f :: * -> *) a b. Applicative f => 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
"name")
            Parser
  (Maybe Server -> Maybe Text -> ServerValidationConfiguration)
-> Parser (Maybe Server)
-> Parser (Maybe Text -> ServerValidationConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Server)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"server")
            Parser (Maybe Text -> ServerValidationConfiguration)
-> Parser (Maybe Text) -> Parser ServerValidationConfiguration
forall (f :: * -> *) a b. Applicative f => 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
"validationId")
      )

instance
  Prelude.Hashable
    ServerValidationConfiguration

instance Prelude.NFData ServerValidationConfiguration

instance Core.ToJSON ServerValidationConfiguration where
  toJSON :: ServerValidationConfiguration -> Value
toJSON ServerValidationConfiguration' {Maybe Text
Maybe ServerValidationStrategy
Maybe UserDataValidationParameters
Maybe Server
validationId :: Maybe Text
server :: Maybe Server
name :: Maybe Text
userDataValidationParameters :: Maybe UserDataValidationParameters
serverValidationStrategy :: Maybe ServerValidationStrategy
$sel:validationId:ServerValidationConfiguration' :: ServerValidationConfiguration -> Maybe Text
$sel:server:ServerValidationConfiguration' :: ServerValidationConfiguration -> Maybe Server
$sel:name:ServerValidationConfiguration' :: ServerValidationConfiguration -> Maybe Text
$sel:userDataValidationParameters:ServerValidationConfiguration' :: ServerValidationConfiguration -> Maybe UserDataValidationParameters
$sel:serverValidationStrategy:ServerValidationConfiguration' :: ServerValidationConfiguration -> Maybe ServerValidationStrategy
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"serverValidationStrategy" Text -> ServerValidationStrategy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ServerValidationStrategy -> Pair)
-> Maybe ServerValidationStrategy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ServerValidationStrategy
serverValidationStrategy,
            (Text
"userDataValidationParameters" Text -> UserDataValidationParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (UserDataValidationParameters -> Pair)
-> Maybe UserDataValidationParameters -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UserDataValidationParameters
userDataValidationParameters,
            (Text
"name" 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
name,
            (Text
"server" Text -> Server -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Server -> Pair) -> Maybe Server -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Server
server,
            (Text
"validationId" 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
validationId
          ]
      )