{-# 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 #-}
module Amazonka.AppConfig.Types.Validator where
import Amazonka.AppConfig.Types.ValidatorType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Validator = Validator'
{
Validator -> ValidatorType
type' :: ValidatorType,
Validator -> Sensitive Text
content :: Core.Sensitive Prelude.Text
}
deriving (Validator -> Validator -> Bool
(Validator -> Validator -> Bool)
-> (Validator -> Validator -> Bool) -> Eq Validator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Validator -> Validator -> Bool
$c/= :: Validator -> Validator -> Bool
== :: Validator -> Validator -> Bool
$c== :: Validator -> Validator -> Bool
Prelude.Eq, Int -> Validator -> ShowS
[Validator] -> ShowS
Validator -> String
(Int -> Validator -> ShowS)
-> (Validator -> String)
-> ([Validator] -> ShowS)
-> Show Validator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Validator] -> ShowS
$cshowList :: [Validator] -> ShowS
show :: Validator -> String
$cshow :: Validator -> String
showsPrec :: Int -> Validator -> ShowS
$cshowsPrec :: Int -> Validator -> ShowS
Prelude.Show, (forall x. Validator -> Rep Validator x)
-> (forall x. Rep Validator x -> Validator) -> Generic Validator
forall x. Rep Validator x -> Validator
forall x. Validator -> Rep Validator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Validator x -> Validator
$cfrom :: forall x. Validator -> Rep Validator x
Prelude.Generic)
newValidator ::
ValidatorType ->
Prelude.Text ->
Validator
newValidator :: ValidatorType -> Text -> Validator
newValidator ValidatorType
pType_ Text
pContent_ =
Validator' :: ValidatorType -> Sensitive Text -> Validator
Validator'
{ $sel:type':Validator' :: ValidatorType
type' = ValidatorType
pType_,
$sel:content:Validator' :: Sensitive Text
content = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pContent_
}
validator_type :: Lens.Lens' Validator ValidatorType
validator_type :: (ValidatorType -> f ValidatorType) -> Validator -> f Validator
validator_type = (Validator -> ValidatorType)
-> (Validator -> ValidatorType -> Validator)
-> Lens Validator Validator ValidatorType ValidatorType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Validator' {ValidatorType
type' :: ValidatorType
$sel:type':Validator' :: Validator -> ValidatorType
type'} -> ValidatorType
type') (\s :: Validator
s@Validator' {} ValidatorType
a -> Validator
s {$sel:type':Validator' :: ValidatorType
type' = ValidatorType
a} :: Validator)
validator_content :: Lens.Lens' Validator Prelude.Text
validator_content :: (Text -> f Text) -> Validator -> f Validator
validator_content = (Validator -> Sensitive Text)
-> (Validator -> Sensitive Text -> Validator)
-> Lens Validator Validator (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Validator' {Sensitive Text
content :: Sensitive Text
$sel:content:Validator' :: Validator -> Sensitive Text
content} -> Sensitive Text
content) (\s :: Validator
s@Validator' {} Sensitive Text
a -> Validator
s {$sel:content:Validator' :: Sensitive Text
content = Sensitive Text
a} :: Validator) ((Sensitive Text -> f (Sensitive Text))
-> Validator -> f Validator)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> Validator
-> f Validator
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
instance Core.FromJSON Validator where
parseJSON :: Value -> Parser Validator
parseJSON =
String -> (Object -> Parser Validator) -> Value -> Parser Validator
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Validator"
( \Object
x ->
ValidatorType -> Sensitive Text -> Validator
Validator'
(ValidatorType -> Sensitive Text -> Validator)
-> Parser ValidatorType -> Parser (Sensitive Text -> Validator)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ValidatorType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type") Parser (Sensitive Text -> Validator)
-> Parser (Sensitive Text) -> Parser Validator
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Content")
)
instance Prelude.Hashable Validator
instance Prelude.NFData Validator
instance Core.ToJSON Validator where
toJSON :: Validator -> Value
toJSON Validator' {Sensitive Text
ValidatorType
content :: Sensitive Text
type' :: ValidatorType
$sel:content:Validator' :: Validator -> Sensitive Text
$sel:type':Validator' :: Validator -> ValidatorType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> ValidatorType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ValidatorType
type'),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Content" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
content)
]
)