{-# 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.KinesisAnalytics.AddApplicationInput
-- 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)
--
-- This documentation is for version 1 of the Amazon Kinesis Data Analytics
-- API, which only supports SQL applications. Version 2 of the API supports
-- SQL and Java applications. For more information about version 2, see
-- </kinesisanalytics/latest/apiv2/Welcome.html Amazon Kinesis Data Analytics API V2 Documentation>.
--
-- Adds a streaming source to your Amazon Kinesis application. For
-- conceptual information, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html Configuring Application Input>.
--
-- You can add a streaming source either when you create an application or
-- you can use this operation to add a streaming source after you create an
-- application. For more information, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_CreateApplication.html CreateApplication>.
--
-- Any configuration update, including adding a streaming source using this
-- operation, results in a new version of the application. You can use the
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html DescribeApplication>
-- operation to find the current application version.
--
-- This operation requires permissions to perform the
-- @kinesisanalytics:AddApplicationInput@ action.
module Amazonka.KinesisAnalytics.AddApplicationInput
  ( -- * Creating a Request
    AddApplicationInput (..),
    newAddApplicationInput,

    -- * Request Lenses
    addApplicationInput_applicationName,
    addApplicationInput_currentApplicationVersionId,
    addApplicationInput_input,

    -- * Destructuring the Response
    AddApplicationInputResponse (..),
    newAddApplicationInputResponse,

    -- * Response Lenses
    addApplicationInputResponse_httpStatus,
  )
where

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

-- |
--
-- /See:/ 'newAddApplicationInput' smart constructor.
data AddApplicationInput = AddApplicationInput'
  { -- | Name of your existing Amazon Kinesis Analytics application to which you
    -- want to add the streaming source.
    AddApplicationInput -> Text
applicationName :: Prelude.Text,
    -- | Current version of your Amazon Kinesis Analytics application. You can
    -- use the
    -- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html DescribeApplication>
    -- operation to find the current application version.
    AddApplicationInput -> Natural
currentApplicationVersionId :: Prelude.Natural,
    -- | The
    -- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_Input.html Input>
    -- to add.
    AddApplicationInput -> Input
input :: Input
  }
  deriving (AddApplicationInput -> AddApplicationInput -> Bool
(AddApplicationInput -> AddApplicationInput -> Bool)
-> (AddApplicationInput -> AddApplicationInput -> Bool)
-> Eq AddApplicationInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddApplicationInput -> AddApplicationInput -> Bool
$c/= :: AddApplicationInput -> AddApplicationInput -> Bool
== :: AddApplicationInput -> AddApplicationInput -> Bool
$c== :: AddApplicationInput -> AddApplicationInput -> Bool
Prelude.Eq, ReadPrec [AddApplicationInput]
ReadPrec AddApplicationInput
Int -> ReadS AddApplicationInput
ReadS [AddApplicationInput]
(Int -> ReadS AddApplicationInput)
-> ReadS [AddApplicationInput]
-> ReadPrec AddApplicationInput
-> ReadPrec [AddApplicationInput]
-> Read AddApplicationInput
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddApplicationInput]
$creadListPrec :: ReadPrec [AddApplicationInput]
readPrec :: ReadPrec AddApplicationInput
$creadPrec :: ReadPrec AddApplicationInput
readList :: ReadS [AddApplicationInput]
$creadList :: ReadS [AddApplicationInput]
readsPrec :: Int -> ReadS AddApplicationInput
$creadsPrec :: Int -> ReadS AddApplicationInput
Prelude.Read, Int -> AddApplicationInput -> ShowS
[AddApplicationInput] -> ShowS
AddApplicationInput -> String
(Int -> AddApplicationInput -> ShowS)
-> (AddApplicationInput -> String)
-> ([AddApplicationInput] -> ShowS)
-> Show AddApplicationInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddApplicationInput] -> ShowS
$cshowList :: [AddApplicationInput] -> ShowS
show :: AddApplicationInput -> String
$cshow :: AddApplicationInput -> String
showsPrec :: Int -> AddApplicationInput -> ShowS
$cshowsPrec :: Int -> AddApplicationInput -> ShowS
Prelude.Show, (forall x. AddApplicationInput -> Rep AddApplicationInput x)
-> (forall x. Rep AddApplicationInput x -> AddApplicationInput)
-> Generic AddApplicationInput
forall x. Rep AddApplicationInput x -> AddApplicationInput
forall x. AddApplicationInput -> Rep AddApplicationInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddApplicationInput x -> AddApplicationInput
$cfrom :: forall x. AddApplicationInput -> Rep AddApplicationInput x
Prelude.Generic)

-- |
-- Create a value of 'AddApplicationInput' 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:
--
-- 'applicationName', 'addApplicationInput_applicationName' - Name of your existing Amazon Kinesis Analytics application to which you
-- want to add the streaming source.
--
-- 'currentApplicationVersionId', 'addApplicationInput_currentApplicationVersionId' - Current version of your Amazon Kinesis Analytics application. You can
-- use the
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html DescribeApplication>
-- operation to find the current application version.
--
-- 'input', 'addApplicationInput_input' - The
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_Input.html Input>
-- to add.
newAddApplicationInput ::
  -- | 'applicationName'
  Prelude.Text ->
  -- | 'currentApplicationVersionId'
  Prelude.Natural ->
  -- | 'input'
  Input ->
  AddApplicationInput
newAddApplicationInput :: Text -> Natural -> Input -> AddApplicationInput
newAddApplicationInput
  Text
pApplicationName_
  Natural
pCurrentApplicationVersionId_
  Input
pInput_ =
    AddApplicationInput' :: Text -> Natural -> Input -> AddApplicationInput
AddApplicationInput'
      { $sel:applicationName:AddApplicationInput' :: Text
applicationName =
          Text
pApplicationName_,
        $sel:currentApplicationVersionId:AddApplicationInput' :: Natural
currentApplicationVersionId =
          Natural
pCurrentApplicationVersionId_,
        $sel:input:AddApplicationInput' :: Input
input = Input
pInput_
      }

-- | Name of your existing Amazon Kinesis Analytics application to which you
-- want to add the streaming source.
addApplicationInput_applicationName :: Lens.Lens' AddApplicationInput Prelude.Text
addApplicationInput_applicationName :: (Text -> f Text) -> AddApplicationInput -> f AddApplicationInput
addApplicationInput_applicationName = (AddApplicationInput -> Text)
-> (AddApplicationInput -> Text -> AddApplicationInput)
-> Lens AddApplicationInput AddApplicationInput Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddApplicationInput' {Text
applicationName :: Text
$sel:applicationName:AddApplicationInput' :: AddApplicationInput -> Text
applicationName} -> Text
applicationName) (\s :: AddApplicationInput
s@AddApplicationInput' {} Text
a -> AddApplicationInput
s {$sel:applicationName:AddApplicationInput' :: Text
applicationName = Text
a} :: AddApplicationInput)

-- | Current version of your Amazon Kinesis Analytics application. You can
-- use the
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html DescribeApplication>
-- operation to find the current application version.
addApplicationInput_currentApplicationVersionId :: Lens.Lens' AddApplicationInput Prelude.Natural
addApplicationInput_currentApplicationVersionId :: (Natural -> f Natural)
-> AddApplicationInput -> f AddApplicationInput
addApplicationInput_currentApplicationVersionId = (AddApplicationInput -> Natural)
-> (AddApplicationInput -> Natural -> AddApplicationInput)
-> Lens AddApplicationInput AddApplicationInput Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddApplicationInput' {Natural
currentApplicationVersionId :: Natural
$sel:currentApplicationVersionId:AddApplicationInput' :: AddApplicationInput -> Natural
currentApplicationVersionId} -> Natural
currentApplicationVersionId) (\s :: AddApplicationInput
s@AddApplicationInput' {} Natural
a -> AddApplicationInput
s {$sel:currentApplicationVersionId:AddApplicationInput' :: Natural
currentApplicationVersionId = Natural
a} :: AddApplicationInput)

-- | The
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_Input.html Input>
-- to add.
addApplicationInput_input :: Lens.Lens' AddApplicationInput Input
addApplicationInput_input :: (Input -> f Input) -> AddApplicationInput -> f AddApplicationInput
addApplicationInput_input = (AddApplicationInput -> Input)
-> (AddApplicationInput -> Input -> AddApplicationInput)
-> Lens AddApplicationInput AddApplicationInput Input Input
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddApplicationInput' {Input
input :: Input
$sel:input:AddApplicationInput' :: AddApplicationInput -> Input
input} -> Input
input) (\s :: AddApplicationInput
s@AddApplicationInput' {} Input
a -> AddApplicationInput
s {$sel:input:AddApplicationInput' :: Input
input = Input
a} :: AddApplicationInput)

instance Core.AWSRequest AddApplicationInput where
  type
    AWSResponse AddApplicationInput =
      AddApplicationInputResponse
  request :: AddApplicationInput -> Request AddApplicationInput
request = Service -> AddApplicationInput -> Request AddApplicationInput
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AddApplicationInput
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AddApplicationInput)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AddApplicationInput))
-> Logger
-> Service
-> Proxy AddApplicationInput
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AddApplicationInput)))
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 -> AddApplicationInputResponse
AddApplicationInputResponse'
            (Int -> AddApplicationInputResponse)
-> Either String Int -> Either String AddApplicationInputResponse
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 AddApplicationInput

instance Prelude.NFData AddApplicationInput

instance Core.ToHeaders AddApplicationInput where
  toHeaders :: AddApplicationInput -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AddApplicationInput -> 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
"KinesisAnalytics_20150814.AddApplicationInput" ::
                          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 AddApplicationInput where
  toJSON :: AddApplicationInput -> Value
toJSON AddApplicationInput' {Natural
Text
Input
input :: Input
currentApplicationVersionId :: Natural
applicationName :: Text
$sel:input:AddApplicationInput' :: AddApplicationInput -> Input
$sel:currentApplicationVersionId:AddApplicationInput' :: AddApplicationInput -> Natural
$sel:applicationName:AddApplicationInput' :: AddApplicationInput -> 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
"ApplicationName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
applicationName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"CurrentApplicationVersionId"
                  Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
currentApplicationVersionId
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Input" Text -> Input -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Input
input)
          ]
      )

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

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

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

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

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

instance Prelude.NFData AddApplicationInputResponse