{-# 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.UsageStatisticsSortBy
-- 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.MacieV2.Types.UsageStatisticsSortBy where

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

-- | Specifies criteria for sorting the results of a query for Amazon Macie
-- account quotas and usage data.
--
-- /See:/ 'newUsageStatisticsSortBy' smart constructor.
data UsageStatisticsSortBy = UsageStatisticsSortBy'
  { -- | The field to sort the results by.
    UsageStatisticsSortBy -> Maybe UsageStatisticsSortKey
key :: Prelude.Maybe UsageStatisticsSortKey,
    -- | The sort order to apply to the results, based on the value for the field
    -- specified by the key property. Valid values are: ASC, sort the results
    -- in ascending order; and, DESC, sort the results in descending order.
    UsageStatisticsSortBy -> Maybe OrderBy
orderBy :: Prelude.Maybe OrderBy
  }
  deriving (UsageStatisticsSortBy -> UsageStatisticsSortBy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UsageStatisticsSortBy -> UsageStatisticsSortBy -> Bool
$c/= :: UsageStatisticsSortBy -> UsageStatisticsSortBy -> Bool
== :: UsageStatisticsSortBy -> UsageStatisticsSortBy -> Bool
$c== :: UsageStatisticsSortBy -> UsageStatisticsSortBy -> Bool
Prelude.Eq, ReadPrec [UsageStatisticsSortBy]
ReadPrec UsageStatisticsSortBy
Int -> ReadS UsageStatisticsSortBy
ReadS [UsageStatisticsSortBy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UsageStatisticsSortBy]
$creadListPrec :: ReadPrec [UsageStatisticsSortBy]
readPrec :: ReadPrec UsageStatisticsSortBy
$creadPrec :: ReadPrec UsageStatisticsSortBy
readList :: ReadS [UsageStatisticsSortBy]
$creadList :: ReadS [UsageStatisticsSortBy]
readsPrec :: Int -> ReadS UsageStatisticsSortBy
$creadsPrec :: Int -> ReadS UsageStatisticsSortBy
Prelude.Read, Int -> UsageStatisticsSortBy -> ShowS
[UsageStatisticsSortBy] -> ShowS
UsageStatisticsSortBy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UsageStatisticsSortBy] -> ShowS
$cshowList :: [UsageStatisticsSortBy] -> ShowS
show :: UsageStatisticsSortBy -> String
$cshow :: UsageStatisticsSortBy -> String
showsPrec :: Int -> UsageStatisticsSortBy -> ShowS
$cshowsPrec :: Int -> UsageStatisticsSortBy -> ShowS
Prelude.Show, forall x. Rep UsageStatisticsSortBy x -> UsageStatisticsSortBy
forall x. UsageStatisticsSortBy -> Rep UsageStatisticsSortBy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UsageStatisticsSortBy x -> UsageStatisticsSortBy
$cfrom :: forall x. UsageStatisticsSortBy -> Rep UsageStatisticsSortBy x
Prelude.Generic)

-- |
-- Create a value of 'UsageStatisticsSortBy' 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:
--
-- 'key', 'usageStatisticsSortBy_key' - The field to sort the results by.
--
-- 'orderBy', 'usageStatisticsSortBy_orderBy' - The sort order to apply to the results, based on the value for the field
-- specified by the key property. Valid values are: ASC, sort the results
-- in ascending order; and, DESC, sort the results in descending order.
newUsageStatisticsSortBy ::
  UsageStatisticsSortBy
newUsageStatisticsSortBy :: UsageStatisticsSortBy
newUsageStatisticsSortBy =
  UsageStatisticsSortBy'
    { $sel:key:UsageStatisticsSortBy' :: Maybe UsageStatisticsSortKey
key = forall a. Maybe a
Prelude.Nothing,
      $sel:orderBy:UsageStatisticsSortBy' :: Maybe OrderBy
orderBy = forall a. Maybe a
Prelude.Nothing
    }

-- | The field to sort the results by.
usageStatisticsSortBy_key :: Lens.Lens' UsageStatisticsSortBy (Prelude.Maybe UsageStatisticsSortKey)
usageStatisticsSortBy_key :: Lens' UsageStatisticsSortBy (Maybe UsageStatisticsSortKey)
usageStatisticsSortBy_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UsageStatisticsSortBy' {Maybe UsageStatisticsSortKey
key :: Maybe UsageStatisticsSortKey
$sel:key:UsageStatisticsSortBy' :: UsageStatisticsSortBy -> Maybe UsageStatisticsSortKey
key} -> Maybe UsageStatisticsSortKey
key) (\s :: UsageStatisticsSortBy
s@UsageStatisticsSortBy' {} Maybe UsageStatisticsSortKey
a -> UsageStatisticsSortBy
s {$sel:key:UsageStatisticsSortBy' :: Maybe UsageStatisticsSortKey
key = Maybe UsageStatisticsSortKey
a} :: UsageStatisticsSortBy)

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

instance Prelude.Hashable UsageStatisticsSortBy where
  hashWithSalt :: Int -> UsageStatisticsSortBy -> Int
hashWithSalt Int
_salt UsageStatisticsSortBy' {Maybe OrderBy
Maybe UsageStatisticsSortKey
orderBy :: Maybe OrderBy
key :: Maybe UsageStatisticsSortKey
$sel:orderBy:UsageStatisticsSortBy' :: UsageStatisticsSortBy -> Maybe OrderBy
$sel:key:UsageStatisticsSortBy' :: UsageStatisticsSortBy -> Maybe UsageStatisticsSortKey
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UsageStatisticsSortKey
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OrderBy
orderBy

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

instance Data.ToJSON UsageStatisticsSortBy where
  toJSON :: UsageStatisticsSortBy -> Value
toJSON UsageStatisticsSortBy' {Maybe OrderBy
Maybe UsageStatisticsSortKey
orderBy :: Maybe OrderBy
key :: Maybe UsageStatisticsSortKey
$sel:orderBy:UsageStatisticsSortBy' :: UsageStatisticsSortBy -> Maybe OrderBy
$sel:key:UsageStatisticsSortBy' :: UsageStatisticsSortBy -> Maybe UsageStatisticsSortKey
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"key" 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 UsageStatisticsSortKey
key,
            (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
          ]
      )