{-# 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.MGN.Types.LaunchedInstance
-- 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.MGN.Types.LaunchedInstance where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MGN.Types.FirstBoot
import qualified Amazonka.Prelude as Prelude

-- | Configure launced instance.
--
-- /See:/ 'newLaunchedInstance' smart constructor.
data LaunchedInstance = LaunchedInstance'
  { -- | Configure launced instance Job ID.
    LaunchedInstance -> Maybe Text
jobID :: Prelude.Maybe Prelude.Text,
    -- | Configure launced instance EC2 ID.
    LaunchedInstance -> Maybe Text
ec2InstanceID :: Prelude.Maybe Prelude.Text,
    -- | Configure launced instance first boot.
    LaunchedInstance -> Maybe FirstBoot
firstBoot :: Prelude.Maybe FirstBoot
  }
  deriving (LaunchedInstance -> LaunchedInstance -> Bool
(LaunchedInstance -> LaunchedInstance -> Bool)
-> (LaunchedInstance -> LaunchedInstance -> Bool)
-> Eq LaunchedInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LaunchedInstance -> LaunchedInstance -> Bool
$c/= :: LaunchedInstance -> LaunchedInstance -> Bool
== :: LaunchedInstance -> LaunchedInstance -> Bool
$c== :: LaunchedInstance -> LaunchedInstance -> Bool
Prelude.Eq, ReadPrec [LaunchedInstance]
ReadPrec LaunchedInstance
Int -> ReadS LaunchedInstance
ReadS [LaunchedInstance]
(Int -> ReadS LaunchedInstance)
-> ReadS [LaunchedInstance]
-> ReadPrec LaunchedInstance
-> ReadPrec [LaunchedInstance]
-> Read LaunchedInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LaunchedInstance]
$creadListPrec :: ReadPrec [LaunchedInstance]
readPrec :: ReadPrec LaunchedInstance
$creadPrec :: ReadPrec LaunchedInstance
readList :: ReadS [LaunchedInstance]
$creadList :: ReadS [LaunchedInstance]
readsPrec :: Int -> ReadS LaunchedInstance
$creadsPrec :: Int -> ReadS LaunchedInstance
Prelude.Read, Int -> LaunchedInstance -> ShowS
[LaunchedInstance] -> ShowS
LaunchedInstance -> String
(Int -> LaunchedInstance -> ShowS)
-> (LaunchedInstance -> String)
-> ([LaunchedInstance] -> ShowS)
-> Show LaunchedInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LaunchedInstance] -> ShowS
$cshowList :: [LaunchedInstance] -> ShowS
show :: LaunchedInstance -> String
$cshow :: LaunchedInstance -> String
showsPrec :: Int -> LaunchedInstance -> ShowS
$cshowsPrec :: Int -> LaunchedInstance -> ShowS
Prelude.Show, (forall x. LaunchedInstance -> Rep LaunchedInstance x)
-> (forall x. Rep LaunchedInstance x -> LaunchedInstance)
-> Generic LaunchedInstance
forall x. Rep LaunchedInstance x -> LaunchedInstance
forall x. LaunchedInstance -> Rep LaunchedInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LaunchedInstance x -> LaunchedInstance
$cfrom :: forall x. LaunchedInstance -> Rep LaunchedInstance x
Prelude.Generic)

-- |
-- Create a value of 'LaunchedInstance' 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:
--
-- 'jobID', 'launchedInstance_jobID' - Configure launced instance Job ID.
--
-- 'ec2InstanceID', 'launchedInstance_ec2InstanceID' - Configure launced instance EC2 ID.
--
-- 'firstBoot', 'launchedInstance_firstBoot' - Configure launced instance first boot.
newLaunchedInstance ::
  LaunchedInstance
newLaunchedInstance :: LaunchedInstance
newLaunchedInstance =
  LaunchedInstance' :: Maybe Text -> Maybe Text -> Maybe FirstBoot -> LaunchedInstance
LaunchedInstance'
    { $sel:jobID:LaunchedInstance' :: Maybe Text
jobID = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ec2InstanceID:LaunchedInstance' :: Maybe Text
ec2InstanceID = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:firstBoot:LaunchedInstance' :: Maybe FirstBoot
firstBoot = Maybe FirstBoot
forall a. Maybe a
Prelude.Nothing
    }

-- | Configure launced instance Job ID.
launchedInstance_jobID :: Lens.Lens' LaunchedInstance (Prelude.Maybe Prelude.Text)
launchedInstance_jobID :: (Maybe Text -> f (Maybe Text))
-> LaunchedInstance -> f LaunchedInstance
launchedInstance_jobID = (LaunchedInstance -> Maybe Text)
-> (LaunchedInstance -> Maybe Text -> LaunchedInstance)
-> Lens LaunchedInstance LaunchedInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchedInstance' {Maybe Text
jobID :: Maybe Text
$sel:jobID:LaunchedInstance' :: LaunchedInstance -> Maybe Text
jobID} -> Maybe Text
jobID) (\s :: LaunchedInstance
s@LaunchedInstance' {} Maybe Text
a -> LaunchedInstance
s {$sel:jobID:LaunchedInstance' :: Maybe Text
jobID = Maybe Text
a} :: LaunchedInstance)

-- | Configure launced instance EC2 ID.
launchedInstance_ec2InstanceID :: Lens.Lens' LaunchedInstance (Prelude.Maybe Prelude.Text)
launchedInstance_ec2InstanceID :: (Maybe Text -> f (Maybe Text))
-> LaunchedInstance -> f LaunchedInstance
launchedInstance_ec2InstanceID = (LaunchedInstance -> Maybe Text)
-> (LaunchedInstance -> Maybe Text -> LaunchedInstance)
-> Lens LaunchedInstance LaunchedInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchedInstance' {Maybe Text
ec2InstanceID :: Maybe Text
$sel:ec2InstanceID:LaunchedInstance' :: LaunchedInstance -> Maybe Text
ec2InstanceID} -> Maybe Text
ec2InstanceID) (\s :: LaunchedInstance
s@LaunchedInstance' {} Maybe Text
a -> LaunchedInstance
s {$sel:ec2InstanceID:LaunchedInstance' :: Maybe Text
ec2InstanceID = Maybe Text
a} :: LaunchedInstance)

-- | Configure launced instance first boot.
launchedInstance_firstBoot :: Lens.Lens' LaunchedInstance (Prelude.Maybe FirstBoot)
launchedInstance_firstBoot :: (Maybe FirstBoot -> f (Maybe FirstBoot))
-> LaunchedInstance -> f LaunchedInstance
launchedInstance_firstBoot = (LaunchedInstance -> Maybe FirstBoot)
-> (LaunchedInstance -> Maybe FirstBoot -> LaunchedInstance)
-> Lens
     LaunchedInstance
     LaunchedInstance
     (Maybe FirstBoot)
     (Maybe FirstBoot)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchedInstance' {Maybe FirstBoot
firstBoot :: Maybe FirstBoot
$sel:firstBoot:LaunchedInstance' :: LaunchedInstance -> Maybe FirstBoot
firstBoot} -> Maybe FirstBoot
firstBoot) (\s :: LaunchedInstance
s@LaunchedInstance' {} Maybe FirstBoot
a -> LaunchedInstance
s {$sel:firstBoot:LaunchedInstance' :: Maybe FirstBoot
firstBoot = Maybe FirstBoot
a} :: LaunchedInstance)

instance Core.FromJSON LaunchedInstance where
  parseJSON :: Value -> Parser LaunchedInstance
parseJSON =
    String
-> (Object -> Parser LaunchedInstance)
-> Value
-> Parser LaunchedInstance
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LaunchedInstance"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe FirstBoot -> LaunchedInstance
LaunchedInstance'
            (Maybe Text -> Maybe Text -> Maybe FirstBoot -> LaunchedInstance)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe FirstBoot -> LaunchedInstance)
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
"jobID")
            Parser (Maybe Text -> Maybe FirstBoot -> LaunchedInstance)
-> Parser (Maybe Text)
-> Parser (Maybe FirstBoot -> LaunchedInstance)
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
"ec2InstanceID")
            Parser (Maybe FirstBoot -> LaunchedInstance)
-> Parser (Maybe FirstBoot) -> Parser LaunchedInstance
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FirstBoot)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"firstBoot")
      )

instance Prelude.Hashable LaunchedInstance

instance Prelude.NFData LaunchedInstance