{-# 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.Discovery.Types.OrderByElement where
import qualified Amazonka.Core as Core
import Amazonka.Discovery.Types.OrderString
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data OrderByElement = OrderByElement'
{
OrderByElement -> Maybe OrderString
sortOrder :: Prelude.Maybe OrderString,
OrderByElement -> Text
fieldName :: Prelude.Text
}
deriving (OrderByElement -> OrderByElement -> Bool
(OrderByElement -> OrderByElement -> Bool)
-> (OrderByElement -> OrderByElement -> Bool) -> Eq OrderByElement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OrderByElement -> OrderByElement -> Bool
$c/= :: OrderByElement -> OrderByElement -> Bool
== :: OrderByElement -> OrderByElement -> Bool
$c== :: OrderByElement -> OrderByElement -> Bool
Prelude.Eq, ReadPrec [OrderByElement]
ReadPrec OrderByElement
Int -> ReadS OrderByElement
ReadS [OrderByElement]
(Int -> ReadS OrderByElement)
-> ReadS [OrderByElement]
-> ReadPrec OrderByElement
-> ReadPrec [OrderByElement]
-> Read OrderByElement
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OrderByElement]
$creadListPrec :: ReadPrec [OrderByElement]
readPrec :: ReadPrec OrderByElement
$creadPrec :: ReadPrec OrderByElement
readList :: ReadS [OrderByElement]
$creadList :: ReadS [OrderByElement]
readsPrec :: Int -> ReadS OrderByElement
$creadsPrec :: Int -> ReadS OrderByElement
Prelude.Read, Int -> OrderByElement -> ShowS
[OrderByElement] -> ShowS
OrderByElement -> String
(Int -> OrderByElement -> ShowS)
-> (OrderByElement -> String)
-> ([OrderByElement] -> ShowS)
-> Show OrderByElement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OrderByElement] -> ShowS
$cshowList :: [OrderByElement] -> ShowS
show :: OrderByElement -> String
$cshow :: OrderByElement -> String
showsPrec :: Int -> OrderByElement -> ShowS
$cshowsPrec :: Int -> OrderByElement -> ShowS
Prelude.Show, (forall x. OrderByElement -> Rep OrderByElement x)
-> (forall x. Rep OrderByElement x -> OrderByElement)
-> Generic OrderByElement
forall x. Rep OrderByElement x -> OrderByElement
forall x. OrderByElement -> Rep OrderByElement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OrderByElement x -> OrderByElement
$cfrom :: forall x. OrderByElement -> Rep OrderByElement x
Prelude.Generic)
newOrderByElement ::
Prelude.Text ->
OrderByElement
newOrderByElement :: Text -> OrderByElement
newOrderByElement Text
pFieldName_ =
OrderByElement' :: Maybe OrderString -> Text -> OrderByElement
OrderByElement'
{ $sel:sortOrder:OrderByElement' :: Maybe OrderString
sortOrder = Maybe OrderString
forall a. Maybe a
Prelude.Nothing,
$sel:fieldName:OrderByElement' :: Text
fieldName = Text
pFieldName_
}
orderByElement_sortOrder :: Lens.Lens' OrderByElement (Prelude.Maybe OrderString)
orderByElement_sortOrder :: (Maybe OrderString -> f (Maybe OrderString))
-> OrderByElement -> f OrderByElement
orderByElement_sortOrder = (OrderByElement -> Maybe OrderString)
-> (OrderByElement -> Maybe OrderString -> OrderByElement)
-> Lens
OrderByElement
OrderByElement
(Maybe OrderString)
(Maybe OrderString)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrderByElement' {Maybe OrderString
sortOrder :: Maybe OrderString
$sel:sortOrder:OrderByElement' :: OrderByElement -> Maybe OrderString
sortOrder} -> Maybe OrderString
sortOrder) (\s :: OrderByElement
s@OrderByElement' {} Maybe OrderString
a -> OrderByElement
s {$sel:sortOrder:OrderByElement' :: Maybe OrderString
sortOrder = Maybe OrderString
a} :: OrderByElement)
orderByElement_fieldName :: Lens.Lens' OrderByElement Prelude.Text
orderByElement_fieldName :: (Text -> f Text) -> OrderByElement -> f OrderByElement
orderByElement_fieldName = (OrderByElement -> Text)
-> (OrderByElement -> Text -> OrderByElement)
-> Lens OrderByElement OrderByElement Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OrderByElement' {Text
fieldName :: Text
$sel:fieldName:OrderByElement' :: OrderByElement -> Text
fieldName} -> Text
fieldName) (\s :: OrderByElement
s@OrderByElement' {} Text
a -> OrderByElement
s {$sel:fieldName:OrderByElement' :: Text
fieldName = Text
a} :: OrderByElement)
instance Prelude.Hashable OrderByElement
instance Prelude.NFData OrderByElement
instance Core.ToJSON OrderByElement where
toJSON :: OrderByElement -> Value
toJSON OrderByElement' {Maybe OrderString
Text
fieldName :: Text
sortOrder :: Maybe OrderString
$sel:fieldName:OrderByElement' :: OrderByElement -> Text
$sel:sortOrder:OrderByElement' :: OrderByElement -> Maybe OrderString
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"sortOrder" Text -> OrderString -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OrderString -> Pair) -> Maybe OrderString -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OrderString
sortOrder,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"fieldName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fieldName)
]
)