{-# 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.StopDeliveryStreamEncryption
-- 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)
--
-- Disables server-side encryption (SSE) for the delivery stream.
--
-- This operation is asynchronous. It returns immediately. When you invoke
-- it, Kinesis Data Firehose first sets the encryption status of the stream
-- to @DISABLING@, and then to @DISABLED@. You can continue to read and
-- write data to your stream while its status is @DISABLING@. It can take
-- up to 5 seconds after the encryption status changes to @DISABLED@ before
-- all records written to the delivery stream are no longer subject to
-- encryption. To find out whether a record or a batch of records was
-- encrypted, check the response elements PutRecordOutput$Encrypted and
-- PutRecordBatchOutput$Encrypted, respectively.
--
-- To check the encryption state of a delivery stream, use
-- DescribeDeliveryStream.
--
-- If SSE is enabled using a customer managed CMK and then you invoke
-- @StopDeliveryStreamEncryption@, Kinesis Data Firehose schedules the
-- related KMS grant for retirement and then retires it after it ensures
-- that it is finished delivering records to the destination.
--
-- The @StartDeliveryStreamEncryption@ and @StopDeliveryStreamEncryption@
-- operations have a combined limit of 25 calls per delivery stream per 24
-- hours. For example, you reach the limit if you call
-- @StartDeliveryStreamEncryption@ 13 times and
-- @StopDeliveryStreamEncryption@ 12 times for the same delivery stream in
-- a 24-hour period.
module Amazonka.Firehose.StopDeliveryStreamEncryption
  ( -- * Creating a Request
    StopDeliveryStreamEncryption (..),
    newStopDeliveryStreamEncryption,

    -- * Request Lenses
    stopDeliveryStreamEncryption_deliveryStreamName,

    -- * Destructuring the Response
    StopDeliveryStreamEncryptionResponse (..),
    newStopDeliveryStreamEncryptionResponse,

    -- * Response Lenses
    stopDeliveryStreamEncryptionResponse_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:/ 'newStopDeliveryStreamEncryption' smart constructor.
data StopDeliveryStreamEncryption = StopDeliveryStreamEncryption'
  { -- | The name of the delivery stream for which you want to disable
    -- server-side encryption (SSE).
    StopDeliveryStreamEncryption -> Text
deliveryStreamName :: Prelude.Text
  }
  deriving (StopDeliveryStreamEncryption
-> StopDeliveryStreamEncryption -> Bool
(StopDeliveryStreamEncryption
 -> StopDeliveryStreamEncryption -> Bool)
-> (StopDeliveryStreamEncryption
    -> StopDeliveryStreamEncryption -> Bool)
-> Eq StopDeliveryStreamEncryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopDeliveryStreamEncryption
-> StopDeliveryStreamEncryption -> Bool
$c/= :: StopDeliveryStreamEncryption
-> StopDeliveryStreamEncryption -> Bool
== :: StopDeliveryStreamEncryption
-> StopDeliveryStreamEncryption -> Bool
$c== :: StopDeliveryStreamEncryption
-> StopDeliveryStreamEncryption -> Bool
Prelude.Eq, ReadPrec [StopDeliveryStreamEncryption]
ReadPrec StopDeliveryStreamEncryption
Int -> ReadS StopDeliveryStreamEncryption
ReadS [StopDeliveryStreamEncryption]
(Int -> ReadS StopDeliveryStreamEncryption)
-> ReadS [StopDeliveryStreamEncryption]
-> ReadPrec StopDeliveryStreamEncryption
-> ReadPrec [StopDeliveryStreamEncryption]
-> Read StopDeliveryStreamEncryption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopDeliveryStreamEncryption]
$creadListPrec :: ReadPrec [StopDeliveryStreamEncryption]
readPrec :: ReadPrec StopDeliveryStreamEncryption
$creadPrec :: ReadPrec StopDeliveryStreamEncryption
readList :: ReadS [StopDeliveryStreamEncryption]
$creadList :: ReadS [StopDeliveryStreamEncryption]
readsPrec :: Int -> ReadS StopDeliveryStreamEncryption
$creadsPrec :: Int -> ReadS StopDeliveryStreamEncryption
Prelude.Read, Int -> StopDeliveryStreamEncryption -> ShowS
[StopDeliveryStreamEncryption] -> ShowS
StopDeliveryStreamEncryption -> String
(Int -> StopDeliveryStreamEncryption -> ShowS)
-> (StopDeliveryStreamEncryption -> String)
-> ([StopDeliveryStreamEncryption] -> ShowS)
-> Show StopDeliveryStreamEncryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopDeliveryStreamEncryption] -> ShowS
$cshowList :: [StopDeliveryStreamEncryption] -> ShowS
show :: StopDeliveryStreamEncryption -> String
$cshow :: StopDeliveryStreamEncryption -> String
showsPrec :: Int -> StopDeliveryStreamEncryption -> ShowS
$cshowsPrec :: Int -> StopDeliveryStreamEncryption -> ShowS
Prelude.Show, (forall x.
 StopDeliveryStreamEncryption -> Rep StopDeliveryStreamEncryption x)
-> (forall x.
    Rep StopDeliveryStreamEncryption x -> StopDeliveryStreamEncryption)
-> Generic StopDeliveryStreamEncryption
forall x.
Rep StopDeliveryStreamEncryption x -> StopDeliveryStreamEncryption
forall x.
StopDeliveryStreamEncryption -> Rep StopDeliveryStreamEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StopDeliveryStreamEncryption x -> StopDeliveryStreamEncryption
$cfrom :: forall x.
StopDeliveryStreamEncryption -> Rep StopDeliveryStreamEncryption x
Prelude.Generic)

-- |
-- Create a value of 'StopDeliveryStreamEncryption' 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:
--
-- 'deliveryStreamName', 'stopDeliveryStreamEncryption_deliveryStreamName' - The name of the delivery stream for which you want to disable
-- server-side encryption (SSE).
newStopDeliveryStreamEncryption ::
  -- | 'deliveryStreamName'
  Prelude.Text ->
  StopDeliveryStreamEncryption
newStopDeliveryStreamEncryption :: Text -> StopDeliveryStreamEncryption
newStopDeliveryStreamEncryption Text
pDeliveryStreamName_ =
  StopDeliveryStreamEncryption' :: Text -> StopDeliveryStreamEncryption
StopDeliveryStreamEncryption'
    { $sel:deliveryStreamName:StopDeliveryStreamEncryption' :: Text
deliveryStreamName =
        Text
pDeliveryStreamName_
    }

-- | The name of the delivery stream for which you want to disable
-- server-side encryption (SSE).
stopDeliveryStreamEncryption_deliveryStreamName :: Lens.Lens' StopDeliveryStreamEncryption Prelude.Text
stopDeliveryStreamEncryption_deliveryStreamName :: (Text -> f Text)
-> StopDeliveryStreamEncryption -> f StopDeliveryStreamEncryption
stopDeliveryStreamEncryption_deliveryStreamName = (StopDeliveryStreamEncryption -> Text)
-> (StopDeliveryStreamEncryption
    -> Text -> StopDeliveryStreamEncryption)
-> Lens
     StopDeliveryStreamEncryption StopDeliveryStreamEncryption Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopDeliveryStreamEncryption' {Text
deliveryStreamName :: Text
$sel:deliveryStreamName:StopDeliveryStreamEncryption' :: StopDeliveryStreamEncryption -> Text
deliveryStreamName} -> Text
deliveryStreamName) (\s :: StopDeliveryStreamEncryption
s@StopDeliveryStreamEncryption' {} Text
a -> StopDeliveryStreamEncryption
s {$sel:deliveryStreamName:StopDeliveryStreamEncryption' :: Text
deliveryStreamName = Text
a} :: StopDeliveryStreamEncryption)

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

instance Prelude.NFData StopDeliveryStreamEncryption

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

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

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

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

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

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

instance
  Prelude.NFData
    StopDeliveryStreamEncryptionResponse