{-# 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.RemoveFlowOutput
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes an output from an existing flow. This request can be made only
-- on an output that does not have an entitlement associated with it. If
-- the output has an entitlement, you must revoke the entitlement instead.
-- When an entitlement is revoked from a flow, the service automatically
-- removes the associated output.
module Amazonka.MediaConnect.RemoveFlowOutput
  ( -- * Creating a Request
    RemoveFlowOutput (..),
    newRemoveFlowOutput,

    -- * Request Lenses
    removeFlowOutput_flowArn,
    removeFlowOutput_outputArn,

    -- * Destructuring the Response
    RemoveFlowOutputResponse (..),
    newRemoveFlowOutputResponse,

    -- * Response Lenses
    removeFlowOutputResponse_flowArn,
    removeFlowOutputResponse_outputArn,
    removeFlowOutputResponse_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:/ 'newRemoveFlowOutput' smart constructor.
data RemoveFlowOutput = RemoveFlowOutput'
  { -- | The flow that you want to remove an output from.
    RemoveFlowOutput -> Text
flowArn :: Prelude.Text,
    -- | The ARN of the output that you want to remove.
    RemoveFlowOutput -> Text
outputArn :: Prelude.Text
  }
  deriving (RemoveFlowOutput -> RemoveFlowOutput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveFlowOutput -> RemoveFlowOutput -> Bool
$c/= :: RemoveFlowOutput -> RemoveFlowOutput -> Bool
== :: RemoveFlowOutput -> RemoveFlowOutput -> Bool
$c== :: RemoveFlowOutput -> RemoveFlowOutput -> Bool
Prelude.Eq, ReadPrec [RemoveFlowOutput]
ReadPrec RemoveFlowOutput
Int -> ReadS RemoveFlowOutput
ReadS [RemoveFlowOutput]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveFlowOutput]
$creadListPrec :: ReadPrec [RemoveFlowOutput]
readPrec :: ReadPrec RemoveFlowOutput
$creadPrec :: ReadPrec RemoveFlowOutput
readList :: ReadS [RemoveFlowOutput]
$creadList :: ReadS [RemoveFlowOutput]
readsPrec :: Int -> ReadS RemoveFlowOutput
$creadsPrec :: Int -> ReadS RemoveFlowOutput
Prelude.Read, Int -> RemoveFlowOutput -> ShowS
[RemoveFlowOutput] -> ShowS
RemoveFlowOutput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveFlowOutput] -> ShowS
$cshowList :: [RemoveFlowOutput] -> ShowS
show :: RemoveFlowOutput -> String
$cshow :: RemoveFlowOutput -> String
showsPrec :: Int -> RemoveFlowOutput -> ShowS
$cshowsPrec :: Int -> RemoveFlowOutput -> ShowS
Prelude.Show, forall x. Rep RemoveFlowOutput x -> RemoveFlowOutput
forall x. RemoveFlowOutput -> Rep RemoveFlowOutput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoveFlowOutput x -> RemoveFlowOutput
$cfrom :: forall x. RemoveFlowOutput -> Rep RemoveFlowOutput x
Prelude.Generic)

-- |
-- Create a value of 'RemoveFlowOutput' 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', 'removeFlowOutput_flowArn' - The flow that you want to remove an output from.
--
-- 'outputArn', 'removeFlowOutput_outputArn' - The ARN of the output that you want to remove.
newRemoveFlowOutput ::
  -- | 'flowArn'
  Prelude.Text ->
  -- | 'outputArn'
  Prelude.Text ->
  RemoveFlowOutput
newRemoveFlowOutput :: Text -> Text -> RemoveFlowOutput
newRemoveFlowOutput Text
pFlowArn_ Text
pOutputArn_ =
  RemoveFlowOutput'
    { $sel:flowArn:RemoveFlowOutput' :: Text
flowArn = Text
pFlowArn_,
      $sel:outputArn:RemoveFlowOutput' :: Text
outputArn = Text
pOutputArn_
    }

-- | The flow that you want to remove an output from.
removeFlowOutput_flowArn :: Lens.Lens' RemoveFlowOutput Prelude.Text
removeFlowOutput_flowArn :: Lens' RemoveFlowOutput Text
removeFlowOutput_flowArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveFlowOutput' {Text
flowArn :: Text
$sel:flowArn:RemoveFlowOutput' :: RemoveFlowOutput -> Text
flowArn} -> Text
flowArn) (\s :: RemoveFlowOutput
s@RemoveFlowOutput' {} Text
a -> RemoveFlowOutput
s {$sel:flowArn:RemoveFlowOutput' :: Text
flowArn = Text
a} :: RemoveFlowOutput)

-- | The ARN of the output that you want to remove.
removeFlowOutput_outputArn :: Lens.Lens' RemoveFlowOutput Prelude.Text
removeFlowOutput_outputArn :: Lens' RemoveFlowOutput Text
removeFlowOutput_outputArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveFlowOutput' {Text
outputArn :: Text
$sel:outputArn:RemoveFlowOutput' :: RemoveFlowOutput -> Text
outputArn} -> Text
outputArn) (\s :: RemoveFlowOutput
s@RemoveFlowOutput' {} Text
a -> RemoveFlowOutput
s {$sel:outputArn:RemoveFlowOutput' :: Text
outputArn = Text
a} :: RemoveFlowOutput)

instance Core.AWSRequest RemoveFlowOutput where
  type
    AWSResponse RemoveFlowOutput =
      RemoveFlowOutputResponse
  request :: (Service -> Service)
-> RemoveFlowOutput -> Request RemoveFlowOutput
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 RemoveFlowOutput
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RemoveFlowOutput)))
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 Text -> Int -> RemoveFlowOutputResponse
RemoveFlowOutputResponse'
            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
"outputArn")
            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 RemoveFlowOutput where
  hashWithSalt :: Int -> RemoveFlowOutput -> Int
hashWithSalt Int
_salt RemoveFlowOutput' {Text
outputArn :: Text
flowArn :: Text
$sel:outputArn:RemoveFlowOutput' :: RemoveFlowOutput -> Text
$sel:flowArn:RemoveFlowOutput' :: RemoveFlowOutput -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
flowArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
outputArn

instance Prelude.NFData RemoveFlowOutput where
  rnf :: RemoveFlowOutput -> ()
rnf RemoveFlowOutput' {Text
outputArn :: Text
flowArn :: Text
$sel:outputArn:RemoveFlowOutput' :: RemoveFlowOutput -> Text
$sel:flowArn:RemoveFlowOutput' :: RemoveFlowOutput -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
flowArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
outputArn

instance Data.ToHeaders RemoveFlowOutput where
  toHeaders :: RemoveFlowOutput -> 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 RemoveFlowOutput where
  toPath :: RemoveFlowOutput -> ByteString
toPath RemoveFlowOutput' {Text
outputArn :: Text
flowArn :: Text
$sel:outputArn:RemoveFlowOutput' :: RemoveFlowOutput -> Text
$sel:flowArn:RemoveFlowOutput' :: RemoveFlowOutput -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/flows/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
flowArn,
        ByteString
"/outputs/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
outputArn
      ]

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

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

-- |
-- Create a value of 'RemoveFlowOutputResponse' 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', 'removeFlowOutputResponse_flowArn' - The ARN of the flow that is associated with the output you removed.
--
-- 'outputArn', 'removeFlowOutputResponse_outputArn' - The ARN of the output that was removed.
--
-- 'httpStatus', 'removeFlowOutputResponse_httpStatus' - The response's http status code.
newRemoveFlowOutputResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RemoveFlowOutputResponse
newRemoveFlowOutputResponse :: Int -> RemoveFlowOutputResponse
newRemoveFlowOutputResponse Int
pHttpStatus_ =
  RemoveFlowOutputResponse'
    { $sel:flowArn:RemoveFlowOutputResponse' :: Maybe Text
flowArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:outputArn:RemoveFlowOutputResponse' :: Maybe Text
outputArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RemoveFlowOutputResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the flow that is associated with the output you removed.
removeFlowOutputResponse_flowArn :: Lens.Lens' RemoveFlowOutputResponse (Prelude.Maybe Prelude.Text)
removeFlowOutputResponse_flowArn :: Lens' RemoveFlowOutputResponse (Maybe Text)
removeFlowOutputResponse_flowArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveFlowOutputResponse' {Maybe Text
flowArn :: Maybe Text
$sel:flowArn:RemoveFlowOutputResponse' :: RemoveFlowOutputResponse -> Maybe Text
flowArn} -> Maybe Text
flowArn) (\s :: RemoveFlowOutputResponse
s@RemoveFlowOutputResponse' {} Maybe Text
a -> RemoveFlowOutputResponse
s {$sel:flowArn:RemoveFlowOutputResponse' :: Maybe Text
flowArn = Maybe Text
a} :: RemoveFlowOutputResponse)

-- | The ARN of the output that was removed.
removeFlowOutputResponse_outputArn :: Lens.Lens' RemoveFlowOutputResponse (Prelude.Maybe Prelude.Text)
removeFlowOutputResponse_outputArn :: Lens' RemoveFlowOutputResponse (Maybe Text)
removeFlowOutputResponse_outputArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveFlowOutputResponse' {Maybe Text
outputArn :: Maybe Text
$sel:outputArn:RemoveFlowOutputResponse' :: RemoveFlowOutputResponse -> Maybe Text
outputArn} -> Maybe Text
outputArn) (\s :: RemoveFlowOutputResponse
s@RemoveFlowOutputResponse' {} Maybe Text
a -> RemoveFlowOutputResponse
s {$sel:outputArn:RemoveFlowOutputResponse' :: Maybe Text
outputArn = Maybe Text
a} :: RemoveFlowOutputResponse)

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

instance Prelude.NFData RemoveFlowOutputResponse where
  rnf :: RemoveFlowOutputResponse -> ()
rnf RemoveFlowOutputResponse' {Int
Maybe Text
httpStatus :: Int
outputArn :: Maybe Text
flowArn :: Maybe Text
$sel:httpStatus:RemoveFlowOutputResponse' :: RemoveFlowOutputResponse -> Int
$sel:outputArn:RemoveFlowOutputResponse' :: RemoveFlowOutputResponse -> Maybe Text
$sel:flowArn:RemoveFlowOutputResponse' :: RemoveFlowOutputResponse -> 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 Text
outputArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus