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

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

-- |
-- Create a value of 'AggregatedUtterancesSortBy' 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', 'aggregatedUtterancesSortBy_attribute' - The utterance attribute to sort by.
--
-- 'order', 'aggregatedUtterancesSortBy_order' - Specifies whether to sort the aggregated utterances in ascending or
-- descending order.
newAggregatedUtterancesSortBy ::
  -- | 'attribute'
  AggregatedUtterancesSortAttribute ->
  -- | 'order'
  SortOrder ->
  AggregatedUtterancesSortBy
newAggregatedUtterancesSortBy :: AggregatedUtterancesSortAttribute
-> SortOrder -> AggregatedUtterancesSortBy
newAggregatedUtterancesSortBy AggregatedUtterancesSortAttribute
pAttribute_ SortOrder
pOrder_ =
  AggregatedUtterancesSortBy'
    { $sel:attribute:AggregatedUtterancesSortBy' :: AggregatedUtterancesSortAttribute
attribute =
        AggregatedUtterancesSortAttribute
pAttribute_,
      $sel:order:AggregatedUtterancesSortBy' :: SortOrder
order = SortOrder
pOrder_
    }

-- | The utterance attribute to sort by.
aggregatedUtterancesSortBy_attribute :: Lens.Lens' AggregatedUtterancesSortBy AggregatedUtterancesSortAttribute
aggregatedUtterancesSortBy_attribute :: Lens' AggregatedUtterancesSortBy AggregatedUtterancesSortAttribute
aggregatedUtterancesSortBy_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregatedUtterancesSortBy' {AggregatedUtterancesSortAttribute
attribute :: AggregatedUtterancesSortAttribute
$sel:attribute:AggregatedUtterancesSortBy' :: AggregatedUtterancesSortBy -> AggregatedUtterancesSortAttribute
attribute} -> AggregatedUtterancesSortAttribute
attribute) (\s :: AggregatedUtterancesSortBy
s@AggregatedUtterancesSortBy' {} AggregatedUtterancesSortAttribute
a -> AggregatedUtterancesSortBy
s {$sel:attribute:AggregatedUtterancesSortBy' :: AggregatedUtterancesSortAttribute
attribute = AggregatedUtterancesSortAttribute
a} :: AggregatedUtterancesSortBy)

-- | Specifies whether to sort the aggregated utterances in ascending or
-- descending order.
aggregatedUtterancesSortBy_order :: Lens.Lens' AggregatedUtterancesSortBy SortOrder
aggregatedUtterancesSortBy_order :: Lens' AggregatedUtterancesSortBy SortOrder
aggregatedUtterancesSortBy_order = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AggregatedUtterancesSortBy' {SortOrder
order :: SortOrder
$sel:order:AggregatedUtterancesSortBy' :: AggregatedUtterancesSortBy -> SortOrder
order} -> SortOrder
order) (\s :: AggregatedUtterancesSortBy
s@AggregatedUtterancesSortBy' {} SortOrder
a -> AggregatedUtterancesSortBy
s {$sel:order:AggregatedUtterancesSortBy' :: SortOrder
order = SortOrder
a} :: AggregatedUtterancesSortBy)

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

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

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