{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MGN.GetLaunchConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists all LaunchConfigurations available, filtered by Source Server IDs.
module Amazonka.MGN.GetLaunchConfiguration
  ( -- * Creating a Request
    GetLaunchConfiguration (..),
    newGetLaunchConfiguration,

    -- * Request Lenses
    getLaunchConfiguration_sourceServerID,

    -- * Destructuring the Response
    LaunchConfiguration (..),
    newLaunchConfiguration,

    -- * Response Lenses
    launchConfiguration_bootMode,
    launchConfiguration_copyPrivateIp,
    launchConfiguration_copyTags,
    launchConfiguration_ec2LaunchTemplateID,
    launchConfiguration_enableMapAutoTagging,
    launchConfiguration_launchDisposition,
    launchConfiguration_licensing,
    launchConfiguration_mapAutoTaggingMpeID,
    launchConfiguration_name,
    launchConfiguration_postLaunchActions,
    launchConfiguration_sourceServerID,
    launchConfiguration_targetInstanceTypeRightSizingMethod,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MGN.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetLaunchConfiguration' smart constructor.
data GetLaunchConfiguration = GetLaunchConfiguration'
  { -- | Request to get Launch Configuration information by Source Server ID.
    GetLaunchConfiguration -> Text
sourceServerID :: Prelude.Text
  }
  deriving (GetLaunchConfiguration -> GetLaunchConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLaunchConfiguration -> GetLaunchConfiguration -> Bool
$c/= :: GetLaunchConfiguration -> GetLaunchConfiguration -> Bool
== :: GetLaunchConfiguration -> GetLaunchConfiguration -> Bool
$c== :: GetLaunchConfiguration -> GetLaunchConfiguration -> Bool
Prelude.Eq, ReadPrec [GetLaunchConfiguration]
ReadPrec GetLaunchConfiguration
Int -> ReadS GetLaunchConfiguration
ReadS [GetLaunchConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLaunchConfiguration]
$creadListPrec :: ReadPrec [GetLaunchConfiguration]
readPrec :: ReadPrec GetLaunchConfiguration
$creadPrec :: ReadPrec GetLaunchConfiguration
readList :: ReadS [GetLaunchConfiguration]
$creadList :: ReadS [GetLaunchConfiguration]
readsPrec :: Int -> ReadS GetLaunchConfiguration
$creadsPrec :: Int -> ReadS GetLaunchConfiguration
Prelude.Read, Int -> GetLaunchConfiguration -> ShowS
[GetLaunchConfiguration] -> ShowS
GetLaunchConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLaunchConfiguration] -> ShowS
$cshowList :: [GetLaunchConfiguration] -> ShowS
show :: GetLaunchConfiguration -> String
$cshow :: GetLaunchConfiguration -> String
showsPrec :: Int -> GetLaunchConfiguration -> ShowS
$cshowsPrec :: Int -> GetLaunchConfiguration -> ShowS
Prelude.Show, forall x. Rep GetLaunchConfiguration x -> GetLaunchConfiguration
forall x. GetLaunchConfiguration -> Rep GetLaunchConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLaunchConfiguration x -> GetLaunchConfiguration
$cfrom :: forall x. GetLaunchConfiguration -> Rep GetLaunchConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'GetLaunchConfiguration' 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:
--
-- 'sourceServerID', 'getLaunchConfiguration_sourceServerID' - Request to get Launch Configuration information by Source Server ID.
newGetLaunchConfiguration ::
  -- | 'sourceServerID'
  Prelude.Text ->
  GetLaunchConfiguration
newGetLaunchConfiguration :: Text -> GetLaunchConfiguration
newGetLaunchConfiguration Text
pSourceServerID_ =
  GetLaunchConfiguration'
    { $sel:sourceServerID:GetLaunchConfiguration' :: Text
sourceServerID =
        Text
pSourceServerID_
    }

-- | Request to get Launch Configuration information by Source Server ID.
getLaunchConfiguration_sourceServerID :: Lens.Lens' GetLaunchConfiguration Prelude.Text
getLaunchConfiguration_sourceServerID :: Lens' GetLaunchConfiguration Text
getLaunchConfiguration_sourceServerID = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLaunchConfiguration' {Text
sourceServerID :: Text
$sel:sourceServerID:GetLaunchConfiguration' :: GetLaunchConfiguration -> Text
sourceServerID} -> Text
sourceServerID) (\s :: GetLaunchConfiguration
s@GetLaunchConfiguration' {} Text
a -> GetLaunchConfiguration
s {$sel:sourceServerID:GetLaunchConfiguration' :: Text
sourceServerID = Text
a} :: GetLaunchConfiguration)

instance Core.AWSRequest GetLaunchConfiguration where
  type
    AWSResponse GetLaunchConfiguration =
      LaunchConfiguration
  request :: (Service -> Service)
-> GetLaunchConfiguration -> Request GetLaunchConfiguration
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetLaunchConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetLaunchConfiguration)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable GetLaunchConfiguration where
  hashWithSalt :: Int -> GetLaunchConfiguration -> Int
hashWithSalt Int
_salt GetLaunchConfiguration' {Text
sourceServerID :: Text
$sel:sourceServerID:GetLaunchConfiguration' :: GetLaunchConfiguration -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourceServerID

instance Prelude.NFData GetLaunchConfiguration where
  rnf :: GetLaunchConfiguration -> ()
rnf GetLaunchConfiguration' {Text
sourceServerID :: Text
$sel:sourceServerID:GetLaunchConfiguration' :: GetLaunchConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
sourceServerID

instance Data.ToHeaders GetLaunchConfiguration where
  toHeaders :: GetLaunchConfiguration -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetLaunchConfiguration where
  toJSON :: GetLaunchConfiguration -> Value
toJSON GetLaunchConfiguration' {Text
sourceServerID :: Text
$sel:sourceServerID:GetLaunchConfiguration' :: GetLaunchConfiguration -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"sourceServerID" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sourceServerID)
          ]
      )

instance Data.ToPath GetLaunchConfiguration where
  toPath :: GetLaunchConfiguration -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/GetLaunchConfiguration"

instance Data.ToQuery GetLaunchConfiguration where
  toQuery :: GetLaunchConfiguration -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty