{-# 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.SMS.Types.ServerGroupLaunchConfiguration
-- 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.SMS.Types.ServerGroupLaunchConfiguration 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
import Amazonka.SMS.Types.ServerLaunchConfiguration

-- | Launch configuration for a server group.
--
-- /See:/ 'newServerGroupLaunchConfiguration' smart constructor.
data ServerGroupLaunchConfiguration = ServerGroupLaunchConfiguration'
  { -- | The launch order of servers in the server group.
    ServerGroupLaunchConfiguration -> Maybe Int
launchOrder :: Prelude.Maybe Prelude.Int,
    -- | The ID of the server group with which the launch configuration is
    -- associated.
    ServerGroupLaunchConfiguration -> Maybe Text
serverGroupId :: Prelude.Maybe Prelude.Text,
    -- | The launch configuration for servers in the server group.
    ServerGroupLaunchConfiguration -> Maybe [ServerLaunchConfiguration]
serverLaunchConfigurations :: Prelude.Maybe [ServerLaunchConfiguration]
  }
  deriving (ServerGroupLaunchConfiguration
-> ServerGroupLaunchConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServerGroupLaunchConfiguration
-> ServerGroupLaunchConfiguration -> Bool
$c/= :: ServerGroupLaunchConfiguration
-> ServerGroupLaunchConfiguration -> Bool
== :: ServerGroupLaunchConfiguration
-> ServerGroupLaunchConfiguration -> Bool
$c== :: ServerGroupLaunchConfiguration
-> ServerGroupLaunchConfiguration -> Bool
Prelude.Eq, ReadPrec [ServerGroupLaunchConfiguration]
ReadPrec ServerGroupLaunchConfiguration
Int -> ReadS ServerGroupLaunchConfiguration
ReadS [ServerGroupLaunchConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServerGroupLaunchConfiguration]
$creadListPrec :: ReadPrec [ServerGroupLaunchConfiguration]
readPrec :: ReadPrec ServerGroupLaunchConfiguration
$creadPrec :: ReadPrec ServerGroupLaunchConfiguration
readList :: ReadS [ServerGroupLaunchConfiguration]
$creadList :: ReadS [ServerGroupLaunchConfiguration]
readsPrec :: Int -> ReadS ServerGroupLaunchConfiguration
$creadsPrec :: Int -> ReadS ServerGroupLaunchConfiguration
Prelude.Read, Int -> ServerGroupLaunchConfiguration -> ShowS
[ServerGroupLaunchConfiguration] -> ShowS
ServerGroupLaunchConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServerGroupLaunchConfiguration] -> ShowS
$cshowList :: [ServerGroupLaunchConfiguration] -> ShowS
show :: ServerGroupLaunchConfiguration -> String
$cshow :: ServerGroupLaunchConfiguration -> String
showsPrec :: Int -> ServerGroupLaunchConfiguration -> ShowS
$cshowsPrec :: Int -> ServerGroupLaunchConfiguration -> ShowS
Prelude.Show, forall x.
Rep ServerGroupLaunchConfiguration x
-> ServerGroupLaunchConfiguration
forall x.
ServerGroupLaunchConfiguration
-> Rep ServerGroupLaunchConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ServerGroupLaunchConfiguration x
-> ServerGroupLaunchConfiguration
$cfrom :: forall x.
ServerGroupLaunchConfiguration
-> Rep ServerGroupLaunchConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ServerGroupLaunchConfiguration' 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:
--
-- 'launchOrder', 'serverGroupLaunchConfiguration_launchOrder' - The launch order of servers in the server group.
--
-- 'serverGroupId', 'serverGroupLaunchConfiguration_serverGroupId' - The ID of the server group with which the launch configuration is
-- associated.
--
-- 'serverLaunchConfigurations', 'serverGroupLaunchConfiguration_serverLaunchConfigurations' - The launch configuration for servers in the server group.
newServerGroupLaunchConfiguration ::
  ServerGroupLaunchConfiguration
newServerGroupLaunchConfiguration :: ServerGroupLaunchConfiguration
newServerGroupLaunchConfiguration =
  ServerGroupLaunchConfiguration'
    { $sel:launchOrder:ServerGroupLaunchConfiguration' :: Maybe Int
launchOrder =
        forall a. Maybe a
Prelude.Nothing,
      $sel:serverGroupId:ServerGroupLaunchConfiguration' :: Maybe Text
serverGroupId = forall a. Maybe a
Prelude.Nothing,
      $sel:serverLaunchConfigurations:ServerGroupLaunchConfiguration' :: Maybe [ServerLaunchConfiguration]
serverLaunchConfigurations =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The launch order of servers in the server group.
serverGroupLaunchConfiguration_launchOrder :: Lens.Lens' ServerGroupLaunchConfiguration (Prelude.Maybe Prelude.Int)
serverGroupLaunchConfiguration_launchOrder :: Lens' ServerGroupLaunchConfiguration (Maybe Int)
serverGroupLaunchConfiguration_launchOrder = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerGroupLaunchConfiguration' {Maybe Int
launchOrder :: Maybe Int
$sel:launchOrder:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe Int
launchOrder} -> Maybe Int
launchOrder) (\s :: ServerGroupLaunchConfiguration
s@ServerGroupLaunchConfiguration' {} Maybe Int
a -> ServerGroupLaunchConfiguration
s {$sel:launchOrder:ServerGroupLaunchConfiguration' :: Maybe Int
launchOrder = Maybe Int
a} :: ServerGroupLaunchConfiguration)

-- | The ID of the server group with which the launch configuration is
-- associated.
serverGroupLaunchConfiguration_serverGroupId :: Lens.Lens' ServerGroupLaunchConfiguration (Prelude.Maybe Prelude.Text)
serverGroupLaunchConfiguration_serverGroupId :: Lens' ServerGroupLaunchConfiguration (Maybe Text)
serverGroupLaunchConfiguration_serverGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerGroupLaunchConfiguration' {Maybe Text
serverGroupId :: Maybe Text
$sel:serverGroupId:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe Text
serverGroupId} -> Maybe Text
serverGroupId) (\s :: ServerGroupLaunchConfiguration
s@ServerGroupLaunchConfiguration' {} Maybe Text
a -> ServerGroupLaunchConfiguration
s {$sel:serverGroupId:ServerGroupLaunchConfiguration' :: Maybe Text
serverGroupId = Maybe Text
a} :: ServerGroupLaunchConfiguration)

-- | The launch configuration for servers in the server group.
serverGroupLaunchConfiguration_serverLaunchConfigurations :: Lens.Lens' ServerGroupLaunchConfiguration (Prelude.Maybe [ServerLaunchConfiguration])
serverGroupLaunchConfiguration_serverLaunchConfigurations :: Lens'
  ServerGroupLaunchConfiguration (Maybe [ServerLaunchConfiguration])
serverGroupLaunchConfiguration_serverLaunchConfigurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerGroupLaunchConfiguration' {Maybe [ServerLaunchConfiguration]
serverLaunchConfigurations :: Maybe [ServerLaunchConfiguration]
$sel:serverLaunchConfigurations:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe [ServerLaunchConfiguration]
serverLaunchConfigurations} -> Maybe [ServerLaunchConfiguration]
serverLaunchConfigurations) (\s :: ServerGroupLaunchConfiguration
s@ServerGroupLaunchConfiguration' {} Maybe [ServerLaunchConfiguration]
a -> ServerGroupLaunchConfiguration
s {$sel:serverLaunchConfigurations:ServerGroupLaunchConfiguration' :: Maybe [ServerLaunchConfiguration]
serverLaunchConfigurations = Maybe [ServerLaunchConfiguration]
a} :: ServerGroupLaunchConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ServerGroupLaunchConfiguration where
  parseJSON :: Value -> Parser ServerGroupLaunchConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ServerGroupLaunchConfiguration"
      ( \Object
x ->
          Maybe Int
-> Maybe Text
-> Maybe [ServerLaunchConfiguration]
-> ServerGroupLaunchConfiguration
ServerGroupLaunchConfiguration'
            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
"launchOrder")
            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
"serverGroupId")
            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
"serverLaunchConfigurations"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance
  Prelude.Hashable
    ServerGroupLaunchConfiguration
  where
  hashWithSalt :: Int -> ServerGroupLaunchConfiguration -> Int
hashWithSalt
    Int
_salt
    ServerGroupLaunchConfiguration' {Maybe Int
Maybe [ServerLaunchConfiguration]
Maybe Text
serverLaunchConfigurations :: Maybe [ServerLaunchConfiguration]
serverGroupId :: Maybe Text
launchOrder :: Maybe Int
$sel:serverLaunchConfigurations:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe [ServerLaunchConfiguration]
$sel:serverGroupId:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe Text
$sel:launchOrder:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe Int
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
launchOrder
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
serverGroupId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ServerLaunchConfiguration]
serverLaunchConfigurations

instance
  Prelude.NFData
    ServerGroupLaunchConfiguration
  where
  rnf :: ServerGroupLaunchConfiguration -> ()
rnf ServerGroupLaunchConfiguration' {Maybe Int
Maybe [ServerLaunchConfiguration]
Maybe Text
serverLaunchConfigurations :: Maybe [ServerLaunchConfiguration]
serverGroupId :: Maybe Text
launchOrder :: Maybe Int
$sel:serverLaunchConfigurations:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe [ServerLaunchConfiguration]
$sel:serverGroupId:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe Text
$sel:launchOrder:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
launchOrder
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
serverGroupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ServerLaunchConfiguration]
serverLaunchConfigurations

instance Data.ToJSON ServerGroupLaunchConfiguration where
  toJSON :: ServerGroupLaunchConfiguration -> Value
toJSON ServerGroupLaunchConfiguration' {Maybe Int
Maybe [ServerLaunchConfiguration]
Maybe Text
serverLaunchConfigurations :: Maybe [ServerLaunchConfiguration]
serverGroupId :: Maybe Text
launchOrder :: Maybe Int
$sel:serverLaunchConfigurations:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe [ServerLaunchConfiguration]
$sel:serverGroupId:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe Text
$sel:launchOrder:ServerGroupLaunchConfiguration' :: ServerGroupLaunchConfiguration -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"launchOrder" 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 Int
launchOrder,
            (Key
"serverGroupId" 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
serverGroupId,
            (Key
"serverLaunchConfigurations" 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 [ServerLaunchConfiguration]
serverLaunchConfigurations
          ]
      )