{-# 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.Glue.Types.PartitionValueList
-- 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.Glue.Types.PartitionValueList where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains a list of values defining partitions.
--
-- /See:/ 'newPartitionValueList' smart constructor.
data PartitionValueList = PartitionValueList'
  { -- | The list of values.
    PartitionValueList -> [Text]
values :: [Prelude.Text]
  }
  deriving (PartitionValueList -> PartitionValueList -> Bool
(PartitionValueList -> PartitionValueList -> Bool)
-> (PartitionValueList -> PartitionValueList -> Bool)
-> Eq PartitionValueList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartitionValueList -> PartitionValueList -> Bool
$c/= :: PartitionValueList -> PartitionValueList -> Bool
== :: PartitionValueList -> PartitionValueList -> Bool
$c== :: PartitionValueList -> PartitionValueList -> Bool
Prelude.Eq, ReadPrec [PartitionValueList]
ReadPrec PartitionValueList
Int -> ReadS PartitionValueList
ReadS [PartitionValueList]
(Int -> ReadS PartitionValueList)
-> ReadS [PartitionValueList]
-> ReadPrec PartitionValueList
-> ReadPrec [PartitionValueList]
-> Read PartitionValueList
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PartitionValueList]
$creadListPrec :: ReadPrec [PartitionValueList]
readPrec :: ReadPrec PartitionValueList
$creadPrec :: ReadPrec PartitionValueList
readList :: ReadS [PartitionValueList]
$creadList :: ReadS [PartitionValueList]
readsPrec :: Int -> ReadS PartitionValueList
$creadsPrec :: Int -> ReadS PartitionValueList
Prelude.Read, Int -> PartitionValueList -> ShowS
[PartitionValueList] -> ShowS
PartitionValueList -> String
(Int -> PartitionValueList -> ShowS)
-> (PartitionValueList -> String)
-> ([PartitionValueList] -> ShowS)
-> Show PartitionValueList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartitionValueList] -> ShowS
$cshowList :: [PartitionValueList] -> ShowS
show :: PartitionValueList -> String
$cshow :: PartitionValueList -> String
showsPrec :: Int -> PartitionValueList -> ShowS
$cshowsPrec :: Int -> PartitionValueList -> ShowS
Prelude.Show, (forall x. PartitionValueList -> Rep PartitionValueList x)
-> (forall x. Rep PartitionValueList x -> PartitionValueList)
-> Generic PartitionValueList
forall x. Rep PartitionValueList x -> PartitionValueList
forall x. PartitionValueList -> Rep PartitionValueList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PartitionValueList x -> PartitionValueList
$cfrom :: forall x. PartitionValueList -> Rep PartitionValueList x
Prelude.Generic)

-- |
-- Create a value of 'PartitionValueList' 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:
--
-- 'values', 'partitionValueList_values' - The list of values.
newPartitionValueList ::
  PartitionValueList
newPartitionValueList :: PartitionValueList
newPartitionValueList =
  PartitionValueList' :: [Text] -> PartitionValueList
PartitionValueList' {$sel:values:PartitionValueList' :: [Text]
values = [Text]
forall a. Monoid a => a
Prelude.mempty}

-- | The list of values.
partitionValueList_values :: Lens.Lens' PartitionValueList [Prelude.Text]
partitionValueList_values :: ([Text] -> f [Text]) -> PartitionValueList -> f PartitionValueList
partitionValueList_values = (PartitionValueList -> [Text])
-> (PartitionValueList -> [Text] -> PartitionValueList)
-> Lens PartitionValueList PartitionValueList [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartitionValueList' {[Text]
values :: [Text]
$sel:values:PartitionValueList' :: PartitionValueList -> [Text]
values} -> [Text]
values) (\s :: PartitionValueList
s@PartitionValueList' {} [Text]
a -> PartitionValueList
s {$sel:values:PartitionValueList' :: [Text]
values = [Text]
a} :: PartitionValueList) (([Text] -> f [Text])
 -> PartitionValueList -> f PartitionValueList)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> PartitionValueList
-> f PartitionValueList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable PartitionValueList

instance Prelude.NFData PartitionValueList

instance Core.ToJSON PartitionValueList where
  toJSON :: PartitionValueList -> Value
toJSON PartitionValueList' {[Text]
values :: [Text]
$sel:values:PartitionValueList' :: PartitionValueList -> [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Values" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
values)]
      )