{-# 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.MemoryDb.Types.ShardDetail
-- 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.MemoryDb.Types.ShardDetail where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MemoryDb.Types.ShardConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Provides details of a shard in a snapshot
--
-- /See:/ 'newShardDetail' smart constructor.
data ShardDetail = ShardDetail'
  { -- | The size of the shard\'s snapshot
    ShardDetail -> Maybe Text
size :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the shard\'s snapshot was created
    ShardDetail -> Maybe POSIX
snapshotCreationTime :: Prelude.Maybe Core.POSIX,
    -- | The name of the shard
    ShardDetail -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The configuration details of the shard
    ShardDetail -> Maybe ShardConfiguration
configuration :: Prelude.Maybe ShardConfiguration
  }
  deriving (ShardDetail -> ShardDetail -> Bool
(ShardDetail -> ShardDetail -> Bool)
-> (ShardDetail -> ShardDetail -> Bool) -> Eq ShardDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ShardDetail -> ShardDetail -> Bool
$c/= :: ShardDetail -> ShardDetail -> Bool
== :: ShardDetail -> ShardDetail -> Bool
$c== :: ShardDetail -> ShardDetail -> Bool
Prelude.Eq, ReadPrec [ShardDetail]
ReadPrec ShardDetail
Int -> ReadS ShardDetail
ReadS [ShardDetail]
(Int -> ReadS ShardDetail)
-> ReadS [ShardDetail]
-> ReadPrec ShardDetail
-> ReadPrec [ShardDetail]
-> Read ShardDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ShardDetail]
$creadListPrec :: ReadPrec [ShardDetail]
readPrec :: ReadPrec ShardDetail
$creadPrec :: ReadPrec ShardDetail
readList :: ReadS [ShardDetail]
$creadList :: ReadS [ShardDetail]
readsPrec :: Int -> ReadS ShardDetail
$creadsPrec :: Int -> ReadS ShardDetail
Prelude.Read, Int -> ShardDetail -> ShowS
[ShardDetail] -> ShowS
ShardDetail -> String
(Int -> ShardDetail -> ShowS)
-> (ShardDetail -> String)
-> ([ShardDetail] -> ShowS)
-> Show ShardDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShardDetail] -> ShowS
$cshowList :: [ShardDetail] -> ShowS
show :: ShardDetail -> String
$cshow :: ShardDetail -> String
showsPrec :: Int -> ShardDetail -> ShowS
$cshowsPrec :: Int -> ShardDetail -> ShowS
Prelude.Show, (forall x. ShardDetail -> Rep ShardDetail x)
-> (forall x. Rep ShardDetail x -> ShardDetail)
-> Generic ShardDetail
forall x. Rep ShardDetail x -> ShardDetail
forall x. ShardDetail -> Rep ShardDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ShardDetail x -> ShardDetail
$cfrom :: forall x. ShardDetail -> Rep ShardDetail x
Prelude.Generic)

-- |
-- Create a value of 'ShardDetail' 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:
--
-- 'size', 'shardDetail_size' - The size of the shard\'s snapshot
--
-- 'snapshotCreationTime', 'shardDetail_snapshotCreationTime' - The date and time that the shard\'s snapshot was created
--
-- 'name', 'shardDetail_name' - The name of the shard
--
-- 'configuration', 'shardDetail_configuration' - The configuration details of the shard
newShardDetail ::
  ShardDetail
newShardDetail :: ShardDetail
newShardDetail =
  ShardDetail' :: Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe ShardConfiguration
-> ShardDetail
ShardDetail'
    { $sel:size:ShardDetail' :: Maybe Text
size = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotCreationTime:ShardDetail' :: Maybe POSIX
snapshotCreationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ShardDetail' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:configuration:ShardDetail' :: Maybe ShardConfiguration
configuration = Maybe ShardConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | The size of the shard\'s snapshot
shardDetail_size :: Lens.Lens' ShardDetail (Prelude.Maybe Prelude.Text)
shardDetail_size :: (Maybe Text -> f (Maybe Text)) -> ShardDetail -> f ShardDetail
shardDetail_size = (ShardDetail -> Maybe Text)
-> (ShardDetail -> Maybe Text -> ShardDetail)
-> Lens ShardDetail ShardDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShardDetail' {Maybe Text
size :: Maybe Text
$sel:size:ShardDetail' :: ShardDetail -> Maybe Text
size} -> Maybe Text
size) (\s :: ShardDetail
s@ShardDetail' {} Maybe Text
a -> ShardDetail
s {$sel:size:ShardDetail' :: Maybe Text
size = Maybe Text
a} :: ShardDetail)

-- | The date and time that the shard\'s snapshot was created
shardDetail_snapshotCreationTime :: Lens.Lens' ShardDetail (Prelude.Maybe Prelude.UTCTime)
shardDetail_snapshotCreationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ShardDetail -> f ShardDetail
shardDetail_snapshotCreationTime = (ShardDetail -> Maybe POSIX)
-> (ShardDetail -> Maybe POSIX -> ShardDetail)
-> Lens ShardDetail ShardDetail (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShardDetail' {Maybe POSIX
snapshotCreationTime :: Maybe POSIX
$sel:snapshotCreationTime:ShardDetail' :: ShardDetail -> Maybe POSIX
snapshotCreationTime} -> Maybe POSIX
snapshotCreationTime) (\s :: ShardDetail
s@ShardDetail' {} Maybe POSIX
a -> ShardDetail
s {$sel:snapshotCreationTime:ShardDetail' :: Maybe POSIX
snapshotCreationTime = Maybe POSIX
a} :: ShardDetail) ((Maybe POSIX -> f (Maybe POSIX)) -> ShardDetail -> f ShardDetail)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ShardDetail
-> f ShardDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the shard
shardDetail_name :: Lens.Lens' ShardDetail (Prelude.Maybe Prelude.Text)
shardDetail_name :: (Maybe Text -> f (Maybe Text)) -> ShardDetail -> f ShardDetail
shardDetail_name = (ShardDetail -> Maybe Text)
-> (ShardDetail -> Maybe Text -> ShardDetail)
-> Lens ShardDetail ShardDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShardDetail' {Maybe Text
name :: Maybe Text
$sel:name:ShardDetail' :: ShardDetail -> Maybe Text
name} -> Maybe Text
name) (\s :: ShardDetail
s@ShardDetail' {} Maybe Text
a -> ShardDetail
s {$sel:name:ShardDetail' :: Maybe Text
name = Maybe Text
a} :: ShardDetail)

-- | The configuration details of the shard
shardDetail_configuration :: Lens.Lens' ShardDetail (Prelude.Maybe ShardConfiguration)
shardDetail_configuration :: (Maybe ShardConfiguration -> f (Maybe ShardConfiguration))
-> ShardDetail -> f ShardDetail
shardDetail_configuration = (ShardDetail -> Maybe ShardConfiguration)
-> (ShardDetail -> Maybe ShardConfiguration -> ShardDetail)
-> Lens
     ShardDetail
     ShardDetail
     (Maybe ShardConfiguration)
     (Maybe ShardConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ShardDetail' {Maybe ShardConfiguration
configuration :: Maybe ShardConfiguration
$sel:configuration:ShardDetail' :: ShardDetail -> Maybe ShardConfiguration
configuration} -> Maybe ShardConfiguration
configuration) (\s :: ShardDetail
s@ShardDetail' {} Maybe ShardConfiguration
a -> ShardDetail
s {$sel:configuration:ShardDetail' :: Maybe ShardConfiguration
configuration = Maybe ShardConfiguration
a} :: ShardDetail)

instance Core.FromJSON ShardDetail where
  parseJSON :: Value -> Parser ShardDetail
parseJSON =
    String
-> (Object -> Parser ShardDetail) -> Value -> Parser ShardDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ShardDetail"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe ShardConfiguration
-> ShardDetail
ShardDetail'
            (Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe ShardConfiguration
 -> ShardDetail)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Text -> Maybe ShardConfiguration -> ShardDetail)
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
"Size")
            Parser
  (Maybe POSIX
   -> Maybe Text -> Maybe ShardConfiguration -> ShardDetail)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe ShardConfiguration -> ShardDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SnapshotCreationTime")
            Parser (Maybe Text -> Maybe ShardConfiguration -> ShardDetail)
-> Parser (Maybe Text)
-> Parser (Maybe ShardConfiguration -> ShardDetail)
forall (f :: * -> *) a b. Applicative f => 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
"Name")
            Parser (Maybe ShardConfiguration -> ShardDetail)
-> Parser (Maybe ShardConfiguration) -> Parser ShardDetail
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ShardConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Configuration")
      )

instance Prelude.Hashable ShardDetail

instance Prelude.NFData ShardDetail