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

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

-- | Specifies criteria for sorting the results of a query for information
-- about Amazon Web Services resources that Amazon Macie monitors and
-- analyzes.
--
-- /See:/ 'newSearchResourcesSortCriteria' smart constructor.
data SearchResourcesSortCriteria = SearchResourcesSortCriteria'
  { -- | 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.
    SearchResourcesSortCriteria -> Maybe OrderBy
orderBy :: Prelude.Maybe OrderBy,
    -- | The property to sort the results by.
    SearchResourcesSortCriteria
-> Maybe SearchResourcesSortAttributeName
attributeName :: Prelude.Maybe SearchResourcesSortAttributeName
  }
  deriving (SearchResourcesSortCriteria -> SearchResourcesSortCriteria -> Bool
(SearchResourcesSortCriteria
 -> SearchResourcesSortCriteria -> Bool)
-> (SearchResourcesSortCriteria
    -> SearchResourcesSortCriteria -> Bool)
-> Eq SearchResourcesSortCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchResourcesSortCriteria -> SearchResourcesSortCriteria -> Bool
$c/= :: SearchResourcesSortCriteria -> SearchResourcesSortCriteria -> Bool
== :: SearchResourcesSortCriteria -> SearchResourcesSortCriteria -> Bool
$c== :: SearchResourcesSortCriteria -> SearchResourcesSortCriteria -> Bool
Prelude.Eq, ReadPrec [SearchResourcesSortCriteria]
ReadPrec SearchResourcesSortCriteria
Int -> ReadS SearchResourcesSortCriteria
ReadS [SearchResourcesSortCriteria]
(Int -> ReadS SearchResourcesSortCriteria)
-> ReadS [SearchResourcesSortCriteria]
-> ReadPrec SearchResourcesSortCriteria
-> ReadPrec [SearchResourcesSortCriteria]
-> Read SearchResourcesSortCriteria
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchResourcesSortCriteria]
$creadListPrec :: ReadPrec [SearchResourcesSortCriteria]
readPrec :: ReadPrec SearchResourcesSortCriteria
$creadPrec :: ReadPrec SearchResourcesSortCriteria
readList :: ReadS [SearchResourcesSortCriteria]
$creadList :: ReadS [SearchResourcesSortCriteria]
readsPrec :: Int -> ReadS SearchResourcesSortCriteria
$creadsPrec :: Int -> ReadS SearchResourcesSortCriteria
Prelude.Read, Int -> SearchResourcesSortCriteria -> ShowS
[SearchResourcesSortCriteria] -> ShowS
SearchResourcesSortCriteria -> String
(Int -> SearchResourcesSortCriteria -> ShowS)
-> (SearchResourcesSortCriteria -> String)
-> ([SearchResourcesSortCriteria] -> ShowS)
-> Show SearchResourcesSortCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchResourcesSortCriteria] -> ShowS
$cshowList :: [SearchResourcesSortCriteria] -> ShowS
show :: SearchResourcesSortCriteria -> String
$cshow :: SearchResourcesSortCriteria -> String
showsPrec :: Int -> SearchResourcesSortCriteria -> ShowS
$cshowsPrec :: Int -> SearchResourcesSortCriteria -> ShowS
Prelude.Show, (forall x.
 SearchResourcesSortCriteria -> Rep SearchResourcesSortCriteria x)
-> (forall x.
    Rep SearchResourcesSortCriteria x -> SearchResourcesSortCriteria)
-> Generic SearchResourcesSortCriteria
forall x.
Rep SearchResourcesSortCriteria x -> SearchResourcesSortCriteria
forall x.
SearchResourcesSortCriteria -> Rep SearchResourcesSortCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SearchResourcesSortCriteria x -> SearchResourcesSortCriteria
$cfrom :: forall x.
SearchResourcesSortCriteria -> Rep SearchResourcesSortCriteria x
Prelude.Generic)

-- |
-- Create a value of 'SearchResourcesSortCriteria' 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', 'searchResourcesSortCriteria_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', 'searchResourcesSortCriteria_attributeName' - The property to sort the results by.
newSearchResourcesSortCriteria ::
  SearchResourcesSortCriteria
newSearchResourcesSortCriteria :: SearchResourcesSortCriteria
newSearchResourcesSortCriteria =
  SearchResourcesSortCriteria' :: Maybe OrderBy
-> Maybe SearchResourcesSortAttributeName
-> SearchResourcesSortCriteria
SearchResourcesSortCriteria'
    { $sel:orderBy:SearchResourcesSortCriteria' :: Maybe OrderBy
orderBy =
        Maybe OrderBy
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeName:SearchResourcesSortCriteria' :: Maybe SearchResourcesSortAttributeName
attributeName = Maybe SearchResourcesSortAttributeName
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.
searchResourcesSortCriteria_orderBy :: Lens.Lens' SearchResourcesSortCriteria (Prelude.Maybe OrderBy)
searchResourcesSortCriteria_orderBy :: (Maybe OrderBy -> f (Maybe OrderBy))
-> SearchResourcesSortCriteria -> f SearchResourcesSortCriteria
searchResourcesSortCriteria_orderBy = (SearchResourcesSortCriteria -> Maybe OrderBy)
-> (SearchResourcesSortCriteria
    -> Maybe OrderBy -> SearchResourcesSortCriteria)
-> Lens
     SearchResourcesSortCriteria
     SearchResourcesSortCriteria
     (Maybe OrderBy)
     (Maybe OrderBy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResourcesSortCriteria' {Maybe OrderBy
orderBy :: Maybe OrderBy
$sel:orderBy:SearchResourcesSortCriteria' :: SearchResourcesSortCriteria -> Maybe OrderBy
orderBy} -> Maybe OrderBy
orderBy) (\s :: SearchResourcesSortCriteria
s@SearchResourcesSortCriteria' {} Maybe OrderBy
a -> SearchResourcesSortCriteria
s {$sel:orderBy:SearchResourcesSortCriteria' :: Maybe OrderBy
orderBy = Maybe OrderBy
a} :: SearchResourcesSortCriteria)

-- | The property to sort the results by.
searchResourcesSortCriteria_attributeName :: Lens.Lens' SearchResourcesSortCriteria (Prelude.Maybe SearchResourcesSortAttributeName)
searchResourcesSortCriteria_attributeName :: (Maybe SearchResourcesSortAttributeName
 -> f (Maybe SearchResourcesSortAttributeName))
-> SearchResourcesSortCriteria -> f SearchResourcesSortCriteria
searchResourcesSortCriteria_attributeName = (SearchResourcesSortCriteria
 -> Maybe SearchResourcesSortAttributeName)
-> (SearchResourcesSortCriteria
    -> Maybe SearchResourcesSortAttributeName
    -> SearchResourcesSortCriteria)
-> Lens
     SearchResourcesSortCriteria
     SearchResourcesSortCriteria
     (Maybe SearchResourcesSortAttributeName)
     (Maybe SearchResourcesSortAttributeName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchResourcesSortCriteria' {Maybe SearchResourcesSortAttributeName
attributeName :: Maybe SearchResourcesSortAttributeName
$sel:attributeName:SearchResourcesSortCriteria' :: SearchResourcesSortCriteria
-> Maybe SearchResourcesSortAttributeName
attributeName} -> Maybe SearchResourcesSortAttributeName
attributeName) (\s :: SearchResourcesSortCriteria
s@SearchResourcesSortCriteria' {} Maybe SearchResourcesSortAttributeName
a -> SearchResourcesSortCriteria
s {$sel:attributeName:SearchResourcesSortCriteria' :: Maybe SearchResourcesSortAttributeName
attributeName = Maybe SearchResourcesSortAttributeName
a} :: SearchResourcesSortCriteria)

instance Prelude.Hashable SearchResourcesSortCriteria

instance Prelude.NFData SearchResourcesSortCriteria

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