{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.LexV2Models.Types.ExportSortBy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LexV2Models.Types.ExportSortBy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexV2Models.Types.ExportSortAttribute
import Amazonka.LexV2Models.Types.SortOrder
import qualified Amazonka.Prelude as Prelude

-- | Provides information about sorting a list of exports.
--
-- /See:/ 'newExportSortBy' smart constructor.
data ExportSortBy = ExportSortBy'
  { -- | The export field to use for sorting.
    ExportSortBy -> ExportSortAttribute
attribute :: ExportSortAttribute,
    -- | The order to sort the list.
    ExportSortBy -> SortOrder
order :: SortOrder
  }
  deriving (ExportSortBy -> ExportSortBy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportSortBy -> ExportSortBy -> Bool
$c/= :: ExportSortBy -> ExportSortBy -> Bool
== :: ExportSortBy -> ExportSortBy -> Bool
$c== :: ExportSortBy -> ExportSortBy -> Bool
Prelude.Eq, ReadPrec [ExportSortBy]
ReadPrec ExportSortBy
Int -> ReadS ExportSortBy
ReadS [ExportSortBy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportSortBy]
$creadListPrec :: ReadPrec [ExportSortBy]
readPrec :: ReadPrec ExportSortBy
$creadPrec :: ReadPrec ExportSortBy
readList :: ReadS [ExportSortBy]
$creadList :: ReadS [ExportSortBy]
readsPrec :: Int -> ReadS ExportSortBy
$creadsPrec :: Int -> ReadS ExportSortBy
Prelude.Read, Int -> ExportSortBy -> ShowS
[ExportSortBy] -> ShowS
ExportSortBy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportSortBy] -> ShowS
$cshowList :: [ExportSortBy] -> ShowS
show :: ExportSortBy -> String
$cshow :: ExportSortBy -> String
showsPrec :: Int -> ExportSortBy -> ShowS
$cshowsPrec :: Int -> ExportSortBy -> ShowS
Prelude.Show, forall x. Rep ExportSortBy x -> ExportSortBy
forall x. ExportSortBy -> Rep ExportSortBy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExportSortBy x -> ExportSortBy
$cfrom :: forall x. ExportSortBy -> Rep ExportSortBy x
Prelude.Generic)

-- |
-- Create a value of 'ExportSortBy' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'attribute', 'exportSortBy_attribute' - The export field to use for sorting.
--
-- 'order', 'exportSortBy_order' - The order to sort the list.
newExportSortBy ::
  -- | 'attribute'
  ExportSortAttribute ->
  -- | 'order'
  SortOrder ->
  ExportSortBy
newExportSortBy :: ExportSortAttribute -> SortOrder -> ExportSortBy
newExportSortBy ExportSortAttribute
pAttribute_ SortOrder
pOrder_ =
  ExportSortBy'
    { $sel:attribute:ExportSortBy' :: ExportSortAttribute
attribute = ExportSortAttribute
pAttribute_,
      $sel:order:ExportSortBy' :: SortOrder
order = SortOrder
pOrder_
    }

-- | The export field to use for sorting.
exportSortBy_attribute :: Lens.Lens' ExportSortBy ExportSortAttribute
exportSortBy_attribute :: Lens' ExportSortBy ExportSortAttribute
exportSortBy_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportSortBy' {ExportSortAttribute
attribute :: ExportSortAttribute
$sel:attribute:ExportSortBy' :: ExportSortBy -> ExportSortAttribute
attribute} -> ExportSortAttribute
attribute) (\s :: ExportSortBy
s@ExportSortBy' {} ExportSortAttribute
a -> ExportSortBy
s {$sel:attribute:ExportSortBy' :: ExportSortAttribute
attribute = ExportSortAttribute
a} :: ExportSortBy)

-- | The order to sort the list.
exportSortBy_order :: Lens.Lens' ExportSortBy SortOrder
exportSortBy_order :: Lens' ExportSortBy SortOrder
exportSortBy_order = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportSortBy' {SortOrder
order :: SortOrder
$sel:order:ExportSortBy' :: ExportSortBy -> SortOrder
order} -> SortOrder
order) (\s :: ExportSortBy
s@ExportSortBy' {} SortOrder
a -> ExportSortBy
s {$sel:order:ExportSortBy' :: SortOrder
order = SortOrder
a} :: ExportSortBy)

instance Prelude.Hashable ExportSortBy where
  hashWithSalt :: Int -> ExportSortBy -> Int
hashWithSalt Int
_salt ExportSortBy' {ExportSortAttribute
SortOrder
order :: SortOrder
attribute :: ExportSortAttribute
$sel:order:ExportSortBy' :: ExportSortBy -> SortOrder
$sel:attribute:ExportSortBy' :: ExportSortBy -> ExportSortAttribute
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ExportSortAttribute
attribute
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SortOrder
order

instance Prelude.NFData ExportSortBy where
  rnf :: ExportSortBy -> ()
rnf ExportSortBy' {ExportSortAttribute
SortOrder
order :: SortOrder
attribute :: ExportSortAttribute
$sel:order:ExportSortBy' :: ExportSortBy -> SortOrder
$sel:attribute:ExportSortBy' :: ExportSortBy -> ExportSortAttribute
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ExportSortAttribute
attribute
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SortOrder
order

instance Data.ToJSON ExportSortBy where
  toJSON :: ExportSortBy -> Value
toJSON ExportSortBy' {ExportSortAttribute
SortOrder
order :: SortOrder
attribute :: ExportSortAttribute
$sel:order:ExportSortBy' :: ExportSortBy -> SortOrder
$sel:attribute:ExportSortBy' :: ExportSortBy -> ExportSortAttribute
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"attribute" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ExportSortAttribute
attribute),
            forall a. a -> Maybe a
Prelude.Just (Key
"order" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SortOrder
order)
          ]
      )