{-# 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.DynamoDB.DisableKinesisStreamingDestination
-- 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)
--
-- Stops replication from the DynamoDB table to the Kinesis data stream.
-- This is done without deleting either of the resources.
module Amazonka.DynamoDB.DisableKinesisStreamingDestination
  ( -- * Creating a Request
    DisableKinesisStreamingDestination (..),
    newDisableKinesisStreamingDestination,

    -- * Request Lenses
    disableKinesisStreamingDestination_tableName,
    disableKinesisStreamingDestination_streamArn,

    -- * Destructuring the Response
    KinesisStreamingDestinationOutput (..),
    newKinesisStreamingDestinationOutput,

    -- * Response Lenses
    kinesisStreamingDestinationOutput_destinationStatus,
    kinesisStreamingDestinationOutput_streamArn,
    kinesisStreamingDestinationOutput_tableName,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.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:/ 'newDisableKinesisStreamingDestination' smart constructor.
data DisableKinesisStreamingDestination = DisableKinesisStreamingDestination'
  { -- | The name of the DynamoDB table.
    DisableKinesisStreamingDestination -> Text
tableName :: Prelude.Text,
    -- | The ARN for a Kinesis data stream.
    DisableKinesisStreamingDestination -> Text
streamArn :: Prelude.Text
  }
  deriving (DisableKinesisStreamingDestination
-> DisableKinesisStreamingDestination -> Bool
(DisableKinesisStreamingDestination
 -> DisableKinesisStreamingDestination -> Bool)
-> (DisableKinesisStreamingDestination
    -> DisableKinesisStreamingDestination -> Bool)
-> Eq DisableKinesisStreamingDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableKinesisStreamingDestination
-> DisableKinesisStreamingDestination -> Bool
$c/= :: DisableKinesisStreamingDestination
-> DisableKinesisStreamingDestination -> Bool
== :: DisableKinesisStreamingDestination
-> DisableKinesisStreamingDestination -> Bool
$c== :: DisableKinesisStreamingDestination
-> DisableKinesisStreamingDestination -> Bool
Prelude.Eq, ReadPrec [DisableKinesisStreamingDestination]
ReadPrec DisableKinesisStreamingDestination
Int -> ReadS DisableKinesisStreamingDestination
ReadS [DisableKinesisStreamingDestination]
(Int -> ReadS DisableKinesisStreamingDestination)
-> ReadS [DisableKinesisStreamingDestination]
-> ReadPrec DisableKinesisStreamingDestination
-> ReadPrec [DisableKinesisStreamingDestination]
-> Read DisableKinesisStreamingDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableKinesisStreamingDestination]
$creadListPrec :: ReadPrec [DisableKinesisStreamingDestination]
readPrec :: ReadPrec DisableKinesisStreamingDestination
$creadPrec :: ReadPrec DisableKinesisStreamingDestination
readList :: ReadS [DisableKinesisStreamingDestination]
$creadList :: ReadS [DisableKinesisStreamingDestination]
readsPrec :: Int -> ReadS DisableKinesisStreamingDestination
$creadsPrec :: Int -> ReadS DisableKinesisStreamingDestination
Prelude.Read, Int -> DisableKinesisStreamingDestination -> ShowS
[DisableKinesisStreamingDestination] -> ShowS
DisableKinesisStreamingDestination -> String
(Int -> DisableKinesisStreamingDestination -> ShowS)
-> (DisableKinesisStreamingDestination -> String)
-> ([DisableKinesisStreamingDestination] -> ShowS)
-> Show DisableKinesisStreamingDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableKinesisStreamingDestination] -> ShowS
$cshowList :: [DisableKinesisStreamingDestination] -> ShowS
show :: DisableKinesisStreamingDestination -> String
$cshow :: DisableKinesisStreamingDestination -> String
showsPrec :: Int -> DisableKinesisStreamingDestination -> ShowS
$cshowsPrec :: Int -> DisableKinesisStreamingDestination -> ShowS
Prelude.Show, (forall x.
 DisableKinesisStreamingDestination
 -> Rep DisableKinesisStreamingDestination x)
-> (forall x.
    Rep DisableKinesisStreamingDestination x
    -> DisableKinesisStreamingDestination)
-> Generic DisableKinesisStreamingDestination
forall x.
Rep DisableKinesisStreamingDestination x
-> DisableKinesisStreamingDestination
forall x.
DisableKinesisStreamingDestination
-> Rep DisableKinesisStreamingDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisableKinesisStreamingDestination x
-> DisableKinesisStreamingDestination
$cfrom :: forall x.
DisableKinesisStreamingDestination
-> Rep DisableKinesisStreamingDestination x
Prelude.Generic)

-- |
-- Create a value of 'DisableKinesisStreamingDestination' 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:
--
-- 'tableName', 'disableKinesisStreamingDestination_tableName' - The name of the DynamoDB table.
--
-- 'streamArn', 'disableKinesisStreamingDestination_streamArn' - The ARN for a Kinesis data stream.
newDisableKinesisStreamingDestination ::
  -- | 'tableName'
  Prelude.Text ->
  -- | 'streamArn'
  Prelude.Text ->
  DisableKinesisStreamingDestination
newDisableKinesisStreamingDestination :: Text -> Text -> DisableKinesisStreamingDestination
newDisableKinesisStreamingDestination
  Text
pTableName_
  Text
pStreamArn_ =
    DisableKinesisStreamingDestination' :: Text -> Text -> DisableKinesisStreamingDestination
DisableKinesisStreamingDestination'
      { $sel:tableName:DisableKinesisStreamingDestination' :: Text
tableName =
          Text
pTableName_,
        $sel:streamArn:DisableKinesisStreamingDestination' :: Text
streamArn = Text
pStreamArn_
      }

-- | The name of the DynamoDB table.
disableKinesisStreamingDestination_tableName :: Lens.Lens' DisableKinesisStreamingDestination Prelude.Text
disableKinesisStreamingDestination_tableName :: (Text -> f Text)
-> DisableKinesisStreamingDestination
-> f DisableKinesisStreamingDestination
disableKinesisStreamingDestination_tableName = (DisableKinesisStreamingDestination -> Text)
-> (DisableKinesisStreamingDestination
    -> Text -> DisableKinesisStreamingDestination)
-> Lens
     DisableKinesisStreamingDestination
     DisableKinesisStreamingDestination
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableKinesisStreamingDestination' {Text
tableName :: Text
$sel:tableName:DisableKinesisStreamingDestination' :: DisableKinesisStreamingDestination -> Text
tableName} -> Text
tableName) (\s :: DisableKinesisStreamingDestination
s@DisableKinesisStreamingDestination' {} Text
a -> DisableKinesisStreamingDestination
s {$sel:tableName:DisableKinesisStreamingDestination' :: Text
tableName = Text
a} :: DisableKinesisStreamingDestination)

-- | The ARN for a Kinesis data stream.
disableKinesisStreamingDestination_streamArn :: Lens.Lens' DisableKinesisStreamingDestination Prelude.Text
disableKinesisStreamingDestination_streamArn :: (Text -> f Text)
-> DisableKinesisStreamingDestination
-> f DisableKinesisStreamingDestination
disableKinesisStreamingDestination_streamArn = (DisableKinesisStreamingDestination -> Text)
-> (DisableKinesisStreamingDestination
    -> Text -> DisableKinesisStreamingDestination)
-> Lens
     DisableKinesisStreamingDestination
     DisableKinesisStreamingDestination
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableKinesisStreamingDestination' {Text
streamArn :: Text
$sel:streamArn:DisableKinesisStreamingDestination' :: DisableKinesisStreamingDestination -> Text
streamArn} -> Text
streamArn) (\s :: DisableKinesisStreamingDestination
s@DisableKinesisStreamingDestination' {} Text
a -> DisableKinesisStreamingDestination
s {$sel:streamArn:DisableKinesisStreamingDestination' :: Text
streamArn = Text
a} :: DisableKinesisStreamingDestination)

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

instance
  Prelude.Hashable
    DisableKinesisStreamingDestination

instance
  Prelude.NFData
    DisableKinesisStreamingDestination

instance
  Core.ToHeaders
    DisableKinesisStreamingDestination
  where
  toHeaders :: DisableKinesisStreamingDestination -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DisableKinesisStreamingDestination -> 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
"DynamoDB_20120810.DisableKinesisStreamingDestination" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance
  Core.ToJSON
    DisableKinesisStreamingDestination
  where
  toJSON :: DisableKinesisStreamingDestination -> Value
toJSON DisableKinesisStreamingDestination' {Text
streamArn :: Text
tableName :: Text
$sel:streamArn:DisableKinesisStreamingDestination' :: DisableKinesisStreamingDestination -> Text
$sel:tableName:DisableKinesisStreamingDestination' :: DisableKinesisStreamingDestination -> 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
"TableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tableName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StreamArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
streamArn)
          ]
      )

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

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