{-# 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.CreateApplication
-- 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)
--
-- Creates a Kinesis Data Analytics application. For information about
-- creating a Kinesis Data Analytics application, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/java/getting-started.html Creating an Application>.
module Amazonka.KinesisAnalyticsV2.CreateApplication
  ( -- * Creating a Request
    CreateApplication (..),
    newCreateApplication,

    -- * Request Lenses
    createApplication_applicationDescription,
    createApplication_cloudWatchLoggingOptions,
    createApplication_applicationMode,
    createApplication_applicationConfiguration,
    createApplication_tags,
    createApplication_applicationName,
    createApplication_runtimeEnvironment,
    createApplication_serviceExecutionRole,

    -- * Destructuring the Response
    CreateApplicationResponse (..),
    newCreateApplicationResponse,

    -- * Response Lenses
    createApplicationResponse_httpStatus,
    createApplicationResponse_applicationDetail,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.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:/ 'newCreateApplication' smart constructor.
data CreateApplication = CreateApplication'
  { -- | A summary description of the application.
    CreateApplication -> Maybe Text
applicationDescription :: Prelude.Maybe Prelude.Text,
    -- | Use this parameter to configure an Amazon CloudWatch log stream to
    -- monitor application configuration errors.
    CreateApplication -> Maybe [CloudWatchLoggingOption]
cloudWatchLoggingOptions :: Prelude.Maybe [CloudWatchLoggingOption],
    -- | Use the @STREAMING@ mode to create a Kinesis Data Analytics Studio
    -- notebook. To create a Kinesis Data Analytics Studio notebook, use the
    -- @INTERACTIVE@ mode.
    CreateApplication -> Maybe ApplicationMode
applicationMode :: Prelude.Maybe ApplicationMode,
    -- | Use this parameter to configure the application.
    CreateApplication -> Maybe ApplicationConfiguration
applicationConfiguration :: Prelude.Maybe ApplicationConfiguration,
    -- | A list of one or more tags to assign to the application. A tag is a
    -- key-value pair that identifies an application. Note that the maximum
    -- number of application tags includes system tags. The maximum number of
    -- user-defined application tags is 50. For more information, see
    -- <https://docs.aws.amazon.com/kinesisanalytics/latest/java/how-tagging.html Using Tagging>.
    CreateApplication -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The name of your application (for example, @sample-app@).
    CreateApplication -> Text
applicationName :: Prelude.Text,
    -- | The runtime environment for the application (@SQL-1_0@, @FLINK-1_6@,
    -- @FLINK-1_8@, or @FLINK-1_11@).
    CreateApplication -> RuntimeEnvironment
runtimeEnvironment :: RuntimeEnvironment,
    -- | The IAM role used by the application to access Kinesis data streams,
    -- Kinesis Data Firehose delivery streams, Amazon S3 objects, and other
    -- external resources.
    CreateApplication -> Text
serviceExecutionRole :: Prelude.Text
  }
  deriving (CreateApplication -> CreateApplication -> Bool
(CreateApplication -> CreateApplication -> Bool)
-> (CreateApplication -> CreateApplication -> Bool)
-> Eq CreateApplication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateApplication -> CreateApplication -> Bool
$c/= :: CreateApplication -> CreateApplication -> Bool
== :: CreateApplication -> CreateApplication -> Bool
$c== :: CreateApplication -> CreateApplication -> Bool
Prelude.Eq, ReadPrec [CreateApplication]
ReadPrec CreateApplication
Int -> ReadS CreateApplication
ReadS [CreateApplication]
(Int -> ReadS CreateApplication)
-> ReadS [CreateApplication]
-> ReadPrec CreateApplication
-> ReadPrec [CreateApplication]
-> Read CreateApplication
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateApplication]
$creadListPrec :: ReadPrec [CreateApplication]
readPrec :: ReadPrec CreateApplication
$creadPrec :: ReadPrec CreateApplication
readList :: ReadS [CreateApplication]
$creadList :: ReadS [CreateApplication]
readsPrec :: Int -> ReadS CreateApplication
$creadsPrec :: Int -> ReadS CreateApplication
Prelude.Read, Int -> CreateApplication -> ShowS
[CreateApplication] -> ShowS
CreateApplication -> String
(Int -> CreateApplication -> ShowS)
-> (CreateApplication -> String)
-> ([CreateApplication] -> ShowS)
-> Show CreateApplication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateApplication] -> ShowS
$cshowList :: [CreateApplication] -> ShowS
show :: CreateApplication -> String
$cshow :: CreateApplication -> String
showsPrec :: Int -> CreateApplication -> ShowS
$cshowsPrec :: Int -> CreateApplication -> ShowS
Prelude.Show, (forall x. CreateApplication -> Rep CreateApplication x)
-> (forall x. Rep CreateApplication x -> CreateApplication)
-> Generic CreateApplication
forall x. Rep CreateApplication x -> CreateApplication
forall x. CreateApplication -> Rep CreateApplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateApplication x -> CreateApplication
$cfrom :: forall x. CreateApplication -> Rep CreateApplication x
Prelude.Generic)

-- |
-- Create a value of 'CreateApplication' 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:
--
-- 'applicationDescription', 'createApplication_applicationDescription' - A summary description of the application.
--
-- 'cloudWatchLoggingOptions', 'createApplication_cloudWatchLoggingOptions' - Use this parameter to configure an Amazon CloudWatch log stream to
-- monitor application configuration errors.
--
-- 'applicationMode', 'createApplication_applicationMode' - Use the @STREAMING@ mode to create a Kinesis Data Analytics Studio
-- notebook. To create a Kinesis Data Analytics Studio notebook, use the
-- @INTERACTIVE@ mode.
--
-- 'applicationConfiguration', 'createApplication_applicationConfiguration' - Use this parameter to configure the application.
--
-- 'tags', 'createApplication_tags' - A list of one or more tags to assign to the application. A tag is a
-- key-value pair that identifies an application. Note that the maximum
-- number of application tags includes system tags. The maximum number of
-- user-defined application tags is 50. For more information, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/java/how-tagging.html Using Tagging>.
--
-- 'applicationName', 'createApplication_applicationName' - The name of your application (for example, @sample-app@).
--
-- 'runtimeEnvironment', 'createApplication_runtimeEnvironment' - The runtime environment for the application (@SQL-1_0@, @FLINK-1_6@,
-- @FLINK-1_8@, or @FLINK-1_11@).
--
-- 'serviceExecutionRole', 'createApplication_serviceExecutionRole' - The IAM role used by the application to access Kinesis data streams,
-- Kinesis Data Firehose delivery streams, Amazon S3 objects, and other
-- external resources.
newCreateApplication ::
  -- | 'applicationName'
  Prelude.Text ->
  -- | 'runtimeEnvironment'
  RuntimeEnvironment ->
  -- | 'serviceExecutionRole'
  Prelude.Text ->
  CreateApplication
newCreateApplication :: Text -> RuntimeEnvironment -> Text -> CreateApplication
newCreateApplication
  Text
pApplicationName_
  RuntimeEnvironment
pRuntimeEnvironment_
  Text
pServiceExecutionRole_ =
    CreateApplication' :: Maybe Text
-> Maybe [CloudWatchLoggingOption]
-> Maybe ApplicationMode
-> Maybe ApplicationConfiguration
-> Maybe (NonEmpty Tag)
-> Text
-> RuntimeEnvironment
-> Text
-> CreateApplication
CreateApplication'
      { $sel:applicationDescription:CreateApplication' :: Maybe Text
applicationDescription =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:cloudWatchLoggingOptions:CreateApplication' :: Maybe [CloudWatchLoggingOption]
cloudWatchLoggingOptions = Maybe [CloudWatchLoggingOption]
forall a. Maybe a
Prelude.Nothing,
        $sel:applicationMode:CreateApplication' :: Maybe ApplicationMode
applicationMode = Maybe ApplicationMode
forall a. Maybe a
Prelude.Nothing,
        $sel:applicationConfiguration:CreateApplication' :: Maybe ApplicationConfiguration
applicationConfiguration = Maybe ApplicationConfiguration
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateApplication' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
        $sel:applicationName:CreateApplication' :: Text
applicationName = Text
pApplicationName_,
        $sel:runtimeEnvironment:CreateApplication' :: RuntimeEnvironment
runtimeEnvironment = RuntimeEnvironment
pRuntimeEnvironment_,
        $sel:serviceExecutionRole:CreateApplication' :: Text
serviceExecutionRole = Text
pServiceExecutionRole_
      }

-- | A summary description of the application.
createApplication_applicationDescription :: Lens.Lens' CreateApplication (Prelude.Maybe Prelude.Text)
createApplication_applicationDescription :: (Maybe Text -> f (Maybe Text))
-> CreateApplication -> f CreateApplication
createApplication_applicationDescription = (CreateApplication -> Maybe Text)
-> (CreateApplication -> Maybe Text -> CreateApplication)
-> Lens
     CreateApplication CreateApplication (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplication' {Maybe Text
applicationDescription :: Maybe Text
$sel:applicationDescription:CreateApplication' :: CreateApplication -> Maybe Text
applicationDescription} -> Maybe Text
applicationDescription) (\s :: CreateApplication
s@CreateApplication' {} Maybe Text
a -> CreateApplication
s {$sel:applicationDescription:CreateApplication' :: Maybe Text
applicationDescription = Maybe Text
a} :: CreateApplication)

-- | Use this parameter to configure an Amazon CloudWatch log stream to
-- monitor application configuration errors.
createApplication_cloudWatchLoggingOptions :: Lens.Lens' CreateApplication (Prelude.Maybe [CloudWatchLoggingOption])
createApplication_cloudWatchLoggingOptions :: (Maybe [CloudWatchLoggingOption]
 -> f (Maybe [CloudWatchLoggingOption]))
-> CreateApplication -> f CreateApplication
createApplication_cloudWatchLoggingOptions = (CreateApplication -> Maybe [CloudWatchLoggingOption])
-> (CreateApplication
    -> Maybe [CloudWatchLoggingOption] -> CreateApplication)
-> Lens
     CreateApplication
     CreateApplication
     (Maybe [CloudWatchLoggingOption])
     (Maybe [CloudWatchLoggingOption])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplication' {Maybe [CloudWatchLoggingOption]
cloudWatchLoggingOptions :: Maybe [CloudWatchLoggingOption]
$sel:cloudWatchLoggingOptions:CreateApplication' :: CreateApplication -> Maybe [CloudWatchLoggingOption]
cloudWatchLoggingOptions} -> Maybe [CloudWatchLoggingOption]
cloudWatchLoggingOptions) (\s :: CreateApplication
s@CreateApplication' {} Maybe [CloudWatchLoggingOption]
a -> CreateApplication
s {$sel:cloudWatchLoggingOptions:CreateApplication' :: Maybe [CloudWatchLoggingOption]
cloudWatchLoggingOptions = Maybe [CloudWatchLoggingOption]
a} :: CreateApplication) ((Maybe [CloudWatchLoggingOption]
  -> f (Maybe [CloudWatchLoggingOption]))
 -> CreateApplication -> f CreateApplication)
-> ((Maybe [CloudWatchLoggingOption]
     -> f (Maybe [CloudWatchLoggingOption]))
    -> Maybe [CloudWatchLoggingOption]
    -> f (Maybe [CloudWatchLoggingOption]))
-> (Maybe [CloudWatchLoggingOption]
    -> f (Maybe [CloudWatchLoggingOption]))
-> CreateApplication
-> f CreateApplication
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CloudWatchLoggingOption]
  [CloudWatchLoggingOption]
  [CloudWatchLoggingOption]
  [CloudWatchLoggingOption]
-> Iso
     (Maybe [CloudWatchLoggingOption])
     (Maybe [CloudWatchLoggingOption])
     (Maybe [CloudWatchLoggingOption])
     (Maybe [CloudWatchLoggingOption])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [CloudWatchLoggingOption]
  [CloudWatchLoggingOption]
  [CloudWatchLoggingOption]
  [CloudWatchLoggingOption]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Use the @STREAMING@ mode to create a Kinesis Data Analytics Studio
-- notebook. To create a Kinesis Data Analytics Studio notebook, use the
-- @INTERACTIVE@ mode.
createApplication_applicationMode :: Lens.Lens' CreateApplication (Prelude.Maybe ApplicationMode)
createApplication_applicationMode :: (Maybe ApplicationMode -> f (Maybe ApplicationMode))
-> CreateApplication -> f CreateApplication
createApplication_applicationMode = (CreateApplication -> Maybe ApplicationMode)
-> (CreateApplication
    -> Maybe ApplicationMode -> CreateApplication)
-> Lens
     CreateApplication
     CreateApplication
     (Maybe ApplicationMode)
     (Maybe ApplicationMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplication' {Maybe ApplicationMode
applicationMode :: Maybe ApplicationMode
$sel:applicationMode:CreateApplication' :: CreateApplication -> Maybe ApplicationMode
applicationMode} -> Maybe ApplicationMode
applicationMode) (\s :: CreateApplication
s@CreateApplication' {} Maybe ApplicationMode
a -> CreateApplication
s {$sel:applicationMode:CreateApplication' :: Maybe ApplicationMode
applicationMode = Maybe ApplicationMode
a} :: CreateApplication)

-- | Use this parameter to configure the application.
createApplication_applicationConfiguration :: Lens.Lens' CreateApplication (Prelude.Maybe ApplicationConfiguration)
createApplication_applicationConfiguration :: (Maybe ApplicationConfiguration
 -> f (Maybe ApplicationConfiguration))
-> CreateApplication -> f CreateApplication
createApplication_applicationConfiguration = (CreateApplication -> Maybe ApplicationConfiguration)
-> (CreateApplication
    -> Maybe ApplicationConfiguration -> CreateApplication)
-> Lens
     CreateApplication
     CreateApplication
     (Maybe ApplicationConfiguration)
     (Maybe ApplicationConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplication' {Maybe ApplicationConfiguration
applicationConfiguration :: Maybe ApplicationConfiguration
$sel:applicationConfiguration:CreateApplication' :: CreateApplication -> Maybe ApplicationConfiguration
applicationConfiguration} -> Maybe ApplicationConfiguration
applicationConfiguration) (\s :: CreateApplication
s@CreateApplication' {} Maybe ApplicationConfiguration
a -> CreateApplication
s {$sel:applicationConfiguration:CreateApplication' :: Maybe ApplicationConfiguration
applicationConfiguration = Maybe ApplicationConfiguration
a} :: CreateApplication)

-- | A list of one or more tags to assign to the application. A tag is a
-- key-value pair that identifies an application. Note that the maximum
-- number of application tags includes system tags. The maximum number of
-- user-defined application tags is 50. For more information, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/java/how-tagging.html Using Tagging>.
createApplication_tags :: Lens.Lens' CreateApplication (Prelude.Maybe (Prelude.NonEmpty Tag))
createApplication_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateApplication -> f CreateApplication
createApplication_tags = (CreateApplication -> Maybe (NonEmpty Tag))
-> (CreateApplication -> Maybe (NonEmpty Tag) -> CreateApplication)
-> Lens
     CreateApplication
     CreateApplication
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplication' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateApplication' :: CreateApplication -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateApplication
s@CreateApplication' {} Maybe (NonEmpty Tag)
a -> CreateApplication
s {$sel:tags:CreateApplication' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateApplication) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateApplication -> f CreateApplication)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateApplication
-> f CreateApplication
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of your application (for example, @sample-app@).
createApplication_applicationName :: Lens.Lens' CreateApplication Prelude.Text
createApplication_applicationName :: (Text -> f Text) -> CreateApplication -> f CreateApplication
createApplication_applicationName = (CreateApplication -> Text)
-> (CreateApplication -> Text -> CreateApplication)
-> Lens CreateApplication CreateApplication Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplication' {Text
applicationName :: Text
$sel:applicationName:CreateApplication' :: CreateApplication -> Text
applicationName} -> Text
applicationName) (\s :: CreateApplication
s@CreateApplication' {} Text
a -> CreateApplication
s {$sel:applicationName:CreateApplication' :: Text
applicationName = Text
a} :: CreateApplication)

-- | The runtime environment for the application (@SQL-1_0@, @FLINK-1_6@,
-- @FLINK-1_8@, or @FLINK-1_11@).
createApplication_runtimeEnvironment :: Lens.Lens' CreateApplication RuntimeEnvironment
createApplication_runtimeEnvironment :: (RuntimeEnvironment -> f RuntimeEnvironment)
-> CreateApplication -> f CreateApplication
createApplication_runtimeEnvironment = (CreateApplication -> RuntimeEnvironment)
-> (CreateApplication -> RuntimeEnvironment -> CreateApplication)
-> Lens
     CreateApplication
     CreateApplication
     RuntimeEnvironment
     RuntimeEnvironment
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplication' {RuntimeEnvironment
runtimeEnvironment :: RuntimeEnvironment
$sel:runtimeEnvironment:CreateApplication' :: CreateApplication -> RuntimeEnvironment
runtimeEnvironment} -> RuntimeEnvironment
runtimeEnvironment) (\s :: CreateApplication
s@CreateApplication' {} RuntimeEnvironment
a -> CreateApplication
s {$sel:runtimeEnvironment:CreateApplication' :: RuntimeEnvironment
runtimeEnvironment = RuntimeEnvironment
a} :: CreateApplication)

-- | The IAM role used by the application to access Kinesis data streams,
-- Kinesis Data Firehose delivery streams, Amazon S3 objects, and other
-- external resources.
createApplication_serviceExecutionRole :: Lens.Lens' CreateApplication Prelude.Text
createApplication_serviceExecutionRole :: (Text -> f Text) -> CreateApplication -> f CreateApplication
createApplication_serviceExecutionRole = (CreateApplication -> Text)
-> (CreateApplication -> Text -> CreateApplication)
-> Lens CreateApplication CreateApplication Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplication' {Text
serviceExecutionRole :: Text
$sel:serviceExecutionRole:CreateApplication' :: CreateApplication -> Text
serviceExecutionRole} -> Text
serviceExecutionRole) (\s :: CreateApplication
s@CreateApplication' {} Text
a -> CreateApplication
s {$sel:serviceExecutionRole:CreateApplication' :: Text
serviceExecutionRole = Text
a} :: CreateApplication)

instance Core.AWSRequest CreateApplication where
  type
    AWSResponse CreateApplication =
      CreateApplicationResponse
  request :: CreateApplication -> Request CreateApplication
request = Service -> CreateApplication -> Request CreateApplication
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateApplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateApplication)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateApplication))
-> Logger
-> Service
-> Proxy CreateApplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateApplication)))
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 ->
          Int -> ApplicationDetail -> CreateApplicationResponse
CreateApplicationResponse'
            (Int -> ApplicationDetail -> CreateApplicationResponse)
-> Either String Int
-> Either String (ApplicationDetail -> CreateApplicationResponse)
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))
            Either String (ApplicationDetail -> CreateApplicationResponse)
-> Either String ApplicationDetail
-> Either String CreateApplicationResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String ApplicationDetail
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"ApplicationDetail")
      )

instance Prelude.Hashable CreateApplication

instance Prelude.NFData CreateApplication

instance Core.ToHeaders CreateApplication where
  toHeaders :: CreateApplication -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateApplication -> 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_20180523.CreateApplication" ::
                          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 CreateApplication where
  toJSON :: CreateApplication -> Value
toJSON CreateApplication' {Maybe [CloudWatchLoggingOption]
Maybe (NonEmpty Tag)
Maybe Text
Maybe ApplicationMode
Maybe ApplicationConfiguration
Text
RuntimeEnvironment
serviceExecutionRole :: Text
runtimeEnvironment :: RuntimeEnvironment
applicationName :: Text
tags :: Maybe (NonEmpty Tag)
applicationConfiguration :: Maybe ApplicationConfiguration
applicationMode :: Maybe ApplicationMode
cloudWatchLoggingOptions :: Maybe [CloudWatchLoggingOption]
applicationDescription :: Maybe Text
$sel:serviceExecutionRole:CreateApplication' :: CreateApplication -> Text
$sel:runtimeEnvironment:CreateApplication' :: CreateApplication -> RuntimeEnvironment
$sel:applicationName:CreateApplication' :: CreateApplication -> Text
$sel:tags:CreateApplication' :: CreateApplication -> Maybe (NonEmpty Tag)
$sel:applicationConfiguration:CreateApplication' :: CreateApplication -> Maybe ApplicationConfiguration
$sel:applicationMode:CreateApplication' :: CreateApplication -> Maybe ApplicationMode
$sel:cloudWatchLoggingOptions:CreateApplication' :: CreateApplication -> Maybe [CloudWatchLoggingOption]
$sel:applicationDescription:CreateApplication' :: CreateApplication -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ApplicationDescription" 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
applicationDescription,
            (Text
"CloudWatchLoggingOptions" Text -> [CloudWatchLoggingOption] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([CloudWatchLoggingOption] -> Pair)
-> Maybe [CloudWatchLoggingOption] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CloudWatchLoggingOption]
cloudWatchLoggingOptions,
            (Text
"ApplicationMode" Text -> ApplicationMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ApplicationMode -> Pair) -> Maybe ApplicationMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ApplicationMode
applicationMode,
            (Text
"ApplicationConfiguration" Text -> ApplicationConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ApplicationConfiguration -> Pair)
-> Maybe ApplicationConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ApplicationConfiguration
applicationConfiguration,
            (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Tag -> Pair) -> Maybe (NonEmpty Tag) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
            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
"RuntimeEnvironment" Text -> RuntimeEnvironment -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RuntimeEnvironment
runtimeEnvironment),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ServiceExecutionRole"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serviceExecutionRole
              )
          ]
      )

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

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

-- | /See:/ 'newCreateApplicationResponse' smart constructor.
data CreateApplicationResponse = CreateApplicationResponse'
  { -- | The response's http status code.
    CreateApplicationResponse -> Int
httpStatus :: Prelude.Int,
    -- | In response to your @CreateApplication@ request, Kinesis Data Analytics
    -- returns a response with details of the application it created.
    CreateApplicationResponse -> ApplicationDetail
applicationDetail :: ApplicationDetail
  }
  deriving (CreateApplicationResponse -> CreateApplicationResponse -> Bool
(CreateApplicationResponse -> CreateApplicationResponse -> Bool)
-> (CreateApplicationResponse -> CreateApplicationResponse -> Bool)
-> Eq CreateApplicationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateApplicationResponse -> CreateApplicationResponse -> Bool
$c/= :: CreateApplicationResponse -> CreateApplicationResponse -> Bool
== :: CreateApplicationResponse -> CreateApplicationResponse -> Bool
$c== :: CreateApplicationResponse -> CreateApplicationResponse -> Bool
Prelude.Eq, ReadPrec [CreateApplicationResponse]
ReadPrec CreateApplicationResponse
Int -> ReadS CreateApplicationResponse
ReadS [CreateApplicationResponse]
(Int -> ReadS CreateApplicationResponse)
-> ReadS [CreateApplicationResponse]
-> ReadPrec CreateApplicationResponse
-> ReadPrec [CreateApplicationResponse]
-> Read CreateApplicationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateApplicationResponse]
$creadListPrec :: ReadPrec [CreateApplicationResponse]
readPrec :: ReadPrec CreateApplicationResponse
$creadPrec :: ReadPrec CreateApplicationResponse
readList :: ReadS [CreateApplicationResponse]
$creadList :: ReadS [CreateApplicationResponse]
readsPrec :: Int -> ReadS CreateApplicationResponse
$creadsPrec :: Int -> ReadS CreateApplicationResponse
Prelude.Read, Int -> CreateApplicationResponse -> ShowS
[CreateApplicationResponse] -> ShowS
CreateApplicationResponse -> String
(Int -> CreateApplicationResponse -> ShowS)
-> (CreateApplicationResponse -> String)
-> ([CreateApplicationResponse] -> ShowS)
-> Show CreateApplicationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateApplicationResponse] -> ShowS
$cshowList :: [CreateApplicationResponse] -> ShowS
show :: CreateApplicationResponse -> String
$cshow :: CreateApplicationResponse -> String
showsPrec :: Int -> CreateApplicationResponse -> ShowS
$cshowsPrec :: Int -> CreateApplicationResponse -> ShowS
Prelude.Show, (forall x.
 CreateApplicationResponse -> Rep CreateApplicationResponse x)
-> (forall x.
    Rep CreateApplicationResponse x -> CreateApplicationResponse)
-> Generic CreateApplicationResponse
forall x.
Rep CreateApplicationResponse x -> CreateApplicationResponse
forall x.
CreateApplicationResponse -> Rep CreateApplicationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateApplicationResponse x -> CreateApplicationResponse
$cfrom :: forall x.
CreateApplicationResponse -> Rep CreateApplicationResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateApplicationResponse' 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', 'createApplicationResponse_httpStatus' - The response's http status code.
--
-- 'applicationDetail', 'createApplicationResponse_applicationDetail' - In response to your @CreateApplication@ request, Kinesis Data Analytics
-- returns a response with details of the application it created.
newCreateApplicationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'applicationDetail'
  ApplicationDetail ->
  CreateApplicationResponse
newCreateApplicationResponse :: Int -> ApplicationDetail -> CreateApplicationResponse
newCreateApplicationResponse
  Int
pHttpStatus_
  ApplicationDetail
pApplicationDetail_ =
    CreateApplicationResponse' :: Int -> ApplicationDetail -> CreateApplicationResponse
CreateApplicationResponse'
      { $sel:httpStatus:CreateApplicationResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:applicationDetail:CreateApplicationResponse' :: ApplicationDetail
applicationDetail = ApplicationDetail
pApplicationDetail_
      }

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

-- | In response to your @CreateApplication@ request, Kinesis Data Analytics
-- returns a response with details of the application it created.
createApplicationResponse_applicationDetail :: Lens.Lens' CreateApplicationResponse ApplicationDetail
createApplicationResponse_applicationDetail :: (ApplicationDetail -> f ApplicationDetail)
-> CreateApplicationResponse -> f CreateApplicationResponse
createApplicationResponse_applicationDetail = (CreateApplicationResponse -> ApplicationDetail)
-> (CreateApplicationResponse
    -> ApplicationDetail -> CreateApplicationResponse)
-> Lens
     CreateApplicationResponse
     CreateApplicationResponse
     ApplicationDetail
     ApplicationDetail
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplicationResponse' {ApplicationDetail
applicationDetail :: ApplicationDetail
$sel:applicationDetail:CreateApplicationResponse' :: CreateApplicationResponse -> ApplicationDetail
applicationDetail} -> ApplicationDetail
applicationDetail) (\s :: CreateApplicationResponse
s@CreateApplicationResponse' {} ApplicationDetail
a -> CreateApplicationResponse
s {$sel:applicationDetail:CreateApplicationResponse' :: ApplicationDetail
applicationDetail = ApplicationDetail
a} :: CreateApplicationResponse)

instance Prelude.NFData CreateApplicationResponse