{-# 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.DescribeApplication
-- 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>.
--
-- Returns information about a specific Amazon Kinesis Analytics
-- application.
--
-- If you want to retrieve a list of all applications in your account, use
-- the
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_ListApplications.html ListApplications>
-- operation.
--
-- This operation requires permissions to perform the
-- @kinesisanalytics:DescribeApplication@ action. You can use
-- @DescribeApplication@ to get the current application versionId, which
-- you need to call other operations such as @Update@.
module Amazonka.KinesisAnalytics.DescribeApplication
  ( -- * Creating a Request
    DescribeApplication (..),
    newDescribeApplication,

    -- * Request Lenses
    describeApplication_applicationName,

    -- * Destructuring the Response
    DescribeApplicationResponse (..),
    newDescribeApplicationResponse,

    -- * Response Lenses
    describeApplicationResponse_httpStatus,
    describeApplicationResponse_applicationDetail,
  )
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:/ 'newDescribeApplication' smart constructor.
data DescribeApplication = DescribeApplication'
  { -- | Name of the application.
    DescribeApplication -> Text
applicationName :: Prelude.Text
  }
  deriving (DescribeApplication -> DescribeApplication -> Bool
(DescribeApplication -> DescribeApplication -> Bool)
-> (DescribeApplication -> DescribeApplication -> Bool)
-> Eq DescribeApplication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeApplication -> DescribeApplication -> Bool
$c/= :: DescribeApplication -> DescribeApplication -> Bool
== :: DescribeApplication -> DescribeApplication -> Bool
$c== :: DescribeApplication -> DescribeApplication -> Bool
Prelude.Eq, ReadPrec [DescribeApplication]
ReadPrec DescribeApplication
Int -> ReadS DescribeApplication
ReadS [DescribeApplication]
(Int -> ReadS DescribeApplication)
-> ReadS [DescribeApplication]
-> ReadPrec DescribeApplication
-> ReadPrec [DescribeApplication]
-> Read DescribeApplication
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeApplication]
$creadListPrec :: ReadPrec [DescribeApplication]
readPrec :: ReadPrec DescribeApplication
$creadPrec :: ReadPrec DescribeApplication
readList :: ReadS [DescribeApplication]
$creadList :: ReadS [DescribeApplication]
readsPrec :: Int -> ReadS DescribeApplication
$creadsPrec :: Int -> ReadS DescribeApplication
Prelude.Read, Int -> DescribeApplication -> ShowS
[DescribeApplication] -> ShowS
DescribeApplication -> String
(Int -> DescribeApplication -> ShowS)
-> (DescribeApplication -> String)
-> ([DescribeApplication] -> ShowS)
-> Show DescribeApplication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeApplication] -> ShowS
$cshowList :: [DescribeApplication] -> ShowS
show :: DescribeApplication -> String
$cshow :: DescribeApplication -> String
showsPrec :: Int -> DescribeApplication -> ShowS
$cshowsPrec :: Int -> DescribeApplication -> ShowS
Prelude.Show, (forall x. DescribeApplication -> Rep DescribeApplication x)
-> (forall x. Rep DescribeApplication x -> DescribeApplication)
-> Generic DescribeApplication
forall x. Rep DescribeApplication x -> DescribeApplication
forall x. DescribeApplication -> Rep DescribeApplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeApplication x -> DescribeApplication
$cfrom :: forall x. DescribeApplication -> Rep DescribeApplication x
Prelude.Generic)

-- |
-- Create a value of 'DescribeApplication' 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', 'describeApplication_applicationName' - Name of the application.
newDescribeApplication ::
  -- | 'applicationName'
  Prelude.Text ->
  DescribeApplication
newDescribeApplication :: Text -> DescribeApplication
newDescribeApplication Text
pApplicationName_ =
  DescribeApplication' :: Text -> DescribeApplication
DescribeApplication'
    { $sel:applicationName:DescribeApplication' :: Text
applicationName =
        Text
pApplicationName_
    }

-- | Name of the application.
describeApplication_applicationName :: Lens.Lens' DescribeApplication Prelude.Text
describeApplication_applicationName :: (Text -> f Text) -> DescribeApplication -> f DescribeApplication
describeApplication_applicationName = (DescribeApplication -> Text)
-> (DescribeApplication -> Text -> DescribeApplication)
-> Lens DescribeApplication DescribeApplication Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplication' {Text
applicationName :: Text
$sel:applicationName:DescribeApplication' :: DescribeApplication -> Text
applicationName} -> Text
applicationName) (\s :: DescribeApplication
s@DescribeApplication' {} Text
a -> DescribeApplication
s {$sel:applicationName:DescribeApplication' :: Text
applicationName = Text
a} :: DescribeApplication)

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

instance Prelude.NFData DescribeApplication

instance Core.ToHeaders DescribeApplication where
  toHeaders :: DescribeApplication -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeApplication -> 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.DescribeApplication" ::
                          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 DescribeApplication where
  toJSON :: DescribeApplication -> Value
toJSON DescribeApplication' {Text
applicationName :: Text
$sel:applicationName:DescribeApplication' :: DescribeApplication -> 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)
          ]
      )

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

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

-- |
--
-- /See:/ 'newDescribeApplicationResponse' smart constructor.
data DescribeApplicationResponse = DescribeApplicationResponse'
  { -- | The response's http status code.
    DescribeApplicationResponse -> Int
httpStatus :: Prelude.Int,
    -- | Provides a description of the application, such as the application
    -- Amazon Resource Name (ARN), status, latest version, and input and output
    -- configuration details.
    DescribeApplicationResponse -> ApplicationDetail
applicationDetail :: ApplicationDetail
  }
  deriving (DescribeApplicationResponse -> DescribeApplicationResponse -> Bool
(DescribeApplicationResponse
 -> DescribeApplicationResponse -> Bool)
-> (DescribeApplicationResponse
    -> DescribeApplicationResponse -> Bool)
-> Eq DescribeApplicationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeApplicationResponse -> DescribeApplicationResponse -> Bool
$c/= :: DescribeApplicationResponse -> DescribeApplicationResponse -> Bool
== :: DescribeApplicationResponse -> DescribeApplicationResponse -> Bool
$c== :: DescribeApplicationResponse -> DescribeApplicationResponse -> Bool
Prelude.Eq, ReadPrec [DescribeApplicationResponse]
ReadPrec DescribeApplicationResponse
Int -> ReadS DescribeApplicationResponse
ReadS [DescribeApplicationResponse]
(Int -> ReadS DescribeApplicationResponse)
-> ReadS [DescribeApplicationResponse]
-> ReadPrec DescribeApplicationResponse
-> ReadPrec [DescribeApplicationResponse]
-> Read DescribeApplicationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeApplicationResponse]
$creadListPrec :: ReadPrec [DescribeApplicationResponse]
readPrec :: ReadPrec DescribeApplicationResponse
$creadPrec :: ReadPrec DescribeApplicationResponse
readList :: ReadS [DescribeApplicationResponse]
$creadList :: ReadS [DescribeApplicationResponse]
readsPrec :: Int -> ReadS DescribeApplicationResponse
$creadsPrec :: Int -> ReadS DescribeApplicationResponse
Prelude.Read, Int -> DescribeApplicationResponse -> ShowS
[DescribeApplicationResponse] -> ShowS
DescribeApplicationResponse -> String
(Int -> DescribeApplicationResponse -> ShowS)
-> (DescribeApplicationResponse -> String)
-> ([DescribeApplicationResponse] -> ShowS)
-> Show DescribeApplicationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeApplicationResponse] -> ShowS
$cshowList :: [DescribeApplicationResponse] -> ShowS
show :: DescribeApplicationResponse -> String
$cshow :: DescribeApplicationResponse -> String
showsPrec :: Int -> DescribeApplicationResponse -> ShowS
$cshowsPrec :: Int -> DescribeApplicationResponse -> ShowS
Prelude.Show, (forall x.
 DescribeApplicationResponse -> Rep DescribeApplicationResponse x)
-> (forall x.
    Rep DescribeApplicationResponse x -> DescribeApplicationResponse)
-> Generic DescribeApplicationResponse
forall x.
Rep DescribeApplicationResponse x -> DescribeApplicationResponse
forall x.
DescribeApplicationResponse -> Rep DescribeApplicationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeApplicationResponse x -> DescribeApplicationResponse
$cfrom :: forall x.
DescribeApplicationResponse -> Rep DescribeApplicationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeApplicationResponse' 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', 'describeApplicationResponse_httpStatus' - The response's http status code.
--
-- 'applicationDetail', 'describeApplicationResponse_applicationDetail' - Provides a description of the application, such as the application
-- Amazon Resource Name (ARN), status, latest version, and input and output
-- configuration details.
newDescribeApplicationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'applicationDetail'
  ApplicationDetail ->
  DescribeApplicationResponse
newDescribeApplicationResponse :: Int -> ApplicationDetail -> DescribeApplicationResponse
newDescribeApplicationResponse
  Int
pHttpStatus_
  ApplicationDetail
pApplicationDetail_ =
    DescribeApplicationResponse' :: Int -> ApplicationDetail -> DescribeApplicationResponse
DescribeApplicationResponse'
      { $sel:httpStatus:DescribeApplicationResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:applicationDetail:DescribeApplicationResponse' :: ApplicationDetail
applicationDetail = ApplicationDetail
pApplicationDetail_
      }

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

-- | Provides a description of the application, such as the application
-- Amazon Resource Name (ARN), status, latest version, and input and output
-- configuration details.
describeApplicationResponse_applicationDetail :: Lens.Lens' DescribeApplicationResponse ApplicationDetail
describeApplicationResponse_applicationDetail :: (ApplicationDetail -> f ApplicationDetail)
-> DescribeApplicationResponse -> f DescribeApplicationResponse
describeApplicationResponse_applicationDetail = (DescribeApplicationResponse -> ApplicationDetail)
-> (DescribeApplicationResponse
    -> ApplicationDetail -> DescribeApplicationResponse)
-> Lens
     DescribeApplicationResponse
     DescribeApplicationResponse
     ApplicationDetail
     ApplicationDetail
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplicationResponse' {ApplicationDetail
applicationDetail :: ApplicationDetail
$sel:applicationDetail:DescribeApplicationResponse' :: DescribeApplicationResponse -> ApplicationDetail
applicationDetail} -> ApplicationDetail
applicationDetail) (\s :: DescribeApplicationResponse
s@DescribeApplicationResponse' {} ApplicationDetail
a -> DescribeApplicationResponse
s {$sel:applicationDetail:DescribeApplicationResponse' :: ApplicationDetail
applicationDetail = ApplicationDetail
a} :: DescribeApplicationResponse)

instance Prelude.NFData DescribeApplicationResponse