{-# 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.ImageBuilder.Types.FastLaunchConfiguration
-- 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.ImageBuilder.Types.FastLaunchConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ImageBuilder.Types.FastLaunchLaunchTemplateSpecification
import Amazonka.ImageBuilder.Types.FastLaunchSnapshotConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Define and configure faster launching for output Windows AMIs.
--
-- /See:/ 'newFastLaunchConfiguration' smart constructor.
data FastLaunchConfiguration = FastLaunchConfiguration'
  { -- | The owner account ID for the fast-launch enabled Windows AMI.
    FastLaunchConfiguration -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The launch template that the fast-launch enabled Windows AMI uses when
    -- it launches Windows instances to create pre-provisioned snapshots.
    FastLaunchConfiguration
-> Maybe FastLaunchLaunchTemplateSpecification
launchTemplate :: Prelude.Maybe FastLaunchLaunchTemplateSpecification,
    -- | The maximum number of parallel instances that are launched for creating
    -- resources.
    FastLaunchConfiguration -> Maybe Natural
maxParallelLaunches :: Prelude.Maybe Prelude.Natural,
    -- | Configuration settings for managing the number of snapshots that are
    -- created from pre-provisioned instances for the Windows AMI when faster
    -- launching is enabled.
    FastLaunchConfiguration -> Maybe FastLaunchSnapshotConfiguration
snapshotConfiguration :: Prelude.Maybe FastLaunchSnapshotConfiguration,
    -- | A Boolean that represents the current state of faster launching for the
    -- Windows AMI. Set to @true@ to start using Windows faster launching, or
    -- @false@ to stop using it.
    FastLaunchConfiguration -> Bool
enabled :: Prelude.Bool
  }
  deriving (FastLaunchConfiguration -> FastLaunchConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FastLaunchConfiguration -> FastLaunchConfiguration -> Bool
$c/= :: FastLaunchConfiguration -> FastLaunchConfiguration -> Bool
== :: FastLaunchConfiguration -> FastLaunchConfiguration -> Bool
$c== :: FastLaunchConfiguration -> FastLaunchConfiguration -> Bool
Prelude.Eq, ReadPrec [FastLaunchConfiguration]
ReadPrec FastLaunchConfiguration
Int -> ReadS FastLaunchConfiguration
ReadS [FastLaunchConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FastLaunchConfiguration]
$creadListPrec :: ReadPrec [FastLaunchConfiguration]
readPrec :: ReadPrec FastLaunchConfiguration
$creadPrec :: ReadPrec FastLaunchConfiguration
readList :: ReadS [FastLaunchConfiguration]
$creadList :: ReadS [FastLaunchConfiguration]
readsPrec :: Int -> ReadS FastLaunchConfiguration
$creadsPrec :: Int -> ReadS FastLaunchConfiguration
Prelude.Read, Int -> FastLaunchConfiguration -> ShowS
[FastLaunchConfiguration] -> ShowS
FastLaunchConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FastLaunchConfiguration] -> ShowS
$cshowList :: [FastLaunchConfiguration] -> ShowS
show :: FastLaunchConfiguration -> String
$cshow :: FastLaunchConfiguration -> String
showsPrec :: Int -> FastLaunchConfiguration -> ShowS
$cshowsPrec :: Int -> FastLaunchConfiguration -> ShowS
Prelude.Show, forall x. Rep FastLaunchConfiguration x -> FastLaunchConfiguration
forall x. FastLaunchConfiguration -> Rep FastLaunchConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FastLaunchConfiguration x -> FastLaunchConfiguration
$cfrom :: forall x. FastLaunchConfiguration -> Rep FastLaunchConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'FastLaunchConfiguration' 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:
--
-- 'accountId', 'fastLaunchConfiguration_accountId' - The owner account ID for the fast-launch enabled Windows AMI.
--
-- 'launchTemplate', 'fastLaunchConfiguration_launchTemplate' - The launch template that the fast-launch enabled Windows AMI uses when
-- it launches Windows instances to create pre-provisioned snapshots.
--
-- 'maxParallelLaunches', 'fastLaunchConfiguration_maxParallelLaunches' - The maximum number of parallel instances that are launched for creating
-- resources.
--
-- 'snapshotConfiguration', 'fastLaunchConfiguration_snapshotConfiguration' - Configuration settings for managing the number of snapshots that are
-- created from pre-provisioned instances for the Windows AMI when faster
-- launching is enabled.
--
-- 'enabled', 'fastLaunchConfiguration_enabled' - A Boolean that represents the current state of faster launching for the
-- Windows AMI. Set to @true@ to start using Windows faster launching, or
-- @false@ to stop using it.
newFastLaunchConfiguration ::
  -- | 'enabled'
  Prelude.Bool ->
  FastLaunchConfiguration
newFastLaunchConfiguration :: Bool -> FastLaunchConfiguration
newFastLaunchConfiguration Bool
pEnabled_ =
  FastLaunchConfiguration'
    { $sel:accountId:FastLaunchConfiguration' :: Maybe Text
accountId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:launchTemplate:FastLaunchConfiguration' :: Maybe FastLaunchLaunchTemplateSpecification
launchTemplate = forall a. Maybe a
Prelude.Nothing,
      $sel:maxParallelLaunches:FastLaunchConfiguration' :: Maybe Natural
maxParallelLaunches = forall a. Maybe a
Prelude.Nothing,
      $sel:snapshotConfiguration:FastLaunchConfiguration' :: Maybe FastLaunchSnapshotConfiguration
snapshotConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:FastLaunchConfiguration' :: Bool
enabled = Bool
pEnabled_
    }

-- | The owner account ID for the fast-launch enabled Windows AMI.
fastLaunchConfiguration_accountId :: Lens.Lens' FastLaunchConfiguration (Prelude.Maybe Prelude.Text)
fastLaunchConfiguration_accountId :: Lens' FastLaunchConfiguration (Maybe Text)
fastLaunchConfiguration_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FastLaunchConfiguration' {Maybe Text
accountId :: Maybe Text
$sel:accountId:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: FastLaunchConfiguration
s@FastLaunchConfiguration' {} Maybe Text
a -> FastLaunchConfiguration
s {$sel:accountId:FastLaunchConfiguration' :: Maybe Text
accountId = Maybe Text
a} :: FastLaunchConfiguration)

-- | The launch template that the fast-launch enabled Windows AMI uses when
-- it launches Windows instances to create pre-provisioned snapshots.
fastLaunchConfiguration_launchTemplate :: Lens.Lens' FastLaunchConfiguration (Prelude.Maybe FastLaunchLaunchTemplateSpecification)
fastLaunchConfiguration_launchTemplate :: Lens'
  FastLaunchConfiguration
  (Maybe FastLaunchLaunchTemplateSpecification)
fastLaunchConfiguration_launchTemplate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FastLaunchConfiguration' {Maybe FastLaunchLaunchTemplateSpecification
launchTemplate :: Maybe FastLaunchLaunchTemplateSpecification
$sel:launchTemplate:FastLaunchConfiguration' :: FastLaunchConfiguration
-> Maybe FastLaunchLaunchTemplateSpecification
launchTemplate} -> Maybe FastLaunchLaunchTemplateSpecification
launchTemplate) (\s :: FastLaunchConfiguration
s@FastLaunchConfiguration' {} Maybe FastLaunchLaunchTemplateSpecification
a -> FastLaunchConfiguration
s {$sel:launchTemplate:FastLaunchConfiguration' :: Maybe FastLaunchLaunchTemplateSpecification
launchTemplate = Maybe FastLaunchLaunchTemplateSpecification
a} :: FastLaunchConfiguration)

-- | The maximum number of parallel instances that are launched for creating
-- resources.
fastLaunchConfiguration_maxParallelLaunches :: Lens.Lens' FastLaunchConfiguration (Prelude.Maybe Prelude.Natural)
fastLaunchConfiguration_maxParallelLaunches :: Lens' FastLaunchConfiguration (Maybe Natural)
fastLaunchConfiguration_maxParallelLaunches = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FastLaunchConfiguration' {Maybe Natural
maxParallelLaunches :: Maybe Natural
$sel:maxParallelLaunches:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe Natural
maxParallelLaunches} -> Maybe Natural
maxParallelLaunches) (\s :: FastLaunchConfiguration
s@FastLaunchConfiguration' {} Maybe Natural
a -> FastLaunchConfiguration
s {$sel:maxParallelLaunches:FastLaunchConfiguration' :: Maybe Natural
maxParallelLaunches = Maybe Natural
a} :: FastLaunchConfiguration)

-- | Configuration settings for managing the number of snapshots that are
-- created from pre-provisioned instances for the Windows AMI when faster
-- launching is enabled.
fastLaunchConfiguration_snapshotConfiguration :: Lens.Lens' FastLaunchConfiguration (Prelude.Maybe FastLaunchSnapshotConfiguration)
fastLaunchConfiguration_snapshotConfiguration :: Lens'
  FastLaunchConfiguration (Maybe FastLaunchSnapshotConfiguration)
fastLaunchConfiguration_snapshotConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FastLaunchConfiguration' {Maybe FastLaunchSnapshotConfiguration
snapshotConfiguration :: Maybe FastLaunchSnapshotConfiguration
$sel:snapshotConfiguration:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe FastLaunchSnapshotConfiguration
snapshotConfiguration} -> Maybe FastLaunchSnapshotConfiguration
snapshotConfiguration) (\s :: FastLaunchConfiguration
s@FastLaunchConfiguration' {} Maybe FastLaunchSnapshotConfiguration
a -> FastLaunchConfiguration
s {$sel:snapshotConfiguration:FastLaunchConfiguration' :: Maybe FastLaunchSnapshotConfiguration
snapshotConfiguration = Maybe FastLaunchSnapshotConfiguration
a} :: FastLaunchConfiguration)

-- | A Boolean that represents the current state of faster launching for the
-- Windows AMI. Set to @true@ to start using Windows faster launching, or
-- @false@ to stop using it.
fastLaunchConfiguration_enabled :: Lens.Lens' FastLaunchConfiguration Prelude.Bool
fastLaunchConfiguration_enabled :: Lens' FastLaunchConfiguration Bool
fastLaunchConfiguration_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FastLaunchConfiguration' {Bool
enabled :: Bool
$sel:enabled:FastLaunchConfiguration' :: FastLaunchConfiguration -> Bool
enabled} -> Bool
enabled) (\s :: FastLaunchConfiguration
s@FastLaunchConfiguration' {} Bool
a -> FastLaunchConfiguration
s {$sel:enabled:FastLaunchConfiguration' :: Bool
enabled = Bool
a} :: FastLaunchConfiguration)

instance Data.FromJSON FastLaunchConfiguration where
  parseJSON :: Value -> Parser FastLaunchConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FastLaunchConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe FastLaunchLaunchTemplateSpecification
-> Maybe Natural
-> Maybe FastLaunchSnapshotConfiguration
-> Bool
-> FastLaunchConfiguration
FastLaunchConfiguration'
            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
"accountId")
            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
"launchTemplate")
            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
"maxParallelLaunches")
            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
"snapshotConfiguration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"enabled")
      )

instance Prelude.Hashable FastLaunchConfiguration where
  hashWithSalt :: Int -> FastLaunchConfiguration -> Int
hashWithSalt Int
_salt FastLaunchConfiguration' {Bool
Maybe Natural
Maybe Text
Maybe FastLaunchLaunchTemplateSpecification
Maybe FastLaunchSnapshotConfiguration
enabled :: Bool
snapshotConfiguration :: Maybe FastLaunchSnapshotConfiguration
maxParallelLaunches :: Maybe Natural
launchTemplate :: Maybe FastLaunchLaunchTemplateSpecification
accountId :: Maybe Text
$sel:enabled:FastLaunchConfiguration' :: FastLaunchConfiguration -> Bool
$sel:snapshotConfiguration:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe FastLaunchSnapshotConfiguration
$sel:maxParallelLaunches:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe Natural
$sel:launchTemplate:FastLaunchConfiguration' :: FastLaunchConfiguration
-> Maybe FastLaunchLaunchTemplateSpecification
$sel:accountId:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FastLaunchLaunchTemplateSpecification
launchTemplate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxParallelLaunches
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FastLaunchSnapshotConfiguration
snapshotConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enabled

instance Prelude.NFData FastLaunchConfiguration where
  rnf :: FastLaunchConfiguration -> ()
rnf FastLaunchConfiguration' {Bool
Maybe Natural
Maybe Text
Maybe FastLaunchLaunchTemplateSpecification
Maybe FastLaunchSnapshotConfiguration
enabled :: Bool
snapshotConfiguration :: Maybe FastLaunchSnapshotConfiguration
maxParallelLaunches :: Maybe Natural
launchTemplate :: Maybe FastLaunchLaunchTemplateSpecification
accountId :: Maybe Text
$sel:enabled:FastLaunchConfiguration' :: FastLaunchConfiguration -> Bool
$sel:snapshotConfiguration:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe FastLaunchSnapshotConfiguration
$sel:maxParallelLaunches:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe Natural
$sel:launchTemplate:FastLaunchConfiguration' :: FastLaunchConfiguration
-> Maybe FastLaunchLaunchTemplateSpecification
$sel:accountId:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FastLaunchLaunchTemplateSpecification
launchTemplate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxParallelLaunches
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FastLaunchSnapshotConfiguration
snapshotConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
enabled

instance Data.ToJSON FastLaunchConfiguration where
  toJSON :: FastLaunchConfiguration -> Value
toJSON FastLaunchConfiguration' {Bool
Maybe Natural
Maybe Text
Maybe FastLaunchLaunchTemplateSpecification
Maybe FastLaunchSnapshotConfiguration
enabled :: Bool
snapshotConfiguration :: Maybe FastLaunchSnapshotConfiguration
maxParallelLaunches :: Maybe Natural
launchTemplate :: Maybe FastLaunchLaunchTemplateSpecification
accountId :: Maybe Text
$sel:enabled:FastLaunchConfiguration' :: FastLaunchConfiguration -> Bool
$sel:snapshotConfiguration:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe FastLaunchSnapshotConfiguration
$sel:maxParallelLaunches:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe Natural
$sel:launchTemplate:FastLaunchConfiguration' :: FastLaunchConfiguration
-> Maybe FastLaunchLaunchTemplateSpecification
$sel:accountId:FastLaunchConfiguration' :: FastLaunchConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"accountId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
accountId,
            (Key
"launchTemplate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FastLaunchLaunchTemplateSpecification
launchTemplate,
            (Key
"maxParallelLaunches" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxParallelLaunches,
            (Key
"snapshotConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FastLaunchSnapshotConfiguration
snapshotConfiguration,
            forall a. a -> Maybe a
Prelude.Just (Key
"enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
enabled)
          ]
      )