{-# 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.AutoScaling.Types.LaunchTemplateSpecification
-- 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.AutoScaling.Types.LaunchTemplateSpecification where

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

-- | Describes the launch template and the version of the launch template
-- that Amazon EC2 Auto Scaling uses to launch Amazon EC2 instances. For
-- more information about launch templates, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/LaunchTemplates.html Launch templates>
-- in the /Amazon EC2 Auto Scaling User Guide/.
--
-- /See:/ 'newLaunchTemplateSpecification' smart constructor.
data LaunchTemplateSpecification = LaunchTemplateSpecification'
  { -- | The ID of the launch template. To get the template ID, use the Amazon
    -- EC2
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeLaunchTemplates.html DescribeLaunchTemplates>
    -- API operation. New launch templates can be created using the Amazon EC2
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplate.html CreateLaunchTemplate>
    -- API.
    --
    -- Conditional: You must specify either a @LaunchTemplateId@ or a
    -- @LaunchTemplateName@.
    LaunchTemplateSpecification -> Maybe Text
launchTemplateId :: Prelude.Maybe Prelude.Text,
    -- | The name of the launch template. To get the template name, use the
    -- Amazon EC2
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeLaunchTemplates.html DescribeLaunchTemplates>
    -- API operation. New launch templates can be created using the Amazon EC2
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplate.html CreateLaunchTemplate>
    -- API.
    --
    -- Conditional: You must specify either a @LaunchTemplateId@ or a
    -- @LaunchTemplateName@.
    LaunchTemplateSpecification -> Maybe Text
launchTemplateName :: Prelude.Maybe Prelude.Text,
    -- | The version number, @$Latest@, or @$Default@. To get the version number,
    -- use the Amazon EC2
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeLaunchTemplateVersions.html DescribeLaunchTemplateVersions>
    -- API operation. New launch template versions can be created using the
    -- Amazon EC2
    -- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplateVersion.html CreateLaunchTemplateVersion>
    -- API. If the value is @$Latest@, Amazon EC2 Auto Scaling selects the
    -- latest version of the launch template when launching instances. If the
    -- value is @$Default@, Amazon EC2 Auto Scaling selects the default version
    -- of the launch template when launching instances. The default value is
    -- @$Default@.
    LaunchTemplateSpecification -> Maybe Text
version :: Prelude.Maybe Prelude.Text
  }
  deriving (LaunchTemplateSpecification -> LaunchTemplateSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LaunchTemplateSpecification -> LaunchTemplateSpecification -> Bool
$c/= :: LaunchTemplateSpecification -> LaunchTemplateSpecification -> Bool
== :: LaunchTemplateSpecification -> LaunchTemplateSpecification -> Bool
$c== :: LaunchTemplateSpecification -> LaunchTemplateSpecification -> Bool
Prelude.Eq, ReadPrec [LaunchTemplateSpecification]
ReadPrec LaunchTemplateSpecification
Int -> ReadS LaunchTemplateSpecification
ReadS [LaunchTemplateSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LaunchTemplateSpecification]
$creadListPrec :: ReadPrec [LaunchTemplateSpecification]
readPrec :: ReadPrec LaunchTemplateSpecification
$creadPrec :: ReadPrec LaunchTemplateSpecification
readList :: ReadS [LaunchTemplateSpecification]
$creadList :: ReadS [LaunchTemplateSpecification]
readsPrec :: Int -> ReadS LaunchTemplateSpecification
$creadsPrec :: Int -> ReadS LaunchTemplateSpecification
Prelude.Read, Int -> LaunchTemplateSpecification -> ShowS
[LaunchTemplateSpecification] -> ShowS
LaunchTemplateSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LaunchTemplateSpecification] -> ShowS
$cshowList :: [LaunchTemplateSpecification] -> ShowS
show :: LaunchTemplateSpecification -> String
$cshow :: LaunchTemplateSpecification -> String
showsPrec :: Int -> LaunchTemplateSpecification -> ShowS
$cshowsPrec :: Int -> LaunchTemplateSpecification -> ShowS
Prelude.Show, forall x.
Rep LaunchTemplateSpecification x -> LaunchTemplateSpecification
forall x.
LaunchTemplateSpecification -> Rep LaunchTemplateSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LaunchTemplateSpecification x -> LaunchTemplateSpecification
$cfrom :: forall x.
LaunchTemplateSpecification -> Rep LaunchTemplateSpecification x
Prelude.Generic)

-- |
-- Create a value of 'LaunchTemplateSpecification' 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:
--
-- 'launchTemplateId', 'launchTemplateSpecification_launchTemplateId' - The ID of the launch template. To get the template ID, use the Amazon
-- EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeLaunchTemplates.html DescribeLaunchTemplates>
-- API operation. New launch templates can be created using the Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplate.html CreateLaunchTemplate>
-- API.
--
-- Conditional: You must specify either a @LaunchTemplateId@ or a
-- @LaunchTemplateName@.
--
-- 'launchTemplateName', 'launchTemplateSpecification_launchTemplateName' - The name of the launch template. To get the template name, use the
-- Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeLaunchTemplates.html DescribeLaunchTemplates>
-- API operation. New launch templates can be created using the Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplate.html CreateLaunchTemplate>
-- API.
--
-- Conditional: You must specify either a @LaunchTemplateId@ or a
-- @LaunchTemplateName@.
--
-- 'version', 'launchTemplateSpecification_version' - The version number, @$Latest@, or @$Default@. To get the version number,
-- use the Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeLaunchTemplateVersions.html DescribeLaunchTemplateVersions>
-- API operation. New launch template versions can be created using the
-- Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplateVersion.html CreateLaunchTemplateVersion>
-- API. If the value is @$Latest@, Amazon EC2 Auto Scaling selects the
-- latest version of the launch template when launching instances. If the
-- value is @$Default@, Amazon EC2 Auto Scaling selects the default version
-- of the launch template when launching instances. The default value is
-- @$Default@.
newLaunchTemplateSpecification ::
  LaunchTemplateSpecification
newLaunchTemplateSpecification :: LaunchTemplateSpecification
newLaunchTemplateSpecification =
  LaunchTemplateSpecification'
    { $sel:launchTemplateId:LaunchTemplateSpecification' :: Maybe Text
launchTemplateId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:launchTemplateName:LaunchTemplateSpecification' :: Maybe Text
launchTemplateName = forall a. Maybe a
Prelude.Nothing,
      $sel:version:LaunchTemplateSpecification' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the launch template. To get the template ID, use the Amazon
-- EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeLaunchTemplates.html DescribeLaunchTemplates>
-- API operation. New launch templates can be created using the Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplate.html CreateLaunchTemplate>
-- API.
--
-- Conditional: You must specify either a @LaunchTemplateId@ or a
-- @LaunchTemplateName@.
launchTemplateSpecification_launchTemplateId :: Lens.Lens' LaunchTemplateSpecification (Prelude.Maybe Prelude.Text)
launchTemplateSpecification_launchTemplateId :: Lens' LaunchTemplateSpecification (Maybe Text)
launchTemplateSpecification_launchTemplateId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateSpecification' {Maybe Text
launchTemplateId :: Maybe Text
$sel:launchTemplateId:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
launchTemplateId} -> Maybe Text
launchTemplateId) (\s :: LaunchTemplateSpecification
s@LaunchTemplateSpecification' {} Maybe Text
a -> LaunchTemplateSpecification
s {$sel:launchTemplateId:LaunchTemplateSpecification' :: Maybe Text
launchTemplateId = Maybe Text
a} :: LaunchTemplateSpecification)

-- | The name of the launch template. To get the template name, use the
-- Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeLaunchTemplates.html DescribeLaunchTemplates>
-- API operation. New launch templates can be created using the Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplate.html CreateLaunchTemplate>
-- API.
--
-- Conditional: You must specify either a @LaunchTemplateId@ or a
-- @LaunchTemplateName@.
launchTemplateSpecification_launchTemplateName :: Lens.Lens' LaunchTemplateSpecification (Prelude.Maybe Prelude.Text)
launchTemplateSpecification_launchTemplateName :: Lens' LaunchTemplateSpecification (Maybe Text)
launchTemplateSpecification_launchTemplateName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateSpecification' {Maybe Text
launchTemplateName :: Maybe Text
$sel:launchTemplateName:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
launchTemplateName} -> Maybe Text
launchTemplateName) (\s :: LaunchTemplateSpecification
s@LaunchTemplateSpecification' {} Maybe Text
a -> LaunchTemplateSpecification
s {$sel:launchTemplateName:LaunchTemplateSpecification' :: Maybe Text
launchTemplateName = Maybe Text
a} :: LaunchTemplateSpecification)

-- | The version number, @$Latest@, or @$Default@. To get the version number,
-- use the Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeLaunchTemplateVersions.html DescribeLaunchTemplateVersions>
-- API operation. New launch template versions can be created using the
-- Amazon EC2
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplateVersion.html CreateLaunchTemplateVersion>
-- API. If the value is @$Latest@, Amazon EC2 Auto Scaling selects the
-- latest version of the launch template when launching instances. If the
-- value is @$Default@, Amazon EC2 Auto Scaling selects the default version
-- of the launch template when launching instances. The default value is
-- @$Default@.
launchTemplateSpecification_version :: Lens.Lens' LaunchTemplateSpecification (Prelude.Maybe Prelude.Text)
launchTemplateSpecification_version :: Lens' LaunchTemplateSpecification (Maybe Text)
launchTemplateSpecification_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateSpecification' {Maybe Text
version :: Maybe Text
$sel:version:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
version} -> Maybe Text
version) (\s :: LaunchTemplateSpecification
s@LaunchTemplateSpecification' {} Maybe Text
a -> LaunchTemplateSpecification
s {$sel:version:LaunchTemplateSpecification' :: Maybe Text
version = Maybe Text
a} :: LaunchTemplateSpecification)

instance Data.FromXML LaunchTemplateSpecification where
  parseXML :: [Node] -> Either String LaunchTemplateSpecification
parseXML [Node]
x =
    Maybe Text
-> Maybe Text -> Maybe Text -> LaunchTemplateSpecification
LaunchTemplateSpecification'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"LaunchTemplateId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"LaunchTemplateName")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Version")

instance Prelude.Hashable LaunchTemplateSpecification where
  hashWithSalt :: Int -> LaunchTemplateSpecification -> Int
hashWithSalt Int
_salt LaunchTemplateSpecification' {Maybe Text
version :: Maybe Text
launchTemplateName :: Maybe Text
launchTemplateId :: Maybe Text
$sel:version:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateName:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateId:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
launchTemplateId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
launchTemplateName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
version

instance Prelude.NFData LaunchTemplateSpecification where
  rnf :: LaunchTemplateSpecification -> ()
rnf LaunchTemplateSpecification' {Maybe Text
version :: Maybe Text
launchTemplateName :: Maybe Text
launchTemplateId :: Maybe Text
$sel:version:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateName:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateId:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
launchTemplateId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
launchTemplateName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
version

instance Data.ToQuery LaunchTemplateSpecification where
  toQuery :: LaunchTemplateSpecification -> QueryString
toQuery LaunchTemplateSpecification' {Maybe Text
version :: Maybe Text
launchTemplateName :: Maybe Text
launchTemplateId :: Maybe Text
$sel:version:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateName:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateId:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"LaunchTemplateId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
launchTemplateId,
        ByteString
"LaunchTemplateName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
launchTemplateName,
        ByteString
"Version" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
version
      ]