{-# 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.MacieV2.Types.FindingStatisticsSortCriteria
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MacieV2.Types.FindingStatisticsSortCriteria where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.FindingStatisticsSortAttributeName
import Amazonka.MacieV2.Types.OrderBy
import qualified Amazonka.Prelude as Prelude

-- | Specifies criteria for sorting the results of a query that retrieves
-- aggregated statistical data about findings.
--
-- /See:/ 'newFindingStatisticsSortCriteria' smart constructor.
data FindingStatisticsSortCriteria = FindingStatisticsSortCriteria'
  { -- | The sort order to apply to the results, based on the value for the
    -- property specified by the attributeName property. Valid values are: ASC,
    -- sort the results in ascending order; and, DESC, sort the results in
    -- descending order.
    FindingStatisticsSortCriteria -> Maybe OrderBy
orderBy :: Prelude.Maybe OrderBy,
    -- | The grouping to sort the results by. Valid values are: count, sort the
    -- results by the number of findings in each group of results; and,
    -- groupKey, sort the results by the name of each group of results.
    FindingStatisticsSortCriteria
-> Maybe FindingStatisticsSortAttributeName
attributeName :: Prelude.Maybe FindingStatisticsSortAttributeName
  }
  deriving (FindingStatisticsSortCriteria
-> FindingStatisticsSortCriteria -> Bool
(FindingStatisticsSortCriteria
 -> FindingStatisticsSortCriteria -> Bool)
-> (FindingStatisticsSortCriteria
    -> FindingStatisticsSortCriteria -> Bool)
-> Eq FindingStatisticsSortCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FindingStatisticsSortCriteria
-> FindingStatisticsSortCriteria -> Bool
$c/= :: FindingStatisticsSortCriteria
-> FindingStatisticsSortCriteria -> Bool
== :: FindingStatisticsSortCriteria
-> FindingStatisticsSortCriteria -> Bool
$c== :: FindingStatisticsSortCriteria
-> FindingStatisticsSortCriteria -> Bool
Prelude.Eq, ReadPrec [FindingStatisticsSortCriteria]
ReadPrec FindingStatisticsSortCriteria
Int -> ReadS FindingStatisticsSortCriteria
ReadS [FindingStatisticsSortCriteria]
(Int -> ReadS FindingStatisticsSortCriteria)
-> ReadS [FindingStatisticsSortCriteria]
-> ReadPrec FindingStatisticsSortCriteria
-> ReadPrec [FindingStatisticsSortCriteria]
-> Read FindingStatisticsSortCriteria
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FindingStatisticsSortCriteria]
$creadListPrec :: ReadPrec [FindingStatisticsSortCriteria]
readPrec :: ReadPrec FindingStatisticsSortCriteria
$creadPrec :: ReadPrec FindingStatisticsSortCriteria
readList :: ReadS [FindingStatisticsSortCriteria]
$creadList :: ReadS [FindingStatisticsSortCriteria]
readsPrec :: Int -> ReadS FindingStatisticsSortCriteria
$creadsPrec :: Int -> ReadS FindingStatisticsSortCriteria
Prelude.Read, Int -> FindingStatisticsSortCriteria -> ShowS
[FindingStatisticsSortCriteria] -> ShowS
FindingStatisticsSortCriteria -> String
(Int -> FindingStatisticsSortCriteria -> ShowS)
-> (FindingStatisticsSortCriteria -> String)
-> ([FindingStatisticsSortCriteria] -> ShowS)
-> Show FindingStatisticsSortCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FindingStatisticsSortCriteria] -> ShowS
$cshowList :: [FindingStatisticsSortCriteria] -> ShowS
show :: FindingStatisticsSortCriteria -> String
$cshow :: FindingStatisticsSortCriteria -> String
showsPrec :: Int -> FindingStatisticsSortCriteria -> ShowS
$cshowsPrec :: Int -> FindingStatisticsSortCriteria -> ShowS
Prelude.Show, (forall x.
 FindingStatisticsSortCriteria
 -> Rep FindingStatisticsSortCriteria x)
-> (forall x.
    Rep FindingStatisticsSortCriteria x
    -> FindingStatisticsSortCriteria)
-> Generic FindingStatisticsSortCriteria
forall x.
Rep FindingStatisticsSortCriteria x
-> FindingStatisticsSortCriteria
forall x.
FindingStatisticsSortCriteria
-> Rep FindingStatisticsSortCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FindingStatisticsSortCriteria x
-> FindingStatisticsSortCriteria
$cfrom :: forall x.
FindingStatisticsSortCriteria
-> Rep FindingStatisticsSortCriteria x
Prelude.Generic)

-- |
-- Create a value of 'FindingStatisticsSortCriteria' 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:
--
-- 'orderBy', 'findingStatisticsSortCriteria_orderBy' - The sort order to apply to the results, based on the value for the
-- property specified by the attributeName property. Valid values are: ASC,
-- sort the results in ascending order; and, DESC, sort the results in
-- descending order.
--
-- 'attributeName', 'findingStatisticsSortCriteria_attributeName' - The grouping to sort the results by. Valid values are: count, sort the
-- results by the number of findings in each group of results; and,
-- groupKey, sort the results by the name of each group of results.
newFindingStatisticsSortCriteria ::
  FindingStatisticsSortCriteria
newFindingStatisticsSortCriteria :: FindingStatisticsSortCriteria
newFindingStatisticsSortCriteria =
  FindingStatisticsSortCriteria' :: Maybe OrderBy
-> Maybe FindingStatisticsSortAttributeName
-> FindingStatisticsSortCriteria
FindingStatisticsSortCriteria'
    { $sel:orderBy:FindingStatisticsSortCriteria' :: Maybe OrderBy
orderBy =
        Maybe OrderBy
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeName:FindingStatisticsSortCriteria' :: Maybe FindingStatisticsSortAttributeName
attributeName = Maybe FindingStatisticsSortAttributeName
forall a. Maybe a
Prelude.Nothing
    }

-- | The sort order to apply to the results, based on the value for the
-- property specified by the attributeName property. Valid values are: ASC,
-- sort the results in ascending order; and, DESC, sort the results in
-- descending order.
findingStatisticsSortCriteria_orderBy :: Lens.Lens' FindingStatisticsSortCriteria (Prelude.Maybe OrderBy)
findingStatisticsSortCriteria_orderBy :: (Maybe OrderBy -> f (Maybe OrderBy))
-> FindingStatisticsSortCriteria -> f FindingStatisticsSortCriteria
findingStatisticsSortCriteria_orderBy = (FindingStatisticsSortCriteria -> Maybe OrderBy)
-> (FindingStatisticsSortCriteria
    -> Maybe OrderBy -> FindingStatisticsSortCriteria)
-> Lens
     FindingStatisticsSortCriteria
     FindingStatisticsSortCriteria
     (Maybe OrderBy)
     (Maybe OrderBy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindingStatisticsSortCriteria' {Maybe OrderBy
orderBy :: Maybe OrderBy
$sel:orderBy:FindingStatisticsSortCriteria' :: FindingStatisticsSortCriteria -> Maybe OrderBy
orderBy} -> Maybe OrderBy
orderBy) (\s :: FindingStatisticsSortCriteria
s@FindingStatisticsSortCriteria' {} Maybe OrderBy
a -> FindingStatisticsSortCriteria
s {$sel:orderBy:FindingStatisticsSortCriteria' :: Maybe OrderBy
orderBy = Maybe OrderBy
a} :: FindingStatisticsSortCriteria)

-- | The grouping to sort the results by. Valid values are: count, sort the
-- results by the number of findings in each group of results; and,
-- groupKey, sort the results by the name of each group of results.
findingStatisticsSortCriteria_attributeName :: Lens.Lens' FindingStatisticsSortCriteria (Prelude.Maybe FindingStatisticsSortAttributeName)
findingStatisticsSortCriteria_attributeName :: (Maybe FindingStatisticsSortAttributeName
 -> f (Maybe FindingStatisticsSortAttributeName))
-> FindingStatisticsSortCriteria -> f FindingStatisticsSortCriteria
findingStatisticsSortCriteria_attributeName = (FindingStatisticsSortCriteria
 -> Maybe FindingStatisticsSortAttributeName)
-> (FindingStatisticsSortCriteria
    -> Maybe FindingStatisticsSortAttributeName
    -> FindingStatisticsSortCriteria)
-> Lens
     FindingStatisticsSortCriteria
     FindingStatisticsSortCriteria
     (Maybe FindingStatisticsSortAttributeName)
     (Maybe FindingStatisticsSortAttributeName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindingStatisticsSortCriteria' {Maybe FindingStatisticsSortAttributeName
attributeName :: Maybe FindingStatisticsSortAttributeName
$sel:attributeName:FindingStatisticsSortCriteria' :: FindingStatisticsSortCriteria
-> Maybe FindingStatisticsSortAttributeName
attributeName} -> Maybe FindingStatisticsSortAttributeName
attributeName) (\s :: FindingStatisticsSortCriteria
s@FindingStatisticsSortCriteria' {} Maybe FindingStatisticsSortAttributeName
a -> FindingStatisticsSortCriteria
s {$sel:attributeName:FindingStatisticsSortCriteria' :: Maybe FindingStatisticsSortAttributeName
attributeName = Maybe FindingStatisticsSortAttributeName
a} :: FindingStatisticsSortCriteria)

instance
  Prelude.Hashable
    FindingStatisticsSortCriteria

instance Prelude.NFData FindingStatisticsSortCriteria

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