{-# 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-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 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_status,
    deleteFlowResponse_flowArn,
    deleteFlowResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(DeleteFlow -> DeleteFlow -> Bool)
-> (DeleteFlow -> DeleteFlow -> Bool) -> Eq DeleteFlow
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]
(Int -> ReadS DeleteFlow)
-> ReadS [DeleteFlow]
-> ReadPrec DeleteFlow
-> ReadPrec [DeleteFlow]
-> Read 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
(Int -> DeleteFlow -> ShowS)
-> (DeleteFlow -> String)
-> ([DeleteFlow] -> ShowS)
-> Show DeleteFlow
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. DeleteFlow -> Rep DeleteFlow x)
-> (forall x. Rep DeleteFlow x -> DeleteFlow) -> Generic DeleteFlow
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' :: Text -> DeleteFlow
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 :: (Text -> f Text) -> DeleteFlow -> f DeleteFlow
deleteFlow_flowArn = (DeleteFlow -> Text)
-> (DeleteFlow -> Text -> DeleteFlow)
-> Lens DeleteFlow DeleteFlow Text Text
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 :: DeleteFlow -> Request DeleteFlow
request = Service -> DeleteFlow -> Request DeleteFlow
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteFlow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFlow)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteFlow))
-> Logger
-> Service
-> Proxy DeleteFlow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFlow)))
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 Status -> Maybe Text -> Int -> DeleteFlowResponse
DeleteFlowResponse'
            (Maybe Status -> Maybe Text -> Int -> DeleteFlowResponse)
-> Either String (Maybe Status)
-> Either String (Maybe Text -> Int -> DeleteFlowResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Status)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"status")
            Either String (Maybe Text -> Int -> DeleteFlowResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteFlowResponse)
forall (f :: * -> *) a b. Applicative f => 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
"flowArn")
            Either String (Int -> DeleteFlowResponse)
-> Either String Int -> Either String DeleteFlowResponse
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 DeleteFlow

instance Prelude.NFData DeleteFlow

instance Core.ToHeaders DeleteFlow where
  toHeaders :: DeleteFlow -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteFlow -> 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.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

-- | /See:/ 'newDeleteFlowResponse' smart constructor.
data DeleteFlowResponse = DeleteFlowResponse'
  { -- | The status of the flow when the DeleteFlow process begins.
    DeleteFlowResponse -> Maybe Status
status :: Prelude.Maybe Status,
    -- | The ARN of the flow that was deleted.
    DeleteFlowResponse -> Maybe Text
flowArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteFlowResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteFlowResponse -> DeleteFlowResponse -> Bool
(DeleteFlowResponse -> DeleteFlowResponse -> Bool)
-> (DeleteFlowResponse -> DeleteFlowResponse -> Bool)
-> Eq DeleteFlowResponse
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]
(Int -> ReadS DeleteFlowResponse)
-> ReadS [DeleteFlowResponse]
-> ReadPrec DeleteFlowResponse
-> ReadPrec [DeleteFlowResponse]
-> Read 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
(Int -> DeleteFlowResponse -> ShowS)
-> (DeleteFlowResponse -> String)
-> ([DeleteFlowResponse] -> ShowS)
-> Show DeleteFlowResponse
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. DeleteFlowResponse -> Rep DeleteFlowResponse x)
-> (forall x. Rep DeleteFlowResponse x -> DeleteFlowResponse)
-> Generic DeleteFlowResponse
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:
--
-- 'status', 'deleteFlowResponse_status' - The status of the flow when the DeleteFlow process begins.
--
-- 'flowArn', 'deleteFlowResponse_flowArn' - The ARN of the flow that was deleted.
--
-- 'httpStatus', 'deleteFlowResponse_httpStatus' - The response's http status code.
newDeleteFlowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteFlowResponse
newDeleteFlowResponse :: Int -> DeleteFlowResponse
newDeleteFlowResponse Int
pHttpStatus_ =
  DeleteFlowResponse' :: Maybe Status -> Maybe Text -> Int -> DeleteFlowResponse
DeleteFlowResponse'
    { $sel:status:DeleteFlowResponse' :: Maybe Status
status = Maybe Status
forall a. Maybe a
Prelude.Nothing,
      $sel:flowArn:DeleteFlowResponse' :: Maybe Text
flowArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteFlowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the flow when the DeleteFlow process begins.
deleteFlowResponse_status :: Lens.Lens' DeleteFlowResponse (Prelude.Maybe Status)
deleteFlowResponse_status :: (Maybe Status -> f (Maybe Status))
-> DeleteFlowResponse -> f DeleteFlowResponse
deleteFlowResponse_status = (DeleteFlowResponse -> Maybe Status)
-> (DeleteFlowResponse -> Maybe Status -> DeleteFlowResponse)
-> Lens
     DeleteFlowResponse DeleteFlowResponse (Maybe Status) (Maybe 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 ARN of the flow that was deleted.
deleteFlowResponse_flowArn :: Lens.Lens' DeleteFlowResponse (Prelude.Maybe Prelude.Text)
deleteFlowResponse_flowArn :: (Maybe Text -> f (Maybe Text))
-> DeleteFlowResponse -> f DeleteFlowResponse
deleteFlowResponse_flowArn = (DeleteFlowResponse -> Maybe Text)
-> (DeleteFlowResponse -> Maybe Text -> DeleteFlowResponse)
-> Lens
     DeleteFlowResponse DeleteFlowResponse (Maybe Text) (Maybe Text)
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 response's http status code.
deleteFlowResponse_httpStatus :: Lens.Lens' DeleteFlowResponse Prelude.Int
deleteFlowResponse_httpStatus :: (Int -> f Int) -> DeleteFlowResponse -> f DeleteFlowResponse
deleteFlowResponse_httpStatus = (DeleteFlowResponse -> Int)
-> (DeleteFlowResponse -> Int -> DeleteFlowResponse)
-> Lens DeleteFlowResponse DeleteFlowResponse Int Int
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