{-# 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.QuickSight.Types.KPISortConfiguration
-- 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.QuickSight.Types.KPISortConfiguration 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.QuickSight.Types.FieldSortOptions

-- | The sort configuration of a KPI visual.
--
-- /See:/ 'newKPISortConfiguration' smart constructor.
data KPISortConfiguration = KPISortConfiguration'
  { -- | The sort configuration of the trend group fields.
    KPISortConfiguration -> Maybe [FieldSortOptions]
trendGroupSort :: Prelude.Maybe [FieldSortOptions]
  }
  deriving (KPISortConfiguration -> KPISortConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KPISortConfiguration -> KPISortConfiguration -> Bool
$c/= :: KPISortConfiguration -> KPISortConfiguration -> Bool
== :: KPISortConfiguration -> KPISortConfiguration -> Bool
$c== :: KPISortConfiguration -> KPISortConfiguration -> Bool
Prelude.Eq, ReadPrec [KPISortConfiguration]
ReadPrec KPISortConfiguration
Int -> ReadS KPISortConfiguration
ReadS [KPISortConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KPISortConfiguration]
$creadListPrec :: ReadPrec [KPISortConfiguration]
readPrec :: ReadPrec KPISortConfiguration
$creadPrec :: ReadPrec KPISortConfiguration
readList :: ReadS [KPISortConfiguration]
$creadList :: ReadS [KPISortConfiguration]
readsPrec :: Int -> ReadS KPISortConfiguration
$creadsPrec :: Int -> ReadS KPISortConfiguration
Prelude.Read, Int -> KPISortConfiguration -> ShowS
[KPISortConfiguration] -> ShowS
KPISortConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KPISortConfiguration] -> ShowS
$cshowList :: [KPISortConfiguration] -> ShowS
show :: KPISortConfiguration -> String
$cshow :: KPISortConfiguration -> String
showsPrec :: Int -> KPISortConfiguration -> ShowS
$cshowsPrec :: Int -> KPISortConfiguration -> ShowS
Prelude.Show, forall x. Rep KPISortConfiguration x -> KPISortConfiguration
forall x. KPISortConfiguration -> Rep KPISortConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KPISortConfiguration x -> KPISortConfiguration
$cfrom :: forall x. KPISortConfiguration -> Rep KPISortConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'KPISortConfiguration' 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:
--
-- 'trendGroupSort', 'kPISortConfiguration_trendGroupSort' - The sort configuration of the trend group fields.
newKPISortConfiguration ::
  KPISortConfiguration
newKPISortConfiguration :: KPISortConfiguration
newKPISortConfiguration =
  KPISortConfiguration'
    { $sel:trendGroupSort:KPISortConfiguration' :: Maybe [FieldSortOptions]
trendGroupSort =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The sort configuration of the trend group fields.
kPISortConfiguration_trendGroupSort :: Lens.Lens' KPISortConfiguration (Prelude.Maybe [FieldSortOptions])
kPISortConfiguration_trendGroupSort :: Lens' KPISortConfiguration (Maybe [FieldSortOptions])
kPISortConfiguration_trendGroupSort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KPISortConfiguration' {Maybe [FieldSortOptions]
trendGroupSort :: Maybe [FieldSortOptions]
$sel:trendGroupSort:KPISortConfiguration' :: KPISortConfiguration -> Maybe [FieldSortOptions]
trendGroupSort} -> Maybe [FieldSortOptions]
trendGroupSort) (\s :: KPISortConfiguration
s@KPISortConfiguration' {} Maybe [FieldSortOptions]
a -> KPISortConfiguration
s {$sel:trendGroupSort:KPISortConfiguration' :: Maybe [FieldSortOptions]
trendGroupSort = Maybe [FieldSortOptions]
a} :: KPISortConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON KPISortConfiguration where
  parseJSON :: Value -> Parser KPISortConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"KPISortConfiguration"
      ( \Object
x ->
          Maybe [FieldSortOptions] -> KPISortConfiguration
KPISortConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TrendGroupSort"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable KPISortConfiguration where
  hashWithSalt :: Int -> KPISortConfiguration -> Int
hashWithSalt Int
_salt KPISortConfiguration' {Maybe [FieldSortOptions]
trendGroupSort :: Maybe [FieldSortOptions]
$sel:trendGroupSort:KPISortConfiguration' :: KPISortConfiguration -> Maybe [FieldSortOptions]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [FieldSortOptions]
trendGroupSort

instance Prelude.NFData KPISortConfiguration where
  rnf :: KPISortConfiguration -> ()
rnf KPISortConfiguration' {Maybe [FieldSortOptions]
trendGroupSort :: Maybe [FieldSortOptions]
$sel:trendGroupSort:KPISortConfiguration' :: KPISortConfiguration -> Maybe [FieldSortOptions]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FieldSortOptions]
trendGroupSort

instance Data.ToJSON KPISortConfiguration where
  toJSON :: KPISortConfiguration -> Value
toJSON KPISortConfiguration' {Maybe [FieldSortOptions]
trendGroupSort :: Maybe [FieldSortOptions]
$sel:trendGroupSort:KPISortConfiguration' :: KPISortConfiguration -> Maybe [FieldSortOptions]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TrendGroupSort" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [FieldSortOptions]
trendGroupSort
          ]
      )