{-# 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-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.SMS.Types.ServerGroupLaunchConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 ID of the server group with which the launch configuration is
    -- associated.
    ServerGroupLaunchConfiguration -> Maybe Text
serverGroupId :: Prelude.Maybe Prelude.Text,
    -- | The launch order of servers in the server group.
    ServerGroupLaunchConfiguration -> Maybe Int
launchOrder :: Prelude.Maybe Prelude.Int,
    -- | The launch configuration for servers in the server group.
    ServerGroupLaunchConfiguration -> Maybe [ServerLaunchConfiguration]
serverLaunchConfigurations :: Prelude.Maybe [ServerLaunchConfiguration]
  }
  deriving (ServerGroupLaunchConfiguration
-> ServerGroupLaunchConfiguration -> Bool
(ServerGroupLaunchConfiguration
 -> ServerGroupLaunchConfiguration -> Bool)
-> (ServerGroupLaunchConfiguration
    -> ServerGroupLaunchConfiguration -> Bool)
-> Eq ServerGroupLaunchConfiguration
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]
(Int -> ReadS ServerGroupLaunchConfiguration)
-> ReadS [ServerGroupLaunchConfiguration]
-> ReadPrec ServerGroupLaunchConfiguration
-> ReadPrec [ServerGroupLaunchConfiguration]
-> Read 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
(Int -> ServerGroupLaunchConfiguration -> ShowS)
-> (ServerGroupLaunchConfiguration -> String)
-> ([ServerGroupLaunchConfiguration] -> ShowS)
-> Show ServerGroupLaunchConfiguration
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.
 ServerGroupLaunchConfiguration
 -> Rep ServerGroupLaunchConfiguration x)
-> (forall x.
    Rep ServerGroupLaunchConfiguration x
    -> ServerGroupLaunchConfiguration)
-> Generic ServerGroupLaunchConfiguration
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:
--
-- 'serverGroupId', 'serverGroupLaunchConfiguration_serverGroupId' - The ID of the server group with which the launch configuration is
-- associated.
--
-- 'launchOrder', 'serverGroupLaunchConfiguration_launchOrder' - The launch order of servers in the server group.
--
-- 'serverLaunchConfigurations', 'serverGroupLaunchConfiguration_serverLaunchConfigurations' - The launch configuration for servers in the server group.
newServerGroupLaunchConfiguration ::
  ServerGroupLaunchConfiguration
newServerGroupLaunchConfiguration :: ServerGroupLaunchConfiguration
newServerGroupLaunchConfiguration =
  ServerGroupLaunchConfiguration' :: Maybe Text
-> Maybe Int
-> Maybe [ServerLaunchConfiguration]
-> ServerGroupLaunchConfiguration
ServerGroupLaunchConfiguration'
    { $sel:serverGroupId:ServerGroupLaunchConfiguration' :: Maybe Text
serverGroupId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:launchOrder:ServerGroupLaunchConfiguration' :: Maybe Int
launchOrder = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:serverLaunchConfigurations:ServerGroupLaunchConfiguration' :: Maybe [ServerLaunchConfiguration]
serverLaunchConfigurations =
        Maybe [ServerLaunchConfiguration]
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the server group with which the launch configuration is
-- associated.
serverGroupLaunchConfiguration_serverGroupId :: Lens.Lens' ServerGroupLaunchConfiguration (Prelude.Maybe Prelude.Text)
serverGroupLaunchConfiguration_serverGroupId :: (Maybe Text -> f (Maybe Text))
-> ServerGroupLaunchConfiguration
-> f ServerGroupLaunchConfiguration
serverGroupLaunchConfiguration_serverGroupId = (ServerGroupLaunchConfiguration -> Maybe Text)
-> (ServerGroupLaunchConfiguration
    -> Maybe Text -> ServerGroupLaunchConfiguration)
-> Lens
     ServerGroupLaunchConfiguration
     ServerGroupLaunchConfiguration
     (Maybe Text)
     (Maybe Text)
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 order of servers in the server group.
serverGroupLaunchConfiguration_launchOrder :: Lens.Lens' ServerGroupLaunchConfiguration (Prelude.Maybe Prelude.Int)
serverGroupLaunchConfiguration_launchOrder :: (Maybe Int -> f (Maybe Int))
-> ServerGroupLaunchConfiguration
-> f ServerGroupLaunchConfiguration
serverGroupLaunchConfiguration_launchOrder = (ServerGroupLaunchConfiguration -> Maybe Int)
-> (ServerGroupLaunchConfiguration
    -> Maybe Int -> ServerGroupLaunchConfiguration)
-> Lens
     ServerGroupLaunchConfiguration
     ServerGroupLaunchConfiguration
     (Maybe Int)
     (Maybe Int)
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 launch configuration for servers in the server group.
serverGroupLaunchConfiguration_serverLaunchConfigurations :: Lens.Lens' ServerGroupLaunchConfiguration (Prelude.Maybe [ServerLaunchConfiguration])
serverGroupLaunchConfiguration_serverLaunchConfigurations :: (Maybe [ServerLaunchConfiguration]
 -> f (Maybe [ServerLaunchConfiguration]))
-> ServerGroupLaunchConfiguration
-> f ServerGroupLaunchConfiguration
serverGroupLaunchConfiguration_serverLaunchConfigurations = (ServerGroupLaunchConfiguration
 -> Maybe [ServerLaunchConfiguration])
-> (ServerGroupLaunchConfiguration
    -> Maybe [ServerLaunchConfiguration]
    -> ServerGroupLaunchConfiguration)
-> Lens
     ServerGroupLaunchConfiguration
     ServerGroupLaunchConfiguration
     (Maybe [ServerLaunchConfiguration])
     (Maybe [ServerLaunchConfiguration])
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) ((Maybe [ServerLaunchConfiguration]
  -> f (Maybe [ServerLaunchConfiguration]))
 -> ServerGroupLaunchConfiguration
 -> f ServerGroupLaunchConfiguration)
-> ((Maybe [ServerLaunchConfiguration]
     -> f (Maybe [ServerLaunchConfiguration]))
    -> Maybe [ServerLaunchConfiguration]
    -> f (Maybe [ServerLaunchConfiguration]))
-> (Maybe [ServerLaunchConfiguration]
    -> f (Maybe [ServerLaunchConfiguration]))
-> ServerGroupLaunchConfiguration
-> f ServerGroupLaunchConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ServerLaunchConfiguration]
  [ServerLaunchConfiguration]
  [ServerLaunchConfiguration]
  [ServerLaunchConfiguration]
-> Iso
     (Maybe [ServerLaunchConfiguration])
     (Maybe [ServerLaunchConfiguration])
     (Maybe [ServerLaunchConfiguration])
     (Maybe [ServerLaunchConfiguration])
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 AnIso
  [ServerLaunchConfiguration]
  [ServerLaunchConfiguration]
  [ServerLaunchConfiguration]
  [ServerLaunchConfiguration]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.Hashable
    ServerGroupLaunchConfiguration

instance
  Prelude.NFData
    ServerGroupLaunchConfiguration

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