{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DirectoryService.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.DirectoryService.Types.SnapshotStatus
import Amazonka.DirectoryService.Types.SnapshotType
import qualified Amazonka.Prelude as Prelude

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

-- | The directory identifier.
snapshot_directoryId :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_directoryId :: Lens' Snapshot (Maybe Text)
snapshot_directoryId = 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 descriptive 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)

-- | The snapshot identifier.
snapshot_snapshotId :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.Text)
snapshot_snapshotId :: Lens' Snapshot (Maybe Text)
snapshot_snapshotId = 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)

-- | The date and time that the snapshot was taken.
snapshot_startTime :: Lens.Lens' Snapshot (Prelude.Maybe Prelude.UTCTime)
snapshot_startTime :: Lens' Snapshot (Maybe UTCTime)
snapshot_startTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The snapshot status.
snapshot_status :: Lens.Lens' Snapshot (Prelude.Maybe SnapshotStatus)
snapshot_status :: Lens' Snapshot (Maybe SnapshotStatus)
snapshot_status = 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 snapshot type.
snapshot_type :: Lens.Lens' Snapshot (Prelude.Maybe SnapshotType)
snapshot_type :: Lens' Snapshot (Maybe SnapshotType)
snapshot_type = 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)

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 Text
-> Maybe Text
-> Maybe POSIX
-> Maybe SnapshotStatus
-> Maybe SnapshotType
-> 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
"DirectoryId")
            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
"SnapshotId")
            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
"StartTime")
            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")
            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
"Type")
      )

instance Prelude.Hashable Snapshot where
  hashWithSalt :: Int -> Snapshot -> Int
hashWithSalt Int
_salt Snapshot' {Maybe Text
Maybe POSIX
Maybe SnapshotStatus
Maybe SnapshotType
type' :: Maybe SnapshotType
status :: Maybe SnapshotStatus
startTime :: Maybe POSIX
snapshotId :: Maybe Text
name :: Maybe Text
directoryId :: Maybe Text
$sel:type':Snapshot' :: Snapshot -> Maybe SnapshotType
$sel:status:Snapshot' :: Snapshot -> Maybe SnapshotStatus
$sel:startTime:Snapshot' :: Snapshot -> Maybe POSIX
$sel:snapshotId:Snapshot' :: Snapshot -> Maybe Text
$sel:name:Snapshot' :: Snapshot -> Maybe Text
$sel:directoryId:Snapshot' :: Snapshot -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
directoryId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
snapshotId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SnapshotStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SnapshotType
type'

instance Prelude.NFData Snapshot where
  rnf :: Snapshot -> ()
rnf Snapshot' {Maybe Text
Maybe POSIX
Maybe SnapshotStatus
Maybe SnapshotType
type' :: Maybe SnapshotType
status :: Maybe SnapshotStatus
startTime :: Maybe POSIX
snapshotId :: Maybe Text
name :: Maybe Text
directoryId :: Maybe Text
$sel:type':Snapshot' :: Snapshot -> Maybe SnapshotType
$sel:status:Snapshot' :: Snapshot -> Maybe SnapshotStatus
$sel:startTime:Snapshot' :: Snapshot -> Maybe POSIX
$sel:snapshotId:Snapshot' :: Snapshot -> Maybe Text
$sel:name:Snapshot' :: Snapshot -> Maybe Text
$sel:directoryId:Snapshot' :: Snapshot -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
directoryId
      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
snapshotId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SnapshotStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SnapshotType
type'