{-# 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.MediaConnect.DeleteFlow
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a flow. Before you can delete a flow, you must stop the flow.
module Amazonka.MediaConnect.DeleteFlow
  ( -- * Creating a Request
    DeleteFlow (..),
    newDeleteFlow,

    -- * Request Lenses
    deleteFlow_flowArn,

    -- * Destructuring the Response
    DeleteFlowResponse (..),
    newDeleteFlowResponse,

    -- * Response Lenses
    deleteFlowResponse_flowArn,
    deleteFlowResponse_status,
    deleteFlowResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaConnect.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteFlow' smart constructor.
data DeleteFlow = DeleteFlow'
  { -- | The ARN of the flow that you want to delete.
    DeleteFlow -> Text
flowArn :: Prelude.Text
  }
  deriving (DeleteFlow -> DeleteFlow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFlow -> DeleteFlow -> Bool
$c/= :: DeleteFlow -> DeleteFlow -> Bool
== :: DeleteFlow -> DeleteFlow -> Bool
$c== :: DeleteFlow -> DeleteFlow -> Bool
Prelude.Eq, ReadPrec [DeleteFlow]
ReadPrec DeleteFlow
Int -> ReadS DeleteFlow
ReadS [DeleteFlow]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFlow]
$creadListPrec :: ReadPrec [DeleteFlow]
readPrec :: ReadPrec DeleteFlow
$creadPrec :: ReadPrec DeleteFlow
readList :: ReadS [DeleteFlow]
$creadList :: ReadS [DeleteFlow]
readsPrec :: Int -> ReadS DeleteFlow
$creadsPrec :: Int -> ReadS DeleteFlow
Prelude.Read, Int -> DeleteFlow -> ShowS
[DeleteFlow] -> ShowS
DeleteFlow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFlow] -> ShowS
$cshowList :: [DeleteFlow] -> ShowS
show :: DeleteFlow -> String
$cshow :: DeleteFlow -> String
showsPrec :: Int -> DeleteFlow -> ShowS
$cshowsPrec :: Int -> DeleteFlow -> ShowS
Prelude.Show, forall x. Rep DeleteFlow x -> DeleteFlow
forall x. DeleteFlow -> Rep DeleteFlow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFlow x -> DeleteFlow
$cfrom :: forall x. DeleteFlow -> Rep DeleteFlow x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFlow' 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:
--
-- 'flowArn', 'deleteFlow_flowArn' - The ARN of the flow that you want to delete.
newDeleteFlow ::
  -- | 'flowArn'
  Prelude.Text ->
  DeleteFlow
newDeleteFlow :: Text -> DeleteFlow
newDeleteFlow Text
pFlowArn_ =
  DeleteFlow' {$sel:flowArn:DeleteFlow' :: Text
flowArn = Text
pFlowArn_}

-- | The ARN of the flow that you want to delete.
deleteFlow_flowArn :: Lens.Lens' DeleteFlow Prelude.Text
deleteFlow_flowArn :: Lens' DeleteFlow Text
deleteFlow_flowArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFlow' {Text
flowArn :: Text
$sel:flowArn:DeleteFlow' :: DeleteFlow -> Text
flowArn} -> Text
flowArn) (\s :: DeleteFlow
s@DeleteFlow' {} Text
a -> DeleteFlow
s {$sel:flowArn:DeleteFlow' :: Text
flowArn = Text
a} :: DeleteFlow)

instance Core.AWSRequest DeleteFlow where
  type AWSResponse DeleteFlow = DeleteFlowResponse
  request :: (Service -> Service) -> DeleteFlow -> Request DeleteFlow
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteFlow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFlow)))
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 ->
          Maybe Text -> Maybe Status -> Int -> DeleteFlowResponse
DeleteFlowResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"flowArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

instance Prelude.NFData DeleteFlow where
  rnf :: DeleteFlow -> ()
rnf DeleteFlow' {Text
flowArn :: Text
$sel:flowArn:DeleteFlow' :: DeleteFlow -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
flowArn

instance Data.ToHeaders DeleteFlow where
  toHeaders :: DeleteFlow -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath DeleteFlow where
  toPath :: DeleteFlow -> ByteString
toPath DeleteFlow' {Text
flowArn :: Text
$sel:flowArn:DeleteFlow' :: DeleteFlow -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/v1/flows/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
flowArn]

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

-- | /See:/ 'newDeleteFlowResponse' smart constructor.
data DeleteFlowResponse = DeleteFlowResponse'
  { -- | The ARN of the flow that was deleted.
    DeleteFlowResponse -> Maybe Text
flowArn :: Prelude.Maybe Prelude.Text,
    -- | The status of the flow when the DeleteFlow process begins.
    DeleteFlowResponse -> Maybe Status
status :: Prelude.Maybe Status,
    -- | The response's http status code.
    DeleteFlowResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteFlowResponse -> DeleteFlowResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFlowResponse -> DeleteFlowResponse -> Bool
$c/= :: DeleteFlowResponse -> DeleteFlowResponse -> Bool
== :: DeleteFlowResponse -> DeleteFlowResponse -> Bool
$c== :: DeleteFlowResponse -> DeleteFlowResponse -> Bool
Prelude.Eq, ReadPrec [DeleteFlowResponse]
ReadPrec DeleteFlowResponse
Int -> ReadS DeleteFlowResponse
ReadS [DeleteFlowResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFlowResponse]
$creadListPrec :: ReadPrec [DeleteFlowResponse]
readPrec :: ReadPrec DeleteFlowResponse
$creadPrec :: ReadPrec DeleteFlowResponse
readList :: ReadS [DeleteFlowResponse]
$creadList :: ReadS [DeleteFlowResponse]
readsPrec :: Int -> ReadS DeleteFlowResponse
$creadsPrec :: Int -> ReadS DeleteFlowResponse
Prelude.Read, Int -> DeleteFlowResponse -> ShowS
[DeleteFlowResponse] -> ShowS
DeleteFlowResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFlowResponse] -> ShowS
$cshowList :: [DeleteFlowResponse] -> ShowS
show :: DeleteFlowResponse -> String
$cshow :: DeleteFlowResponse -> String
showsPrec :: Int -> DeleteFlowResponse -> ShowS
$cshowsPrec :: Int -> DeleteFlowResponse -> ShowS
Prelude.Show, forall x. Rep DeleteFlowResponse x -> DeleteFlowResponse
forall x. DeleteFlowResponse -> Rep DeleteFlowResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFlowResponse x -> DeleteFlowResponse
$cfrom :: forall x. DeleteFlowResponse -> Rep DeleteFlowResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFlowResponse' 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:
--
-- 'flowArn', 'deleteFlowResponse_flowArn' - The ARN of the flow that was deleted.
--
-- 'status', 'deleteFlowResponse_status' - The status of the flow when the DeleteFlow process begins.
--
-- 'httpStatus', 'deleteFlowResponse_httpStatus' - The response's http status code.
newDeleteFlowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteFlowResponse
newDeleteFlowResponse :: Int -> DeleteFlowResponse
newDeleteFlowResponse Int
pHttpStatus_ =
  DeleteFlowResponse'
    { $sel:flowArn:DeleteFlowResponse' :: Maybe Text
flowArn = forall a. Maybe a
Prelude.Nothing,
      $sel:status:DeleteFlowResponse' :: Maybe Status
status = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteFlowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the flow that was deleted.
deleteFlowResponse_flowArn :: Lens.Lens' DeleteFlowResponse (Prelude.Maybe Prelude.Text)
deleteFlowResponse_flowArn :: Lens' DeleteFlowResponse (Maybe Text)
deleteFlowResponse_flowArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFlowResponse' {Maybe Text
flowArn :: Maybe Text
$sel:flowArn:DeleteFlowResponse' :: DeleteFlowResponse -> Maybe Text
flowArn} -> Maybe Text
flowArn) (\s :: DeleteFlowResponse
s@DeleteFlowResponse' {} Maybe Text
a -> DeleteFlowResponse
s {$sel:flowArn:DeleteFlowResponse' :: Maybe Text
flowArn = Maybe Text
a} :: DeleteFlowResponse)

-- | The status of the flow when the DeleteFlow process begins.
deleteFlowResponse_status :: Lens.Lens' DeleteFlowResponse (Prelude.Maybe Status)
deleteFlowResponse_status :: Lens' DeleteFlowResponse (Maybe Status)
deleteFlowResponse_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFlowResponse' {Maybe Status
status :: Maybe Status
$sel:status:DeleteFlowResponse' :: DeleteFlowResponse -> Maybe Status
status} -> Maybe Status
status) (\s :: DeleteFlowResponse
s@DeleteFlowResponse' {} Maybe Status
a -> DeleteFlowResponse
s {$sel:status:DeleteFlowResponse' :: Maybe Status
status = Maybe Status
a} :: DeleteFlowResponse)

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

instance Prelude.NFData DeleteFlowResponse where
  rnf :: DeleteFlowResponse -> ()
rnf DeleteFlowResponse' {Int
Maybe Text
Maybe Status
httpStatus :: Int
status :: Maybe Status
flowArn :: Maybe Text
$sel:httpStatus:DeleteFlowResponse' :: DeleteFlowResponse -> Int
$sel:status:DeleteFlowResponse' :: DeleteFlowResponse -> Maybe Status
$sel:flowArn:DeleteFlowResponse' :: DeleteFlowResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
flowArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Status
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus