{-# 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.CostExplorer.Types.SortDefinition where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.CostExplorer.Types.SortOrder
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
data SortDefinition = SortDefinition'
{
SortDefinition -> Maybe SortOrder
sortOrder :: Prelude.Maybe SortOrder,
SortDefinition -> Text
key :: Prelude.Text
}
deriving (SortDefinition -> SortDefinition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SortDefinition -> SortDefinition -> Bool
$c/= :: SortDefinition -> SortDefinition -> Bool
== :: SortDefinition -> SortDefinition -> Bool
$c== :: SortDefinition -> SortDefinition -> Bool
Prelude.Eq, ReadPrec [SortDefinition]
ReadPrec SortDefinition
Int -> ReadS SortDefinition
ReadS [SortDefinition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SortDefinition]
$creadListPrec :: ReadPrec [SortDefinition]
readPrec :: ReadPrec SortDefinition
$creadPrec :: ReadPrec SortDefinition
readList :: ReadS [SortDefinition]
$creadList :: ReadS [SortDefinition]
readsPrec :: Int -> ReadS SortDefinition
$creadsPrec :: Int -> ReadS SortDefinition
Prelude.Read, Int -> SortDefinition -> ShowS
[SortDefinition] -> ShowS
SortDefinition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SortDefinition] -> ShowS
$cshowList :: [SortDefinition] -> ShowS
show :: SortDefinition -> String
$cshow :: SortDefinition -> String
showsPrec :: Int -> SortDefinition -> ShowS
$cshowsPrec :: Int -> SortDefinition -> ShowS
Prelude.Show, forall x. Rep SortDefinition x -> SortDefinition
forall x. SortDefinition -> Rep SortDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SortDefinition x -> SortDefinition
$cfrom :: forall x. SortDefinition -> Rep SortDefinition x
Prelude.Generic)
newSortDefinition ::
Prelude.Text ->
SortDefinition
newSortDefinition :: Text -> SortDefinition
newSortDefinition Text
pKey_ =
SortDefinition'
{ $sel:sortOrder:SortDefinition' :: Maybe SortOrder
sortOrder = forall a. Maybe a
Prelude.Nothing,
$sel:key:SortDefinition' :: Text
key = Text
pKey_
}
sortDefinition_sortOrder :: Lens.Lens' SortDefinition (Prelude.Maybe SortOrder)
sortDefinition_sortOrder :: Lens' SortDefinition (Maybe SortOrder)
sortDefinition_sortOrder = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SortDefinition' {Maybe SortOrder
sortOrder :: Maybe SortOrder
$sel:sortOrder:SortDefinition' :: SortDefinition -> Maybe SortOrder
sortOrder} -> Maybe SortOrder
sortOrder) (\s :: SortDefinition
s@SortDefinition' {} Maybe SortOrder
a -> SortDefinition
s {$sel:sortOrder:SortDefinition' :: Maybe SortOrder
sortOrder = Maybe SortOrder
a} :: SortDefinition)
sortDefinition_key :: Lens.Lens' SortDefinition Prelude.Text
sortDefinition_key :: Lens' SortDefinition Text
sortDefinition_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SortDefinition' {Text
key :: Text
$sel:key:SortDefinition' :: SortDefinition -> Text
key} -> Text
key) (\s :: SortDefinition
s@SortDefinition' {} Text
a -> SortDefinition
s {$sel:key:SortDefinition' :: Text
key = Text
a} :: SortDefinition)
instance Prelude.Hashable SortDefinition where
hashWithSalt :: Int -> SortDefinition -> Int
hashWithSalt Int
_salt SortDefinition' {Maybe SortOrder
Text
key :: Text
sortOrder :: Maybe SortOrder
$sel:key:SortDefinition' :: SortDefinition -> Text
$sel:sortOrder:SortDefinition' :: SortDefinition -> Maybe SortOrder
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SortOrder
sortOrder
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
key
instance Prelude.NFData SortDefinition where
rnf :: SortDefinition -> ()
rnf SortDefinition' {Maybe SortOrder
Text
key :: Text
sortOrder :: Maybe SortOrder
$sel:key:SortDefinition' :: SortDefinition -> Text
$sel:sortOrder:SortDefinition' :: SortDefinition -> Maybe SortOrder
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe SortOrder
sortOrder seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
key
instance Data.ToJSON SortDefinition where
toJSON :: SortDefinition -> Value
toJSON SortDefinition' {Maybe SortOrder
Text
key :: Text
sortOrder :: Maybe SortOrder
$sel:key:SortDefinition' :: SortDefinition -> Text
$sel:sortOrder:SortDefinition' :: SortDefinition -> Maybe SortOrder
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"SortOrder" 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 SortOrder
sortOrder,
forall a. a -> Maybe a
Prelude.Just (Key
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
key)
]
)