{-# 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.Kinesis.StopStreamEncryption
-- 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 for a specified stream.
--
-- Stopping encryption is an asynchronous operation. Upon receiving the
-- request, Kinesis Data Streams returns immediately and sets the status of
-- the stream to @UPDATING@. After the update is complete, Kinesis Data
-- Streams sets the status of the stream back to @ACTIVE@. Stopping
-- encryption normally takes a few seconds to complete, but it can take
-- minutes. You can continue to read and write data to your stream while
-- its status is @UPDATING@. Once the status of the stream is @ACTIVE@,
-- records written to the stream are no longer encrypted by Kinesis Data
-- Streams.
--
-- API Limits: You can successfully disable server-side encryption 25 times
-- in a rolling 24-hour period.
--
-- Note: It can take up to 5 seconds after the stream is in an @ACTIVE@
-- status before all records written to the stream are no longer subject to
-- encryption. After you disabled encryption, you can verify that
-- encryption is not applied by inspecting the API response from
-- @PutRecord@ or @PutRecords@.
module Amazonka.Kinesis.StopStreamEncryption
  ( -- * Creating a Request
    StopStreamEncryption (..),
    newStopStreamEncryption,

    -- * Request Lenses
    stopStreamEncryption_streamName,
    stopStreamEncryption_encryptionType,
    stopStreamEncryption_keyId,

    -- * Destructuring the Response
    StopStreamEncryptionResponse (..),
    newStopStreamEncryptionResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Kinesis.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:/ 'newStopStreamEncryption' smart constructor.
data StopStreamEncryption = StopStreamEncryption'
  { -- | The name of the stream on which to stop encrypting records.
    StopStreamEncryption -> Text
streamName :: Prelude.Text,
    -- | The encryption type. The only valid value is @KMS@.
    StopStreamEncryption -> EncryptionType
encryptionType :: EncryptionType,
    -- | The GUID for the customer-managed AWS KMS key to use for encryption.
    -- This value can be a globally unique identifier, a fully specified Amazon
    -- Resource Name (ARN) to either an alias or a key, or an alias name
    -- prefixed by \"alias\/\".You can also use a master key owned by Kinesis
    -- Data Streams by specifying the alias @aws\/kinesis@.
    --
    -- -   Key ARN example:
    --     @arn:aws:kms:us-east-1:123456789012:key\/12345678-1234-1234-1234-123456789012@
    --
    -- -   Alias ARN example:
    --     @arn:aws:kms:us-east-1:123456789012:alias\/MyAliasName@
    --
    -- -   Globally unique key ID example:
    --     @12345678-1234-1234-1234-123456789012@
    --
    -- -   Alias name example: @alias\/MyAliasName@
    --
    -- -   Master key owned by Kinesis Data Streams: @alias\/aws\/kinesis@
    StopStreamEncryption -> Text
keyId :: Prelude.Text
  }
  deriving (StopStreamEncryption -> StopStreamEncryption -> Bool
(StopStreamEncryption -> StopStreamEncryption -> Bool)
-> (StopStreamEncryption -> StopStreamEncryption -> Bool)
-> Eq StopStreamEncryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopStreamEncryption -> StopStreamEncryption -> Bool
$c/= :: StopStreamEncryption -> StopStreamEncryption -> Bool
== :: StopStreamEncryption -> StopStreamEncryption -> Bool
$c== :: StopStreamEncryption -> StopStreamEncryption -> Bool
Prelude.Eq, ReadPrec [StopStreamEncryption]
ReadPrec StopStreamEncryption
Int -> ReadS StopStreamEncryption
ReadS [StopStreamEncryption]
(Int -> ReadS StopStreamEncryption)
-> ReadS [StopStreamEncryption]
-> ReadPrec StopStreamEncryption
-> ReadPrec [StopStreamEncryption]
-> Read StopStreamEncryption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopStreamEncryption]
$creadListPrec :: ReadPrec [StopStreamEncryption]
readPrec :: ReadPrec StopStreamEncryption
$creadPrec :: ReadPrec StopStreamEncryption
readList :: ReadS [StopStreamEncryption]
$creadList :: ReadS [StopStreamEncryption]
readsPrec :: Int -> ReadS StopStreamEncryption
$creadsPrec :: Int -> ReadS StopStreamEncryption
Prelude.Read, Int -> StopStreamEncryption -> ShowS
[StopStreamEncryption] -> ShowS
StopStreamEncryption -> String
(Int -> StopStreamEncryption -> ShowS)
-> (StopStreamEncryption -> String)
-> ([StopStreamEncryption] -> ShowS)
-> Show StopStreamEncryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopStreamEncryption] -> ShowS
$cshowList :: [StopStreamEncryption] -> ShowS
show :: StopStreamEncryption -> String
$cshow :: StopStreamEncryption -> String
showsPrec :: Int -> StopStreamEncryption -> ShowS
$cshowsPrec :: Int -> StopStreamEncryption -> ShowS
Prelude.Show, (forall x. StopStreamEncryption -> Rep StopStreamEncryption x)
-> (forall x. Rep StopStreamEncryption x -> StopStreamEncryption)
-> Generic StopStreamEncryption
forall x. Rep StopStreamEncryption x -> StopStreamEncryption
forall x. StopStreamEncryption -> Rep StopStreamEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopStreamEncryption x -> StopStreamEncryption
$cfrom :: forall x. StopStreamEncryption -> Rep StopStreamEncryption x
Prelude.Generic)

-- |
-- Create a value of 'StopStreamEncryption' 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:
--
-- 'streamName', 'stopStreamEncryption_streamName' - The name of the stream on which to stop encrypting records.
--
-- 'encryptionType', 'stopStreamEncryption_encryptionType' - The encryption type. The only valid value is @KMS@.
--
-- 'keyId', 'stopStreamEncryption_keyId' - The GUID for the customer-managed AWS KMS key to use for encryption.
-- This value can be a globally unique identifier, a fully specified Amazon
-- Resource Name (ARN) to either an alias or a key, or an alias name
-- prefixed by \"alias\/\".You can also use a master key owned by Kinesis
-- Data Streams by specifying the alias @aws\/kinesis@.
--
-- -   Key ARN example:
--     @arn:aws:kms:us-east-1:123456789012:key\/12345678-1234-1234-1234-123456789012@
--
-- -   Alias ARN example:
--     @arn:aws:kms:us-east-1:123456789012:alias\/MyAliasName@
--
-- -   Globally unique key ID example:
--     @12345678-1234-1234-1234-123456789012@
--
-- -   Alias name example: @alias\/MyAliasName@
--
-- -   Master key owned by Kinesis Data Streams: @alias\/aws\/kinesis@
newStopStreamEncryption ::
  -- | 'streamName'
  Prelude.Text ->
  -- | 'encryptionType'
  EncryptionType ->
  -- | 'keyId'
  Prelude.Text ->
  StopStreamEncryption
newStopStreamEncryption :: Text -> EncryptionType -> Text -> StopStreamEncryption
newStopStreamEncryption
  Text
pStreamName_
  EncryptionType
pEncryptionType_
  Text
pKeyId_ =
    StopStreamEncryption' :: Text -> EncryptionType -> Text -> StopStreamEncryption
StopStreamEncryption'
      { $sel:streamName:StopStreamEncryption' :: Text
streamName = Text
pStreamName_,
        $sel:encryptionType:StopStreamEncryption' :: EncryptionType
encryptionType = EncryptionType
pEncryptionType_,
        $sel:keyId:StopStreamEncryption' :: Text
keyId = Text
pKeyId_
      }

-- | The name of the stream on which to stop encrypting records.
stopStreamEncryption_streamName :: Lens.Lens' StopStreamEncryption Prelude.Text
stopStreamEncryption_streamName :: (Text -> f Text) -> StopStreamEncryption -> f StopStreamEncryption
stopStreamEncryption_streamName = (StopStreamEncryption -> Text)
-> (StopStreamEncryption -> Text -> StopStreamEncryption)
-> Lens StopStreamEncryption StopStreamEncryption Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopStreamEncryption' {Text
streamName :: Text
$sel:streamName:StopStreamEncryption' :: StopStreamEncryption -> Text
streamName} -> Text
streamName) (\s :: StopStreamEncryption
s@StopStreamEncryption' {} Text
a -> StopStreamEncryption
s {$sel:streamName:StopStreamEncryption' :: Text
streamName = Text
a} :: StopStreamEncryption)

-- | The encryption type. The only valid value is @KMS@.
stopStreamEncryption_encryptionType :: Lens.Lens' StopStreamEncryption EncryptionType
stopStreamEncryption_encryptionType :: (EncryptionType -> f EncryptionType)
-> StopStreamEncryption -> f StopStreamEncryption
stopStreamEncryption_encryptionType = (StopStreamEncryption -> EncryptionType)
-> (StopStreamEncryption -> EncryptionType -> StopStreamEncryption)
-> Lens
     StopStreamEncryption
     StopStreamEncryption
     EncryptionType
     EncryptionType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopStreamEncryption' {EncryptionType
encryptionType :: EncryptionType
$sel:encryptionType:StopStreamEncryption' :: StopStreamEncryption -> EncryptionType
encryptionType} -> EncryptionType
encryptionType) (\s :: StopStreamEncryption
s@StopStreamEncryption' {} EncryptionType
a -> StopStreamEncryption
s {$sel:encryptionType:StopStreamEncryption' :: EncryptionType
encryptionType = EncryptionType
a} :: StopStreamEncryption)

-- | The GUID for the customer-managed AWS KMS key to use for encryption.
-- This value can be a globally unique identifier, a fully specified Amazon
-- Resource Name (ARN) to either an alias or a key, or an alias name
-- prefixed by \"alias\/\".You can also use a master key owned by Kinesis
-- Data Streams by specifying the alias @aws\/kinesis@.
--
-- -   Key ARN example:
--     @arn:aws:kms:us-east-1:123456789012:key\/12345678-1234-1234-1234-123456789012@
--
-- -   Alias ARN example:
--     @arn:aws:kms:us-east-1:123456789012:alias\/MyAliasName@
--
-- -   Globally unique key ID example:
--     @12345678-1234-1234-1234-123456789012@
--
-- -   Alias name example: @alias\/MyAliasName@
--
-- -   Master key owned by Kinesis Data Streams: @alias\/aws\/kinesis@
stopStreamEncryption_keyId :: Lens.Lens' StopStreamEncryption Prelude.Text
stopStreamEncryption_keyId :: (Text -> f Text) -> StopStreamEncryption -> f StopStreamEncryption
stopStreamEncryption_keyId = (StopStreamEncryption -> Text)
-> (StopStreamEncryption -> Text -> StopStreamEncryption)
-> Lens StopStreamEncryption StopStreamEncryption Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopStreamEncryption' {Text
keyId :: Text
$sel:keyId:StopStreamEncryption' :: StopStreamEncryption -> Text
keyId} -> Text
keyId) (\s :: StopStreamEncryption
s@StopStreamEncryption' {} Text
a -> StopStreamEncryption
s {$sel:keyId:StopStreamEncryption' :: Text
keyId = Text
a} :: StopStreamEncryption)

instance Core.AWSRequest StopStreamEncryption where
  type
    AWSResponse StopStreamEncryption =
      StopStreamEncryptionResponse
  request :: StopStreamEncryption -> Request StopStreamEncryption
request = Service -> StopStreamEncryption -> Request StopStreamEncryption
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopStreamEncryption
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopStreamEncryption)))
response =
    AWSResponse StopStreamEncryption
-> Logger
-> Service
-> Proxy StopStreamEncryption
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopStreamEncryption)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse StopStreamEncryption
StopStreamEncryptionResponse
StopStreamEncryptionResponse'

instance Prelude.Hashable StopStreamEncryption

instance Prelude.NFData StopStreamEncryption

instance Core.ToHeaders StopStreamEncryption where
  toHeaders :: StopStreamEncryption -> [Header]
toHeaders =
    [Header] -> StopStreamEncryption -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"Kinesis_20131202.StopStreamEncryption" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON StopStreamEncryption where
  toJSON :: StopStreamEncryption -> Value
toJSON StopStreamEncryption' {Text
EncryptionType
keyId :: Text
encryptionType :: EncryptionType
streamName :: Text
$sel:keyId:StopStreamEncryption' :: StopStreamEncryption -> Text
$sel:encryptionType:StopStreamEncryption' :: StopStreamEncryption -> EncryptionType
$sel:streamName:StopStreamEncryption' :: StopStreamEncryption -> 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
"StreamName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
streamName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"EncryptionType" Text -> EncryptionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EncryptionType
encryptionType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"KeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
keyId)
          ]
      )

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

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

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

-- |
-- Create a value of 'StopStreamEncryptionResponse' 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.
newStopStreamEncryptionResponse ::
  StopStreamEncryptionResponse
newStopStreamEncryptionResponse :: StopStreamEncryptionResponse
newStopStreamEncryptionResponse =
  StopStreamEncryptionResponse
StopStreamEncryptionResponse'

instance Prelude.NFData StopStreamEncryptionResponse