{-# 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.AppMesh.Types.LoggingFormat where
import Amazonka.AppMesh.Types.JsonFormatRef
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
data LoggingFormat = LoggingFormat'
{ LoggingFormat -> Maybe [JsonFormatRef]
json :: Prelude.Maybe [JsonFormatRef],
LoggingFormat -> Maybe Text
text :: Prelude.Maybe Prelude.Text
}
deriving (LoggingFormat -> LoggingFormat -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoggingFormat -> LoggingFormat -> Bool
$c/= :: LoggingFormat -> LoggingFormat -> Bool
== :: LoggingFormat -> LoggingFormat -> Bool
$c== :: LoggingFormat -> LoggingFormat -> Bool
Prelude.Eq, ReadPrec [LoggingFormat]
ReadPrec LoggingFormat
Int -> ReadS LoggingFormat
ReadS [LoggingFormat]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoggingFormat]
$creadListPrec :: ReadPrec [LoggingFormat]
readPrec :: ReadPrec LoggingFormat
$creadPrec :: ReadPrec LoggingFormat
readList :: ReadS [LoggingFormat]
$creadList :: ReadS [LoggingFormat]
readsPrec :: Int -> ReadS LoggingFormat
$creadsPrec :: Int -> ReadS LoggingFormat
Prelude.Read, Int -> LoggingFormat -> ShowS
[LoggingFormat] -> ShowS
LoggingFormat -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoggingFormat] -> ShowS
$cshowList :: [LoggingFormat] -> ShowS
show :: LoggingFormat -> String
$cshow :: LoggingFormat -> String
showsPrec :: Int -> LoggingFormat -> ShowS
$cshowsPrec :: Int -> LoggingFormat -> ShowS
Prelude.Show, forall x. Rep LoggingFormat x -> LoggingFormat
forall x. LoggingFormat -> Rep LoggingFormat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoggingFormat x -> LoggingFormat
$cfrom :: forall x. LoggingFormat -> Rep LoggingFormat x
Prelude.Generic)
newLoggingFormat ::
LoggingFormat
newLoggingFormat :: LoggingFormat
newLoggingFormat =
LoggingFormat'
{ $sel:json:LoggingFormat' :: Maybe [JsonFormatRef]
json = forall a. Maybe a
Prelude.Nothing,
$sel:text:LoggingFormat' :: Maybe Text
text = forall a. Maybe a
Prelude.Nothing
}
loggingFormat_json :: Lens.Lens' LoggingFormat (Prelude.Maybe [JsonFormatRef])
loggingFormat_json :: Lens' LoggingFormat (Maybe [JsonFormatRef])
loggingFormat_json = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingFormat' {Maybe [JsonFormatRef]
json :: Maybe [JsonFormatRef]
$sel:json:LoggingFormat' :: LoggingFormat -> Maybe [JsonFormatRef]
json} -> Maybe [JsonFormatRef]
json) (\s :: LoggingFormat
s@LoggingFormat' {} Maybe [JsonFormatRef]
a -> LoggingFormat
s {$sel:json:LoggingFormat' :: Maybe [JsonFormatRef]
json = Maybe [JsonFormatRef]
a} :: LoggingFormat) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
loggingFormat_text :: Lens.Lens' LoggingFormat (Prelude.Maybe Prelude.Text)
loggingFormat_text :: Lens' LoggingFormat (Maybe Text)
loggingFormat_text = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingFormat' {Maybe Text
text :: Maybe Text
$sel:text:LoggingFormat' :: LoggingFormat -> Maybe Text
text} -> Maybe Text
text) (\s :: LoggingFormat
s@LoggingFormat' {} Maybe Text
a -> LoggingFormat
s {$sel:text:LoggingFormat' :: Maybe Text
text = Maybe Text
a} :: LoggingFormat)
instance Data.FromJSON LoggingFormat where
parseJSON :: Value -> Parser LoggingFormat
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"LoggingFormat"
( \Object
x ->
Maybe [JsonFormatRef] -> Maybe Text -> LoggingFormat
LoggingFormat'
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
"json" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
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
"text")
)
instance Prelude.Hashable LoggingFormat where
hashWithSalt :: Int -> LoggingFormat -> Int
hashWithSalt Int
_salt LoggingFormat' {Maybe [JsonFormatRef]
Maybe Text
text :: Maybe Text
json :: Maybe [JsonFormatRef]
$sel:text:LoggingFormat' :: LoggingFormat -> Maybe Text
$sel:json:LoggingFormat' :: LoggingFormat -> Maybe [JsonFormatRef]
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [JsonFormatRef]
json
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
text
instance Prelude.NFData LoggingFormat where
rnf :: LoggingFormat -> ()
rnf LoggingFormat' {Maybe [JsonFormatRef]
Maybe Text
text :: Maybe Text
json :: Maybe [JsonFormatRef]
$sel:text:LoggingFormat' :: LoggingFormat -> Maybe Text
$sel:json:LoggingFormat' :: LoggingFormat -> Maybe [JsonFormatRef]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [JsonFormatRef]
json seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
text
instance Data.ToJSON LoggingFormat where
toJSON :: LoggingFormat -> Value
toJSON LoggingFormat' {Maybe [JsonFormatRef]
Maybe Text
text :: Maybe Text
json :: Maybe [JsonFormatRef]
$sel:text:LoggingFormat' :: LoggingFormat -> Maybe Text
$sel:json:LoggingFormat' :: LoggingFormat -> Maybe [JsonFormatRef]
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"json" 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 [JsonFormatRef]
json,
(Key
"text" 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
text
]
)