{-# 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.Firehose.DeleteDeliveryStream
-- 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 a delivery stream and its data.
--
-- To check the state of a delivery stream, use DescribeDeliveryStream. You
-- can delete a delivery stream only if it is in one of the following
-- states: @ACTIVE@, @DELETING@, @CREATING_FAILED@, or @DELETING_FAILED@.
-- You can\'t delete a delivery stream that is in the @CREATING@ state.
-- While the deletion request is in process, the delivery stream is in the
-- @DELETING@ state.
--
-- While the delivery stream is in the @DELETING@ state, the service might
-- continue to accept records, but it doesn\'t make any guarantees with
-- respect to delivering the data. Therefore, as a best practice, first
-- stop any applications that are sending records before you delete a
-- delivery stream.
module Amazonka.Firehose.DeleteDeliveryStream
  ( -- * Creating a Request
    DeleteDeliveryStream (..),
    newDeleteDeliveryStream,

    -- * Request Lenses
    deleteDeliveryStream_allowForceDelete,
    deleteDeliveryStream_deliveryStreamName,

    -- * Destructuring the Response
    DeleteDeliveryStreamResponse (..),
    newDeleteDeliveryStreamResponse,

    -- * Response Lenses
    deleteDeliveryStreamResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Firehose.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:/ 'newDeleteDeliveryStream' smart constructor.
data DeleteDeliveryStream = DeleteDeliveryStream'
  { -- | Set this to true if you want to delete the delivery stream even if
    -- Kinesis Data Firehose is unable to retire the grant for the CMK. Kinesis
    -- Data Firehose might be unable to retire the grant due to a customer
    -- error, such as when the CMK or the grant are in an invalid state. If you
    -- force deletion, you can then use the
    -- <https://docs.aws.amazon.com/kms/latest/APIReference/API_RevokeGrant.html RevokeGrant>
    -- operation to revoke the grant you gave to Kinesis Data Firehose. If a
    -- failure to retire the grant happens due to an AWS KMS issue, Kinesis
    -- Data Firehose keeps retrying the delete operation.
    --
    -- The default value is false.
    DeleteDeliveryStream -> Maybe Bool
allowForceDelete :: Prelude.Maybe Prelude.Bool,
    -- | The name of the delivery stream.
    DeleteDeliveryStream -> Text
deliveryStreamName :: Prelude.Text
  }
  deriving (DeleteDeliveryStream -> DeleteDeliveryStream -> Bool
(DeleteDeliveryStream -> DeleteDeliveryStream -> Bool)
-> (DeleteDeliveryStream -> DeleteDeliveryStream -> Bool)
-> Eq DeleteDeliveryStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDeliveryStream -> DeleteDeliveryStream -> Bool
$c/= :: DeleteDeliveryStream -> DeleteDeliveryStream -> Bool
== :: DeleteDeliveryStream -> DeleteDeliveryStream -> Bool
$c== :: DeleteDeliveryStream -> DeleteDeliveryStream -> Bool
Prelude.Eq, ReadPrec [DeleteDeliveryStream]
ReadPrec DeleteDeliveryStream
Int -> ReadS DeleteDeliveryStream
ReadS [DeleteDeliveryStream]
(Int -> ReadS DeleteDeliveryStream)
-> ReadS [DeleteDeliveryStream]
-> ReadPrec DeleteDeliveryStream
-> ReadPrec [DeleteDeliveryStream]
-> Read DeleteDeliveryStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDeliveryStream]
$creadListPrec :: ReadPrec [DeleteDeliveryStream]
readPrec :: ReadPrec DeleteDeliveryStream
$creadPrec :: ReadPrec DeleteDeliveryStream
readList :: ReadS [DeleteDeliveryStream]
$creadList :: ReadS [DeleteDeliveryStream]
readsPrec :: Int -> ReadS DeleteDeliveryStream
$creadsPrec :: Int -> ReadS DeleteDeliveryStream
Prelude.Read, Int -> DeleteDeliveryStream -> ShowS
[DeleteDeliveryStream] -> ShowS
DeleteDeliveryStream -> String
(Int -> DeleteDeliveryStream -> ShowS)
-> (DeleteDeliveryStream -> String)
-> ([DeleteDeliveryStream] -> ShowS)
-> Show DeleteDeliveryStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDeliveryStream] -> ShowS
$cshowList :: [DeleteDeliveryStream] -> ShowS
show :: DeleteDeliveryStream -> String
$cshow :: DeleteDeliveryStream -> String
showsPrec :: Int -> DeleteDeliveryStream -> ShowS
$cshowsPrec :: Int -> DeleteDeliveryStream -> ShowS
Prelude.Show, (forall x. DeleteDeliveryStream -> Rep DeleteDeliveryStream x)
-> (forall x. Rep DeleteDeliveryStream x -> DeleteDeliveryStream)
-> Generic DeleteDeliveryStream
forall x. Rep DeleteDeliveryStream x -> DeleteDeliveryStream
forall x. DeleteDeliveryStream -> Rep DeleteDeliveryStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDeliveryStream x -> DeleteDeliveryStream
$cfrom :: forall x. DeleteDeliveryStream -> Rep DeleteDeliveryStream x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDeliveryStream' 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:
--
-- 'allowForceDelete', 'deleteDeliveryStream_allowForceDelete' - Set this to true if you want to delete the delivery stream even if
-- Kinesis Data Firehose is unable to retire the grant for the CMK. Kinesis
-- Data Firehose might be unable to retire the grant due to a customer
-- error, such as when the CMK or the grant are in an invalid state. If you
-- force deletion, you can then use the
-- <https://docs.aws.amazon.com/kms/latest/APIReference/API_RevokeGrant.html RevokeGrant>
-- operation to revoke the grant you gave to Kinesis Data Firehose. If a
-- failure to retire the grant happens due to an AWS KMS issue, Kinesis
-- Data Firehose keeps retrying the delete operation.
--
-- The default value is false.
--
-- 'deliveryStreamName', 'deleteDeliveryStream_deliveryStreamName' - The name of the delivery stream.
newDeleteDeliveryStream ::
  -- | 'deliveryStreamName'
  Prelude.Text ->
  DeleteDeliveryStream
newDeleteDeliveryStream :: Text -> DeleteDeliveryStream
newDeleteDeliveryStream Text
pDeliveryStreamName_ =
  DeleteDeliveryStream' :: Maybe Bool -> Text -> DeleteDeliveryStream
DeleteDeliveryStream'
    { $sel:allowForceDelete:DeleteDeliveryStream' :: Maybe Bool
allowForceDelete =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:deliveryStreamName:DeleteDeliveryStream' :: Text
deliveryStreamName = Text
pDeliveryStreamName_
    }

-- | Set this to true if you want to delete the delivery stream even if
-- Kinesis Data Firehose is unable to retire the grant for the CMK. Kinesis
-- Data Firehose might be unable to retire the grant due to a customer
-- error, such as when the CMK or the grant are in an invalid state. If you
-- force deletion, you can then use the
-- <https://docs.aws.amazon.com/kms/latest/APIReference/API_RevokeGrant.html RevokeGrant>
-- operation to revoke the grant you gave to Kinesis Data Firehose. If a
-- failure to retire the grant happens due to an AWS KMS issue, Kinesis
-- Data Firehose keeps retrying the delete operation.
--
-- The default value is false.
deleteDeliveryStream_allowForceDelete :: Lens.Lens' DeleteDeliveryStream (Prelude.Maybe Prelude.Bool)
deleteDeliveryStream_allowForceDelete :: (Maybe Bool -> f (Maybe Bool))
-> DeleteDeliveryStream -> f DeleteDeliveryStream
deleteDeliveryStream_allowForceDelete = (DeleteDeliveryStream -> Maybe Bool)
-> (DeleteDeliveryStream -> Maybe Bool -> DeleteDeliveryStream)
-> Lens
     DeleteDeliveryStream DeleteDeliveryStream (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDeliveryStream' {Maybe Bool
allowForceDelete :: Maybe Bool
$sel:allowForceDelete:DeleteDeliveryStream' :: DeleteDeliveryStream -> Maybe Bool
allowForceDelete} -> Maybe Bool
allowForceDelete) (\s :: DeleteDeliveryStream
s@DeleteDeliveryStream' {} Maybe Bool
a -> DeleteDeliveryStream
s {$sel:allowForceDelete:DeleteDeliveryStream' :: Maybe Bool
allowForceDelete = Maybe Bool
a} :: DeleteDeliveryStream)

-- | The name of the delivery stream.
deleteDeliveryStream_deliveryStreamName :: Lens.Lens' DeleteDeliveryStream Prelude.Text
deleteDeliveryStream_deliveryStreamName :: (Text -> f Text) -> DeleteDeliveryStream -> f DeleteDeliveryStream
deleteDeliveryStream_deliveryStreamName = (DeleteDeliveryStream -> Text)
-> (DeleteDeliveryStream -> Text -> DeleteDeliveryStream)
-> Lens DeleteDeliveryStream DeleteDeliveryStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDeliveryStream' {Text
deliveryStreamName :: Text
$sel:deliveryStreamName:DeleteDeliveryStream' :: DeleteDeliveryStream -> Text
deliveryStreamName} -> Text
deliveryStreamName) (\s :: DeleteDeliveryStream
s@DeleteDeliveryStream' {} Text
a -> DeleteDeliveryStream
s {$sel:deliveryStreamName:DeleteDeliveryStream' :: Text
deliveryStreamName = Text
a} :: DeleteDeliveryStream)

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

instance Prelude.NFData DeleteDeliveryStream

instance Core.ToHeaders DeleteDeliveryStream where
  toHeaders :: DeleteDeliveryStream -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteDeliveryStream -> 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
"Firehose_20150804.DeleteDeliveryStream" ::
                          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 DeleteDeliveryStream where
  toJSON :: DeleteDeliveryStream -> Value
toJSON DeleteDeliveryStream' {Maybe Bool
Text
deliveryStreamName :: Text
allowForceDelete :: Maybe Bool
$sel:deliveryStreamName:DeleteDeliveryStream' :: DeleteDeliveryStream -> Text
$sel:allowForceDelete:DeleteDeliveryStream' :: DeleteDeliveryStream -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AllowForceDelete" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allowForceDelete,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DeliveryStreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deliveryStreamName)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeleteDeliveryStreamResponse