{-# 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.FilterOperationSelectedFieldsConfiguration
-- 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.FilterOperationSelectedFieldsConfiguration 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.SelectedFieldOptions

-- | The configuration of selected fields in
-- the@CustomActionFilterOperation@.
--
-- This is a union type structure. For this structure to be valid, only one
-- of the attributes can be defined.
--
-- /See:/ 'newFilterOperationSelectedFieldsConfiguration' smart constructor.
data FilterOperationSelectedFieldsConfiguration = FilterOperationSelectedFieldsConfiguration'
  { -- | A structure that contains the options that choose which fields are
    -- filtered in the @CustomActionFilterOperation@.
    --
    -- Valid values are defined as follows:
    --
    -- -   @ALL_FIELDS@: Applies the filter operation to all fields.
    FilterOperationSelectedFieldsConfiguration
-> Maybe SelectedFieldOptions
selectedFieldOptions :: Prelude.Maybe SelectedFieldOptions,
    -- | Chooses the fields that are filtered in @CustomActionFilterOperation@.
    FilterOperationSelectedFieldsConfiguration -> Maybe (NonEmpty Text)
selectedFields :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
  }
  deriving (FilterOperationSelectedFieldsConfiguration
-> FilterOperationSelectedFieldsConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FilterOperationSelectedFieldsConfiguration
-> FilterOperationSelectedFieldsConfiguration -> Bool
$c/= :: FilterOperationSelectedFieldsConfiguration
-> FilterOperationSelectedFieldsConfiguration -> Bool
== :: FilterOperationSelectedFieldsConfiguration
-> FilterOperationSelectedFieldsConfiguration -> Bool
$c== :: FilterOperationSelectedFieldsConfiguration
-> FilterOperationSelectedFieldsConfiguration -> Bool
Prelude.Eq, ReadPrec [FilterOperationSelectedFieldsConfiguration]
ReadPrec FilterOperationSelectedFieldsConfiguration
Int -> ReadS FilterOperationSelectedFieldsConfiguration
ReadS [FilterOperationSelectedFieldsConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FilterOperationSelectedFieldsConfiguration]
$creadListPrec :: ReadPrec [FilterOperationSelectedFieldsConfiguration]
readPrec :: ReadPrec FilterOperationSelectedFieldsConfiguration
$creadPrec :: ReadPrec FilterOperationSelectedFieldsConfiguration
readList :: ReadS [FilterOperationSelectedFieldsConfiguration]
$creadList :: ReadS [FilterOperationSelectedFieldsConfiguration]
readsPrec :: Int -> ReadS FilterOperationSelectedFieldsConfiguration
$creadsPrec :: Int -> ReadS FilterOperationSelectedFieldsConfiguration
Prelude.Read, Int -> FilterOperationSelectedFieldsConfiguration -> ShowS
[FilterOperationSelectedFieldsConfiguration] -> ShowS
FilterOperationSelectedFieldsConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FilterOperationSelectedFieldsConfiguration] -> ShowS
$cshowList :: [FilterOperationSelectedFieldsConfiguration] -> ShowS
show :: FilterOperationSelectedFieldsConfiguration -> String
$cshow :: FilterOperationSelectedFieldsConfiguration -> String
showsPrec :: Int -> FilterOperationSelectedFieldsConfiguration -> ShowS
$cshowsPrec :: Int -> FilterOperationSelectedFieldsConfiguration -> ShowS
Prelude.Show, forall x.
Rep FilterOperationSelectedFieldsConfiguration x
-> FilterOperationSelectedFieldsConfiguration
forall x.
FilterOperationSelectedFieldsConfiguration
-> Rep FilterOperationSelectedFieldsConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FilterOperationSelectedFieldsConfiguration x
-> FilterOperationSelectedFieldsConfiguration
$cfrom :: forall x.
FilterOperationSelectedFieldsConfiguration
-> Rep FilterOperationSelectedFieldsConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'FilterOperationSelectedFieldsConfiguration' 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:
--
-- 'selectedFieldOptions', 'filterOperationSelectedFieldsConfiguration_selectedFieldOptions' - A structure that contains the options that choose which fields are
-- filtered in the @CustomActionFilterOperation@.
--
-- Valid values are defined as follows:
--
-- -   @ALL_FIELDS@: Applies the filter operation to all fields.
--
-- 'selectedFields', 'filterOperationSelectedFieldsConfiguration_selectedFields' - Chooses the fields that are filtered in @CustomActionFilterOperation@.
newFilterOperationSelectedFieldsConfiguration ::
  FilterOperationSelectedFieldsConfiguration
newFilterOperationSelectedFieldsConfiguration :: FilterOperationSelectedFieldsConfiguration
newFilterOperationSelectedFieldsConfiguration =
  FilterOperationSelectedFieldsConfiguration'
    { $sel:selectedFieldOptions:FilterOperationSelectedFieldsConfiguration' :: Maybe SelectedFieldOptions
selectedFieldOptions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:selectedFields:FilterOperationSelectedFieldsConfiguration' :: Maybe (NonEmpty Text)
selectedFields =
        forall a. Maybe a
Prelude.Nothing
    }

-- | A structure that contains the options that choose which fields are
-- filtered in the @CustomActionFilterOperation@.
--
-- Valid values are defined as follows:
--
-- -   @ALL_FIELDS@: Applies the filter operation to all fields.
filterOperationSelectedFieldsConfiguration_selectedFieldOptions :: Lens.Lens' FilterOperationSelectedFieldsConfiguration (Prelude.Maybe SelectedFieldOptions)
filterOperationSelectedFieldsConfiguration_selectedFieldOptions :: Lens'
  FilterOperationSelectedFieldsConfiguration
  (Maybe SelectedFieldOptions)
filterOperationSelectedFieldsConfiguration_selectedFieldOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterOperationSelectedFieldsConfiguration' {Maybe SelectedFieldOptions
selectedFieldOptions :: Maybe SelectedFieldOptions
$sel:selectedFieldOptions:FilterOperationSelectedFieldsConfiguration' :: FilterOperationSelectedFieldsConfiguration
-> Maybe SelectedFieldOptions
selectedFieldOptions} -> Maybe SelectedFieldOptions
selectedFieldOptions) (\s :: FilterOperationSelectedFieldsConfiguration
s@FilterOperationSelectedFieldsConfiguration' {} Maybe SelectedFieldOptions
a -> FilterOperationSelectedFieldsConfiguration
s {$sel:selectedFieldOptions:FilterOperationSelectedFieldsConfiguration' :: Maybe SelectedFieldOptions
selectedFieldOptions = Maybe SelectedFieldOptions
a} :: FilterOperationSelectedFieldsConfiguration)

-- | Chooses the fields that are filtered in @CustomActionFilterOperation@.
filterOperationSelectedFieldsConfiguration_selectedFields :: Lens.Lens' FilterOperationSelectedFieldsConfiguration (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
filterOperationSelectedFieldsConfiguration_selectedFields :: Lens'
  FilterOperationSelectedFieldsConfiguration (Maybe (NonEmpty Text))
filterOperationSelectedFieldsConfiguration_selectedFields = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FilterOperationSelectedFieldsConfiguration' {Maybe (NonEmpty Text)
selectedFields :: Maybe (NonEmpty Text)
$sel:selectedFields:FilterOperationSelectedFieldsConfiguration' :: FilterOperationSelectedFieldsConfiguration -> Maybe (NonEmpty Text)
selectedFields} -> Maybe (NonEmpty Text)
selectedFields) (\s :: FilterOperationSelectedFieldsConfiguration
s@FilterOperationSelectedFieldsConfiguration' {} Maybe (NonEmpty Text)
a -> FilterOperationSelectedFieldsConfiguration
s {$sel:selectedFields:FilterOperationSelectedFieldsConfiguration' :: Maybe (NonEmpty Text)
selectedFields = Maybe (NonEmpty Text)
a} :: FilterOperationSelectedFieldsConfiguration) 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
    FilterOperationSelectedFieldsConfiguration
  where
  parseJSON :: Value -> Parser FilterOperationSelectedFieldsConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FilterOperationSelectedFieldsConfiguration"
      ( \Object
x ->
          Maybe SelectedFieldOptions
-> Maybe (NonEmpty Text)
-> FilterOperationSelectedFieldsConfiguration
FilterOperationSelectedFieldsConfiguration'
            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
"SelectedFieldOptions")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SelectedFields")
      )

instance
  Prelude.Hashable
    FilterOperationSelectedFieldsConfiguration
  where
  hashWithSalt :: Int -> FilterOperationSelectedFieldsConfiguration -> Int
hashWithSalt
    Int
_salt
    FilterOperationSelectedFieldsConfiguration' {Maybe (NonEmpty Text)
Maybe SelectedFieldOptions
selectedFields :: Maybe (NonEmpty Text)
selectedFieldOptions :: Maybe SelectedFieldOptions
$sel:selectedFields:FilterOperationSelectedFieldsConfiguration' :: FilterOperationSelectedFieldsConfiguration -> Maybe (NonEmpty Text)
$sel:selectedFieldOptions:FilterOperationSelectedFieldsConfiguration' :: FilterOperationSelectedFieldsConfiguration
-> Maybe SelectedFieldOptions
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SelectedFieldOptions
selectedFieldOptions
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
selectedFields

instance
  Prelude.NFData
    FilterOperationSelectedFieldsConfiguration
  where
  rnf :: FilterOperationSelectedFieldsConfiguration -> ()
rnf FilterOperationSelectedFieldsConfiguration' {Maybe (NonEmpty Text)
Maybe SelectedFieldOptions
selectedFields :: Maybe (NonEmpty Text)
selectedFieldOptions :: Maybe SelectedFieldOptions
$sel:selectedFields:FilterOperationSelectedFieldsConfiguration' :: FilterOperationSelectedFieldsConfiguration -> Maybe (NonEmpty Text)
$sel:selectedFieldOptions:FilterOperationSelectedFieldsConfiguration' :: FilterOperationSelectedFieldsConfiguration
-> Maybe SelectedFieldOptions
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SelectedFieldOptions
selectedFieldOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
selectedFields

instance
  Data.ToJSON
    FilterOperationSelectedFieldsConfiguration
  where
  toJSON :: FilterOperationSelectedFieldsConfiguration -> Value
toJSON
    FilterOperationSelectedFieldsConfiguration' {Maybe (NonEmpty Text)
Maybe SelectedFieldOptions
selectedFields :: Maybe (NonEmpty Text)
selectedFieldOptions :: Maybe SelectedFieldOptions
$sel:selectedFields:FilterOperationSelectedFieldsConfiguration' :: FilterOperationSelectedFieldsConfiguration -> Maybe (NonEmpty Text)
$sel:selectedFieldOptions:FilterOperationSelectedFieldsConfiguration' :: FilterOperationSelectedFieldsConfiguration
-> Maybe SelectedFieldOptions
..} =
      [Pair] -> Value
Data.object
        ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Key
"SelectedFieldOptions" 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 SelectedFieldOptions
selectedFieldOptions,
              (Key
"SelectedFields" 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 (NonEmpty Text)
selectedFields
            ]
        )