{-# 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-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)
--
-- 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_ec2LaunchTemplateID,
    launchConfiguration_targetInstanceTypeRightSizingMethod,
    launchConfiguration_launchDisposition,
    launchConfiguration_copyTags,
    launchConfiguration_name,
    launchConfiguration_sourceServerID,
    launchConfiguration_licensing,
    launchConfiguration_copyPrivateIp,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(GetLaunchConfiguration -> GetLaunchConfiguration -> Bool)
-> (GetLaunchConfiguration -> GetLaunchConfiguration -> Bool)
-> Eq GetLaunchConfiguration
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]
(Int -> ReadS GetLaunchConfiguration)
-> ReadS [GetLaunchConfiguration]
-> ReadPrec GetLaunchConfiguration
-> ReadPrec [GetLaunchConfiguration]
-> Read 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
(Int -> GetLaunchConfiguration -> ShowS)
-> (GetLaunchConfiguration -> String)
-> ([GetLaunchConfiguration] -> ShowS)
-> Show GetLaunchConfiguration
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. GetLaunchConfiguration -> Rep GetLaunchConfiguration x)
-> (forall x.
    Rep GetLaunchConfiguration x -> GetLaunchConfiguration)
-> Generic GetLaunchConfiguration
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' :: Text -> GetLaunchConfiguration
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 :: (Text -> f Text)
-> GetLaunchConfiguration -> f GetLaunchConfiguration
getLaunchConfiguration_sourceServerID = (GetLaunchConfiguration -> Text)
-> (GetLaunchConfiguration -> Text -> GetLaunchConfiguration)
-> Lens GetLaunchConfiguration GetLaunchConfiguration Text Text
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 :: GetLaunchConfiguration -> Request GetLaunchConfiguration
request = Service -> GetLaunchConfiguration -> Request GetLaunchConfiguration
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetLaunchConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetLaunchConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetLaunchConfiguration))
-> Logger
-> Service
-> Proxy GetLaunchConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetLaunchConfiguration)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String LaunchConfiguration
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetLaunchConfiguration

instance Prelude.NFData GetLaunchConfiguration

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

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

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

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