{-# 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.KinesisAnalyticsV2.StartApplication
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Starts the specified Kinesis Data Analytics application. After creating
-- an application, you must exclusively call this operation to start your
-- application.
module Amazonka.KinesisAnalyticsV2.StartApplication
  ( -- * Creating a Request
    StartApplication (..),
    newStartApplication,

    -- * Request Lenses
    startApplication_runConfiguration,
    startApplication_applicationName,

    -- * Destructuring the Response
    StartApplicationResponse (..),
    newStartApplicationResponse,

    -- * Response Lenses
    startApplicationResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStartApplication' smart constructor.
data StartApplication = StartApplication'
  { -- | Identifies the run configuration (start parameters) of a Kinesis Data
    -- Analytics application.
    StartApplication -> Maybe RunConfiguration
runConfiguration :: Prelude.Maybe RunConfiguration,
    -- | The name of the application.
    StartApplication -> Text
applicationName :: Prelude.Text
  }
  deriving (StartApplication -> StartApplication -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartApplication -> StartApplication -> Bool
$c/= :: StartApplication -> StartApplication -> Bool
== :: StartApplication -> StartApplication -> Bool
$c== :: StartApplication -> StartApplication -> Bool
Prelude.Eq, ReadPrec [StartApplication]
ReadPrec StartApplication
Int -> ReadS StartApplication
ReadS [StartApplication]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartApplication]
$creadListPrec :: ReadPrec [StartApplication]
readPrec :: ReadPrec StartApplication
$creadPrec :: ReadPrec StartApplication
readList :: ReadS [StartApplication]
$creadList :: ReadS [StartApplication]
readsPrec :: Int -> ReadS StartApplication
$creadsPrec :: Int -> ReadS StartApplication
Prelude.Read, Int -> StartApplication -> ShowS
[StartApplication] -> ShowS
StartApplication -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartApplication] -> ShowS
$cshowList :: [StartApplication] -> ShowS
show :: StartApplication -> String
$cshow :: StartApplication -> String
showsPrec :: Int -> StartApplication -> ShowS
$cshowsPrec :: Int -> StartApplication -> ShowS
Prelude.Show, forall x. Rep StartApplication x -> StartApplication
forall x. StartApplication -> Rep StartApplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartApplication x -> StartApplication
$cfrom :: forall x. StartApplication -> Rep StartApplication x
Prelude.Generic)

-- |
-- Create a value of 'StartApplication' 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:
--
-- 'runConfiguration', 'startApplication_runConfiguration' - Identifies the run configuration (start parameters) of a Kinesis Data
-- Analytics application.
--
-- 'applicationName', 'startApplication_applicationName' - The name of the application.
newStartApplication ::
  -- | 'applicationName'
  Prelude.Text ->
  StartApplication
newStartApplication :: Text -> StartApplication
newStartApplication Text
pApplicationName_ =
  StartApplication'
    { $sel:runConfiguration:StartApplication' :: Maybe RunConfiguration
runConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:applicationName:StartApplication' :: Text
applicationName = Text
pApplicationName_
    }

-- | Identifies the run configuration (start parameters) of a Kinesis Data
-- Analytics application.
startApplication_runConfiguration :: Lens.Lens' StartApplication (Prelude.Maybe RunConfiguration)
startApplication_runConfiguration :: Lens' StartApplication (Maybe RunConfiguration)
startApplication_runConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartApplication' {Maybe RunConfiguration
runConfiguration :: Maybe RunConfiguration
$sel:runConfiguration:StartApplication' :: StartApplication -> Maybe RunConfiguration
runConfiguration} -> Maybe RunConfiguration
runConfiguration) (\s :: StartApplication
s@StartApplication' {} Maybe RunConfiguration
a -> StartApplication
s {$sel:runConfiguration:StartApplication' :: Maybe RunConfiguration
runConfiguration = Maybe RunConfiguration
a} :: StartApplication)

-- | The name of the application.
startApplication_applicationName :: Lens.Lens' StartApplication Prelude.Text
startApplication_applicationName :: Lens' StartApplication Text
startApplication_applicationName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartApplication' {Text
applicationName :: Text
$sel:applicationName:StartApplication' :: StartApplication -> Text
applicationName} -> Text
applicationName) (\s :: StartApplication
s@StartApplication' {} Text
a -> StartApplication
s {$sel:applicationName:StartApplication' :: Text
applicationName = Text
a} :: StartApplication)

instance Core.AWSRequest StartApplication where
  type
    AWSResponse StartApplication =
      StartApplicationResponse
  request :: (Service -> Service)
-> StartApplication -> Request StartApplication
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 StartApplication
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartApplication)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartApplicationResponse
StartApplicationResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StartApplication where
  hashWithSalt :: Int -> StartApplication -> Int
hashWithSalt Int
_salt StartApplication' {Maybe RunConfiguration
Text
applicationName :: Text
runConfiguration :: Maybe RunConfiguration
$sel:applicationName:StartApplication' :: StartApplication -> Text
$sel:runConfiguration:StartApplication' :: StartApplication -> Maybe RunConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RunConfiguration
runConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationName

instance Prelude.NFData StartApplication where
  rnf :: StartApplication -> ()
rnf StartApplication' {Maybe RunConfiguration
Text
applicationName :: Text
runConfiguration :: Maybe RunConfiguration
$sel:applicationName:StartApplication' :: StartApplication -> Text
$sel:runConfiguration:StartApplication' :: StartApplication -> Maybe RunConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RunConfiguration
runConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
applicationName

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

instance Data.ToJSON StartApplication where
  toJSON :: StartApplication -> Value
toJSON StartApplication' {Maybe RunConfiguration
Text
applicationName :: Text
runConfiguration :: Maybe RunConfiguration
$sel:applicationName:StartApplication' :: StartApplication -> Text
$sel:runConfiguration:StartApplication' :: StartApplication -> Maybe RunConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RunConfiguration" 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 RunConfiguration
runConfiguration,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ApplicationName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
applicationName)
          ]
      )

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

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

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

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

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

instance Prelude.NFData StartApplicationResponse where
  rnf :: StartApplicationResponse -> ()
rnf StartApplicationResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartApplicationResponse' :: StartApplicationResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus