{-# 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.QLDB.CancelJournalKinesisStream
-- 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)
--
-- Ends a given Amazon QLDB journal stream. Before a stream can be
-- canceled, its current status must be @ACTIVE@.
--
-- You can\'t restart a stream after you cancel it. Canceled QLDB stream
-- resources are subject to a 7-day retention period, so they are
-- automatically deleted after this limit expires.
module Amazonka.QLDB.CancelJournalKinesisStream
  ( -- * Creating a Request
    CancelJournalKinesisStream (..),
    newCancelJournalKinesisStream,

    -- * Request Lenses
    cancelJournalKinesisStream_ledgerName,
    cancelJournalKinesisStream_streamId,

    -- * Destructuring the Response
    CancelJournalKinesisStreamResponse (..),
    newCancelJournalKinesisStreamResponse,

    -- * Response Lenses
    cancelJournalKinesisStreamResponse_streamId,
    cancelJournalKinesisStreamResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QLDB.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCancelJournalKinesisStream' smart constructor.
data CancelJournalKinesisStream = CancelJournalKinesisStream'
  { -- | The name of the ledger.
    CancelJournalKinesisStream -> Text
ledgerName :: Prelude.Text,
    -- | The UUID (represented in Base62-encoded text) of the QLDB journal stream
    -- to be canceled.
    CancelJournalKinesisStream -> Text
streamId :: Prelude.Text
  }
  deriving (CancelJournalKinesisStream -> CancelJournalKinesisStream -> Bool
(CancelJournalKinesisStream -> CancelJournalKinesisStream -> Bool)
-> (CancelJournalKinesisStream
    -> CancelJournalKinesisStream -> Bool)
-> Eq CancelJournalKinesisStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelJournalKinesisStream -> CancelJournalKinesisStream -> Bool
$c/= :: CancelJournalKinesisStream -> CancelJournalKinesisStream -> Bool
== :: CancelJournalKinesisStream -> CancelJournalKinesisStream -> Bool
$c== :: CancelJournalKinesisStream -> CancelJournalKinesisStream -> Bool
Prelude.Eq, ReadPrec [CancelJournalKinesisStream]
ReadPrec CancelJournalKinesisStream
Int -> ReadS CancelJournalKinesisStream
ReadS [CancelJournalKinesisStream]
(Int -> ReadS CancelJournalKinesisStream)
-> ReadS [CancelJournalKinesisStream]
-> ReadPrec CancelJournalKinesisStream
-> ReadPrec [CancelJournalKinesisStream]
-> Read CancelJournalKinesisStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelJournalKinesisStream]
$creadListPrec :: ReadPrec [CancelJournalKinesisStream]
readPrec :: ReadPrec CancelJournalKinesisStream
$creadPrec :: ReadPrec CancelJournalKinesisStream
readList :: ReadS [CancelJournalKinesisStream]
$creadList :: ReadS [CancelJournalKinesisStream]
readsPrec :: Int -> ReadS CancelJournalKinesisStream
$creadsPrec :: Int -> ReadS CancelJournalKinesisStream
Prelude.Read, Int -> CancelJournalKinesisStream -> ShowS
[CancelJournalKinesisStream] -> ShowS
CancelJournalKinesisStream -> String
(Int -> CancelJournalKinesisStream -> ShowS)
-> (CancelJournalKinesisStream -> String)
-> ([CancelJournalKinesisStream] -> ShowS)
-> Show CancelJournalKinesisStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelJournalKinesisStream] -> ShowS
$cshowList :: [CancelJournalKinesisStream] -> ShowS
show :: CancelJournalKinesisStream -> String
$cshow :: CancelJournalKinesisStream -> String
showsPrec :: Int -> CancelJournalKinesisStream -> ShowS
$cshowsPrec :: Int -> CancelJournalKinesisStream -> ShowS
Prelude.Show, (forall x.
 CancelJournalKinesisStream -> Rep CancelJournalKinesisStream x)
-> (forall x.
    Rep CancelJournalKinesisStream x -> CancelJournalKinesisStream)
-> Generic CancelJournalKinesisStream
forall x.
Rep CancelJournalKinesisStream x -> CancelJournalKinesisStream
forall x.
CancelJournalKinesisStream -> Rep CancelJournalKinesisStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelJournalKinesisStream x -> CancelJournalKinesisStream
$cfrom :: forall x.
CancelJournalKinesisStream -> Rep CancelJournalKinesisStream x
Prelude.Generic)

-- |
-- Create a value of 'CancelJournalKinesisStream' 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:
--
-- 'ledgerName', 'cancelJournalKinesisStream_ledgerName' - The name of the ledger.
--
-- 'streamId', 'cancelJournalKinesisStream_streamId' - The UUID (represented in Base62-encoded text) of the QLDB journal stream
-- to be canceled.
newCancelJournalKinesisStream ::
  -- | 'ledgerName'
  Prelude.Text ->
  -- | 'streamId'
  Prelude.Text ->
  CancelJournalKinesisStream
newCancelJournalKinesisStream :: Text -> Text -> CancelJournalKinesisStream
newCancelJournalKinesisStream Text
pLedgerName_ Text
pStreamId_ =
  CancelJournalKinesisStream' :: Text -> Text -> CancelJournalKinesisStream
CancelJournalKinesisStream'
    { $sel:ledgerName:CancelJournalKinesisStream' :: Text
ledgerName =
        Text
pLedgerName_,
      $sel:streamId:CancelJournalKinesisStream' :: Text
streamId = Text
pStreamId_
    }

-- | The name of the ledger.
cancelJournalKinesisStream_ledgerName :: Lens.Lens' CancelJournalKinesisStream Prelude.Text
cancelJournalKinesisStream_ledgerName :: (Text -> f Text)
-> CancelJournalKinesisStream -> f CancelJournalKinesisStream
cancelJournalKinesisStream_ledgerName = (CancelJournalKinesisStream -> Text)
-> (CancelJournalKinesisStream
    -> Text -> CancelJournalKinesisStream)
-> Lens
     CancelJournalKinesisStream CancelJournalKinesisStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJournalKinesisStream' {Text
ledgerName :: Text
$sel:ledgerName:CancelJournalKinesisStream' :: CancelJournalKinesisStream -> Text
ledgerName} -> Text
ledgerName) (\s :: CancelJournalKinesisStream
s@CancelJournalKinesisStream' {} Text
a -> CancelJournalKinesisStream
s {$sel:ledgerName:CancelJournalKinesisStream' :: Text
ledgerName = Text
a} :: CancelJournalKinesisStream)

-- | The UUID (represented in Base62-encoded text) of the QLDB journal stream
-- to be canceled.
cancelJournalKinesisStream_streamId :: Lens.Lens' CancelJournalKinesisStream Prelude.Text
cancelJournalKinesisStream_streamId :: (Text -> f Text)
-> CancelJournalKinesisStream -> f CancelJournalKinesisStream
cancelJournalKinesisStream_streamId = (CancelJournalKinesisStream -> Text)
-> (CancelJournalKinesisStream
    -> Text -> CancelJournalKinesisStream)
-> Lens
     CancelJournalKinesisStream CancelJournalKinesisStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJournalKinesisStream' {Text
streamId :: Text
$sel:streamId:CancelJournalKinesisStream' :: CancelJournalKinesisStream -> Text
streamId} -> Text
streamId) (\s :: CancelJournalKinesisStream
s@CancelJournalKinesisStream' {} Text
a -> CancelJournalKinesisStream
s {$sel:streamId:CancelJournalKinesisStream' :: Text
streamId = Text
a} :: CancelJournalKinesisStream)

instance Core.AWSRequest CancelJournalKinesisStream where
  type
    AWSResponse CancelJournalKinesisStream =
      CancelJournalKinesisStreamResponse
  request :: CancelJournalKinesisStream -> Request CancelJournalKinesisStream
request = Service
-> CancelJournalKinesisStream -> Request CancelJournalKinesisStream
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelJournalKinesisStream
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelJournalKinesisStream)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CancelJournalKinesisStream))
-> Logger
-> Service
-> Proxy CancelJournalKinesisStream
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelJournalKinesisStream)))
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 ->
          Maybe Text -> Int -> CancelJournalKinesisStreamResponse
CancelJournalKinesisStreamResponse'
            (Maybe Text -> Int -> CancelJournalKinesisStreamResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CancelJournalKinesisStreamResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"StreamId")
            Either String (Int -> CancelJournalKinesisStreamResponse)
-> Either String Int
-> Either String CancelJournalKinesisStreamResponse
forall (f :: * -> *) a b. Applicative f => 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 CancelJournalKinesisStream

instance Prelude.NFData CancelJournalKinesisStream

instance Core.ToHeaders CancelJournalKinesisStream where
  toHeaders :: CancelJournalKinesisStream -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CancelJournalKinesisStream -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath CancelJournalKinesisStream where
  toPath :: CancelJournalKinesisStream -> ByteString
toPath CancelJournalKinesisStream' {Text
streamId :: Text
ledgerName :: Text
$sel:streamId:CancelJournalKinesisStream' :: CancelJournalKinesisStream -> Text
$sel:ledgerName:CancelJournalKinesisStream' :: CancelJournalKinesisStream -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/ledgers/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
ledgerName,
        ByteString
"/journal-kinesis-streams/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
streamId
      ]

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

-- | /See:/ 'newCancelJournalKinesisStreamResponse' smart constructor.
data CancelJournalKinesisStreamResponse = CancelJournalKinesisStreamResponse'
  { -- | The UUID (Base62-encoded text) of the canceled QLDB journal stream.
    CancelJournalKinesisStreamResponse -> Maybe Text
streamId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CancelJournalKinesisStreamResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CancelJournalKinesisStreamResponse
-> CancelJournalKinesisStreamResponse -> Bool
(CancelJournalKinesisStreamResponse
 -> CancelJournalKinesisStreamResponse -> Bool)
-> (CancelJournalKinesisStreamResponse
    -> CancelJournalKinesisStreamResponse -> Bool)
-> Eq CancelJournalKinesisStreamResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelJournalKinesisStreamResponse
-> CancelJournalKinesisStreamResponse -> Bool
$c/= :: CancelJournalKinesisStreamResponse
-> CancelJournalKinesisStreamResponse -> Bool
== :: CancelJournalKinesisStreamResponse
-> CancelJournalKinesisStreamResponse -> Bool
$c== :: CancelJournalKinesisStreamResponse
-> CancelJournalKinesisStreamResponse -> Bool
Prelude.Eq, ReadPrec [CancelJournalKinesisStreamResponse]
ReadPrec CancelJournalKinesisStreamResponse
Int -> ReadS CancelJournalKinesisStreamResponse
ReadS [CancelJournalKinesisStreamResponse]
(Int -> ReadS CancelJournalKinesisStreamResponse)
-> ReadS [CancelJournalKinesisStreamResponse]
-> ReadPrec CancelJournalKinesisStreamResponse
-> ReadPrec [CancelJournalKinesisStreamResponse]
-> Read CancelJournalKinesisStreamResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelJournalKinesisStreamResponse]
$creadListPrec :: ReadPrec [CancelJournalKinesisStreamResponse]
readPrec :: ReadPrec CancelJournalKinesisStreamResponse
$creadPrec :: ReadPrec CancelJournalKinesisStreamResponse
readList :: ReadS [CancelJournalKinesisStreamResponse]
$creadList :: ReadS [CancelJournalKinesisStreamResponse]
readsPrec :: Int -> ReadS CancelJournalKinesisStreamResponse
$creadsPrec :: Int -> ReadS CancelJournalKinesisStreamResponse
Prelude.Read, Int -> CancelJournalKinesisStreamResponse -> ShowS
[CancelJournalKinesisStreamResponse] -> ShowS
CancelJournalKinesisStreamResponse -> String
(Int -> CancelJournalKinesisStreamResponse -> ShowS)
-> (CancelJournalKinesisStreamResponse -> String)
-> ([CancelJournalKinesisStreamResponse] -> ShowS)
-> Show CancelJournalKinesisStreamResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelJournalKinesisStreamResponse] -> ShowS
$cshowList :: [CancelJournalKinesisStreamResponse] -> ShowS
show :: CancelJournalKinesisStreamResponse -> String
$cshow :: CancelJournalKinesisStreamResponse -> String
showsPrec :: Int -> CancelJournalKinesisStreamResponse -> ShowS
$cshowsPrec :: Int -> CancelJournalKinesisStreamResponse -> ShowS
Prelude.Show, (forall x.
 CancelJournalKinesisStreamResponse
 -> Rep CancelJournalKinesisStreamResponse x)
-> (forall x.
    Rep CancelJournalKinesisStreamResponse x
    -> CancelJournalKinesisStreamResponse)
-> Generic CancelJournalKinesisStreamResponse
forall x.
Rep CancelJournalKinesisStreamResponse x
-> CancelJournalKinesisStreamResponse
forall x.
CancelJournalKinesisStreamResponse
-> Rep CancelJournalKinesisStreamResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelJournalKinesisStreamResponse x
-> CancelJournalKinesisStreamResponse
$cfrom :: forall x.
CancelJournalKinesisStreamResponse
-> Rep CancelJournalKinesisStreamResponse x
Prelude.Generic)

-- |
-- Create a value of 'CancelJournalKinesisStreamResponse' 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:
--
-- 'streamId', 'cancelJournalKinesisStreamResponse_streamId' - The UUID (Base62-encoded text) of the canceled QLDB journal stream.
--
-- 'httpStatus', 'cancelJournalKinesisStreamResponse_httpStatus' - The response's http status code.
newCancelJournalKinesisStreamResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CancelJournalKinesisStreamResponse
newCancelJournalKinesisStreamResponse :: Int -> CancelJournalKinesisStreamResponse
newCancelJournalKinesisStreamResponse Int
pHttpStatus_ =
  CancelJournalKinesisStreamResponse' :: Maybe Text -> Int -> CancelJournalKinesisStreamResponse
CancelJournalKinesisStreamResponse'
    { $sel:streamId:CancelJournalKinesisStreamResponse' :: Maybe Text
streamId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CancelJournalKinesisStreamResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The UUID (Base62-encoded text) of the canceled QLDB journal stream.
cancelJournalKinesisStreamResponse_streamId :: Lens.Lens' CancelJournalKinesisStreamResponse (Prelude.Maybe Prelude.Text)
cancelJournalKinesisStreamResponse_streamId :: (Maybe Text -> f (Maybe Text))
-> CancelJournalKinesisStreamResponse
-> f CancelJournalKinesisStreamResponse
cancelJournalKinesisStreamResponse_streamId = (CancelJournalKinesisStreamResponse -> Maybe Text)
-> (CancelJournalKinesisStreamResponse
    -> Maybe Text -> CancelJournalKinesisStreamResponse)
-> Lens
     CancelJournalKinesisStreamResponse
     CancelJournalKinesisStreamResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelJournalKinesisStreamResponse' {Maybe Text
streamId :: Maybe Text
$sel:streamId:CancelJournalKinesisStreamResponse' :: CancelJournalKinesisStreamResponse -> Maybe Text
streamId} -> Maybe Text
streamId) (\s :: CancelJournalKinesisStreamResponse
s@CancelJournalKinesisStreamResponse' {} Maybe Text
a -> CancelJournalKinesisStreamResponse
s {$sel:streamId:CancelJournalKinesisStreamResponse' :: Maybe Text
streamId = Maybe Text
a} :: CancelJournalKinesisStreamResponse)

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

instance
  Prelude.NFData
    CancelJournalKinesisStreamResponse