{-# 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.SMS.LaunchApp
-- 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)
--
-- Launches the specified application as a stack in AWS CloudFormation.
module Amazonka.SMS.LaunchApp
  ( -- * Creating a Request
    LaunchApp (..),
    newLaunchApp,

    -- * Request Lenses
    launchApp_appId,

    -- * Destructuring the Response
    LaunchAppResponse (..),
    newLaunchAppResponse,

    -- * Response Lenses
    launchAppResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SMS.Types

-- | /See:/ 'newLaunchApp' smart constructor.
data LaunchApp = LaunchApp'
  { -- | The ID of the application.
    LaunchApp -> Maybe Text
appId :: Prelude.Maybe Prelude.Text
  }
  deriving (LaunchApp -> LaunchApp -> Bool
(LaunchApp -> LaunchApp -> Bool)
-> (LaunchApp -> LaunchApp -> Bool) -> Eq LaunchApp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LaunchApp -> LaunchApp -> Bool
$c/= :: LaunchApp -> LaunchApp -> Bool
== :: LaunchApp -> LaunchApp -> Bool
$c== :: LaunchApp -> LaunchApp -> Bool
Prelude.Eq, ReadPrec [LaunchApp]
ReadPrec LaunchApp
Int -> ReadS LaunchApp
ReadS [LaunchApp]
(Int -> ReadS LaunchApp)
-> ReadS [LaunchApp]
-> ReadPrec LaunchApp
-> ReadPrec [LaunchApp]
-> Read LaunchApp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LaunchApp]
$creadListPrec :: ReadPrec [LaunchApp]
readPrec :: ReadPrec LaunchApp
$creadPrec :: ReadPrec LaunchApp
readList :: ReadS [LaunchApp]
$creadList :: ReadS [LaunchApp]
readsPrec :: Int -> ReadS LaunchApp
$creadsPrec :: Int -> ReadS LaunchApp
Prelude.Read, Int -> LaunchApp -> ShowS
[LaunchApp] -> ShowS
LaunchApp -> String
(Int -> LaunchApp -> ShowS)
-> (LaunchApp -> String)
-> ([LaunchApp] -> ShowS)
-> Show LaunchApp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LaunchApp] -> ShowS
$cshowList :: [LaunchApp] -> ShowS
show :: LaunchApp -> String
$cshow :: LaunchApp -> String
showsPrec :: Int -> LaunchApp -> ShowS
$cshowsPrec :: Int -> LaunchApp -> ShowS
Prelude.Show, (forall x. LaunchApp -> Rep LaunchApp x)
-> (forall x. Rep LaunchApp x -> LaunchApp) -> Generic LaunchApp
forall x. Rep LaunchApp x -> LaunchApp
forall x. LaunchApp -> Rep LaunchApp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LaunchApp x -> LaunchApp
$cfrom :: forall x. LaunchApp -> Rep LaunchApp x
Prelude.Generic)

-- |
-- Create a value of 'LaunchApp' 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:
--
-- 'appId', 'launchApp_appId' - The ID of the application.
newLaunchApp ::
  LaunchApp
newLaunchApp :: LaunchApp
newLaunchApp = LaunchApp' :: Maybe Text -> LaunchApp
LaunchApp' {$sel:appId:LaunchApp' :: Maybe Text
appId = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The ID of the application.
launchApp_appId :: Lens.Lens' LaunchApp (Prelude.Maybe Prelude.Text)
launchApp_appId :: (Maybe Text -> f (Maybe Text)) -> LaunchApp -> f LaunchApp
launchApp_appId = (LaunchApp -> Maybe Text)
-> (LaunchApp -> Maybe Text -> LaunchApp)
-> Lens LaunchApp LaunchApp (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchApp' {Maybe Text
appId :: Maybe Text
$sel:appId:LaunchApp' :: LaunchApp -> Maybe Text
appId} -> Maybe Text
appId) (\s :: LaunchApp
s@LaunchApp' {} Maybe Text
a -> LaunchApp
s {$sel:appId:LaunchApp' :: Maybe Text
appId = Maybe Text
a} :: LaunchApp)

instance Core.AWSRequest LaunchApp where
  type AWSResponse LaunchApp = LaunchAppResponse
  request :: LaunchApp -> Request LaunchApp
request = Service -> LaunchApp -> Request LaunchApp
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy LaunchApp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse LaunchApp)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse LaunchApp))
-> Logger
-> Service
-> Proxy LaunchApp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse LaunchApp)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> LaunchAppResponse
LaunchAppResponse'
            (Int -> LaunchAppResponse)
-> Either String Int -> Either String LaunchAppResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable LaunchApp

instance Prelude.NFData LaunchApp

instance Core.ToHeaders LaunchApp where
  toHeaders :: LaunchApp -> ResponseHeaders
toHeaders =
    ResponseHeaders -> LaunchApp -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSServerMigrationService_V2016_10_24.LaunchApp" ::
                          Prelude.ByteString
                      ),
            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 LaunchApp where
  toJSON :: LaunchApp -> Value
toJSON LaunchApp' {Maybe Text
appId :: Maybe Text
$sel:appId:LaunchApp' :: LaunchApp -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"appId" 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
appId]
      )

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

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

-- | /See:/ 'newLaunchAppResponse' smart constructor.
data LaunchAppResponse = LaunchAppResponse'
  { -- | The response's http status code.
    LaunchAppResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (LaunchAppResponse -> LaunchAppResponse -> Bool
(LaunchAppResponse -> LaunchAppResponse -> Bool)
-> (LaunchAppResponse -> LaunchAppResponse -> Bool)
-> Eq LaunchAppResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LaunchAppResponse -> LaunchAppResponse -> Bool
$c/= :: LaunchAppResponse -> LaunchAppResponse -> Bool
== :: LaunchAppResponse -> LaunchAppResponse -> Bool
$c== :: LaunchAppResponse -> LaunchAppResponse -> Bool
Prelude.Eq, ReadPrec [LaunchAppResponse]
ReadPrec LaunchAppResponse
Int -> ReadS LaunchAppResponse
ReadS [LaunchAppResponse]
(Int -> ReadS LaunchAppResponse)
-> ReadS [LaunchAppResponse]
-> ReadPrec LaunchAppResponse
-> ReadPrec [LaunchAppResponse]
-> Read LaunchAppResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LaunchAppResponse]
$creadListPrec :: ReadPrec [LaunchAppResponse]
readPrec :: ReadPrec LaunchAppResponse
$creadPrec :: ReadPrec LaunchAppResponse
readList :: ReadS [LaunchAppResponse]
$creadList :: ReadS [LaunchAppResponse]
readsPrec :: Int -> ReadS LaunchAppResponse
$creadsPrec :: Int -> ReadS LaunchAppResponse
Prelude.Read, Int -> LaunchAppResponse -> ShowS
[LaunchAppResponse] -> ShowS
LaunchAppResponse -> String
(Int -> LaunchAppResponse -> ShowS)
-> (LaunchAppResponse -> String)
-> ([LaunchAppResponse] -> ShowS)
-> Show LaunchAppResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LaunchAppResponse] -> ShowS
$cshowList :: [LaunchAppResponse] -> ShowS
show :: LaunchAppResponse -> String
$cshow :: LaunchAppResponse -> String
showsPrec :: Int -> LaunchAppResponse -> ShowS
$cshowsPrec :: Int -> LaunchAppResponse -> ShowS
Prelude.Show, (forall x. LaunchAppResponse -> Rep LaunchAppResponse x)
-> (forall x. Rep LaunchAppResponse x -> LaunchAppResponse)
-> Generic LaunchAppResponse
forall x. Rep LaunchAppResponse x -> LaunchAppResponse
forall x. LaunchAppResponse -> Rep LaunchAppResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LaunchAppResponse x -> LaunchAppResponse
$cfrom :: forall x. LaunchAppResponse -> Rep LaunchAppResponse x
Prelude.Generic)

-- |
-- Create a value of 'LaunchAppResponse' 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:
--
-- 'httpStatus', 'launchAppResponse_httpStatus' - The response's http status code.
newLaunchAppResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  LaunchAppResponse
newLaunchAppResponse :: Int -> LaunchAppResponse
newLaunchAppResponse Int
pHttpStatus_ =
  LaunchAppResponse' :: Int -> LaunchAppResponse
LaunchAppResponse' {$sel:httpStatus:LaunchAppResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
launchAppResponse_httpStatus :: Lens.Lens' LaunchAppResponse Prelude.Int
launchAppResponse_httpStatus :: (Int -> f Int) -> LaunchAppResponse -> f LaunchAppResponse
launchAppResponse_httpStatus = (LaunchAppResponse -> Int)
-> (LaunchAppResponse -> Int -> LaunchAppResponse)
-> Lens LaunchAppResponse LaunchAppResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LaunchAppResponse' {Int
httpStatus :: Int
$sel:httpStatus:LaunchAppResponse' :: LaunchAppResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: LaunchAppResponse
s@LaunchAppResponse' {} Int
a -> LaunchAppResponse
s {$sel:httpStatus:LaunchAppResponse' :: Int
httpStatus = Int
a} :: LaunchAppResponse)

instance Prelude.NFData LaunchAppResponse