{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MemoryDb.Types.Snapshot where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MemoryDb.Types.ClusterConfiguration
import Amazonka.MemoryDb.Types.DataTieringStatus
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 ARN (Amazon Resource Name) of the snapshot.
    Snapshot -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The configuration of the cluster from which the snapshot was taken
    Snapshot -> Maybe ClusterConfiguration
clusterConfiguration :: Prelude.Maybe ClusterConfiguration,
    -- | Enables data tiering. Data tiering is only supported for clusters using
    -- the r6gd node type. This parameter must be set when using r6gd nodes.
    -- For more information, see
    -- <https://docs.aws.amazon.com/memorydb/latest/devguide/data-tiering.html Data tiering>.
    Snapshot -> Maybe DataTieringStatus
dataTiering :: Prelude.Maybe DataTieringStatus,
    -- | 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,
    -- | Indicates whether the snapshot is from an automatic backup (automated)
    -- or was created manually (manual).
    Snapshot -> Maybe Text
source :: Prelude.Maybe Prelude.Text,
    -- | The status of the snapshot. Valid values: creating | available |
    -- restoring | copying | deleting.
    Snapshot -> Maybe Text
status :: Prelude.Maybe Prelude.Text
  }
  deriving (Snapshot -> Snapshot -> Bool
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]
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
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. 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:
--
-- 'arn', 'snapshot_arn' - The ARN (Amazon Resource Name) of the snapshot.
--
-- 'clusterConfiguration', 'snapshot_clusterConfiguration' - The configuration of the cluster from which the snapshot was taken
--
-- 'dataTiering', 'snapshot_dataTiering' - Enables data tiering. Data tiering is only supported for clusters using
-- the r6gd node type. This parameter must be set when using r6gd nodes.
-- For more information, see
-- <https://docs.aws.amazon.com/memorydb/latest/devguide/data-tiering.html Data tiering>.
--
-- 'kmsKeyId', 'snapshot_kmsKeyId' - The ID of the KMS key used to encrypt the snapshot.
--
-- 'name', 'snapshot_name' - The name of the snapshot
--
-- 'source', 'snapshot_source' - Indicates whether the snapshot is from an automatic backup (automated)
-- or was created manually (manual).
--
-- 'status', 'snapshot_status' - The status of the snapshot. Valid values: creating | available |
-- restoring | copying | deleting.
newSnapshot ::
  Snapshot
newSnapshot :: Snapshot
newSnapshot =
  Snapshot'
    { $sel:arn:Snapshot' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:clusterConfiguration:Snapshot' :: Maybe ClusterConfiguration
clusterConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:dataTiering:Snapshot' :: Maybe DataTieringStatus
dataTiering = forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:Snapshot' :: Maybe Text
kmsKeyId = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Snapshot' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:source:Snapshot' :: Maybe Text
source = forall a. Maybe a
Prelude.Nothing,
      $sel:status:Snapshot' :: Maybe Text
status = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN (Amazon Resource Name) of the snapshot.
snapshot_arn :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_arn :: Lens' Snapshot (Maybe Text)
snapshot_arn = 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 configuration of the cluster from which the snapshot was taken
snapshot_clusterConfiguration :: Lens.Lens' Snapshot (Prelude.Maybe ClusterConfiguration)
snapshot_clusterConfiguration :: Lens' Snapshot (Maybe ClusterConfiguration)
snapshot_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)

-- | Enables data tiering. Data tiering is only supported for clusters using
-- the r6gd node type. This parameter must be set when using r6gd nodes.
-- For more information, see
-- <https://docs.aws.amazon.com/memorydb/latest/devguide/data-tiering.html Data tiering>.
snapshot_dataTiering :: Lens.Lens' Snapshot (Prelude.Maybe DataTieringStatus)
snapshot_dataTiering :: Lens' Snapshot (Maybe DataTieringStatus)
snapshot_dataTiering = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Snapshot' {Maybe DataTieringStatus
dataTiering :: Maybe DataTieringStatus
$sel:dataTiering:Snapshot' :: Snapshot -> Maybe DataTieringStatus
dataTiering} -> Maybe DataTieringStatus
dataTiering) (\s :: Snapshot
s@Snapshot' {} Maybe DataTieringStatus
a -> Snapshot
s {$sel:dataTiering:Snapshot' :: Maybe DataTieringStatus
dataTiering = Maybe DataTieringStatus
a} :: Snapshot)

-- | The ID of the KMS key used to encrypt the snapshot.
snapshot_kmsKeyId :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_kmsKeyId :: Lens' Snapshot (Maybe Text)
snapshot_kmsKeyId = 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 :: Lens' Snapshot (Maybe Text)
snapshot_name = 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)

-- | 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 :: Lens' Snapshot (Maybe Text)
snapshot_source = 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)

-- | The status of the snapshot. Valid values: creating | available |
-- restoring | copying | deleting.
snapshot_status :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_status :: Lens' Snapshot (Maybe Text)
snapshot_status = 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)

instance Data.FromJSON Snapshot where
  parseJSON :: Value -> Parser Snapshot
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Snapshot"
      ( \Object
x ->
          Maybe Text
-> Maybe ClusterConfiguration
-> Maybe DataTieringStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Snapshot
Snapshot'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ARN")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ClusterConfiguration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DataTiering")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"KmsKeyId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Source")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Status")
      )

instance Prelude.Hashable Snapshot where
  hashWithSalt :: Int -> Snapshot -> Int
hashWithSalt Int
_salt Snapshot' {Maybe Text
Maybe DataTieringStatus
Maybe ClusterConfiguration
status :: Maybe Text
source :: Maybe Text
name :: Maybe Text
kmsKeyId :: Maybe Text
dataTiering :: Maybe DataTieringStatus
clusterConfiguration :: Maybe ClusterConfiguration
arn :: Maybe Text
$sel:status:Snapshot' :: Snapshot -> Maybe Text
$sel:source:Snapshot' :: Snapshot -> Maybe Text
$sel:name:Snapshot' :: Snapshot -> Maybe Text
$sel:kmsKeyId:Snapshot' :: Snapshot -> Maybe Text
$sel:dataTiering:Snapshot' :: Snapshot -> Maybe DataTieringStatus
$sel:clusterConfiguration:Snapshot' :: Snapshot -> Maybe ClusterConfiguration
$sel:arn:Snapshot' :: Snapshot -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ClusterConfiguration
clusterConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DataTieringStatus
dataTiering
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
source
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
status

instance Prelude.NFData Snapshot where
  rnf :: Snapshot -> ()
rnf Snapshot' {Maybe Text
Maybe DataTieringStatus
Maybe ClusterConfiguration
status :: Maybe Text
source :: Maybe Text
name :: Maybe Text
kmsKeyId :: Maybe Text
dataTiering :: Maybe DataTieringStatus
clusterConfiguration :: Maybe ClusterConfiguration
arn :: Maybe Text
$sel:status:Snapshot' :: Snapshot -> Maybe Text
$sel:source:Snapshot' :: Snapshot -> Maybe Text
$sel:name:Snapshot' :: Snapshot -> Maybe Text
$sel:kmsKeyId:Snapshot' :: Snapshot -> Maybe Text
$sel:dataTiering:Snapshot' :: Snapshot -> Maybe DataTieringStatus
$sel:clusterConfiguration:Snapshot' :: Snapshot -> Maybe ClusterConfiguration
$sel:arn:Snapshot' :: Snapshot -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ClusterConfiguration
clusterConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DataTieringStatus
dataTiering
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
source
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
status