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

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

-- |
-- Create a value of 'BuiltInIntentSortBy' 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', 'builtInIntentSortBy_attribute' - The attribute to use to sort the list of built-in intents.
--
-- 'order', 'builtInIntentSortBy_order' - The order to sort the list. You can specify ascending or descending
-- order.
newBuiltInIntentSortBy ::
  -- | 'attribute'
  BuiltInIntentSortAttribute ->
  -- | 'order'
  SortOrder ->
  BuiltInIntentSortBy
newBuiltInIntentSortBy :: BuiltInIntentSortAttribute -> SortOrder -> BuiltInIntentSortBy
newBuiltInIntentSortBy BuiltInIntentSortAttribute
pAttribute_ SortOrder
pOrder_ =
  BuiltInIntentSortBy'
    { $sel:attribute:BuiltInIntentSortBy' :: BuiltInIntentSortAttribute
attribute = BuiltInIntentSortAttribute
pAttribute_,
      $sel:order:BuiltInIntentSortBy' :: SortOrder
order = SortOrder
pOrder_
    }

-- | The attribute to use to sort the list of built-in intents.
builtInIntentSortBy_attribute :: Lens.Lens' BuiltInIntentSortBy BuiltInIntentSortAttribute
builtInIntentSortBy_attribute :: Lens' BuiltInIntentSortBy BuiltInIntentSortAttribute
builtInIntentSortBy_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuiltInIntentSortBy' {BuiltInIntentSortAttribute
attribute :: BuiltInIntentSortAttribute
$sel:attribute:BuiltInIntentSortBy' :: BuiltInIntentSortBy -> BuiltInIntentSortAttribute
attribute} -> BuiltInIntentSortAttribute
attribute) (\s :: BuiltInIntentSortBy
s@BuiltInIntentSortBy' {} BuiltInIntentSortAttribute
a -> BuiltInIntentSortBy
s {$sel:attribute:BuiltInIntentSortBy' :: BuiltInIntentSortAttribute
attribute = BuiltInIntentSortAttribute
a} :: BuiltInIntentSortBy)

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

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

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

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