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

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

-- |
-- Create a value of 'BotSortBy' 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', 'botSortBy_attribute' - The attribute to use to sort the list of bots.
--
-- 'order', 'botSortBy_order' - The order to sort the list. You can choose ascending or descending.
newBotSortBy ::
  -- | 'attribute'
  BotSortAttribute ->
  -- | 'order'
  SortOrder ->
  BotSortBy
newBotSortBy :: BotSortAttribute -> SortOrder -> BotSortBy
newBotSortBy BotSortAttribute
pAttribute_ SortOrder
pOrder_ =
  BotSortBy'
    { $sel:attribute:BotSortBy' :: BotSortAttribute
attribute = BotSortAttribute
pAttribute_,
      $sel:order:BotSortBy' :: SortOrder
order = SortOrder
pOrder_
    }

-- | The attribute to use to sort the list of bots.
botSortBy_attribute :: Lens.Lens' BotSortBy BotSortAttribute
botSortBy_attribute :: Lens' BotSortBy BotSortAttribute
botSortBy_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BotSortBy' {BotSortAttribute
attribute :: BotSortAttribute
$sel:attribute:BotSortBy' :: BotSortBy -> BotSortAttribute
attribute} -> BotSortAttribute
attribute) (\s :: BotSortBy
s@BotSortBy' {} BotSortAttribute
a -> BotSortBy
s {$sel:attribute:BotSortBy' :: BotSortAttribute
attribute = BotSortAttribute
a} :: BotSortBy)

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

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

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

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