{-# 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.SlotSortBy
-- 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.SlotSortBy 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.SlotSortAttribute
import Amazonka.LexV2Models.Types.SortOrder
import qualified Amazonka.Prelude as Prelude

-- | Specifies attributes for sorting a list of bots.
--
-- /See:/ 'newSlotSortBy' smart constructor.
data SlotSortBy = SlotSortBy'
  { -- | The attribute to use to sort the list.
    SlotSortBy -> SlotSortAttribute
attribute :: SlotSortAttribute,
    -- | The order to sort the list. You can choose ascending or descending.
    SlotSortBy -> SortOrder
order :: SortOrder
  }
  deriving (SlotSortBy -> SlotSortBy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotSortBy -> SlotSortBy -> Bool
$c/= :: SlotSortBy -> SlotSortBy -> Bool
== :: SlotSortBy -> SlotSortBy -> Bool
$c== :: SlotSortBy -> SlotSortBy -> Bool
Prelude.Eq, ReadPrec [SlotSortBy]
ReadPrec SlotSortBy
Int -> ReadS SlotSortBy
ReadS [SlotSortBy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SlotSortBy]
$creadListPrec :: ReadPrec [SlotSortBy]
readPrec :: ReadPrec SlotSortBy
$creadPrec :: ReadPrec SlotSortBy
readList :: ReadS [SlotSortBy]
$creadList :: ReadS [SlotSortBy]
readsPrec :: Int -> ReadS SlotSortBy
$creadsPrec :: Int -> ReadS SlotSortBy
Prelude.Read, Int -> SlotSortBy -> ShowS
[SlotSortBy] -> ShowS
SlotSortBy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotSortBy] -> ShowS
$cshowList :: [SlotSortBy] -> ShowS
show :: SlotSortBy -> String
$cshow :: SlotSortBy -> String
showsPrec :: Int -> SlotSortBy -> ShowS
$cshowsPrec :: Int -> SlotSortBy -> ShowS
Prelude.Show, forall x. Rep SlotSortBy x -> SlotSortBy
forall x. SlotSortBy -> Rep SlotSortBy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotSortBy x -> SlotSortBy
$cfrom :: forall x. SlotSortBy -> Rep SlotSortBy x
Prelude.Generic)

-- |
-- Create a value of 'SlotSortBy' 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', 'slotSortBy_attribute' - The attribute to use to sort the list.
--
-- 'order', 'slotSortBy_order' - The order to sort the list. You can choose ascending or descending.
newSlotSortBy ::
  -- | 'attribute'
  SlotSortAttribute ->
  -- | 'order'
  SortOrder ->
  SlotSortBy
newSlotSortBy :: SlotSortAttribute -> SortOrder -> SlotSortBy
newSlotSortBy SlotSortAttribute
pAttribute_ SortOrder
pOrder_ =
  SlotSortBy'
    { $sel:attribute:SlotSortBy' :: SlotSortAttribute
attribute = SlotSortAttribute
pAttribute_,
      $sel:order:SlotSortBy' :: SortOrder
order = SortOrder
pOrder_
    }

-- | The attribute to use to sort the list.
slotSortBy_attribute :: Lens.Lens' SlotSortBy SlotSortAttribute
slotSortBy_attribute :: Lens' SlotSortBy SlotSortAttribute
slotSortBy_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotSortBy' {SlotSortAttribute
attribute :: SlotSortAttribute
$sel:attribute:SlotSortBy' :: SlotSortBy -> SlotSortAttribute
attribute} -> SlotSortAttribute
attribute) (\s :: SlotSortBy
s@SlotSortBy' {} SlotSortAttribute
a -> SlotSortBy
s {$sel:attribute:SlotSortBy' :: SlotSortAttribute
attribute = SlotSortAttribute
a} :: SlotSortBy)

-- | The order to sort the list. You can choose ascending or descending.
slotSortBy_order :: Lens.Lens' SlotSortBy SortOrder
slotSortBy_order :: Lens' SlotSortBy SortOrder
slotSortBy_order = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SlotSortBy' {SortOrder
order :: SortOrder
$sel:order:SlotSortBy' :: SlotSortBy -> SortOrder
order} -> SortOrder
order) (\s :: SlotSortBy
s@SlotSortBy' {} SortOrder
a -> SlotSortBy
s {$sel:order:SlotSortBy' :: SortOrder
order = SortOrder
a} :: SlotSortBy)

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

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

instance Data.ToJSON SlotSortBy where
  toJSON :: SlotSortBy -> Value
toJSON SlotSortBy' {SlotSortAttribute
SortOrder
order :: SortOrder
attribute :: SlotSortAttribute
$sel:order:SlotSortBy' :: SlotSortBy -> SortOrder
$sel:attribute:SlotSortBy' :: SlotSortBy -> SlotSortAttribute
..} =
    [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..= SlotSortAttribute
attribute),
            forall a. a -> Maybe a
Prelude.Just (Key
"order" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SortOrder
order)
          ]
      )