{-# 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.KinesisVideo.DeleteStream
-- 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)
--
-- Deletes a Kinesis video stream and the data contained in the stream.
--
-- This method marks the stream for deletion, and makes the data in the
-- stream inaccessible immediately.
--
-- To ensure that you have the latest version of the stream before deleting
-- it, you can specify the stream version. Kinesis Video Streams assigns a
-- version to each stream. When you update a stream, Kinesis Video Streams
-- assigns a new version number. To get the latest stream version, use the
-- @DescribeStream@ API.
--
-- This operation requires permission for the @KinesisVideo:DeleteStream@
-- action.
module Amazonka.KinesisVideo.DeleteStream
  ( -- * Creating a Request
    DeleteStream (..),
    newDeleteStream,

    -- * Request Lenses
    deleteStream_currentVersion,
    deleteStream_streamARN,

    -- * Destructuring the Response
    DeleteStreamResponse (..),
    newDeleteStreamResponse,

    -- * Response Lenses
    deleteStreamResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.KinesisVideo.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:/ 'newDeleteStream' smart constructor.
data DeleteStream = DeleteStream'
  { -- | Optional: The version of the stream that you want to delete.
    --
    -- Specify the version as a safeguard to ensure that your are deleting the
    -- correct stream. To get the stream version, use the @DescribeStream@ API.
    --
    -- If not specified, only the @CreationTime@ is checked before deleting the
    -- stream.
    DeleteStream -> Maybe Text
currentVersion :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the stream that you want to delete.
    DeleteStream -> Text
streamARN :: Prelude.Text
  }
  deriving (DeleteStream -> DeleteStream -> Bool
(DeleteStream -> DeleteStream -> Bool)
-> (DeleteStream -> DeleteStream -> Bool) -> Eq DeleteStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteStream -> DeleteStream -> Bool
$c/= :: DeleteStream -> DeleteStream -> Bool
== :: DeleteStream -> DeleteStream -> Bool
$c== :: DeleteStream -> DeleteStream -> Bool
Prelude.Eq, ReadPrec [DeleteStream]
ReadPrec DeleteStream
Int -> ReadS DeleteStream
ReadS [DeleteStream]
(Int -> ReadS DeleteStream)
-> ReadS [DeleteStream]
-> ReadPrec DeleteStream
-> ReadPrec [DeleteStream]
-> Read DeleteStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteStream]
$creadListPrec :: ReadPrec [DeleteStream]
readPrec :: ReadPrec DeleteStream
$creadPrec :: ReadPrec DeleteStream
readList :: ReadS [DeleteStream]
$creadList :: ReadS [DeleteStream]
readsPrec :: Int -> ReadS DeleteStream
$creadsPrec :: Int -> ReadS DeleteStream
Prelude.Read, Int -> DeleteStream -> ShowS
[DeleteStream] -> ShowS
DeleteStream -> String
(Int -> DeleteStream -> ShowS)
-> (DeleteStream -> String)
-> ([DeleteStream] -> ShowS)
-> Show DeleteStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteStream] -> ShowS
$cshowList :: [DeleteStream] -> ShowS
show :: DeleteStream -> String
$cshow :: DeleteStream -> String
showsPrec :: Int -> DeleteStream -> ShowS
$cshowsPrec :: Int -> DeleteStream -> ShowS
Prelude.Show, (forall x. DeleteStream -> Rep DeleteStream x)
-> (forall x. Rep DeleteStream x -> DeleteStream)
-> Generic DeleteStream
forall x. Rep DeleteStream x -> DeleteStream
forall x. DeleteStream -> Rep DeleteStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteStream x -> DeleteStream
$cfrom :: forall x. DeleteStream -> Rep DeleteStream x
Prelude.Generic)

-- |
-- Create a value of 'DeleteStream' 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:
--
-- 'currentVersion', 'deleteStream_currentVersion' - Optional: The version of the stream that you want to delete.
--
-- Specify the version as a safeguard to ensure that your are deleting the
-- correct stream. To get the stream version, use the @DescribeStream@ API.
--
-- If not specified, only the @CreationTime@ is checked before deleting the
-- stream.
--
-- 'streamARN', 'deleteStream_streamARN' - The Amazon Resource Name (ARN) of the stream that you want to delete.
newDeleteStream ::
  -- | 'streamARN'
  Prelude.Text ->
  DeleteStream
newDeleteStream :: Text -> DeleteStream
newDeleteStream Text
pStreamARN_ =
  DeleteStream' :: Maybe Text -> Text -> DeleteStream
DeleteStream'
    { $sel:currentVersion:DeleteStream' :: Maybe Text
currentVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:streamARN:DeleteStream' :: Text
streamARN = Text
pStreamARN_
    }

-- | Optional: The version of the stream that you want to delete.
--
-- Specify the version as a safeguard to ensure that your are deleting the
-- correct stream. To get the stream version, use the @DescribeStream@ API.
--
-- If not specified, only the @CreationTime@ is checked before deleting the
-- stream.
deleteStream_currentVersion :: Lens.Lens' DeleteStream (Prelude.Maybe Prelude.Text)
deleteStream_currentVersion :: (Maybe Text -> f (Maybe Text)) -> DeleteStream -> f DeleteStream
deleteStream_currentVersion = (DeleteStream -> Maybe Text)
-> (DeleteStream -> Maybe Text -> DeleteStream)
-> Lens DeleteStream DeleteStream (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteStream' {Maybe Text
currentVersion :: Maybe Text
$sel:currentVersion:DeleteStream' :: DeleteStream -> Maybe Text
currentVersion} -> Maybe Text
currentVersion) (\s :: DeleteStream
s@DeleteStream' {} Maybe Text
a -> DeleteStream
s {$sel:currentVersion:DeleteStream' :: Maybe Text
currentVersion = Maybe Text
a} :: DeleteStream)

-- | The Amazon Resource Name (ARN) of the stream that you want to delete.
deleteStream_streamARN :: Lens.Lens' DeleteStream Prelude.Text
deleteStream_streamARN :: (Text -> f Text) -> DeleteStream -> f DeleteStream
deleteStream_streamARN = (DeleteStream -> Text)
-> (DeleteStream -> Text -> DeleteStream)
-> Lens DeleteStream DeleteStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteStream' {Text
streamARN :: Text
$sel:streamARN:DeleteStream' :: DeleteStream -> Text
streamARN} -> Text
streamARN) (\s :: DeleteStream
s@DeleteStream' {} Text
a -> DeleteStream
s {$sel:streamARN:DeleteStream' :: Text
streamARN = Text
a} :: DeleteStream)

instance Core.AWSRequest DeleteStream where
  type AWSResponse DeleteStream = DeleteStreamResponse
  request :: DeleteStream -> Request DeleteStream
request = Service -> DeleteStream -> Request DeleteStream
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteStream)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteStream))
-> Logger
-> Service
-> Proxy DeleteStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteStream)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteStreamResponse
DeleteStreamResponse'
            (Int -> DeleteStreamResponse)
-> Either String Int -> Either String DeleteStreamResponse
forall (f :: * -> *) a b. Functor 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 DeleteStream

instance Prelude.NFData DeleteStream

instance Core.ToHeaders DeleteStream where
  toHeaders :: DeleteStream -> ResponseHeaders
toHeaders = ResponseHeaders -> DeleteStream -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON DeleteStream where
  toJSON :: DeleteStream -> Value
toJSON DeleteStream' {Maybe Text
Text
streamARN :: Text
currentVersion :: Maybe Text
$sel:streamARN:DeleteStream' :: DeleteStream -> Text
$sel:currentVersion:DeleteStream' :: DeleteStream -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CurrentVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
currentVersion,
            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 DeleteStream where
  toPath :: DeleteStream -> ByteString
toPath = ByteString -> DeleteStream -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/deleteStream"

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

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

-- |
-- Create a value of 'DeleteStreamResponse' 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:
--
-- 'httpStatus', 'deleteStreamResponse_httpStatus' - The response's http status code.
newDeleteStreamResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteStreamResponse
newDeleteStreamResponse :: Int -> DeleteStreamResponse
newDeleteStreamResponse Int
pHttpStatus_ =
  DeleteStreamResponse' :: Int -> DeleteStreamResponse
DeleteStreamResponse' {$sel:httpStatus:DeleteStreamResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData DeleteStreamResponse