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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(SnapshotSortingEntity -> SnapshotSortingEntity -> Bool)
-> (SnapshotSortingEntity -> SnapshotSortingEntity -> Bool)
-> Eq SnapshotSortingEntity
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]
(Int -> ReadS SnapshotSortingEntity)
-> ReadS [SnapshotSortingEntity]
-> ReadPrec SnapshotSortingEntity
-> ReadPrec [SnapshotSortingEntity]
-> Read 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
(Int -> SnapshotSortingEntity -> ShowS)
-> (SnapshotSortingEntity -> String)
-> ([SnapshotSortingEntity] -> ShowS)
-> Show SnapshotSortingEntity
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. SnapshotSortingEntity -> Rep SnapshotSortingEntity x)
-> (forall x. Rep SnapshotSortingEntity x -> SnapshotSortingEntity)
-> Generic SnapshotSortingEntity
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' :: Maybe SortByOrder
-> SnapshotAttributeToSortBy -> SnapshotSortingEntity
SnapshotSortingEntity'
    { $sel:sortOrder:SnapshotSortingEntity' :: Maybe SortByOrder
sortOrder = Maybe SortByOrder
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 :: (Maybe SortByOrder -> f (Maybe SortByOrder))
-> SnapshotSortingEntity -> f SnapshotSortingEntity
snapshotSortingEntity_sortOrder = (SnapshotSortingEntity -> Maybe SortByOrder)
-> (SnapshotSortingEntity
    -> Maybe SortByOrder -> SnapshotSortingEntity)
-> Lens
     SnapshotSortingEntity
     SnapshotSortingEntity
     (Maybe SortByOrder)
     (Maybe SortByOrder)
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 :: (SnapshotAttributeToSortBy -> f SnapshotAttributeToSortBy)
-> SnapshotSortingEntity -> f SnapshotSortingEntity
snapshotSortingEntity_attribute = (SnapshotSortingEntity -> SnapshotAttributeToSortBy)
-> (SnapshotSortingEntity
    -> SnapshotAttributeToSortBy -> SnapshotSortingEntity)
-> Lens
     SnapshotSortingEntity
     SnapshotSortingEntity
     SnapshotAttributeToSortBy
     SnapshotAttributeToSortBy
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

instance Prelude.NFData SnapshotSortingEntity

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SortOrder" ByteString -> Maybe SortByOrder -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe SortByOrder
sortOrder,
        ByteString
"Attribute" ByteString -> SnapshotAttributeToSortBy -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: SnapshotAttributeToSortBy
attribute
      ]