{-# 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.EnableKinesisStreamingDestination
-- 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)
--
-- Starts table data replication to the specified Kinesis data stream at a
-- timestamp chosen during the enable workflow. If this operation doesn\'t
-- return results immediately, use DescribeKinesisStreamingDestination to
-- check if streaming to the Kinesis data stream is ACTIVE.
module Amazonka.DynamoDB.EnableKinesisStreamingDestination
  ( -- * Creating a Request
    EnableKinesisStreamingDestination (..),
    newEnableKinesisStreamingDestination,

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

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

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

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

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

instance
  Prelude.NFData
    EnableKinesisStreamingDestination

instance
  Core.ToHeaders
    EnableKinesisStreamingDestination
  where
  toHeaders :: EnableKinesisStreamingDestination -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> EnableKinesisStreamingDestination -> 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.EnableKinesisStreamingDestination" ::
                          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
    EnableKinesisStreamingDestination
  where
  toJSON :: EnableKinesisStreamingDestination -> Value
toJSON EnableKinesisStreamingDestination' {Text
streamArn :: Text
tableName :: Text
$sel:streamArn:EnableKinesisStreamingDestination' :: EnableKinesisStreamingDestination -> Text
$sel:tableName:EnableKinesisStreamingDestination' :: EnableKinesisStreamingDestination -> 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
    EnableKinesisStreamingDestination
  where
  toPath :: EnableKinesisStreamingDestination -> ByteString
toPath = ByteString -> EnableKinesisStreamingDestination -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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