{-# 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.IoTAnalytics.Types.DatastorePartitions
-- 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.IoTAnalytics.Types.DatastorePartitions where

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.DatastorePartition
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the partition dimensions in a data store.
--
-- /See:/ 'newDatastorePartitions' smart constructor.
data DatastorePartitions = DatastorePartitions'
  { -- | A list of partition dimensions in a data store.
    DatastorePartitions -> Maybe [DatastorePartition]
partitions :: Prelude.Maybe [DatastorePartition]
  }
  deriving (DatastorePartitions -> DatastorePartitions -> Bool
(DatastorePartitions -> DatastorePartitions -> Bool)
-> (DatastorePartitions -> DatastorePartitions -> Bool)
-> Eq DatastorePartitions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatastorePartitions -> DatastorePartitions -> Bool
$c/= :: DatastorePartitions -> DatastorePartitions -> Bool
== :: DatastorePartitions -> DatastorePartitions -> Bool
$c== :: DatastorePartitions -> DatastorePartitions -> Bool
Prelude.Eq, ReadPrec [DatastorePartitions]
ReadPrec DatastorePartitions
Int -> ReadS DatastorePartitions
ReadS [DatastorePartitions]
(Int -> ReadS DatastorePartitions)
-> ReadS [DatastorePartitions]
-> ReadPrec DatastorePartitions
-> ReadPrec [DatastorePartitions]
-> Read DatastorePartitions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatastorePartitions]
$creadListPrec :: ReadPrec [DatastorePartitions]
readPrec :: ReadPrec DatastorePartitions
$creadPrec :: ReadPrec DatastorePartitions
readList :: ReadS [DatastorePartitions]
$creadList :: ReadS [DatastorePartitions]
readsPrec :: Int -> ReadS DatastorePartitions
$creadsPrec :: Int -> ReadS DatastorePartitions
Prelude.Read, Int -> DatastorePartitions -> ShowS
[DatastorePartitions] -> ShowS
DatastorePartitions -> String
(Int -> DatastorePartitions -> ShowS)
-> (DatastorePartitions -> String)
-> ([DatastorePartitions] -> ShowS)
-> Show DatastorePartitions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatastorePartitions] -> ShowS
$cshowList :: [DatastorePartitions] -> ShowS
show :: DatastorePartitions -> String
$cshow :: DatastorePartitions -> String
showsPrec :: Int -> DatastorePartitions -> ShowS
$cshowsPrec :: Int -> DatastorePartitions -> ShowS
Prelude.Show, (forall x. DatastorePartitions -> Rep DatastorePartitions x)
-> (forall x. Rep DatastorePartitions x -> DatastorePartitions)
-> Generic DatastorePartitions
forall x. Rep DatastorePartitions x -> DatastorePartitions
forall x. DatastorePartitions -> Rep DatastorePartitions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatastorePartitions x -> DatastorePartitions
$cfrom :: forall x. DatastorePartitions -> Rep DatastorePartitions x
Prelude.Generic)

-- |
-- Create a value of 'DatastorePartitions' 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:
--
-- 'partitions', 'datastorePartitions_partitions' - A list of partition dimensions in a data store.
newDatastorePartitions ::
  DatastorePartitions
newDatastorePartitions :: DatastorePartitions
newDatastorePartitions =
  DatastorePartitions' :: Maybe [DatastorePartition] -> DatastorePartitions
DatastorePartitions' {$sel:partitions:DatastorePartitions' :: Maybe [DatastorePartition]
partitions = Maybe [DatastorePartition]
forall a. Maybe a
Prelude.Nothing}

-- | A list of partition dimensions in a data store.
datastorePartitions_partitions :: Lens.Lens' DatastorePartitions (Prelude.Maybe [DatastorePartition])
datastorePartitions_partitions :: (Maybe [DatastorePartition] -> f (Maybe [DatastorePartition]))
-> DatastorePartitions -> f DatastorePartitions
datastorePartitions_partitions = (DatastorePartitions -> Maybe [DatastorePartition])
-> (DatastorePartitions
    -> Maybe [DatastorePartition] -> DatastorePartitions)
-> Lens
     DatastorePartitions
     DatastorePartitions
     (Maybe [DatastorePartition])
     (Maybe [DatastorePartition])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatastorePartitions' {Maybe [DatastorePartition]
partitions :: Maybe [DatastorePartition]
$sel:partitions:DatastorePartitions' :: DatastorePartitions -> Maybe [DatastorePartition]
partitions} -> Maybe [DatastorePartition]
partitions) (\s :: DatastorePartitions
s@DatastorePartitions' {} Maybe [DatastorePartition]
a -> DatastorePartitions
s {$sel:partitions:DatastorePartitions' :: Maybe [DatastorePartition]
partitions = Maybe [DatastorePartition]
a} :: DatastorePartitions) ((Maybe [DatastorePartition] -> f (Maybe [DatastorePartition]))
 -> DatastorePartitions -> f DatastorePartitions)
-> ((Maybe [DatastorePartition] -> f (Maybe [DatastorePartition]))
    -> Maybe [DatastorePartition] -> f (Maybe [DatastorePartition]))
-> (Maybe [DatastorePartition] -> f (Maybe [DatastorePartition]))
-> DatastorePartitions
-> f DatastorePartitions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DatastorePartition]
  [DatastorePartition]
  [DatastorePartition]
  [DatastorePartition]
-> Iso
     (Maybe [DatastorePartition])
     (Maybe [DatastorePartition])
     (Maybe [DatastorePartition])
     (Maybe [DatastorePartition])
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
  [DatastorePartition]
  [DatastorePartition]
  [DatastorePartition]
  [DatastorePartition]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable DatastorePartitions

instance Prelude.NFData DatastorePartitions

instance Core.ToJSON DatastorePartitions where
  toJSON :: DatastorePartitions -> Value
toJSON DatastorePartitions' {Maybe [DatastorePartition]
partitions :: Maybe [DatastorePartition]
$sel:partitions:DatastorePartitions' :: DatastorePartitions -> Maybe [DatastorePartition]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"partitions" Text -> [DatastorePartition] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([DatastorePartition] -> Pair)
-> Maybe [DatastorePartition] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [DatastorePartition]
partitions]
      )