{-# 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.ContributionAnalysisDefault
-- 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.ContributionAnalysisDefault 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.ColumnIdentifier

-- | The contribution analysis visual display for a line, pie, or bar chart.
--
-- /See:/ 'newContributionAnalysisDefault' smart constructor.
data ContributionAnalysisDefault = ContributionAnalysisDefault'
  { -- | The measure field that is used in the contribution analysis.
    ContributionAnalysisDefault -> Text
measureFieldId :: Prelude.Text,
    -- | The dimensions columns that are used in the contribution analysis,
    -- usually a list of @ColumnIdentifiers@.
    ContributionAnalysisDefault -> NonEmpty ColumnIdentifier
contributorDimensions :: Prelude.NonEmpty ColumnIdentifier
  }
  deriving (ContributionAnalysisDefault -> ContributionAnalysisDefault -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContributionAnalysisDefault -> ContributionAnalysisDefault -> Bool
$c/= :: ContributionAnalysisDefault -> ContributionAnalysisDefault -> Bool
== :: ContributionAnalysisDefault -> ContributionAnalysisDefault -> Bool
$c== :: ContributionAnalysisDefault -> ContributionAnalysisDefault -> Bool
Prelude.Eq, ReadPrec [ContributionAnalysisDefault]
ReadPrec ContributionAnalysisDefault
Int -> ReadS ContributionAnalysisDefault
ReadS [ContributionAnalysisDefault]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContributionAnalysisDefault]
$creadListPrec :: ReadPrec [ContributionAnalysisDefault]
readPrec :: ReadPrec ContributionAnalysisDefault
$creadPrec :: ReadPrec ContributionAnalysisDefault
readList :: ReadS [ContributionAnalysisDefault]
$creadList :: ReadS [ContributionAnalysisDefault]
readsPrec :: Int -> ReadS ContributionAnalysisDefault
$creadsPrec :: Int -> ReadS ContributionAnalysisDefault
Prelude.Read, Int -> ContributionAnalysisDefault -> ShowS
[ContributionAnalysisDefault] -> ShowS
ContributionAnalysisDefault -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContributionAnalysisDefault] -> ShowS
$cshowList :: [ContributionAnalysisDefault] -> ShowS
show :: ContributionAnalysisDefault -> String
$cshow :: ContributionAnalysisDefault -> String
showsPrec :: Int -> ContributionAnalysisDefault -> ShowS
$cshowsPrec :: Int -> ContributionAnalysisDefault -> ShowS
Prelude.Show, forall x.
Rep ContributionAnalysisDefault x -> ContributionAnalysisDefault
forall x.
ContributionAnalysisDefault -> Rep ContributionAnalysisDefault x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ContributionAnalysisDefault x -> ContributionAnalysisDefault
$cfrom :: forall x.
ContributionAnalysisDefault -> Rep ContributionAnalysisDefault x
Prelude.Generic)

-- |
-- Create a value of 'ContributionAnalysisDefault' 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:
--
-- 'measureFieldId', 'contributionAnalysisDefault_measureFieldId' - The measure field that is used in the contribution analysis.
--
-- 'contributorDimensions', 'contributionAnalysisDefault_contributorDimensions' - The dimensions columns that are used in the contribution analysis,
-- usually a list of @ColumnIdentifiers@.
newContributionAnalysisDefault ::
  -- | 'measureFieldId'
  Prelude.Text ->
  -- | 'contributorDimensions'
  Prelude.NonEmpty ColumnIdentifier ->
  ContributionAnalysisDefault
newContributionAnalysisDefault :: Text -> NonEmpty ColumnIdentifier -> ContributionAnalysisDefault
newContributionAnalysisDefault
  Text
pMeasureFieldId_
  NonEmpty ColumnIdentifier
pContributorDimensions_ =
    ContributionAnalysisDefault'
      { $sel:measureFieldId:ContributionAnalysisDefault' :: Text
measureFieldId =
          Text
pMeasureFieldId_,
        $sel:contributorDimensions:ContributionAnalysisDefault' :: NonEmpty ColumnIdentifier
contributorDimensions =
          forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty ColumnIdentifier
pContributorDimensions_
      }

-- | The measure field that is used in the contribution analysis.
contributionAnalysisDefault_measureFieldId :: Lens.Lens' ContributionAnalysisDefault Prelude.Text
contributionAnalysisDefault_measureFieldId :: Lens' ContributionAnalysisDefault Text
contributionAnalysisDefault_measureFieldId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContributionAnalysisDefault' {Text
measureFieldId :: Text
$sel:measureFieldId:ContributionAnalysisDefault' :: ContributionAnalysisDefault -> Text
measureFieldId} -> Text
measureFieldId) (\s :: ContributionAnalysisDefault
s@ContributionAnalysisDefault' {} Text
a -> ContributionAnalysisDefault
s {$sel:measureFieldId:ContributionAnalysisDefault' :: Text
measureFieldId = Text
a} :: ContributionAnalysisDefault)

-- | The dimensions columns that are used in the contribution analysis,
-- usually a list of @ColumnIdentifiers@.
contributionAnalysisDefault_contributorDimensions :: Lens.Lens' ContributionAnalysisDefault (Prelude.NonEmpty ColumnIdentifier)
contributionAnalysisDefault_contributorDimensions :: Lens' ContributionAnalysisDefault (NonEmpty ColumnIdentifier)
contributionAnalysisDefault_contributorDimensions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContributionAnalysisDefault' {NonEmpty ColumnIdentifier
contributorDimensions :: NonEmpty ColumnIdentifier
$sel:contributorDimensions:ContributionAnalysisDefault' :: ContributionAnalysisDefault -> NonEmpty ColumnIdentifier
contributorDimensions} -> NonEmpty ColumnIdentifier
contributorDimensions) (\s :: ContributionAnalysisDefault
s@ContributionAnalysisDefault' {} NonEmpty ColumnIdentifier
a -> ContributionAnalysisDefault
s {$sel:contributorDimensions:ContributionAnalysisDefault' :: NonEmpty ColumnIdentifier
contributorDimensions = NonEmpty ColumnIdentifier
a} :: ContributionAnalysisDefault) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ContributionAnalysisDefault where
  parseJSON :: Value -> Parser ContributionAnalysisDefault
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ContributionAnalysisDefault"
      ( \Object
x ->
          Text -> NonEmpty ColumnIdentifier -> ContributionAnalysisDefault
ContributionAnalysisDefault'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MeasureFieldId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ContributorDimensions")
      )

instance Prelude.Hashable ContributionAnalysisDefault where
  hashWithSalt :: Int -> ContributionAnalysisDefault -> Int
hashWithSalt Int
_salt ContributionAnalysisDefault' {NonEmpty ColumnIdentifier
Text
contributorDimensions :: NonEmpty ColumnIdentifier
measureFieldId :: Text
$sel:contributorDimensions:ContributionAnalysisDefault' :: ContributionAnalysisDefault -> NonEmpty ColumnIdentifier
$sel:measureFieldId:ContributionAnalysisDefault' :: ContributionAnalysisDefault -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
measureFieldId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty ColumnIdentifier
contributorDimensions

instance Prelude.NFData ContributionAnalysisDefault where
  rnf :: ContributionAnalysisDefault -> ()
rnf ContributionAnalysisDefault' {NonEmpty ColumnIdentifier
Text
contributorDimensions :: NonEmpty ColumnIdentifier
measureFieldId :: Text
$sel:contributorDimensions:ContributionAnalysisDefault' :: ContributionAnalysisDefault -> NonEmpty ColumnIdentifier
$sel:measureFieldId:ContributionAnalysisDefault' :: ContributionAnalysisDefault -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
measureFieldId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty ColumnIdentifier
contributorDimensions

instance Data.ToJSON ContributionAnalysisDefault where
  toJSON :: ContributionAnalysisDefault -> Value
toJSON ContributionAnalysisDefault' {NonEmpty ColumnIdentifier
Text
contributorDimensions :: NonEmpty ColumnIdentifier
measureFieldId :: Text
$sel:contributorDimensions:ContributionAnalysisDefault' :: ContributionAnalysisDefault -> NonEmpty ColumnIdentifier
$sel:measureFieldId:ContributionAnalysisDefault' :: ContributionAnalysisDefault -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"MeasureFieldId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
measureFieldId),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"ContributorDimensions"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty ColumnIdentifier
contributorDimensions
              )
          ]
      )