{-# 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-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)
--
-- 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.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:/ '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
(RemoveFlowOutput -> RemoveFlowOutput -> Bool)
-> (RemoveFlowOutput -> RemoveFlowOutput -> Bool)
-> Eq RemoveFlowOutput
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]
(Int -> ReadS RemoveFlowOutput)
-> ReadS [RemoveFlowOutput]
-> ReadPrec RemoveFlowOutput
-> ReadPrec [RemoveFlowOutput]
-> Read 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
(Int -> RemoveFlowOutput -> ShowS)
-> (RemoveFlowOutput -> String)
-> ([RemoveFlowOutput] -> ShowS)
-> Show RemoveFlowOutput
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. RemoveFlowOutput -> Rep RemoveFlowOutput x)
-> (forall x. Rep RemoveFlowOutput x -> RemoveFlowOutput)
-> Generic RemoveFlowOutput
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' :: Text -> Text -> RemoveFlowOutput
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 :: (Text -> f Text) -> RemoveFlowOutput -> f RemoveFlowOutput
removeFlowOutput_flowArn = (RemoveFlowOutput -> Text)
-> (RemoveFlowOutput -> Text -> RemoveFlowOutput)
-> Lens RemoveFlowOutput RemoveFlowOutput Text Text
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 :: (Text -> f Text) -> RemoveFlowOutput -> f RemoveFlowOutput
removeFlowOutput_outputArn = (RemoveFlowOutput -> Text)
-> (RemoveFlowOutput -> Text -> RemoveFlowOutput)
-> Lens RemoveFlowOutput RemoveFlowOutput Text Text
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 :: RemoveFlowOutput -> Request RemoveFlowOutput
request = Service -> RemoveFlowOutput -> Request RemoveFlowOutput
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy RemoveFlowOutput
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RemoveFlowOutput)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RemoveFlowOutput))
-> Logger
-> Service
-> Proxy RemoveFlowOutput
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RemoveFlowOutput)))
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 -> Maybe Text -> Int -> RemoveFlowOutputResponse
RemoveFlowOutputResponse'
            (Maybe Text -> Maybe Text -> Int -> RemoveFlowOutputResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> RemoveFlowOutputResponse)
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
"flowArn")
            Either String (Maybe Text -> Int -> RemoveFlowOutputResponse)
-> Either String (Maybe Text)
-> Either String (Int -> RemoveFlowOutputResponse)
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
"outputArn")
            Either String (Int -> RemoveFlowOutputResponse)
-> Either String Int -> Either String RemoveFlowOutputResponse
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 RemoveFlowOutput

instance Prelude.NFData RemoveFlowOutput

instance Core.ToHeaders RemoveFlowOutput where
  toHeaders :: RemoveFlowOutput -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RemoveFlowOutput -> 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 RemoveFlowOutput where
  toPath :: RemoveFlowOutput -> ByteString
toPath RemoveFlowOutput' {Text
outputArn :: Text
flowArn :: Text
$sel:outputArn:RemoveFlowOutput' :: RemoveFlowOutput -> Text
$sel:flowArn:RemoveFlowOutput' :: RemoveFlowOutput -> 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,
        ByteString
"/outputs/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
outputArn
      ]

instance Core.ToQuery RemoveFlowOutput where
  toQuery :: RemoveFlowOutput -> QueryString
toQuery = QueryString -> RemoveFlowOutput -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(RemoveFlowOutputResponse -> RemoveFlowOutputResponse -> Bool)
-> (RemoveFlowOutputResponse -> RemoveFlowOutputResponse -> Bool)
-> Eq RemoveFlowOutputResponse
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]
(Int -> ReadS RemoveFlowOutputResponse)
-> ReadS [RemoveFlowOutputResponse]
-> ReadPrec RemoveFlowOutputResponse
-> ReadPrec [RemoveFlowOutputResponse]
-> Read 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
(Int -> RemoveFlowOutputResponse -> ShowS)
-> (RemoveFlowOutputResponse -> String)
-> ([RemoveFlowOutputResponse] -> ShowS)
-> Show RemoveFlowOutputResponse
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.
 RemoveFlowOutputResponse -> Rep RemoveFlowOutputResponse x)
-> (forall x.
    Rep RemoveFlowOutputResponse x -> RemoveFlowOutputResponse)
-> Generic RemoveFlowOutputResponse
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' :: Maybe Text -> Maybe Text -> Int -> RemoveFlowOutputResponse
RemoveFlowOutputResponse'
    { $sel:flowArn:RemoveFlowOutputResponse' :: Maybe Text
flowArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:outputArn:RemoveFlowOutputResponse' :: Maybe Text
outputArn = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> RemoveFlowOutputResponse -> f RemoveFlowOutputResponse
removeFlowOutputResponse_flowArn = (RemoveFlowOutputResponse -> Maybe Text)
-> (RemoveFlowOutputResponse
    -> Maybe Text -> RemoveFlowOutputResponse)
-> Lens
     RemoveFlowOutputResponse
     RemoveFlowOutputResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> RemoveFlowOutputResponse -> f RemoveFlowOutputResponse
removeFlowOutputResponse_outputArn = (RemoveFlowOutputResponse -> Maybe Text)
-> (RemoveFlowOutputResponse
    -> Maybe Text -> RemoveFlowOutputResponse)
-> Lens
     RemoveFlowOutputResponse
     RemoveFlowOutputResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> RemoveFlowOutputResponse -> f RemoveFlowOutputResponse
removeFlowOutputResponse_httpStatus = (RemoveFlowOutputResponse -> Int)
-> (RemoveFlowOutputResponse -> Int -> RemoveFlowOutputResponse)
-> Lens RemoveFlowOutputResponse RemoveFlowOutputResponse Int Int
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