{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DynamoDB.Types
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
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]
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
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.
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'
      { $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 :: Lens' EnableKinesisStreamingDestination Text
enableKinesisStreamingDestination_tableName = 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 :: Lens' EnableKinesisStreamingDestination Text
enableKinesisStreamingDestination_streamArn = 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 :: (Service -> Service)
-> EnableKinesisStreamingDestination
-> Request EnableKinesisStreamingDestination
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy EnableKinesisStreamingDestination
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse EnableKinesisStreamingDestination)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance
  Prelude.Hashable
    EnableKinesisStreamingDestination
  where
  hashWithSalt :: Int -> EnableKinesisStreamingDestination -> Int
hashWithSalt
    Int
_salt
    EnableKinesisStreamingDestination' {Text
streamArn :: Text
tableName :: Text
$sel:streamArn:EnableKinesisStreamingDestination' :: EnableKinesisStreamingDestination -> Text
$sel:tableName:EnableKinesisStreamingDestination' :: EnableKinesisStreamingDestination -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
streamArn

instance
  Prelude.NFData
    EnableKinesisStreamingDestination
  where
  rnf :: EnableKinesisStreamingDestination -> ()
rnf EnableKinesisStreamingDestination' {Text
streamArn :: Text
tableName :: Text
$sel:streamArn:EnableKinesisStreamingDestination' :: EnableKinesisStreamingDestination -> Text
$sel:tableName:EnableKinesisStreamingDestination' :: EnableKinesisStreamingDestination -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
tableName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
streamArn

instance
  Data.ToHeaders
    EnableKinesisStreamingDestination
  where
  toHeaders :: EnableKinesisStreamingDestination -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"DynamoDB_20120810.EnableKinesisStreamingDestination" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance
  Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"TableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tableName),
            forall a. a -> Maybe a
Prelude.Just (Key
"StreamArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
streamArn)
          ]
      )

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

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