{-# 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.Glue.Types.Order where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Order = Order'
{
Order -> Text
column :: Prelude.Text,
Order -> Natural
sortOrder :: Prelude.Natural
}
deriving (Order -> Order -> Bool
(Order -> Order -> Bool) -> (Order -> Order -> Bool) -> Eq Order
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Order -> Order -> Bool
$c/= :: Order -> Order -> Bool
== :: Order -> Order -> Bool
$c== :: Order -> Order -> Bool
Prelude.Eq, ReadPrec [Order]
ReadPrec Order
Int -> ReadS Order
ReadS [Order]
(Int -> ReadS Order)
-> ReadS [Order]
-> ReadPrec Order
-> ReadPrec [Order]
-> Read Order
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Order]
$creadListPrec :: ReadPrec [Order]
readPrec :: ReadPrec Order
$creadPrec :: ReadPrec Order
readList :: ReadS [Order]
$creadList :: ReadS [Order]
readsPrec :: Int -> ReadS Order
$creadsPrec :: Int -> ReadS Order
Prelude.Read, Int -> Order -> ShowS
[Order] -> ShowS
Order -> String
(Int -> Order -> ShowS)
-> (Order -> String) -> ([Order] -> ShowS) -> Show Order
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Order] -> ShowS
$cshowList :: [Order] -> ShowS
show :: Order -> String
$cshow :: Order -> String
showsPrec :: Int -> Order -> ShowS
$cshowsPrec :: Int -> Order -> ShowS
Prelude.Show, (forall x. Order -> Rep Order x)
-> (forall x. Rep Order x -> Order) -> Generic Order
forall x. Rep Order x -> Order
forall x. Order -> Rep Order x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Order x -> Order
$cfrom :: forall x. Order -> Rep Order x
Prelude.Generic)
newOrder ::
Prelude.Text ->
Prelude.Natural ->
Order
newOrder :: Text -> Natural -> Order
newOrder Text
pColumn_ Natural
pSortOrder_ =
Order' :: Text -> Natural -> Order
Order' {$sel:column:Order' :: Text
column = Text
pColumn_, $sel:sortOrder:Order' :: Natural
sortOrder = Natural
pSortOrder_}
order_column :: Lens.Lens' Order Prelude.Text
order_column :: (Text -> f Text) -> Order -> f Order
order_column = (Order -> Text)
-> (Order -> Text -> Order) -> Lens Order Order Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Order' {Text
column :: Text
$sel:column:Order' :: Order -> Text
column} -> Text
column) (\s :: Order
s@Order' {} Text
a -> Order
s {$sel:column:Order' :: Text
column = Text
a} :: Order)
order_sortOrder :: Lens.Lens' Order Prelude.Natural
order_sortOrder :: (Natural -> f Natural) -> Order -> f Order
order_sortOrder = (Order -> Natural)
-> (Order -> Natural -> Order) -> Lens Order Order Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Order' {Natural
sortOrder :: Natural
$sel:sortOrder:Order' :: Order -> Natural
sortOrder} -> Natural
sortOrder) (\s :: Order
s@Order' {} Natural
a -> Order
s {$sel:sortOrder:Order' :: Natural
sortOrder = Natural
a} :: Order)
instance Core.FromJSON Order where
parseJSON :: Value -> Parser Order
parseJSON =
String -> (Object -> Parser Order) -> Value -> Parser Order
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Order"
( \Object
x ->
Text -> Natural -> Order
Order'
(Text -> Natural -> Order)
-> Parser Text -> Parser (Natural -> Order)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Column")
Parser (Natural -> Order) -> Parser Natural -> Parser Order
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SortOrder")
)
instance Prelude.Hashable Order
instance Prelude.NFData Order
instance Core.ToJSON Order where
toJSON :: Order -> Value
toJSON Order' {Natural
Text
sortOrder :: Natural
column :: Text
$sel:sortOrder:Order' :: Order -> Natural
$sel:column:Order' :: Order -> Text
..} =
[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
"Column" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
column),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SortOrder" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
sortOrder)
]
)