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

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

-- | Specifies criteria for sorting the results of a query for information
-- about S3 buckets.
--
-- /See:/ 'newBucketSortCriteria' smart constructor.
data BucketSortCriteria = BucketSortCriteria'
  { -- | The sort order to apply to the results, based on the value specified by
    -- the attributeName property. Valid values are: ASC, sort the results in
    -- ascending order; and, DESC, sort the results in descending order.
    BucketSortCriteria -> Maybe OrderBy
orderBy :: Prelude.Maybe OrderBy,
    -- | The name of the bucket property to sort the results by. This value can
    -- be one of the following properties that Amazon Macie defines as bucket
    -- metadata: accountId, bucketName, classifiableObjectCount,
    -- classifiableSizeInBytes, objectCount, or sizeInBytes.
    BucketSortCriteria -> Maybe Text
attributeName :: Prelude.Maybe Prelude.Text
  }
  deriving (BucketSortCriteria -> BucketSortCriteria -> Bool
(BucketSortCriteria -> BucketSortCriteria -> Bool)
-> (BucketSortCriteria -> BucketSortCriteria -> Bool)
-> Eq BucketSortCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BucketSortCriteria -> BucketSortCriteria -> Bool
$c/= :: BucketSortCriteria -> BucketSortCriteria -> Bool
== :: BucketSortCriteria -> BucketSortCriteria -> Bool
$c== :: BucketSortCriteria -> BucketSortCriteria -> Bool
Prelude.Eq, ReadPrec [BucketSortCriteria]
ReadPrec BucketSortCriteria
Int -> ReadS BucketSortCriteria
ReadS [BucketSortCriteria]
(Int -> ReadS BucketSortCriteria)
-> ReadS [BucketSortCriteria]
-> ReadPrec BucketSortCriteria
-> ReadPrec [BucketSortCriteria]
-> Read BucketSortCriteria
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BucketSortCriteria]
$creadListPrec :: ReadPrec [BucketSortCriteria]
readPrec :: ReadPrec BucketSortCriteria
$creadPrec :: ReadPrec BucketSortCriteria
readList :: ReadS [BucketSortCriteria]
$creadList :: ReadS [BucketSortCriteria]
readsPrec :: Int -> ReadS BucketSortCriteria
$creadsPrec :: Int -> ReadS BucketSortCriteria
Prelude.Read, Int -> BucketSortCriteria -> ShowS
[BucketSortCriteria] -> ShowS
BucketSortCriteria -> String
(Int -> BucketSortCriteria -> ShowS)
-> (BucketSortCriteria -> String)
-> ([BucketSortCriteria] -> ShowS)
-> Show BucketSortCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BucketSortCriteria] -> ShowS
$cshowList :: [BucketSortCriteria] -> ShowS
show :: BucketSortCriteria -> String
$cshow :: BucketSortCriteria -> String
showsPrec :: Int -> BucketSortCriteria -> ShowS
$cshowsPrec :: Int -> BucketSortCriteria -> ShowS
Prelude.Show, (forall x. BucketSortCriteria -> Rep BucketSortCriteria x)
-> (forall x. Rep BucketSortCriteria x -> BucketSortCriteria)
-> Generic BucketSortCriteria
forall x. Rep BucketSortCriteria x -> BucketSortCriteria
forall x. BucketSortCriteria -> Rep BucketSortCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BucketSortCriteria x -> BucketSortCriteria
$cfrom :: forall x. BucketSortCriteria -> Rep BucketSortCriteria x
Prelude.Generic)

-- |
-- Create a value of 'BucketSortCriteria' 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', 'bucketSortCriteria_orderBy' - The sort order to apply to the results, based on the value specified by
-- the attributeName property. Valid values are: ASC, sort the results in
-- ascending order; and, DESC, sort the results in descending order.
--
-- 'attributeName', 'bucketSortCriteria_attributeName' - The name of the bucket property to sort the results by. This value can
-- be one of the following properties that Amazon Macie defines as bucket
-- metadata: accountId, bucketName, classifiableObjectCount,
-- classifiableSizeInBytes, objectCount, or sizeInBytes.
newBucketSortCriteria ::
  BucketSortCriteria
newBucketSortCriteria :: BucketSortCriteria
newBucketSortCriteria =
  BucketSortCriteria' :: Maybe OrderBy -> Maybe Text -> BucketSortCriteria
BucketSortCriteria'
    { $sel:orderBy:BucketSortCriteria' :: Maybe OrderBy
orderBy = Maybe OrderBy
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeName:BucketSortCriteria' :: Maybe Text
attributeName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The name of the bucket property to sort the results by. This value can
-- be one of the following properties that Amazon Macie defines as bucket
-- metadata: accountId, bucketName, classifiableObjectCount,
-- classifiableSizeInBytes, objectCount, or sizeInBytes.
bucketSortCriteria_attributeName :: Lens.Lens' BucketSortCriteria (Prelude.Maybe Prelude.Text)
bucketSortCriteria_attributeName :: (Maybe Text -> f (Maybe Text))
-> BucketSortCriteria -> f BucketSortCriteria
bucketSortCriteria_attributeName = (BucketSortCriteria -> Maybe Text)
-> (BucketSortCriteria -> Maybe Text -> BucketSortCriteria)
-> Lens
     BucketSortCriteria BucketSortCriteria (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketSortCriteria' {Maybe Text
attributeName :: Maybe Text
$sel:attributeName:BucketSortCriteria' :: BucketSortCriteria -> Maybe Text
attributeName} -> Maybe Text
attributeName) (\s :: BucketSortCriteria
s@BucketSortCriteria' {} Maybe Text
a -> BucketSortCriteria
s {$sel:attributeName:BucketSortCriteria' :: Maybe Text
attributeName = Maybe Text
a} :: BucketSortCriteria)

instance Prelude.Hashable BucketSortCriteria

instance Prelude.NFData BucketSortCriteria

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