{-# 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.EC2.Types.FleetLaunchTemplateSpecification
-- 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.EC2.Types.FleetLaunchTemplateSpecification where

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

-- | The Amazon EC2 launch template that can be used by a Spot Fleet to
-- configure Amazon EC2 instances. You must specify either the ID or name
-- of the launch template in the request, but not both.
--
-- For information about launch templates, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html Launch an instance from a launch template>
-- in the /Amazon EC2 User Guide/.
--
-- /See:/ 'newFleetLaunchTemplateSpecification' smart constructor.
data FleetLaunchTemplateSpecification = FleetLaunchTemplateSpecification'
  { -- | The ID of the launch template.
    --
    -- You must specify the @LaunchTemplateId@ or the @LaunchTemplateName@, but
    -- not both.
    FleetLaunchTemplateSpecification -> Maybe Text
launchTemplateId :: Prelude.Maybe Prelude.Text,
    -- | The name of the launch template.
    --
    -- You must specify the @LaunchTemplateName@ or the @LaunchTemplateId@, but
    -- not both.
    FleetLaunchTemplateSpecification -> Maybe Text
launchTemplateName :: Prelude.Maybe Prelude.Text,
    -- | The launch template version number, @$Latest@, or @$Default@. You must
    -- specify a value, otherwise the request fails.
    --
    -- If the value is @$Latest@, Amazon EC2 uses the latest version of the
    -- launch template.
    --
    -- If the value is @$Default@, Amazon EC2 uses the default version of the
    -- launch template.
    FleetLaunchTemplateSpecification -> Maybe Text
version :: Prelude.Maybe Prelude.Text
  }
  deriving (FleetLaunchTemplateSpecification
-> FleetLaunchTemplateSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FleetLaunchTemplateSpecification
-> FleetLaunchTemplateSpecification -> Bool
$c/= :: FleetLaunchTemplateSpecification
-> FleetLaunchTemplateSpecification -> Bool
== :: FleetLaunchTemplateSpecification
-> FleetLaunchTemplateSpecification -> Bool
$c== :: FleetLaunchTemplateSpecification
-> FleetLaunchTemplateSpecification -> Bool
Prelude.Eq, ReadPrec [FleetLaunchTemplateSpecification]
ReadPrec FleetLaunchTemplateSpecification
Int -> ReadS FleetLaunchTemplateSpecification
ReadS [FleetLaunchTemplateSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FleetLaunchTemplateSpecification]
$creadListPrec :: ReadPrec [FleetLaunchTemplateSpecification]
readPrec :: ReadPrec FleetLaunchTemplateSpecification
$creadPrec :: ReadPrec FleetLaunchTemplateSpecification
readList :: ReadS [FleetLaunchTemplateSpecification]
$creadList :: ReadS [FleetLaunchTemplateSpecification]
readsPrec :: Int -> ReadS FleetLaunchTemplateSpecification
$creadsPrec :: Int -> ReadS FleetLaunchTemplateSpecification
Prelude.Read, Int -> FleetLaunchTemplateSpecification -> ShowS
[FleetLaunchTemplateSpecification] -> ShowS
FleetLaunchTemplateSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FleetLaunchTemplateSpecification] -> ShowS
$cshowList :: [FleetLaunchTemplateSpecification] -> ShowS
show :: FleetLaunchTemplateSpecification -> String
$cshow :: FleetLaunchTemplateSpecification -> String
showsPrec :: Int -> FleetLaunchTemplateSpecification -> ShowS
$cshowsPrec :: Int -> FleetLaunchTemplateSpecification -> ShowS
Prelude.Show, forall x.
Rep FleetLaunchTemplateSpecification x
-> FleetLaunchTemplateSpecification
forall x.
FleetLaunchTemplateSpecification
-> Rep FleetLaunchTemplateSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FleetLaunchTemplateSpecification x
-> FleetLaunchTemplateSpecification
$cfrom :: forall x.
FleetLaunchTemplateSpecification
-> Rep FleetLaunchTemplateSpecification x
Prelude.Generic)

-- |
-- Create a value of 'FleetLaunchTemplateSpecification' 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', 'fleetLaunchTemplateSpecification_launchTemplateId' - The ID of the launch template.
--
-- You must specify the @LaunchTemplateId@ or the @LaunchTemplateName@, but
-- not both.
--
-- 'launchTemplateName', 'fleetLaunchTemplateSpecification_launchTemplateName' - The name of the launch template.
--
-- You must specify the @LaunchTemplateName@ or the @LaunchTemplateId@, but
-- not both.
--
-- 'version', 'fleetLaunchTemplateSpecification_version' - The launch template version number, @$Latest@, or @$Default@. You must
-- specify a value, otherwise the request fails.
--
-- If the value is @$Latest@, Amazon EC2 uses the latest version of the
-- launch template.
--
-- If the value is @$Default@, Amazon EC2 uses the default version of the
-- launch template.
newFleetLaunchTemplateSpecification ::
  FleetLaunchTemplateSpecification
newFleetLaunchTemplateSpecification :: FleetLaunchTemplateSpecification
newFleetLaunchTemplateSpecification =
  FleetLaunchTemplateSpecification'
    { $sel:launchTemplateId:FleetLaunchTemplateSpecification' :: Maybe Text
launchTemplateId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:launchTemplateName:FleetLaunchTemplateSpecification' :: Maybe Text
launchTemplateName = forall a. Maybe a
Prelude.Nothing,
      $sel:version:FleetLaunchTemplateSpecification' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the launch template.
--
-- You must specify the @LaunchTemplateId@ or the @LaunchTemplateName@, but
-- not both.
fleetLaunchTemplateSpecification_launchTemplateId :: Lens.Lens' FleetLaunchTemplateSpecification (Prelude.Maybe Prelude.Text)
fleetLaunchTemplateSpecification_launchTemplateId :: Lens' FleetLaunchTemplateSpecification (Maybe Text)
fleetLaunchTemplateSpecification_launchTemplateId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FleetLaunchTemplateSpecification' {Maybe Text
launchTemplateId :: Maybe Text
$sel:launchTemplateId:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> Maybe Text
launchTemplateId} -> Maybe Text
launchTemplateId) (\s :: FleetLaunchTemplateSpecification
s@FleetLaunchTemplateSpecification' {} Maybe Text
a -> FleetLaunchTemplateSpecification
s {$sel:launchTemplateId:FleetLaunchTemplateSpecification' :: Maybe Text
launchTemplateId = Maybe Text
a} :: FleetLaunchTemplateSpecification)

-- | The name of the launch template.
--
-- You must specify the @LaunchTemplateName@ or the @LaunchTemplateId@, but
-- not both.
fleetLaunchTemplateSpecification_launchTemplateName :: Lens.Lens' FleetLaunchTemplateSpecification (Prelude.Maybe Prelude.Text)
fleetLaunchTemplateSpecification_launchTemplateName :: Lens' FleetLaunchTemplateSpecification (Maybe Text)
fleetLaunchTemplateSpecification_launchTemplateName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FleetLaunchTemplateSpecification' {Maybe Text
launchTemplateName :: Maybe Text
$sel:launchTemplateName:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> Maybe Text
launchTemplateName} -> Maybe Text
launchTemplateName) (\s :: FleetLaunchTemplateSpecification
s@FleetLaunchTemplateSpecification' {} Maybe Text
a -> FleetLaunchTemplateSpecification
s {$sel:launchTemplateName:FleetLaunchTemplateSpecification' :: Maybe Text
launchTemplateName = Maybe Text
a} :: FleetLaunchTemplateSpecification)

-- | The launch template version number, @$Latest@, or @$Default@. You must
-- specify a value, otherwise the request fails.
--
-- If the value is @$Latest@, Amazon EC2 uses the latest version of the
-- launch template.
--
-- If the value is @$Default@, Amazon EC2 uses the default version of the
-- launch template.
fleetLaunchTemplateSpecification_version :: Lens.Lens' FleetLaunchTemplateSpecification (Prelude.Maybe Prelude.Text)
fleetLaunchTemplateSpecification_version :: Lens' FleetLaunchTemplateSpecification (Maybe Text)
fleetLaunchTemplateSpecification_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FleetLaunchTemplateSpecification' {Maybe Text
version :: Maybe Text
$sel:version:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> Maybe Text
version} -> Maybe Text
version) (\s :: FleetLaunchTemplateSpecification
s@FleetLaunchTemplateSpecification' {} Maybe Text
a -> FleetLaunchTemplateSpecification
s {$sel:version:FleetLaunchTemplateSpecification' :: Maybe Text
version = Maybe Text
a} :: FleetLaunchTemplateSpecification)

instance
  Data.FromXML
    FleetLaunchTemplateSpecification
  where
  parseXML :: [Node] -> Either String FleetLaunchTemplateSpecification
parseXML [Node]
x =
    Maybe Text
-> Maybe Text -> Maybe Text -> FleetLaunchTemplateSpecification
FleetLaunchTemplateSpecification'
      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
    FleetLaunchTemplateSpecification
  where
  hashWithSalt :: Int -> FleetLaunchTemplateSpecification -> Int
hashWithSalt
    Int
_salt
    FleetLaunchTemplateSpecification' {Maybe Text
version :: Maybe Text
launchTemplateName :: Maybe Text
launchTemplateId :: Maybe Text
$sel:version:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateName:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateId:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> 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
    FleetLaunchTemplateSpecification
  where
  rnf :: FleetLaunchTemplateSpecification -> ()
rnf FleetLaunchTemplateSpecification' {Maybe Text
version :: Maybe Text
launchTemplateName :: Maybe Text
launchTemplateId :: Maybe Text
$sel:version:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateName:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateId:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> 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
    FleetLaunchTemplateSpecification
  where
  toQuery :: FleetLaunchTemplateSpecification -> QueryString
toQuery FleetLaunchTemplateSpecification' {Maybe Text
version :: Maybe Text
launchTemplateName :: Maybe Text
launchTemplateId :: Maybe Text
$sel:version:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateName:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> Maybe Text
$sel:launchTemplateId:FleetLaunchTemplateSpecification' :: FleetLaunchTemplateSpecification -> 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
      ]