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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Identifies an Amazon EC2 launch template to use for a specific account.
--
-- /See:/ 'newLaunchTemplateConfiguration' smart constructor.
data LaunchTemplateConfiguration = LaunchTemplateConfiguration'
  { -- | Set the specified Amazon EC2 launch template as the default launch
    -- template for the specified account.
    LaunchTemplateConfiguration -> Maybe Bool
setDefaultVersion :: Prelude.Maybe Prelude.Bool,
    -- | The account ID that this configuration applies to.
    LaunchTemplateConfiguration -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | Identifies the Amazon EC2 launch template to use.
    LaunchTemplateConfiguration -> Text
launchTemplateId :: Prelude.Text
  }
  deriving (LaunchTemplateConfiguration -> LaunchTemplateConfiguration -> Bool
(LaunchTemplateConfiguration
 -> LaunchTemplateConfiguration -> Bool)
-> (LaunchTemplateConfiguration
    -> LaunchTemplateConfiguration -> Bool)
-> Eq LaunchTemplateConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LaunchTemplateConfiguration -> LaunchTemplateConfiguration -> Bool
$c/= :: LaunchTemplateConfiguration -> LaunchTemplateConfiguration -> Bool
== :: LaunchTemplateConfiguration -> LaunchTemplateConfiguration -> Bool
$c== :: LaunchTemplateConfiguration -> LaunchTemplateConfiguration -> Bool
Prelude.Eq, ReadPrec [LaunchTemplateConfiguration]
ReadPrec LaunchTemplateConfiguration
Int -> ReadS LaunchTemplateConfiguration
ReadS [LaunchTemplateConfiguration]
(Int -> ReadS LaunchTemplateConfiguration)
-> ReadS [LaunchTemplateConfiguration]
-> ReadPrec LaunchTemplateConfiguration
-> ReadPrec [LaunchTemplateConfiguration]
-> Read LaunchTemplateConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LaunchTemplateConfiguration]
$creadListPrec :: ReadPrec [LaunchTemplateConfiguration]
readPrec :: ReadPrec LaunchTemplateConfiguration
$creadPrec :: ReadPrec LaunchTemplateConfiguration
readList :: ReadS [LaunchTemplateConfiguration]
$creadList :: ReadS [LaunchTemplateConfiguration]
readsPrec :: Int -> ReadS LaunchTemplateConfiguration
$creadsPrec :: Int -> ReadS LaunchTemplateConfiguration
Prelude.Read, Int -> LaunchTemplateConfiguration -> ShowS
[LaunchTemplateConfiguration] -> ShowS
LaunchTemplateConfiguration -> String
(Int -> LaunchTemplateConfiguration -> ShowS)
-> (LaunchTemplateConfiguration -> String)
-> ([LaunchTemplateConfiguration] -> ShowS)
-> Show LaunchTemplateConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LaunchTemplateConfiguration] -> ShowS
$cshowList :: [LaunchTemplateConfiguration] -> ShowS
show :: LaunchTemplateConfiguration -> String
$cshow :: LaunchTemplateConfiguration -> String
showsPrec :: Int -> LaunchTemplateConfiguration -> ShowS
$cshowsPrec :: Int -> LaunchTemplateConfiguration -> ShowS
Prelude.Show, (forall x.
 LaunchTemplateConfiguration -> Rep LaunchTemplateConfiguration x)
-> (forall x.
    Rep LaunchTemplateConfiguration x -> LaunchTemplateConfiguration)
-> Generic LaunchTemplateConfiguration
forall x.
Rep LaunchTemplateConfiguration x -> LaunchTemplateConfiguration
forall x.
LaunchTemplateConfiguration -> Rep LaunchTemplateConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LaunchTemplateConfiguration x -> LaunchTemplateConfiguration
$cfrom :: forall x.
LaunchTemplateConfiguration -> Rep LaunchTemplateConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LaunchTemplateConfiguration' 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:
--
-- 'setDefaultVersion', 'launchTemplateConfiguration_setDefaultVersion' - Set the specified Amazon EC2 launch template as the default launch
-- template for the specified account.
--
-- 'accountId', 'launchTemplateConfiguration_accountId' - The account ID that this configuration applies to.
--
-- 'launchTemplateId', 'launchTemplateConfiguration_launchTemplateId' - Identifies the Amazon EC2 launch template to use.
newLaunchTemplateConfiguration ::
  -- | 'launchTemplateId'
  Prelude.Text ->
  LaunchTemplateConfiguration
newLaunchTemplateConfiguration :: Text -> LaunchTemplateConfiguration
newLaunchTemplateConfiguration Text
pLaunchTemplateId_ =
  LaunchTemplateConfiguration' :: Maybe Bool -> Maybe Text -> Text -> LaunchTemplateConfiguration
LaunchTemplateConfiguration'
    { $sel:setDefaultVersion:LaunchTemplateConfiguration' :: Maybe Bool
setDefaultVersion =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:LaunchTemplateConfiguration' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:launchTemplateId:LaunchTemplateConfiguration' :: Text
launchTemplateId = Text
pLaunchTemplateId_
    }

-- | Set the specified Amazon EC2 launch template as the default launch
-- template for the specified account.
launchTemplateConfiguration_setDefaultVersion :: Lens.Lens' LaunchTemplateConfiguration (Prelude.Maybe Prelude.Bool)
launchTemplateConfiguration_setDefaultVersion :: (Maybe Bool -> f (Maybe Bool))
-> LaunchTemplateConfiguration -> f LaunchTemplateConfiguration
launchTemplateConfiguration_setDefaultVersion = (LaunchTemplateConfiguration -> Maybe Bool)
-> (LaunchTemplateConfiguration
    -> Maybe Bool -> LaunchTemplateConfiguration)
-> Lens
     LaunchTemplateConfiguration
     LaunchTemplateConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateConfiguration' {Maybe Bool
setDefaultVersion :: Maybe Bool
$sel:setDefaultVersion:LaunchTemplateConfiguration' :: LaunchTemplateConfiguration -> Maybe Bool
setDefaultVersion} -> Maybe Bool
setDefaultVersion) (\s :: LaunchTemplateConfiguration
s@LaunchTemplateConfiguration' {} Maybe Bool
a -> LaunchTemplateConfiguration
s {$sel:setDefaultVersion:LaunchTemplateConfiguration' :: Maybe Bool
setDefaultVersion = Maybe Bool
a} :: LaunchTemplateConfiguration)

-- | The account ID that this configuration applies to.
launchTemplateConfiguration_accountId :: Lens.Lens' LaunchTemplateConfiguration (Prelude.Maybe Prelude.Text)
launchTemplateConfiguration_accountId :: (Maybe Text -> f (Maybe Text))
-> LaunchTemplateConfiguration -> f LaunchTemplateConfiguration
launchTemplateConfiguration_accountId = (LaunchTemplateConfiguration -> Maybe Text)
-> (LaunchTemplateConfiguration
    -> Maybe Text -> LaunchTemplateConfiguration)
-> Lens
     LaunchTemplateConfiguration
     LaunchTemplateConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateConfiguration' {Maybe Text
accountId :: Maybe Text
$sel:accountId:LaunchTemplateConfiguration' :: LaunchTemplateConfiguration -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: LaunchTemplateConfiguration
s@LaunchTemplateConfiguration' {} Maybe Text
a -> LaunchTemplateConfiguration
s {$sel:accountId:LaunchTemplateConfiguration' :: Maybe Text
accountId = Maybe Text
a} :: LaunchTemplateConfiguration)

-- | Identifies the Amazon EC2 launch template to use.
launchTemplateConfiguration_launchTemplateId :: Lens.Lens' LaunchTemplateConfiguration Prelude.Text
launchTemplateConfiguration_launchTemplateId :: (Text -> f Text)
-> LaunchTemplateConfiguration -> f LaunchTemplateConfiguration
launchTemplateConfiguration_launchTemplateId = (LaunchTemplateConfiguration -> Text)
-> (LaunchTemplateConfiguration
    -> Text -> LaunchTemplateConfiguration)
-> Lens
     LaunchTemplateConfiguration LaunchTemplateConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateConfiguration' {Text
launchTemplateId :: Text
$sel:launchTemplateId:LaunchTemplateConfiguration' :: LaunchTemplateConfiguration -> Text
launchTemplateId} -> Text
launchTemplateId) (\s :: LaunchTemplateConfiguration
s@LaunchTemplateConfiguration' {} Text
a -> LaunchTemplateConfiguration
s {$sel:launchTemplateId:LaunchTemplateConfiguration' :: Text
launchTemplateId = Text
a} :: LaunchTemplateConfiguration)

instance Core.FromJSON LaunchTemplateConfiguration where
  parseJSON :: Value -> Parser LaunchTemplateConfiguration
parseJSON =
    String
-> (Object -> Parser LaunchTemplateConfiguration)
-> Value
-> Parser LaunchTemplateConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LaunchTemplateConfiguration"
      ( \Object
x ->
          Maybe Bool -> Maybe Text -> Text -> LaunchTemplateConfiguration
LaunchTemplateConfiguration'
            (Maybe Bool -> Maybe Text -> Text -> LaunchTemplateConfiguration)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> Text -> LaunchTemplateConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"setDefaultVersion")
            Parser (Maybe Text -> Text -> LaunchTemplateConfiguration)
-> Parser (Maybe Text)
-> Parser (Text -> LaunchTemplateConfiguration)
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
"accountId")
            Parser (Text -> LaunchTemplateConfiguration)
-> Parser Text -> Parser LaunchTemplateConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"launchTemplateId")
      )

instance Prelude.Hashable LaunchTemplateConfiguration

instance Prelude.NFData LaunchTemplateConfiguration

instance Core.ToJSON LaunchTemplateConfiguration where
  toJSON :: LaunchTemplateConfiguration -> Value
toJSON LaunchTemplateConfiguration' {Maybe Bool
Maybe Text
Text
launchTemplateId :: Text
accountId :: Maybe Text
setDefaultVersion :: Maybe Bool
$sel:launchTemplateId:LaunchTemplateConfiguration' :: LaunchTemplateConfiguration -> Text
$sel:accountId:LaunchTemplateConfiguration' :: LaunchTemplateConfiguration -> Maybe Text
$sel:setDefaultVersion:LaunchTemplateConfiguration' :: LaunchTemplateConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"setDefaultVersion" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
setDefaultVersion,
            (Text
"accountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
accountId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"launchTemplateId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
launchTemplateId)
          ]
      )