{-# 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.DeleteApplication
-- 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)
--
-- Deletes the specified application. Kinesis Data Analytics halts
-- application execution and deletes the application.
module Amazonka.KinesisAnalyticsV2.DeleteApplication
  ( -- * Creating a Request
    DeleteApplication (..),
    newDeleteApplication,

    -- * Request Lenses
    deleteApplication_applicationName,
    deleteApplication_createTimestamp,

    -- * Destructuring the Response
    DeleteApplicationResponse (..),
    newDeleteApplicationResponse,

    -- * Response Lenses
    deleteApplicationResponse_httpStatus,
  )
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:/ 'newDeleteApplication' smart constructor.
data DeleteApplication = DeleteApplication'
  { -- | The name of the application to delete.
    DeleteApplication -> Text
applicationName :: Prelude.Text,
    -- | Use the @DescribeApplication@ operation to get this value.
    DeleteApplication -> POSIX
createTimestamp :: Core.POSIX
  }
  deriving (DeleteApplication -> DeleteApplication -> Bool
(DeleteApplication -> DeleteApplication -> Bool)
-> (DeleteApplication -> DeleteApplication -> Bool)
-> Eq DeleteApplication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteApplication -> DeleteApplication -> Bool
$c/= :: DeleteApplication -> DeleteApplication -> Bool
== :: DeleteApplication -> DeleteApplication -> Bool
$c== :: DeleteApplication -> DeleteApplication -> Bool
Prelude.Eq, ReadPrec [DeleteApplication]
ReadPrec DeleteApplication
Int -> ReadS DeleteApplication
ReadS [DeleteApplication]
(Int -> ReadS DeleteApplication)
-> ReadS [DeleteApplication]
-> ReadPrec DeleteApplication
-> ReadPrec [DeleteApplication]
-> Read DeleteApplication
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteApplication]
$creadListPrec :: ReadPrec [DeleteApplication]
readPrec :: ReadPrec DeleteApplication
$creadPrec :: ReadPrec DeleteApplication
readList :: ReadS [DeleteApplication]
$creadList :: ReadS [DeleteApplication]
readsPrec :: Int -> ReadS DeleteApplication
$creadsPrec :: Int -> ReadS DeleteApplication
Prelude.Read, Int -> DeleteApplication -> ShowS
[DeleteApplication] -> ShowS
DeleteApplication -> String
(Int -> DeleteApplication -> ShowS)
-> (DeleteApplication -> String)
-> ([DeleteApplication] -> ShowS)
-> Show DeleteApplication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteApplication] -> ShowS
$cshowList :: [DeleteApplication] -> ShowS
show :: DeleteApplication -> String
$cshow :: DeleteApplication -> String
showsPrec :: Int -> DeleteApplication -> ShowS
$cshowsPrec :: Int -> DeleteApplication -> ShowS
Prelude.Show, (forall x. DeleteApplication -> Rep DeleteApplication x)
-> (forall x. Rep DeleteApplication x -> DeleteApplication)
-> Generic DeleteApplication
forall x. Rep DeleteApplication x -> DeleteApplication
forall x. DeleteApplication -> Rep DeleteApplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteApplication x -> DeleteApplication
$cfrom :: forall x. DeleteApplication -> Rep DeleteApplication x
Prelude.Generic)

-- |
-- Create a value of 'DeleteApplication' 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', 'deleteApplication_applicationName' - The name of the application to delete.
--
-- 'createTimestamp', 'deleteApplication_createTimestamp' - Use the @DescribeApplication@ operation to get this value.
newDeleteApplication ::
  -- | 'applicationName'
  Prelude.Text ->
  -- | 'createTimestamp'
  Prelude.UTCTime ->
  DeleteApplication
newDeleteApplication :: Text -> UTCTime -> DeleteApplication
newDeleteApplication
  Text
pApplicationName_
  UTCTime
pCreateTimestamp_ =
    DeleteApplication' :: Text -> POSIX -> DeleteApplication
DeleteApplication'
      { $sel:applicationName:DeleteApplication' :: Text
applicationName =
          Text
pApplicationName_,
        $sel:createTimestamp:DeleteApplication' :: POSIX
createTimestamp =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreateTimestamp_
      }

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

-- | Use the @DescribeApplication@ operation to get this value.
deleteApplication_createTimestamp :: Lens.Lens' DeleteApplication Prelude.UTCTime
deleteApplication_createTimestamp :: (UTCTime -> f UTCTime) -> DeleteApplication -> f DeleteApplication
deleteApplication_createTimestamp = (DeleteApplication -> POSIX)
-> (DeleteApplication -> POSIX -> DeleteApplication)
-> Lens DeleteApplication DeleteApplication POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteApplication' {POSIX
createTimestamp :: POSIX
$sel:createTimestamp:DeleteApplication' :: DeleteApplication -> POSIX
createTimestamp} -> POSIX
createTimestamp) (\s :: DeleteApplication
s@DeleteApplication' {} POSIX
a -> DeleteApplication
s {$sel:createTimestamp:DeleteApplication' :: POSIX
createTimestamp = POSIX
a} :: DeleteApplication) ((POSIX -> f POSIX) -> DeleteApplication -> f DeleteApplication)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> DeleteApplication
-> f DeleteApplication
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.NFData DeleteApplication

instance Core.ToHeaders DeleteApplication where
  toHeaders :: DeleteApplication -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteApplication -> 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.DeleteApplication" ::
                          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 DeleteApplication where
  toJSON :: DeleteApplication -> Value
toJSON DeleteApplication' {Text
POSIX
createTimestamp :: POSIX
applicationName :: Text
$sel:createTimestamp:DeleteApplication' :: DeleteApplication -> POSIX
$sel:applicationName:DeleteApplication' :: DeleteApplication -> 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
"CreateTimestamp" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
createTimestamp)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteApplicationResponse