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

import qualified Amazonka.Core as Core
import Amazonka.DirectoryService.Types.SnapshotStatus
import Amazonka.DirectoryService.Types.SnapshotType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a directory snapshot.
--
-- /See:/ 'newSnapshot' smart constructor.
data Snapshot = Snapshot'
  { -- | The snapshot status.
    Snapshot -> Maybe SnapshotStatus
status :: Prelude.Maybe SnapshotStatus,
    -- | The directory identifier.
    Snapshot -> Maybe Text
directoryId :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the snapshot was taken.
    Snapshot -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | The descriptive name of the snapshot.
    Snapshot -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The snapshot type.
    Snapshot -> Maybe SnapshotType
type' :: Prelude.Maybe SnapshotType,
    -- | The snapshot identifier.
    Snapshot -> Maybe Text
snapshotId :: 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 snapshot status.
--
-- 'directoryId', 'snapshot_directoryId' - The directory identifier.
--
-- 'startTime', 'snapshot_startTime' - The date and time that the snapshot was taken.
--
-- 'name', 'snapshot_name' - The descriptive name of the snapshot.
--
-- 'type'', 'snapshot_type' - The snapshot type.
--
-- 'snapshotId', 'snapshot_snapshotId' - The snapshot identifier.
newSnapshot ::
  Snapshot
newSnapshot :: Snapshot
newSnapshot =
  Snapshot' :: Maybe SnapshotStatus
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe SnapshotType
-> Maybe Text
-> Snapshot
Snapshot'
    { $sel:status:Snapshot' :: Maybe SnapshotStatus
status = Maybe SnapshotStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:directoryId:Snapshot' :: Maybe Text
directoryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:Snapshot' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Snapshot' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Snapshot' :: Maybe SnapshotType
type' = Maybe SnapshotType
forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotId:Snapshot' :: Maybe Text
snapshotId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The snapshot status.
snapshot_status :: Lens.Lens' Snapshot (Prelude.Maybe SnapshotStatus)
snapshot_status :: (Maybe SnapshotStatus -> f (Maybe SnapshotStatus))
-> Snapshot -> f Snapshot
snapshot_status = (Snapshot -> Maybe SnapshotStatus)
-> (Snapshot -> Maybe SnapshotStatus -> Snapshot)
-> Lens
     Snapshot Snapshot (Maybe SnapshotStatus) (Maybe SnapshotStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Snapshot' {Maybe SnapshotStatus
status :: Maybe SnapshotStatus
$sel:status:Snapshot' :: Snapshot -> Maybe SnapshotStatus
status} -> Maybe SnapshotStatus
status) (\s :: Snapshot
s@Snapshot' {} Maybe SnapshotStatus
a -> Snapshot
s {$sel:status:Snapshot' :: Maybe SnapshotStatus
status = Maybe SnapshotStatus
a} :: Snapshot)

-- | The directory identifier.
snapshot_directoryId :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_directoryId :: (Maybe Text -> f (Maybe Text)) -> Snapshot -> f Snapshot
snapshot_directoryId = (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
directoryId :: Maybe Text
$sel:directoryId:Snapshot' :: Snapshot -> Maybe Text
directoryId} -> Maybe Text
directoryId) (\s :: Snapshot
s@Snapshot' {} Maybe Text
a -> Snapshot
s {$sel:directoryId:Snapshot' :: Maybe Text
directoryId = Maybe Text
a} :: Snapshot)

-- | The date and time that the snapshot was taken.
snapshot_startTime :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.UTCTime)
snapshot_startTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Snapshot -> f Snapshot
snapshot_startTime = (Snapshot -> Maybe POSIX)
-> (Snapshot -> Maybe POSIX -> Snapshot)
-> Lens Snapshot Snapshot (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Snapshot' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:Snapshot' :: Snapshot -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: Snapshot
s@Snapshot' {} Maybe POSIX
a -> Snapshot
s {$sel:startTime:Snapshot' :: Maybe POSIX
startTime = Maybe POSIX
a} :: Snapshot) ((Maybe POSIX -> f (Maybe POSIX)) -> Snapshot -> f Snapshot)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Snapshot
-> f Snapshot
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 descriptive 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 snapshot type.
snapshot_type :: Lens.Lens' Snapshot (Prelude.Maybe SnapshotType)
snapshot_type :: (Maybe SnapshotType -> f (Maybe SnapshotType))
-> Snapshot -> f Snapshot
snapshot_type = (Snapshot -> Maybe SnapshotType)
-> (Snapshot -> Maybe SnapshotType -> Snapshot)
-> Lens Snapshot Snapshot (Maybe SnapshotType) (Maybe SnapshotType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Snapshot' {Maybe SnapshotType
type' :: Maybe SnapshotType
$sel:type':Snapshot' :: Snapshot -> Maybe SnapshotType
type'} -> Maybe SnapshotType
type') (\s :: Snapshot
s@Snapshot' {} Maybe SnapshotType
a -> Snapshot
s {$sel:type':Snapshot' :: Maybe SnapshotType
type' = Maybe SnapshotType
a} :: Snapshot)

-- | The snapshot identifier.
snapshot_snapshotId :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_snapshotId :: (Maybe Text -> f (Maybe Text)) -> Snapshot -> f Snapshot
snapshot_snapshotId = (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
snapshotId :: Maybe Text
$sel:snapshotId:Snapshot' :: Snapshot -> Maybe Text
snapshotId} -> Maybe Text
snapshotId) (\s :: Snapshot
s@Snapshot' {} Maybe Text
a -> Snapshot
s {$sel:snapshotId:Snapshot' :: Maybe Text
snapshotId = 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 SnapshotStatus
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe SnapshotType
-> Maybe Text
-> Snapshot
Snapshot'
            (Maybe SnapshotStatus
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe SnapshotType
 -> Maybe Text
 -> Snapshot)
-> Parser (Maybe SnapshotStatus)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe SnapshotType
      -> Maybe Text
      -> Snapshot)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SnapshotStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe SnapshotType
   -> Maybe Text
   -> Snapshot)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Text -> Maybe SnapshotType -> 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
"DirectoryId")
            Parser
  (Maybe POSIX
   -> Maybe Text -> Maybe SnapshotType -> Maybe Text -> Snapshot)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text -> Maybe SnapshotType -> Maybe Text -> Snapshot)
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
"StartTime")
            Parser (Maybe Text -> Maybe SnapshotType -> Maybe Text -> Snapshot)
-> Parser (Maybe Text)
-> Parser (Maybe SnapshotType -> 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 SnapshotType -> Maybe Text -> Snapshot)
-> Parser (Maybe SnapshotType) -> Parser (Maybe Text -> Snapshot)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SnapshotType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            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
"SnapshotId")
      )

instance Prelude.Hashable Snapshot

instance Prelude.NFData Snapshot