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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | The field to sort the results by.
    UsageStatisticsSortBy -> Maybe UsageStatisticsSortKey
key :: Prelude.Maybe UsageStatisticsSortKey
  }
  deriving (UsageStatisticsSortBy -> UsageStatisticsSortBy -> Bool
(UsageStatisticsSortBy -> UsageStatisticsSortBy -> Bool)
-> (UsageStatisticsSortBy -> UsageStatisticsSortBy -> Bool)
-> Eq UsageStatisticsSortBy
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]
(Int -> ReadS UsageStatisticsSortBy)
-> ReadS [UsageStatisticsSortBy]
-> ReadPrec UsageStatisticsSortBy
-> ReadPrec [UsageStatisticsSortBy]
-> Read 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
(Int -> UsageStatisticsSortBy -> ShowS)
-> (UsageStatisticsSortBy -> String)
-> ([UsageStatisticsSortBy] -> ShowS)
-> Show UsageStatisticsSortBy
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. UsageStatisticsSortBy -> Rep UsageStatisticsSortBy x)
-> (forall x. Rep UsageStatisticsSortBy x -> UsageStatisticsSortBy)
-> Generic UsageStatisticsSortBy
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:
--
-- '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.
--
-- 'key', 'usageStatisticsSortBy_key' - The field to sort the results by.
newUsageStatisticsSortBy ::
  UsageStatisticsSortBy
newUsageStatisticsSortBy :: UsageStatisticsSortBy
newUsageStatisticsSortBy =
  UsageStatisticsSortBy' :: Maybe OrderBy
-> Maybe UsageStatisticsSortKey -> UsageStatisticsSortBy
UsageStatisticsSortBy'
    { $sel:orderBy:UsageStatisticsSortBy' :: Maybe OrderBy
orderBy = Maybe OrderBy
forall a. Maybe a
Prelude.Nothing,
      $sel:key:UsageStatisticsSortBy' :: Maybe UsageStatisticsSortKey
key = Maybe UsageStatisticsSortKey
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe OrderBy -> f (Maybe OrderBy))
-> UsageStatisticsSortBy -> f UsageStatisticsSortBy
usageStatisticsSortBy_orderBy = (UsageStatisticsSortBy -> Maybe OrderBy)
-> (UsageStatisticsSortBy
    -> Maybe OrderBy -> UsageStatisticsSortBy)
-> Lens
     UsageStatisticsSortBy
     UsageStatisticsSortBy
     (Maybe OrderBy)
     (Maybe 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)

-- | The field to sort the results by.
usageStatisticsSortBy_key :: Lens.Lens' UsageStatisticsSortBy (Prelude.Maybe UsageStatisticsSortKey)
usageStatisticsSortBy_key :: (Maybe UsageStatisticsSortKey -> f (Maybe UsageStatisticsSortKey))
-> UsageStatisticsSortBy -> f UsageStatisticsSortBy
usageStatisticsSortBy_key = (UsageStatisticsSortBy -> Maybe UsageStatisticsSortKey)
-> (UsageStatisticsSortBy
    -> Maybe UsageStatisticsSortKey -> UsageStatisticsSortBy)
-> Lens
     UsageStatisticsSortBy
     UsageStatisticsSortBy
     (Maybe UsageStatisticsSortKey)
     (Maybe UsageStatisticsSortKey)
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)

instance Prelude.Hashable UsageStatisticsSortBy

instance Prelude.NFData UsageStatisticsSortBy

instance Core.ToJSON UsageStatisticsSortBy where
  toJSON :: UsageStatisticsSortBy -> Value
toJSON UsageStatisticsSortBy' {Maybe OrderBy
Maybe UsageStatisticsSortKey
key :: Maybe UsageStatisticsSortKey
orderBy :: Maybe OrderBy
$sel:key:UsageStatisticsSortBy' :: UsageStatisticsSortBy -> Maybe UsageStatisticsSortKey
$sel:orderBy:UsageStatisticsSortBy' :: UsageStatisticsSortBy -> 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
"key" Text -> UsageStatisticsSortKey -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (UsageStatisticsSortKey -> Pair)
-> Maybe UsageStatisticsSortKey -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UsageStatisticsSortKey
key
          ]
      )