{-# 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.GuardDuty.Types.SortCriteria
-- 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.GuardDuty.Types.SortCriteria where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GuardDuty.Types.OrderBy
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the criteria used for sorting findings.
--
-- /See:/ 'newSortCriteria' smart constructor.
data SortCriteria = SortCriteria'
  { -- | Represents the finding attribute (for example, accountId) to sort
    -- findings by.
    SortCriteria -> Maybe Text
attributeName :: Prelude.Maybe Prelude.Text,
    -- | The order by which the sorted findings are to be displayed.
    SortCriteria -> Maybe OrderBy
orderBy :: Prelude.Maybe OrderBy
  }
  deriving (SortCriteria -> SortCriteria -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SortCriteria -> SortCriteria -> Bool
$c/= :: SortCriteria -> SortCriteria -> Bool
== :: SortCriteria -> SortCriteria -> Bool
$c== :: SortCriteria -> SortCriteria -> Bool
Prelude.Eq, ReadPrec [SortCriteria]
ReadPrec SortCriteria
Int -> ReadS SortCriteria
ReadS [SortCriteria]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SortCriteria]
$creadListPrec :: ReadPrec [SortCriteria]
readPrec :: ReadPrec SortCriteria
$creadPrec :: ReadPrec SortCriteria
readList :: ReadS [SortCriteria]
$creadList :: ReadS [SortCriteria]
readsPrec :: Int -> ReadS SortCriteria
$creadsPrec :: Int -> ReadS SortCriteria
Prelude.Read, Int -> SortCriteria -> ShowS
[SortCriteria] -> ShowS
SortCriteria -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SortCriteria] -> ShowS
$cshowList :: [SortCriteria] -> ShowS
show :: SortCriteria -> String
$cshow :: SortCriteria -> String
showsPrec :: Int -> SortCriteria -> ShowS
$cshowsPrec :: Int -> SortCriteria -> ShowS
Prelude.Show, forall x. Rep SortCriteria x -> SortCriteria
forall x. SortCriteria -> Rep SortCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SortCriteria x -> SortCriteria
$cfrom :: forall x. SortCriteria -> Rep SortCriteria x
Prelude.Generic)

-- |
-- Create a value of 'SortCriteria' 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:
--
-- 'attributeName', 'sortCriteria_attributeName' - Represents the finding attribute (for example, accountId) to sort
-- findings by.
--
-- 'orderBy', 'sortCriteria_orderBy' - The order by which the sorted findings are to be displayed.
newSortCriteria ::
  SortCriteria
newSortCriteria :: SortCriteria
newSortCriteria =
  SortCriteria'
    { $sel:attributeName:SortCriteria' :: Maybe Text
attributeName = forall a. Maybe a
Prelude.Nothing,
      $sel:orderBy:SortCriteria' :: Maybe OrderBy
orderBy = forall a. Maybe a
Prelude.Nothing
    }

-- | Represents the finding attribute (for example, accountId) to sort
-- findings by.
sortCriteria_attributeName :: Lens.Lens' SortCriteria (Prelude.Maybe Prelude.Text)
sortCriteria_attributeName :: Lens' SortCriteria (Maybe Text)
sortCriteria_attributeName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SortCriteria' {Maybe Text
attributeName :: Maybe Text
$sel:attributeName:SortCriteria' :: SortCriteria -> Maybe Text
attributeName} -> Maybe Text
attributeName) (\s :: SortCriteria
s@SortCriteria' {} Maybe Text
a -> SortCriteria
s {$sel:attributeName:SortCriteria' :: Maybe Text
attributeName = Maybe Text
a} :: SortCriteria)

-- | The order by which the sorted findings are to be displayed.
sortCriteria_orderBy :: Lens.Lens' SortCriteria (Prelude.Maybe OrderBy)
sortCriteria_orderBy :: Lens' SortCriteria (Maybe OrderBy)
sortCriteria_orderBy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SortCriteria' {Maybe OrderBy
orderBy :: Maybe OrderBy
$sel:orderBy:SortCriteria' :: SortCriteria -> Maybe OrderBy
orderBy} -> Maybe OrderBy
orderBy) (\s :: SortCriteria
s@SortCriteria' {} Maybe OrderBy
a -> SortCriteria
s {$sel:orderBy:SortCriteria' :: Maybe OrderBy
orderBy = Maybe OrderBy
a} :: SortCriteria)

instance Prelude.Hashable SortCriteria where
  hashWithSalt :: Int -> SortCriteria -> Int
hashWithSalt Int
_salt SortCriteria' {Maybe Text
Maybe OrderBy
orderBy :: Maybe OrderBy
attributeName :: Maybe Text
$sel:orderBy:SortCriteria' :: SortCriteria -> Maybe OrderBy
$sel:attributeName:SortCriteria' :: SortCriteria -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
attributeName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OrderBy
orderBy

instance Prelude.NFData SortCriteria where
  rnf :: SortCriteria -> ()
rnf SortCriteria' {Maybe Text
Maybe OrderBy
orderBy :: Maybe OrderBy
attributeName :: Maybe Text
$sel:orderBy:SortCriteria' :: SortCriteria -> Maybe OrderBy
$sel:attributeName:SortCriteria' :: SortCriteria -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
attributeName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe OrderBy
orderBy

instance Data.ToJSON SortCriteria where
  toJSON :: SortCriteria -> Value
toJSON SortCriteria' {Maybe Text
Maybe OrderBy
orderBy :: Maybe OrderBy
attributeName :: Maybe Text
$sel:orderBy:SortCriteria' :: SortCriteria -> Maybe OrderBy
$sel:attributeName:SortCriteria' :: SortCriteria -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"attributeName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
attributeName,
            (Key
"orderBy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OrderBy
orderBy
          ]
      )