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

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

-- | An object representing a node group launch template specification. The
-- launch template cannot include
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateNetworkInterface.html SubnetId>
-- ,
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_IamInstanceProfile.html IamInstanceProfile>
-- ,
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RequestSpotInstances.html RequestSpotInstances>
-- ,
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_HibernationOptionsRequest.html HibernationOptions>
-- , or
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_TerminateInstances.html TerminateInstances>
-- , or the node group deployment or update will fail. For more information
-- about launch templates, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateLaunchTemplate.html CreateLaunchTemplate>
-- in the Amazon EC2 API Reference. For more information about using launch
-- templates with Amazon EKS, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/launch-templates.html Launch template support>
-- in the Amazon EKS User Guide.
--
-- Specify either @name@ or @id@, but not both.
--
-- /See:/ 'newLaunchTemplateSpecification' smart constructor.
data LaunchTemplateSpecification = LaunchTemplateSpecification'
  { -- | The name of the launch template.
    LaunchTemplateSpecification -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The version of the launch template to use. If no version is specified,
    -- then the template\'s default version is used.
    LaunchTemplateSpecification -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | The ID of the launch template.
    LaunchTemplateSpecification -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (LaunchTemplateSpecification -> LaunchTemplateSpecification -> Bool
(LaunchTemplateSpecification
 -> LaunchTemplateSpecification -> Bool)
-> (LaunchTemplateSpecification
    -> LaunchTemplateSpecification -> Bool)
-> Eq LaunchTemplateSpecification
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]
(Int -> ReadS LaunchTemplateSpecification)
-> ReadS [LaunchTemplateSpecification]
-> ReadPrec LaunchTemplateSpecification
-> ReadPrec [LaunchTemplateSpecification]
-> Read 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
(Int -> LaunchTemplateSpecification -> ShowS)
-> (LaunchTemplateSpecification -> String)
-> ([LaunchTemplateSpecification] -> ShowS)
-> Show LaunchTemplateSpecification
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.
 LaunchTemplateSpecification -> Rep LaunchTemplateSpecification x)
-> (forall x.
    Rep LaunchTemplateSpecification x -> LaunchTemplateSpecification)
-> Generic LaunchTemplateSpecification
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:
--
-- 'name', 'launchTemplateSpecification_name' - The name of the launch template.
--
-- 'version', 'launchTemplateSpecification_version' - The version of the launch template to use. If no version is specified,
-- then the template\'s default version is used.
--
-- 'id', 'launchTemplateSpecification_id' - The ID of the launch template.
newLaunchTemplateSpecification ::
  LaunchTemplateSpecification
newLaunchTemplateSpecification :: LaunchTemplateSpecification
newLaunchTemplateSpecification =
  LaunchTemplateSpecification' :: Maybe Text
-> Maybe Text -> Maybe Text -> LaunchTemplateSpecification
LaunchTemplateSpecification'
    { $sel:name:LaunchTemplateSpecification' :: Maybe Text
name =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:version:LaunchTemplateSpecification' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:LaunchTemplateSpecification' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the launch template.
launchTemplateSpecification_name :: Lens.Lens' LaunchTemplateSpecification (Prelude.Maybe Prelude.Text)
launchTemplateSpecification_name :: (Maybe Text -> f (Maybe Text))
-> LaunchTemplateSpecification -> f LaunchTemplateSpecification
launchTemplateSpecification_name = (LaunchTemplateSpecification -> Maybe Text)
-> (LaunchTemplateSpecification
    -> Maybe Text -> LaunchTemplateSpecification)
-> Lens
     LaunchTemplateSpecification
     LaunchTemplateSpecification
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateSpecification' {Maybe Text
name :: Maybe Text
$sel:name:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
name} -> Maybe Text
name) (\s :: LaunchTemplateSpecification
s@LaunchTemplateSpecification' {} Maybe Text
a -> LaunchTemplateSpecification
s {$sel:name:LaunchTemplateSpecification' :: Maybe Text
name = Maybe Text
a} :: LaunchTemplateSpecification)

-- | The version of the launch template to use. If no version is specified,
-- then the template\'s default version is used.
launchTemplateSpecification_version :: Lens.Lens' LaunchTemplateSpecification (Prelude.Maybe Prelude.Text)
launchTemplateSpecification_version :: (Maybe Text -> f (Maybe Text))
-> LaunchTemplateSpecification -> f LaunchTemplateSpecification
launchTemplateSpecification_version = (LaunchTemplateSpecification -> Maybe Text)
-> (LaunchTemplateSpecification
    -> Maybe Text -> LaunchTemplateSpecification)
-> Lens
     LaunchTemplateSpecification
     LaunchTemplateSpecification
     (Maybe Text)
     (Maybe Text)
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)

-- | The ID of the launch template.
launchTemplateSpecification_id :: Lens.Lens' LaunchTemplateSpecification (Prelude.Maybe Prelude.Text)
launchTemplateSpecification_id :: (Maybe Text -> f (Maybe Text))
-> LaunchTemplateSpecification -> f LaunchTemplateSpecification
launchTemplateSpecification_id = (LaunchTemplateSpecification -> Maybe Text)
-> (LaunchTemplateSpecification
    -> Maybe Text -> LaunchTemplateSpecification)
-> Lens
     LaunchTemplateSpecification
     LaunchTemplateSpecification
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchTemplateSpecification' {Maybe Text
id :: Maybe Text
$sel:id:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
id} -> Maybe Text
id) (\s :: LaunchTemplateSpecification
s@LaunchTemplateSpecification' {} Maybe Text
a -> LaunchTemplateSpecification
s {$sel:id:LaunchTemplateSpecification' :: Maybe Text
id = Maybe Text
a} :: LaunchTemplateSpecification)

instance Core.FromJSON LaunchTemplateSpecification where
  parseJSON :: Value -> Parser LaunchTemplateSpecification
parseJSON =
    String
-> (Object -> Parser LaunchTemplateSpecification)
-> Value
-> Parser LaunchTemplateSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LaunchTemplateSpecification"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> LaunchTemplateSpecification
LaunchTemplateSpecification'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> LaunchTemplateSpecification)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> LaunchTemplateSpecification)
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
"name")
            Parser (Maybe Text -> Maybe Text -> LaunchTemplateSpecification)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> LaunchTemplateSpecification)
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
"version")
            Parser (Maybe Text -> LaunchTemplateSpecification)
-> Parser (Maybe Text) -> Parser LaunchTemplateSpecification
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
"id")
      )

instance Prelude.Hashable LaunchTemplateSpecification

instance Prelude.NFData LaunchTemplateSpecification

instance Core.ToJSON LaunchTemplateSpecification where
  toJSON :: LaunchTemplateSpecification -> Value
toJSON LaunchTemplateSpecification' {Maybe Text
id :: Maybe Text
version :: Maybe Text
name :: Maybe Text
$sel:id:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
$sel:version:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
$sel:name:LaunchTemplateSpecification' :: LaunchTemplateSpecification -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"name" 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
name,
            (Text
"version" 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
version,
            (Text
"id" 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
id
          ]
      )