{-# 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.RDSData.Types.ArrayValue
-- 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.RDSData.Types.ArrayValue where

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

-- | Contains an array.
--
-- /See:/ 'newArrayValue' smart constructor.
data ArrayValue = ArrayValue'
  { -- | An array of floating point numbers.
    ArrayValue -> Maybe [Integer]
longValues :: Prelude.Maybe [Prelude.Integer],
    -- | An array of integers.
    ArrayValue -> Maybe [Double]
doubleValues :: Prelude.Maybe [Prelude.Double],
    -- | An array of strings.
    ArrayValue -> Maybe [Text]
stringValues :: Prelude.Maybe [Prelude.Text],
    -- | An array of arrays.
    ArrayValue -> Maybe [ArrayValue]
arrayValues :: Prelude.Maybe [ArrayValue],
    -- | An array of Boolean values.
    ArrayValue -> Maybe [Bool]
booleanValues :: Prelude.Maybe [Prelude.Bool]
  }
  deriving (ArrayValue -> ArrayValue -> Bool
(ArrayValue -> ArrayValue -> Bool)
-> (ArrayValue -> ArrayValue -> Bool) -> Eq ArrayValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArrayValue -> ArrayValue -> Bool
$c/= :: ArrayValue -> ArrayValue -> Bool
== :: ArrayValue -> ArrayValue -> Bool
$c== :: ArrayValue -> ArrayValue -> Bool
Prelude.Eq, ReadPrec [ArrayValue]
ReadPrec ArrayValue
Int -> ReadS ArrayValue
ReadS [ArrayValue]
(Int -> ReadS ArrayValue)
-> ReadS [ArrayValue]
-> ReadPrec ArrayValue
-> ReadPrec [ArrayValue]
-> Read ArrayValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ArrayValue]
$creadListPrec :: ReadPrec [ArrayValue]
readPrec :: ReadPrec ArrayValue
$creadPrec :: ReadPrec ArrayValue
readList :: ReadS [ArrayValue]
$creadList :: ReadS [ArrayValue]
readsPrec :: Int -> ReadS ArrayValue
$creadsPrec :: Int -> ReadS ArrayValue
Prelude.Read, Int -> ArrayValue -> ShowS
[ArrayValue] -> ShowS
ArrayValue -> String
(Int -> ArrayValue -> ShowS)
-> (ArrayValue -> String)
-> ([ArrayValue] -> ShowS)
-> Show ArrayValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ArrayValue] -> ShowS
$cshowList :: [ArrayValue] -> ShowS
show :: ArrayValue -> String
$cshow :: ArrayValue -> String
showsPrec :: Int -> ArrayValue -> ShowS
$cshowsPrec :: Int -> ArrayValue -> ShowS
Prelude.Show, (forall x. ArrayValue -> Rep ArrayValue x)
-> (forall x. Rep ArrayValue x -> ArrayValue) -> Generic ArrayValue
forall x. Rep ArrayValue x -> ArrayValue
forall x. ArrayValue -> Rep ArrayValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ArrayValue x -> ArrayValue
$cfrom :: forall x. ArrayValue -> Rep ArrayValue x
Prelude.Generic)

-- |
-- Create a value of 'ArrayValue' 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:
--
-- 'longValues', 'arrayValue_longValues' - An array of floating point numbers.
--
-- 'doubleValues', 'arrayValue_doubleValues' - An array of integers.
--
-- 'stringValues', 'arrayValue_stringValues' - An array of strings.
--
-- 'arrayValues', 'arrayValue_arrayValues' - An array of arrays.
--
-- 'booleanValues', 'arrayValue_booleanValues' - An array of Boolean values.
newArrayValue ::
  ArrayValue
newArrayValue :: ArrayValue
newArrayValue =
  ArrayValue' :: Maybe [Integer]
-> Maybe [Double]
-> Maybe [Text]
-> Maybe [ArrayValue]
-> Maybe [Bool]
-> ArrayValue
ArrayValue'
    { $sel:longValues:ArrayValue' :: Maybe [Integer]
longValues = Maybe [Integer]
forall a. Maybe a
Prelude.Nothing,
      $sel:doubleValues:ArrayValue' :: Maybe [Double]
doubleValues = Maybe [Double]
forall a. Maybe a
Prelude.Nothing,
      $sel:stringValues:ArrayValue' :: Maybe [Text]
stringValues = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:arrayValues:ArrayValue' :: Maybe [ArrayValue]
arrayValues = Maybe [ArrayValue]
forall a. Maybe a
Prelude.Nothing,
      $sel:booleanValues:ArrayValue' :: Maybe [Bool]
booleanValues = Maybe [Bool]
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of floating point numbers.
arrayValue_longValues :: Lens.Lens' ArrayValue (Prelude.Maybe [Prelude.Integer])
arrayValue_longValues :: (Maybe [Integer] -> f (Maybe [Integer]))
-> ArrayValue -> f ArrayValue
arrayValue_longValues = (ArrayValue -> Maybe [Integer])
-> (ArrayValue -> Maybe [Integer] -> ArrayValue)
-> Lens ArrayValue ArrayValue (Maybe [Integer]) (Maybe [Integer])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArrayValue' {Maybe [Integer]
longValues :: Maybe [Integer]
$sel:longValues:ArrayValue' :: ArrayValue -> Maybe [Integer]
longValues} -> Maybe [Integer]
longValues) (\s :: ArrayValue
s@ArrayValue' {} Maybe [Integer]
a -> ArrayValue
s {$sel:longValues:ArrayValue' :: Maybe [Integer]
longValues = Maybe [Integer]
a} :: ArrayValue) ((Maybe [Integer] -> f (Maybe [Integer]))
 -> ArrayValue -> f ArrayValue)
-> ((Maybe [Integer] -> f (Maybe [Integer]))
    -> Maybe [Integer] -> f (Maybe [Integer]))
-> (Maybe [Integer] -> f (Maybe [Integer]))
-> ArrayValue
-> f ArrayValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Integer] [Integer] [Integer] [Integer]
-> Iso
     (Maybe [Integer])
     (Maybe [Integer])
     (Maybe [Integer])
     (Maybe [Integer])
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 AnIso [Integer] [Integer] [Integer] [Integer]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of integers.
arrayValue_doubleValues :: Lens.Lens' ArrayValue (Prelude.Maybe [Prelude.Double])
arrayValue_doubleValues :: (Maybe [Double] -> f (Maybe [Double]))
-> ArrayValue -> f ArrayValue
arrayValue_doubleValues = (ArrayValue -> Maybe [Double])
-> (ArrayValue -> Maybe [Double] -> ArrayValue)
-> Lens ArrayValue ArrayValue (Maybe [Double]) (Maybe [Double])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArrayValue' {Maybe [Double]
doubleValues :: Maybe [Double]
$sel:doubleValues:ArrayValue' :: ArrayValue -> Maybe [Double]
doubleValues} -> Maybe [Double]
doubleValues) (\s :: ArrayValue
s@ArrayValue' {} Maybe [Double]
a -> ArrayValue
s {$sel:doubleValues:ArrayValue' :: Maybe [Double]
doubleValues = Maybe [Double]
a} :: ArrayValue) ((Maybe [Double] -> f (Maybe [Double]))
 -> ArrayValue -> f ArrayValue)
-> ((Maybe [Double] -> f (Maybe [Double]))
    -> Maybe [Double] -> f (Maybe [Double]))
-> (Maybe [Double] -> f (Maybe [Double]))
-> ArrayValue
-> f ArrayValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Double] [Double] [Double] [Double]
-> Iso
     (Maybe [Double]) (Maybe [Double]) (Maybe [Double]) (Maybe [Double])
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 AnIso [Double] [Double] [Double] [Double]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of strings.
arrayValue_stringValues :: Lens.Lens' ArrayValue (Prelude.Maybe [Prelude.Text])
arrayValue_stringValues :: (Maybe [Text] -> f (Maybe [Text])) -> ArrayValue -> f ArrayValue
arrayValue_stringValues = (ArrayValue -> Maybe [Text])
-> (ArrayValue -> Maybe [Text] -> ArrayValue)
-> Lens ArrayValue ArrayValue (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArrayValue' {Maybe [Text]
stringValues :: Maybe [Text]
$sel:stringValues:ArrayValue' :: ArrayValue -> Maybe [Text]
stringValues} -> Maybe [Text]
stringValues) (\s :: ArrayValue
s@ArrayValue' {} Maybe [Text]
a -> ArrayValue
s {$sel:stringValues:ArrayValue' :: Maybe [Text]
stringValues = Maybe [Text]
a} :: ArrayValue) ((Maybe [Text] -> f (Maybe [Text])) -> ArrayValue -> f ArrayValue)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ArrayValue
-> f ArrayValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of arrays.
arrayValue_arrayValues :: Lens.Lens' ArrayValue (Prelude.Maybe [ArrayValue])
arrayValue_arrayValues :: (Maybe [ArrayValue] -> f (Maybe [ArrayValue]))
-> ArrayValue -> f ArrayValue
arrayValue_arrayValues = (ArrayValue -> Maybe [ArrayValue])
-> (ArrayValue -> Maybe [ArrayValue] -> ArrayValue)
-> Lens
     ArrayValue ArrayValue (Maybe [ArrayValue]) (Maybe [ArrayValue])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArrayValue' {Maybe [ArrayValue]
arrayValues :: Maybe [ArrayValue]
$sel:arrayValues:ArrayValue' :: ArrayValue -> Maybe [ArrayValue]
arrayValues} -> Maybe [ArrayValue]
arrayValues) (\s :: ArrayValue
s@ArrayValue' {} Maybe [ArrayValue]
a -> ArrayValue
s {$sel:arrayValues:ArrayValue' :: Maybe [ArrayValue]
arrayValues = Maybe [ArrayValue]
a} :: ArrayValue) ((Maybe [ArrayValue] -> f (Maybe [ArrayValue]))
 -> ArrayValue -> f ArrayValue)
-> ((Maybe [ArrayValue] -> f (Maybe [ArrayValue]))
    -> Maybe [ArrayValue] -> f (Maybe [ArrayValue]))
-> (Maybe [ArrayValue] -> f (Maybe [ArrayValue]))
-> ArrayValue
-> f ArrayValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ArrayValue] [ArrayValue] [ArrayValue] [ArrayValue]
-> Iso
     (Maybe [ArrayValue])
     (Maybe [ArrayValue])
     (Maybe [ArrayValue])
     (Maybe [ArrayValue])
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 AnIso [ArrayValue] [ArrayValue] [ArrayValue] [ArrayValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of Boolean values.
arrayValue_booleanValues :: Lens.Lens' ArrayValue (Prelude.Maybe [Prelude.Bool])
arrayValue_booleanValues :: (Maybe [Bool] -> f (Maybe [Bool])) -> ArrayValue -> f ArrayValue
arrayValue_booleanValues = (ArrayValue -> Maybe [Bool])
-> (ArrayValue -> Maybe [Bool] -> ArrayValue)
-> Lens ArrayValue ArrayValue (Maybe [Bool]) (Maybe [Bool])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ArrayValue' {Maybe [Bool]
booleanValues :: Maybe [Bool]
$sel:booleanValues:ArrayValue' :: ArrayValue -> Maybe [Bool]
booleanValues} -> Maybe [Bool]
booleanValues) (\s :: ArrayValue
s@ArrayValue' {} Maybe [Bool]
a -> ArrayValue
s {$sel:booleanValues:ArrayValue' :: Maybe [Bool]
booleanValues = Maybe [Bool]
a} :: ArrayValue) ((Maybe [Bool] -> f (Maybe [Bool])) -> ArrayValue -> f ArrayValue)
-> ((Maybe [Bool] -> f (Maybe [Bool]))
    -> Maybe [Bool] -> f (Maybe [Bool]))
-> (Maybe [Bool] -> f (Maybe [Bool]))
-> ArrayValue
-> f ArrayValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Bool] [Bool] [Bool] [Bool]
-> Iso (Maybe [Bool]) (Maybe [Bool]) (Maybe [Bool]) (Maybe [Bool])
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 AnIso [Bool] [Bool] [Bool] [Bool]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ArrayValue where
  parseJSON :: Value -> Parser ArrayValue
parseJSON =
    String
-> (Object -> Parser ArrayValue) -> Value -> Parser ArrayValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ArrayValue"
      ( \Object
x ->
          Maybe [Integer]
-> Maybe [Double]
-> Maybe [Text]
-> Maybe [ArrayValue]
-> Maybe [Bool]
-> ArrayValue
ArrayValue'
            (Maybe [Integer]
 -> Maybe [Double]
 -> Maybe [Text]
 -> Maybe [ArrayValue]
 -> Maybe [Bool]
 -> ArrayValue)
-> Parser (Maybe [Integer])
-> Parser
     (Maybe [Double]
      -> Maybe [Text]
      -> Maybe [ArrayValue]
      -> Maybe [Bool]
      -> ArrayValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Integer]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"longValues" Parser (Maybe (Maybe [Integer]))
-> Maybe [Integer] -> Parser (Maybe [Integer])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Integer]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [Double]
   -> Maybe [Text]
   -> Maybe [ArrayValue]
   -> Maybe [Bool]
   -> ArrayValue)
-> Parser (Maybe [Double])
-> Parser
     (Maybe [Text] -> Maybe [ArrayValue] -> Maybe [Bool] -> ArrayValue)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Double]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"doubleValues" Parser (Maybe (Maybe [Double]))
-> Maybe [Double] -> Parser (Maybe [Double])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Double]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [Text] -> Maybe [ArrayValue] -> Maybe [Bool] -> ArrayValue)
-> Parser (Maybe [Text])
-> Parser (Maybe [ArrayValue] -> Maybe [Bool] -> ArrayValue)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"stringValues" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [ArrayValue] -> Maybe [Bool] -> ArrayValue)
-> Parser (Maybe [ArrayValue])
-> Parser (Maybe [Bool] -> ArrayValue)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ArrayValue]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"arrayValues" Parser (Maybe (Maybe [ArrayValue]))
-> Maybe [ArrayValue] -> Parser (Maybe [ArrayValue])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ArrayValue]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Bool] -> ArrayValue)
-> Parser (Maybe [Bool]) -> Parser ArrayValue
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Bool]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"booleanValues" Parser (Maybe (Maybe [Bool]))
-> Maybe [Bool] -> Parser (Maybe [Bool])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Bool]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ArrayValue

instance Prelude.NFData ArrayValue

instance Core.ToJSON ArrayValue where
  toJSON :: ArrayValue -> Value
toJSON ArrayValue' {Maybe [Bool]
Maybe [Double]
Maybe [Integer]
Maybe [Text]
Maybe [ArrayValue]
booleanValues :: Maybe [Bool]
arrayValues :: Maybe [ArrayValue]
stringValues :: Maybe [Text]
doubleValues :: Maybe [Double]
longValues :: Maybe [Integer]
$sel:booleanValues:ArrayValue' :: ArrayValue -> Maybe [Bool]
$sel:arrayValues:ArrayValue' :: ArrayValue -> Maybe [ArrayValue]
$sel:stringValues:ArrayValue' :: ArrayValue -> Maybe [Text]
$sel:doubleValues:ArrayValue' :: ArrayValue -> Maybe [Double]
$sel:longValues:ArrayValue' :: ArrayValue -> Maybe [Integer]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"longValues" Text -> [Integer] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Integer] -> Pair) -> Maybe [Integer] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Integer]
longValues,
            (Text
"doubleValues" Text -> [Double] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Double] -> Pair) -> Maybe [Double] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Double]
doubleValues,
            (Text
"stringValues" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
stringValues,
            (Text
"arrayValues" Text -> [ArrayValue] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ArrayValue] -> Pair) -> Maybe [ArrayValue] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ArrayValue]
arrayValues,
            (Text
"booleanValues" Text -> [Bool] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Bool] -> Pair) -> Maybe [Bool] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Bool]
booleanValues
          ]
      )