{-# 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.Snapshot
-- 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.Snapshot where

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

-- | Represents a copy of an entire cluster as of the time when the snapshot
-- was taken.
--
-- /See:/ 'newSnapshot' smart constructor.
data Snapshot = Snapshot'
  { -- | The status of the snapshot. Valid values: creating | available |
    -- restoring | copying | deleting.
    Snapshot -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The ARN (Amazon Resource Name) of the snapshot.
    Snapshot -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the KMS key used to encrypt the snapshot.
    Snapshot -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The name of the snapshot
    Snapshot -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The configuration of the cluster from which the snapshot was taken
    Snapshot -> Maybe ClusterConfiguration
clusterConfiguration :: Prelude.Maybe ClusterConfiguration,
    -- | Indicates whether the snapshot is from an automatic backup (automated)
    -- or was created manually (manual).
    Snapshot -> Maybe Text
source :: Prelude.Maybe Prelude.Text
  }
  deriving (Snapshot -> Snapshot -> Bool
(Snapshot -> Snapshot -> Bool)
-> (Snapshot -> Snapshot -> Bool) -> Eq Snapshot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Snapshot -> Snapshot -> Bool
$c/= :: Snapshot -> Snapshot -> Bool
== :: Snapshot -> Snapshot -> Bool
$c== :: Snapshot -> Snapshot -> Bool
Prelude.Eq, ReadPrec [Snapshot]
ReadPrec Snapshot
Int -> ReadS Snapshot
ReadS [Snapshot]
(Int -> ReadS Snapshot)
-> ReadS [Snapshot]
-> ReadPrec Snapshot
-> ReadPrec [Snapshot]
-> Read Snapshot
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Snapshot]
$creadListPrec :: ReadPrec [Snapshot]
readPrec :: ReadPrec Snapshot
$creadPrec :: ReadPrec Snapshot
readList :: ReadS [Snapshot]
$creadList :: ReadS [Snapshot]
readsPrec :: Int -> ReadS Snapshot
$creadsPrec :: Int -> ReadS Snapshot
Prelude.Read, Int -> Snapshot -> ShowS
[Snapshot] -> ShowS
Snapshot -> String
(Int -> Snapshot -> ShowS)
-> (Snapshot -> String) -> ([Snapshot] -> ShowS) -> Show Snapshot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Snapshot] -> ShowS
$cshowList :: [Snapshot] -> ShowS
show :: Snapshot -> String
$cshow :: Snapshot -> String
showsPrec :: Int -> Snapshot -> ShowS
$cshowsPrec :: Int -> Snapshot -> ShowS
Prelude.Show, (forall x. Snapshot -> Rep Snapshot x)
-> (forall x. Rep Snapshot x -> Snapshot) -> Generic Snapshot
forall x. Rep Snapshot x -> Snapshot
forall x. Snapshot -> Rep Snapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Snapshot x -> Snapshot
$cfrom :: forall x. Snapshot -> Rep Snapshot x
Prelude.Generic)

-- |
-- Create a value of 'Snapshot' 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:
--
-- 'status', 'snapshot_status' - The status of the snapshot. Valid values: creating | available |
-- restoring | copying | deleting.
--
-- 'arn', 'snapshot_arn' - The ARN (Amazon Resource Name) of the snapshot.
--
-- 'kmsKeyId', 'snapshot_kmsKeyId' - The ID of the KMS key used to encrypt the snapshot.
--
-- 'name', 'snapshot_name' - The name of the snapshot
--
-- 'clusterConfiguration', 'snapshot_clusterConfiguration' - The configuration of the cluster from which the snapshot was taken
--
-- 'source', 'snapshot_source' - Indicates whether the snapshot is from an automatic backup (automated)
-- or was created manually (manual).
newSnapshot ::
  Snapshot
newSnapshot :: Snapshot
newSnapshot =
  Snapshot' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ClusterConfiguration
-> Maybe Text
-> Snapshot
Snapshot'
    { $sel:status:Snapshot' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:Snapshot' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:Snapshot' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Snapshot' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterConfiguration:Snapshot' :: Maybe ClusterConfiguration
clusterConfiguration = Maybe ClusterConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:source:Snapshot' :: Maybe Text
source = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the snapshot. Valid values: creating | available |
-- restoring | copying | deleting.
snapshot_status :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_status :: (Maybe Text -> f (Maybe Text)) -> Snapshot -> f Snapshot
snapshot_status = (Snapshot -> Maybe Text)
-> (Snapshot -> Maybe Text -> Snapshot)
-> Lens Snapshot Snapshot (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Snapshot' {Maybe Text
status :: Maybe Text
$sel:status:Snapshot' :: Snapshot -> Maybe Text
status} -> Maybe Text
status) (\s :: Snapshot
s@Snapshot' {} Maybe Text
a -> Snapshot
s {$sel:status:Snapshot' :: Maybe Text
status = Maybe Text
a} :: Snapshot)

-- | The ARN (Amazon Resource Name) of the snapshot.
snapshot_arn :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_arn :: (Maybe Text -> f (Maybe Text)) -> Snapshot -> f Snapshot
snapshot_arn = (Snapshot -> Maybe Text)
-> (Snapshot -> Maybe Text -> Snapshot)
-> Lens Snapshot Snapshot (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Snapshot' {Maybe Text
arn :: Maybe Text
$sel:arn:Snapshot' :: Snapshot -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Snapshot
s@Snapshot' {} Maybe Text
a -> Snapshot
s {$sel:arn:Snapshot' :: Maybe Text
arn = Maybe Text
a} :: Snapshot)

-- | The ID of the KMS key used to encrypt the snapshot.
snapshot_kmsKeyId :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_kmsKeyId :: (Maybe Text -> f (Maybe Text)) -> Snapshot -> f Snapshot
snapshot_kmsKeyId = (Snapshot -> Maybe Text)
-> (Snapshot -> Maybe Text -> Snapshot)
-> Lens Snapshot Snapshot (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Snapshot' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:Snapshot' :: Snapshot -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: Snapshot
s@Snapshot' {} Maybe Text
a -> Snapshot
s {$sel:kmsKeyId:Snapshot' :: Maybe Text
kmsKeyId = Maybe Text
a} :: Snapshot)

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

-- | The configuration of the cluster from which the snapshot was taken
snapshot_clusterConfiguration :: Lens.Lens' Snapshot (Prelude.Maybe ClusterConfiguration)
snapshot_clusterConfiguration :: (Maybe ClusterConfiguration -> f (Maybe ClusterConfiguration))
-> Snapshot -> f Snapshot
snapshot_clusterConfiguration = (Snapshot -> Maybe ClusterConfiguration)
-> (Snapshot -> Maybe ClusterConfiguration -> Snapshot)
-> Lens
     Snapshot
     Snapshot
     (Maybe ClusterConfiguration)
     (Maybe ClusterConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Snapshot' {Maybe ClusterConfiguration
clusterConfiguration :: Maybe ClusterConfiguration
$sel:clusterConfiguration:Snapshot' :: Snapshot -> Maybe ClusterConfiguration
clusterConfiguration} -> Maybe ClusterConfiguration
clusterConfiguration) (\s :: Snapshot
s@Snapshot' {} Maybe ClusterConfiguration
a -> Snapshot
s {$sel:clusterConfiguration:Snapshot' :: Maybe ClusterConfiguration
clusterConfiguration = Maybe ClusterConfiguration
a} :: Snapshot)

-- | Indicates whether the snapshot is from an automatic backup (automated)
-- or was created manually (manual).
snapshot_source :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_source :: (Maybe Text -> f (Maybe Text)) -> Snapshot -> f Snapshot
snapshot_source = (Snapshot -> Maybe Text)
-> (Snapshot -> Maybe Text -> Snapshot)
-> Lens Snapshot Snapshot (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Snapshot' {Maybe Text
source :: Maybe Text
$sel:source:Snapshot' :: Snapshot -> Maybe Text
source} -> Maybe Text
source) (\s :: Snapshot
s@Snapshot' {} Maybe Text
a -> Snapshot
s {$sel:source:Snapshot' :: Maybe Text
source = Maybe Text
a} :: Snapshot)

instance Core.FromJSON Snapshot where
  parseJSON :: Value -> Parser Snapshot
parseJSON =
    String -> (Object -> Parser Snapshot) -> Value -> Parser Snapshot
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Snapshot"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ClusterConfiguration
-> Maybe Text
-> Snapshot
Snapshot'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe ClusterConfiguration
 -> Maybe Text
 -> Snapshot)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe ClusterConfiguration
      -> Maybe Text
      -> Snapshot)
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
"Status")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe ClusterConfiguration
   -> Maybe Text
   -> Snapshot)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe ClusterConfiguration
      -> Maybe Text
      -> Snapshot)
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
"ARN")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe ClusterConfiguration
   -> Maybe Text
   -> Snapshot)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe ClusterConfiguration -> Maybe Text -> Snapshot)
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
"KmsKeyId")
            Parser
  (Maybe Text
   -> Maybe ClusterConfiguration -> Maybe Text -> Snapshot)
-> Parser (Maybe Text)
-> Parser (Maybe ClusterConfiguration -> Maybe Text -> Snapshot)
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 ClusterConfiguration -> Maybe Text -> Snapshot)
-> Parser (Maybe ClusterConfiguration)
-> Parser (Maybe Text -> Snapshot)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ClusterConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClusterConfiguration")
            Parser (Maybe Text -> Snapshot)
-> Parser (Maybe Text) -> Parser Snapshot
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
"Source")
      )

instance Prelude.Hashable Snapshot

instance Prelude.NFData Snapshot