{-# 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.Redshift.Types.SnapshotSortingEntity
-- 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.Redshift.Types.SnapshotSortingEntity where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Internal
import Amazonka.Redshift.Types.SnapshotAttributeToSortBy
import Amazonka.Redshift.Types.SortByOrder

-- | Describes a sorting entity
--
-- /See:/ 'newSnapshotSortingEntity' smart constructor.
data SnapshotSortingEntity = SnapshotSortingEntity'
  { -- | The order for listing the attributes.
    SnapshotSortingEntity -> Maybe SortByOrder
sortOrder :: Prelude.Maybe SortByOrder,
    -- | The category for sorting the snapshots.
    SnapshotSortingEntity -> SnapshotAttributeToSortBy
attribute :: SnapshotAttributeToSortBy
  }
  deriving (SnapshotSortingEntity -> SnapshotSortingEntity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnapshotSortingEntity -> SnapshotSortingEntity -> Bool
$c/= :: SnapshotSortingEntity -> SnapshotSortingEntity -> Bool
== :: SnapshotSortingEntity -> SnapshotSortingEntity -> Bool
$c== :: SnapshotSortingEntity -> SnapshotSortingEntity -> Bool
Prelude.Eq, ReadPrec [SnapshotSortingEntity]
ReadPrec SnapshotSortingEntity
Int -> ReadS SnapshotSortingEntity
ReadS [SnapshotSortingEntity]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnapshotSortingEntity]
$creadListPrec :: ReadPrec [SnapshotSortingEntity]
readPrec :: ReadPrec SnapshotSortingEntity
$creadPrec :: ReadPrec SnapshotSortingEntity
readList :: ReadS [SnapshotSortingEntity]
$creadList :: ReadS [SnapshotSortingEntity]
readsPrec :: Int -> ReadS SnapshotSortingEntity
$creadsPrec :: Int -> ReadS SnapshotSortingEntity
Prelude.Read, Int -> SnapshotSortingEntity -> ShowS
[SnapshotSortingEntity] -> ShowS
SnapshotSortingEntity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnapshotSortingEntity] -> ShowS
$cshowList :: [SnapshotSortingEntity] -> ShowS
show :: SnapshotSortingEntity -> String
$cshow :: SnapshotSortingEntity -> String
showsPrec :: Int -> SnapshotSortingEntity -> ShowS
$cshowsPrec :: Int -> SnapshotSortingEntity -> ShowS
Prelude.Show, forall x. Rep SnapshotSortingEntity x -> SnapshotSortingEntity
forall x. SnapshotSortingEntity -> Rep SnapshotSortingEntity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnapshotSortingEntity x -> SnapshotSortingEntity
$cfrom :: forall x. SnapshotSortingEntity -> Rep SnapshotSortingEntity x
Prelude.Generic)

-- |
-- Create a value of 'SnapshotSortingEntity' 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:
--
-- 'sortOrder', 'snapshotSortingEntity_sortOrder' - The order for listing the attributes.
--
-- 'attribute', 'snapshotSortingEntity_attribute' - The category for sorting the snapshots.
newSnapshotSortingEntity ::
  -- | 'attribute'
  SnapshotAttributeToSortBy ->
  SnapshotSortingEntity
newSnapshotSortingEntity :: SnapshotAttributeToSortBy -> SnapshotSortingEntity
newSnapshotSortingEntity SnapshotAttributeToSortBy
pAttribute_ =
  SnapshotSortingEntity'
    { $sel:sortOrder:SnapshotSortingEntity' :: Maybe SortByOrder
sortOrder = forall a. Maybe a
Prelude.Nothing,
      $sel:attribute:SnapshotSortingEntity' :: SnapshotAttributeToSortBy
attribute = SnapshotAttributeToSortBy
pAttribute_
    }

-- | The order for listing the attributes.
snapshotSortingEntity_sortOrder :: Lens.Lens' SnapshotSortingEntity (Prelude.Maybe SortByOrder)
snapshotSortingEntity_sortOrder :: Lens' SnapshotSortingEntity (Maybe SortByOrder)
snapshotSortingEntity_sortOrder = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotSortingEntity' {Maybe SortByOrder
sortOrder :: Maybe SortByOrder
$sel:sortOrder:SnapshotSortingEntity' :: SnapshotSortingEntity -> Maybe SortByOrder
sortOrder} -> Maybe SortByOrder
sortOrder) (\s :: SnapshotSortingEntity
s@SnapshotSortingEntity' {} Maybe SortByOrder
a -> SnapshotSortingEntity
s {$sel:sortOrder:SnapshotSortingEntity' :: Maybe SortByOrder
sortOrder = Maybe SortByOrder
a} :: SnapshotSortingEntity)

-- | The category for sorting the snapshots.
snapshotSortingEntity_attribute :: Lens.Lens' SnapshotSortingEntity SnapshotAttributeToSortBy
snapshotSortingEntity_attribute :: Lens' SnapshotSortingEntity SnapshotAttributeToSortBy
snapshotSortingEntity_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotSortingEntity' {SnapshotAttributeToSortBy
attribute :: SnapshotAttributeToSortBy
$sel:attribute:SnapshotSortingEntity' :: SnapshotSortingEntity -> SnapshotAttributeToSortBy
attribute} -> SnapshotAttributeToSortBy
attribute) (\s :: SnapshotSortingEntity
s@SnapshotSortingEntity' {} SnapshotAttributeToSortBy
a -> SnapshotSortingEntity
s {$sel:attribute:SnapshotSortingEntity' :: SnapshotAttributeToSortBy
attribute = SnapshotAttributeToSortBy
a} :: SnapshotSortingEntity)

instance Prelude.Hashable SnapshotSortingEntity where
  hashWithSalt :: Int -> SnapshotSortingEntity -> Int
hashWithSalt Int
_salt SnapshotSortingEntity' {Maybe SortByOrder
SnapshotAttributeToSortBy
attribute :: SnapshotAttributeToSortBy
sortOrder :: Maybe SortByOrder
$sel:attribute:SnapshotSortingEntity' :: SnapshotSortingEntity -> SnapshotAttributeToSortBy
$sel:sortOrder:SnapshotSortingEntity' :: SnapshotSortingEntity -> Maybe SortByOrder
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SortByOrder
sortOrder
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SnapshotAttributeToSortBy
attribute

instance Prelude.NFData SnapshotSortingEntity where
  rnf :: SnapshotSortingEntity -> ()
rnf SnapshotSortingEntity' {Maybe SortByOrder
SnapshotAttributeToSortBy
attribute :: SnapshotAttributeToSortBy
sortOrder :: Maybe SortByOrder
$sel:attribute:SnapshotSortingEntity' :: SnapshotSortingEntity -> SnapshotAttributeToSortBy
$sel:sortOrder:SnapshotSortingEntity' :: SnapshotSortingEntity -> Maybe SortByOrder
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SortByOrder
sortOrder
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SnapshotAttributeToSortBy
attribute

instance Data.ToQuery SnapshotSortingEntity where
  toQuery :: SnapshotSortingEntity -> QueryString
toQuery SnapshotSortingEntity' {Maybe SortByOrder
SnapshotAttributeToSortBy
attribute :: SnapshotAttributeToSortBy
sortOrder :: Maybe SortByOrder
$sel:attribute:SnapshotSortingEntity' :: SnapshotSortingEntity -> SnapshotAttributeToSortBy
$sel:sortOrder:SnapshotSortingEntity' :: SnapshotSortingEntity -> Maybe SortByOrder
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SortOrder" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe SortByOrder
sortOrder,
        ByteString
"Attribute" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: SnapshotAttributeToSortBy
attribute
      ]