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

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

-- |
-- Create a value of 'BotVersionSortBy' 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', 'botVersionSortBy_attribute' - The attribute to use to sort the list of versions.
--
-- 'order', 'botVersionSortBy_order' - The order to sort the list. You can specify ascending or descending
-- order.
newBotVersionSortBy ::
  -- | 'attribute'
  BotVersionSortAttribute ->
  -- | 'order'
  SortOrder ->
  BotVersionSortBy
newBotVersionSortBy :: BotVersionSortAttribute -> SortOrder -> BotVersionSortBy
newBotVersionSortBy BotVersionSortAttribute
pAttribute_ SortOrder
pOrder_ =
  BotVersionSortBy'
    { $sel:attribute:BotVersionSortBy' :: BotVersionSortAttribute
attribute = BotVersionSortAttribute
pAttribute_,
      $sel:order:BotVersionSortBy' :: SortOrder
order = SortOrder
pOrder_
    }

-- | The attribute to use to sort the list of versions.
botVersionSortBy_attribute :: Lens.Lens' BotVersionSortBy BotVersionSortAttribute
botVersionSortBy_attribute :: Lens' BotVersionSortBy BotVersionSortAttribute
botVersionSortBy_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BotVersionSortBy' {BotVersionSortAttribute
attribute :: BotVersionSortAttribute
$sel:attribute:BotVersionSortBy' :: BotVersionSortBy -> BotVersionSortAttribute
attribute} -> BotVersionSortAttribute
attribute) (\s :: BotVersionSortBy
s@BotVersionSortBy' {} BotVersionSortAttribute
a -> BotVersionSortBy
s {$sel:attribute:BotVersionSortBy' :: BotVersionSortAttribute
attribute = BotVersionSortAttribute
a} :: BotVersionSortBy)

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

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

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

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