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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.DiskInfo
import qualified Amazonka.Prelude as Prelude

-- | Describes an instance snapshot.
--
-- /See:/ 'newInstanceSnapshotInfo' smart constructor.
data InstanceSnapshotInfo = InstanceSnapshotInfo'
  { -- | The blueprint ID from which the source instance (e.g., @os_debian_8_3@).
    InstanceSnapshotInfo -> Maybe Text
fromBlueprintId :: Prelude.Maybe Prelude.Text,
    -- | The bundle ID from which the source instance was created (e.g.,
    -- @micro_1_0@).
    InstanceSnapshotInfo -> Maybe Text
fromBundleId :: Prelude.Maybe Prelude.Text,
    -- | A list of objects describing the disks that were attached to the source
    -- instance.
    InstanceSnapshotInfo -> Maybe [DiskInfo]
fromDiskInfo :: Prelude.Maybe [DiskInfo]
  }
  deriving (InstanceSnapshotInfo -> InstanceSnapshotInfo -> Bool
(InstanceSnapshotInfo -> InstanceSnapshotInfo -> Bool)
-> (InstanceSnapshotInfo -> InstanceSnapshotInfo -> Bool)
-> Eq InstanceSnapshotInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceSnapshotInfo -> InstanceSnapshotInfo -> Bool
$c/= :: InstanceSnapshotInfo -> InstanceSnapshotInfo -> Bool
== :: InstanceSnapshotInfo -> InstanceSnapshotInfo -> Bool
$c== :: InstanceSnapshotInfo -> InstanceSnapshotInfo -> Bool
Prelude.Eq, ReadPrec [InstanceSnapshotInfo]
ReadPrec InstanceSnapshotInfo
Int -> ReadS InstanceSnapshotInfo
ReadS [InstanceSnapshotInfo]
(Int -> ReadS InstanceSnapshotInfo)
-> ReadS [InstanceSnapshotInfo]
-> ReadPrec InstanceSnapshotInfo
-> ReadPrec [InstanceSnapshotInfo]
-> Read InstanceSnapshotInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceSnapshotInfo]
$creadListPrec :: ReadPrec [InstanceSnapshotInfo]
readPrec :: ReadPrec InstanceSnapshotInfo
$creadPrec :: ReadPrec InstanceSnapshotInfo
readList :: ReadS [InstanceSnapshotInfo]
$creadList :: ReadS [InstanceSnapshotInfo]
readsPrec :: Int -> ReadS InstanceSnapshotInfo
$creadsPrec :: Int -> ReadS InstanceSnapshotInfo
Prelude.Read, Int -> InstanceSnapshotInfo -> ShowS
[InstanceSnapshotInfo] -> ShowS
InstanceSnapshotInfo -> String
(Int -> InstanceSnapshotInfo -> ShowS)
-> (InstanceSnapshotInfo -> String)
-> ([InstanceSnapshotInfo] -> ShowS)
-> Show InstanceSnapshotInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceSnapshotInfo] -> ShowS
$cshowList :: [InstanceSnapshotInfo] -> ShowS
show :: InstanceSnapshotInfo -> String
$cshow :: InstanceSnapshotInfo -> String
showsPrec :: Int -> InstanceSnapshotInfo -> ShowS
$cshowsPrec :: Int -> InstanceSnapshotInfo -> ShowS
Prelude.Show, (forall x. InstanceSnapshotInfo -> Rep InstanceSnapshotInfo x)
-> (forall x. Rep InstanceSnapshotInfo x -> InstanceSnapshotInfo)
-> Generic InstanceSnapshotInfo
forall x. Rep InstanceSnapshotInfo x -> InstanceSnapshotInfo
forall x. InstanceSnapshotInfo -> Rep InstanceSnapshotInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceSnapshotInfo x -> InstanceSnapshotInfo
$cfrom :: forall x. InstanceSnapshotInfo -> Rep InstanceSnapshotInfo x
Prelude.Generic)

-- |
-- Create a value of 'InstanceSnapshotInfo' 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:
--
-- 'fromBlueprintId', 'instanceSnapshotInfo_fromBlueprintId' - The blueprint ID from which the source instance (e.g., @os_debian_8_3@).
--
-- 'fromBundleId', 'instanceSnapshotInfo_fromBundleId' - The bundle ID from which the source instance was created (e.g.,
-- @micro_1_0@).
--
-- 'fromDiskInfo', 'instanceSnapshotInfo_fromDiskInfo' - A list of objects describing the disks that were attached to the source
-- instance.
newInstanceSnapshotInfo ::
  InstanceSnapshotInfo
newInstanceSnapshotInfo :: InstanceSnapshotInfo
newInstanceSnapshotInfo =
  InstanceSnapshotInfo' :: Maybe Text
-> Maybe Text -> Maybe [DiskInfo] -> InstanceSnapshotInfo
InstanceSnapshotInfo'
    { $sel:fromBlueprintId:InstanceSnapshotInfo' :: Maybe Text
fromBlueprintId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fromBundleId:InstanceSnapshotInfo' :: Maybe Text
fromBundleId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fromDiskInfo:InstanceSnapshotInfo' :: Maybe [DiskInfo]
fromDiskInfo = Maybe [DiskInfo]
forall a. Maybe a
Prelude.Nothing
    }

-- | The blueprint ID from which the source instance (e.g., @os_debian_8_3@).
instanceSnapshotInfo_fromBlueprintId :: Lens.Lens' InstanceSnapshotInfo (Prelude.Maybe Prelude.Text)
instanceSnapshotInfo_fromBlueprintId :: (Maybe Text -> f (Maybe Text))
-> InstanceSnapshotInfo -> f InstanceSnapshotInfo
instanceSnapshotInfo_fromBlueprintId = (InstanceSnapshotInfo -> Maybe Text)
-> (InstanceSnapshotInfo -> Maybe Text -> InstanceSnapshotInfo)
-> Lens
     InstanceSnapshotInfo InstanceSnapshotInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceSnapshotInfo' {Maybe Text
fromBlueprintId :: Maybe Text
$sel:fromBlueprintId:InstanceSnapshotInfo' :: InstanceSnapshotInfo -> Maybe Text
fromBlueprintId} -> Maybe Text
fromBlueprintId) (\s :: InstanceSnapshotInfo
s@InstanceSnapshotInfo' {} Maybe Text
a -> InstanceSnapshotInfo
s {$sel:fromBlueprintId:InstanceSnapshotInfo' :: Maybe Text
fromBlueprintId = Maybe Text
a} :: InstanceSnapshotInfo)

-- | The bundle ID from which the source instance was created (e.g.,
-- @micro_1_0@).
instanceSnapshotInfo_fromBundleId :: Lens.Lens' InstanceSnapshotInfo (Prelude.Maybe Prelude.Text)
instanceSnapshotInfo_fromBundleId :: (Maybe Text -> f (Maybe Text))
-> InstanceSnapshotInfo -> f InstanceSnapshotInfo
instanceSnapshotInfo_fromBundleId = (InstanceSnapshotInfo -> Maybe Text)
-> (InstanceSnapshotInfo -> Maybe Text -> InstanceSnapshotInfo)
-> Lens
     InstanceSnapshotInfo InstanceSnapshotInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceSnapshotInfo' {Maybe Text
fromBundleId :: Maybe Text
$sel:fromBundleId:InstanceSnapshotInfo' :: InstanceSnapshotInfo -> Maybe Text
fromBundleId} -> Maybe Text
fromBundleId) (\s :: InstanceSnapshotInfo
s@InstanceSnapshotInfo' {} Maybe Text
a -> InstanceSnapshotInfo
s {$sel:fromBundleId:InstanceSnapshotInfo' :: Maybe Text
fromBundleId = Maybe Text
a} :: InstanceSnapshotInfo)

-- | A list of objects describing the disks that were attached to the source
-- instance.
instanceSnapshotInfo_fromDiskInfo :: Lens.Lens' InstanceSnapshotInfo (Prelude.Maybe [DiskInfo])
instanceSnapshotInfo_fromDiskInfo :: (Maybe [DiskInfo] -> f (Maybe [DiskInfo]))
-> InstanceSnapshotInfo -> f InstanceSnapshotInfo
instanceSnapshotInfo_fromDiskInfo = (InstanceSnapshotInfo -> Maybe [DiskInfo])
-> (InstanceSnapshotInfo
    -> Maybe [DiskInfo] -> InstanceSnapshotInfo)
-> Lens
     InstanceSnapshotInfo
     InstanceSnapshotInfo
     (Maybe [DiskInfo])
     (Maybe [DiskInfo])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceSnapshotInfo' {Maybe [DiskInfo]
fromDiskInfo :: Maybe [DiskInfo]
$sel:fromDiskInfo:InstanceSnapshotInfo' :: InstanceSnapshotInfo -> Maybe [DiskInfo]
fromDiskInfo} -> Maybe [DiskInfo]
fromDiskInfo) (\s :: InstanceSnapshotInfo
s@InstanceSnapshotInfo' {} Maybe [DiskInfo]
a -> InstanceSnapshotInfo
s {$sel:fromDiskInfo:InstanceSnapshotInfo' :: Maybe [DiskInfo]
fromDiskInfo = Maybe [DiskInfo]
a} :: InstanceSnapshotInfo) ((Maybe [DiskInfo] -> f (Maybe [DiskInfo]))
 -> InstanceSnapshotInfo -> f InstanceSnapshotInfo)
-> ((Maybe [DiskInfo] -> f (Maybe [DiskInfo]))
    -> Maybe [DiskInfo] -> f (Maybe [DiskInfo]))
-> (Maybe [DiskInfo] -> f (Maybe [DiskInfo]))
-> InstanceSnapshotInfo
-> f InstanceSnapshotInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [DiskInfo] [DiskInfo] [DiskInfo] [DiskInfo]
-> Iso
     (Maybe [DiskInfo])
     (Maybe [DiskInfo])
     (Maybe [DiskInfo])
     (Maybe [DiskInfo])
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 [DiskInfo] [DiskInfo] [DiskInfo] [DiskInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON InstanceSnapshotInfo where
  parseJSON :: Value -> Parser InstanceSnapshotInfo
parseJSON =
    String
-> (Object -> Parser InstanceSnapshotInfo)
-> Value
-> Parser InstanceSnapshotInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InstanceSnapshotInfo"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe [DiskInfo] -> InstanceSnapshotInfo
InstanceSnapshotInfo'
            (Maybe Text
 -> Maybe Text -> Maybe [DiskInfo] -> InstanceSnapshotInfo)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe [DiskInfo] -> InstanceSnapshotInfo)
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
"fromBlueprintId")
            Parser (Maybe Text -> Maybe [DiskInfo] -> InstanceSnapshotInfo)
-> Parser (Maybe Text)
-> Parser (Maybe [DiskInfo] -> InstanceSnapshotInfo)
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
"fromBundleId")
            Parser (Maybe [DiskInfo] -> InstanceSnapshotInfo)
-> Parser (Maybe [DiskInfo]) -> Parser InstanceSnapshotInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [DiskInfo]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"fromDiskInfo" Parser (Maybe (Maybe [DiskInfo]))
-> Maybe [DiskInfo] -> Parser (Maybe [DiskInfo])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DiskInfo]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable InstanceSnapshotInfo

instance Prelude.NFData InstanceSnapshotInfo