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

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

-- |
-- Create a value of 'IntentSortBy' 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', 'intentSortBy_attribute' - The attribute to use to sort the list of intents.
--
-- 'order', 'intentSortBy_order' - The order to sort the list. You can choose ascending or descending.
newIntentSortBy ::
  -- | 'attribute'
  IntentSortAttribute ->
  -- | 'order'
  SortOrder ->
  IntentSortBy
newIntentSortBy :: IntentSortAttribute -> SortOrder -> IntentSortBy
newIntentSortBy IntentSortAttribute
pAttribute_ SortOrder
pOrder_ =
  IntentSortBy'
    { $sel:attribute:IntentSortBy' :: IntentSortAttribute
attribute = IntentSortAttribute
pAttribute_,
      $sel:order:IntentSortBy' :: SortOrder
order = SortOrder
pOrder_
    }

-- | The attribute to use to sort the list of intents.
intentSortBy_attribute :: Lens.Lens' IntentSortBy IntentSortAttribute
intentSortBy_attribute :: Lens' IntentSortBy IntentSortAttribute
intentSortBy_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntentSortBy' {IntentSortAttribute
attribute :: IntentSortAttribute
$sel:attribute:IntentSortBy' :: IntentSortBy -> IntentSortAttribute
attribute} -> IntentSortAttribute
attribute) (\s :: IntentSortBy
s@IntentSortBy' {} IntentSortAttribute
a -> IntentSortBy
s {$sel:attribute:IntentSortBy' :: IntentSortAttribute
attribute = IntentSortAttribute
a} :: IntentSortBy)

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

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

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

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