{-# 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.Lightsail.Types.AutoSnapshotDetails
-- 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.Lightsail.Types.AutoSnapshotDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.AttachedDisk
import Amazonka.Lightsail.Types.AutoSnapshotStatus
import qualified Amazonka.Prelude as Prelude

-- | Describes an automatic snapshot.
--
-- /See:/ 'newAutoSnapshotDetails' smart constructor.
data AutoSnapshotDetails = AutoSnapshotDetails'
  { -- | The status of the automatic snapshot.
    AutoSnapshotDetails -> Maybe AutoSnapshotStatus
status :: Prelude.Maybe AutoSnapshotStatus,
    -- | An array of objects that describe the block storage disks attached to
    -- the instance when the automatic snapshot was created.
    AutoSnapshotDetails -> Maybe [AttachedDisk]
fromAttachedDisks :: Prelude.Maybe [AttachedDisk],
    -- | The timestamp when the automatic snapshot was created.
    AutoSnapshotDetails -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX,
    -- | The date of the automatic snapshot in @YYYY-MM-DD@ format.
    AutoSnapshotDetails -> Maybe Text
date :: Prelude.Maybe Prelude.Text
  }
  deriving (AutoSnapshotDetails -> AutoSnapshotDetails -> Bool
(AutoSnapshotDetails -> AutoSnapshotDetails -> Bool)
-> (AutoSnapshotDetails -> AutoSnapshotDetails -> Bool)
-> Eq AutoSnapshotDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoSnapshotDetails -> AutoSnapshotDetails -> Bool
$c/= :: AutoSnapshotDetails -> AutoSnapshotDetails -> Bool
== :: AutoSnapshotDetails -> AutoSnapshotDetails -> Bool
$c== :: AutoSnapshotDetails -> AutoSnapshotDetails -> Bool
Prelude.Eq, ReadPrec [AutoSnapshotDetails]
ReadPrec AutoSnapshotDetails
Int -> ReadS AutoSnapshotDetails
ReadS [AutoSnapshotDetails]
(Int -> ReadS AutoSnapshotDetails)
-> ReadS [AutoSnapshotDetails]
-> ReadPrec AutoSnapshotDetails
-> ReadPrec [AutoSnapshotDetails]
-> Read AutoSnapshotDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoSnapshotDetails]
$creadListPrec :: ReadPrec [AutoSnapshotDetails]
readPrec :: ReadPrec AutoSnapshotDetails
$creadPrec :: ReadPrec AutoSnapshotDetails
readList :: ReadS [AutoSnapshotDetails]
$creadList :: ReadS [AutoSnapshotDetails]
readsPrec :: Int -> ReadS AutoSnapshotDetails
$creadsPrec :: Int -> ReadS AutoSnapshotDetails
Prelude.Read, Int -> AutoSnapshotDetails -> ShowS
[AutoSnapshotDetails] -> ShowS
AutoSnapshotDetails -> String
(Int -> AutoSnapshotDetails -> ShowS)
-> (AutoSnapshotDetails -> String)
-> ([AutoSnapshotDetails] -> ShowS)
-> Show AutoSnapshotDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoSnapshotDetails] -> ShowS
$cshowList :: [AutoSnapshotDetails] -> ShowS
show :: AutoSnapshotDetails -> String
$cshow :: AutoSnapshotDetails -> String
showsPrec :: Int -> AutoSnapshotDetails -> ShowS
$cshowsPrec :: Int -> AutoSnapshotDetails -> ShowS
Prelude.Show, (forall x. AutoSnapshotDetails -> Rep AutoSnapshotDetails x)
-> (forall x. Rep AutoSnapshotDetails x -> AutoSnapshotDetails)
-> Generic AutoSnapshotDetails
forall x. Rep AutoSnapshotDetails x -> AutoSnapshotDetails
forall x. AutoSnapshotDetails -> Rep AutoSnapshotDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoSnapshotDetails x -> AutoSnapshotDetails
$cfrom :: forall x. AutoSnapshotDetails -> Rep AutoSnapshotDetails x
Prelude.Generic)

-- |
-- Create a value of 'AutoSnapshotDetails' 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', 'autoSnapshotDetails_status' - The status of the automatic snapshot.
--
-- 'fromAttachedDisks', 'autoSnapshotDetails_fromAttachedDisks' - An array of objects that describe the block storage disks attached to
-- the instance when the automatic snapshot was created.
--
-- 'createdAt', 'autoSnapshotDetails_createdAt' - The timestamp when the automatic snapshot was created.
--
-- 'date', 'autoSnapshotDetails_date' - The date of the automatic snapshot in @YYYY-MM-DD@ format.
newAutoSnapshotDetails ::
  AutoSnapshotDetails
newAutoSnapshotDetails :: AutoSnapshotDetails
newAutoSnapshotDetails =
  AutoSnapshotDetails' :: Maybe AutoSnapshotStatus
-> Maybe [AttachedDisk]
-> Maybe POSIX
-> Maybe Text
-> AutoSnapshotDetails
AutoSnapshotDetails'
    { $sel:status:AutoSnapshotDetails' :: Maybe AutoSnapshotStatus
status = Maybe AutoSnapshotStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:fromAttachedDisks:AutoSnapshotDetails' :: Maybe [AttachedDisk]
fromAttachedDisks = Maybe [AttachedDisk]
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:AutoSnapshotDetails' :: Maybe POSIX
createdAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:date:AutoSnapshotDetails' :: Maybe Text
date = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the automatic snapshot.
autoSnapshotDetails_status :: Lens.Lens' AutoSnapshotDetails (Prelude.Maybe AutoSnapshotStatus)
autoSnapshotDetails_status :: (Maybe AutoSnapshotStatus -> f (Maybe AutoSnapshotStatus))
-> AutoSnapshotDetails -> f AutoSnapshotDetails
autoSnapshotDetails_status = (AutoSnapshotDetails -> Maybe AutoSnapshotStatus)
-> (AutoSnapshotDetails
    -> Maybe AutoSnapshotStatus -> AutoSnapshotDetails)
-> Lens
     AutoSnapshotDetails
     AutoSnapshotDetails
     (Maybe AutoSnapshotStatus)
     (Maybe AutoSnapshotStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoSnapshotDetails' {Maybe AutoSnapshotStatus
status :: Maybe AutoSnapshotStatus
$sel:status:AutoSnapshotDetails' :: AutoSnapshotDetails -> Maybe AutoSnapshotStatus
status} -> Maybe AutoSnapshotStatus
status) (\s :: AutoSnapshotDetails
s@AutoSnapshotDetails' {} Maybe AutoSnapshotStatus
a -> AutoSnapshotDetails
s {$sel:status:AutoSnapshotDetails' :: Maybe AutoSnapshotStatus
status = Maybe AutoSnapshotStatus
a} :: AutoSnapshotDetails)

-- | An array of objects that describe the block storage disks attached to
-- the instance when the automatic snapshot was created.
autoSnapshotDetails_fromAttachedDisks :: Lens.Lens' AutoSnapshotDetails (Prelude.Maybe [AttachedDisk])
autoSnapshotDetails_fromAttachedDisks :: (Maybe [AttachedDisk] -> f (Maybe [AttachedDisk]))
-> AutoSnapshotDetails -> f AutoSnapshotDetails
autoSnapshotDetails_fromAttachedDisks = (AutoSnapshotDetails -> Maybe [AttachedDisk])
-> (AutoSnapshotDetails
    -> Maybe [AttachedDisk] -> AutoSnapshotDetails)
-> Lens
     AutoSnapshotDetails
     AutoSnapshotDetails
     (Maybe [AttachedDisk])
     (Maybe [AttachedDisk])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoSnapshotDetails' {Maybe [AttachedDisk]
fromAttachedDisks :: Maybe [AttachedDisk]
$sel:fromAttachedDisks:AutoSnapshotDetails' :: AutoSnapshotDetails -> Maybe [AttachedDisk]
fromAttachedDisks} -> Maybe [AttachedDisk]
fromAttachedDisks) (\s :: AutoSnapshotDetails
s@AutoSnapshotDetails' {} Maybe [AttachedDisk]
a -> AutoSnapshotDetails
s {$sel:fromAttachedDisks:AutoSnapshotDetails' :: Maybe [AttachedDisk]
fromAttachedDisks = Maybe [AttachedDisk]
a} :: AutoSnapshotDetails) ((Maybe [AttachedDisk] -> f (Maybe [AttachedDisk]))
 -> AutoSnapshotDetails -> f AutoSnapshotDetails)
-> ((Maybe [AttachedDisk] -> f (Maybe [AttachedDisk]))
    -> Maybe [AttachedDisk] -> f (Maybe [AttachedDisk]))
-> (Maybe [AttachedDisk] -> f (Maybe [AttachedDisk]))
-> AutoSnapshotDetails
-> f AutoSnapshotDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [AttachedDisk] [AttachedDisk] [AttachedDisk] [AttachedDisk]
-> Iso
     (Maybe [AttachedDisk])
     (Maybe [AttachedDisk])
     (Maybe [AttachedDisk])
     (Maybe [AttachedDisk])
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 [AttachedDisk] [AttachedDisk] [AttachedDisk] [AttachedDisk]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The timestamp when the automatic snapshot was created.
autoSnapshotDetails_createdAt :: Lens.Lens' AutoSnapshotDetails (Prelude.Maybe Prelude.UTCTime)
autoSnapshotDetails_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AutoSnapshotDetails -> f AutoSnapshotDetails
autoSnapshotDetails_createdAt = (AutoSnapshotDetails -> Maybe POSIX)
-> (AutoSnapshotDetails -> Maybe POSIX -> AutoSnapshotDetails)
-> Lens
     AutoSnapshotDetails AutoSnapshotDetails (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoSnapshotDetails' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:AutoSnapshotDetails' :: AutoSnapshotDetails -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: AutoSnapshotDetails
s@AutoSnapshotDetails' {} Maybe POSIX
a -> AutoSnapshotDetails
s {$sel:createdAt:AutoSnapshotDetails' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: AutoSnapshotDetails) ((Maybe POSIX -> f (Maybe POSIX))
 -> AutoSnapshotDetails -> f AutoSnapshotDetails)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AutoSnapshotDetails
-> f AutoSnapshotDetails
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 date of the automatic snapshot in @YYYY-MM-DD@ format.
autoSnapshotDetails_date :: Lens.Lens' AutoSnapshotDetails (Prelude.Maybe Prelude.Text)
autoSnapshotDetails_date :: (Maybe Text -> f (Maybe Text))
-> AutoSnapshotDetails -> f AutoSnapshotDetails
autoSnapshotDetails_date = (AutoSnapshotDetails -> Maybe Text)
-> (AutoSnapshotDetails -> Maybe Text -> AutoSnapshotDetails)
-> Lens
     AutoSnapshotDetails AutoSnapshotDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoSnapshotDetails' {Maybe Text
date :: Maybe Text
$sel:date:AutoSnapshotDetails' :: AutoSnapshotDetails -> Maybe Text
date} -> Maybe Text
date) (\s :: AutoSnapshotDetails
s@AutoSnapshotDetails' {} Maybe Text
a -> AutoSnapshotDetails
s {$sel:date:AutoSnapshotDetails' :: Maybe Text
date = Maybe Text
a} :: AutoSnapshotDetails)

instance Core.FromJSON AutoSnapshotDetails where
  parseJSON :: Value -> Parser AutoSnapshotDetails
parseJSON =
    String
-> (Object -> Parser AutoSnapshotDetails)
-> Value
-> Parser AutoSnapshotDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AutoSnapshotDetails"
      ( \Object
x ->
          Maybe AutoSnapshotStatus
-> Maybe [AttachedDisk]
-> Maybe POSIX
-> Maybe Text
-> AutoSnapshotDetails
AutoSnapshotDetails'
            (Maybe AutoSnapshotStatus
 -> Maybe [AttachedDisk]
 -> Maybe POSIX
 -> Maybe Text
 -> AutoSnapshotDetails)
-> Parser (Maybe AutoSnapshotStatus)
-> Parser
     (Maybe [AttachedDisk]
      -> Maybe POSIX -> Maybe Text -> AutoSnapshotDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AutoSnapshotStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser
  (Maybe [AttachedDisk]
   -> Maybe POSIX -> Maybe Text -> AutoSnapshotDetails)
-> Parser (Maybe [AttachedDisk])
-> Parser (Maybe POSIX -> Maybe Text -> AutoSnapshotDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [AttachedDisk]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"fromAttachedDisks"
                            Parser (Maybe (Maybe [AttachedDisk]))
-> Maybe [AttachedDisk] -> Parser (Maybe [AttachedDisk])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AttachedDisk]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe POSIX -> Maybe Text -> AutoSnapshotDetails)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> AutoSnapshotDetails)
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
"createdAt")
            Parser (Maybe Text -> AutoSnapshotDetails)
-> Parser (Maybe Text) -> Parser AutoSnapshotDetails
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
"date")
      )

instance Prelude.Hashable AutoSnapshotDetails

instance Prelude.NFData AutoSnapshotDetails