{-# 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.AddFlowOutputs
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Adds outputs to an existing flow. You can create up to 50 outputs per
-- flow.
module Amazonka.MediaConnect.AddFlowOutputs
  ( -- * Creating a Request
    AddFlowOutputs (..),
    newAddFlowOutputs,

    -- * Request Lenses
    addFlowOutputs_flowArn,
    addFlowOutputs_outputs,

    -- * Destructuring the Response
    AddFlowOutputsResponse (..),
    newAddFlowOutputsResponse,

    -- * Response Lenses
    addFlowOutputsResponse_flowArn,
    addFlowOutputsResponse_outputs,
    addFlowOutputsResponse_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

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

-- |
-- Create a value of 'AddFlowOutputs' 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', 'addFlowOutputs_flowArn' - The flow that you want to add outputs to.
--
-- 'outputs', 'addFlowOutputs_outputs' - A list of outputs that you want to add.
newAddFlowOutputs ::
  -- | 'flowArn'
  Prelude.Text ->
  AddFlowOutputs
newAddFlowOutputs :: Text -> AddFlowOutputs
newAddFlowOutputs Text
pFlowArn_ =
  AddFlowOutputs'
    { $sel:flowArn:AddFlowOutputs' :: Text
flowArn = Text
pFlowArn_,
      $sel:outputs:AddFlowOutputs' :: [AddOutputRequest]
outputs = forall a. Monoid a => a
Prelude.mempty
    }

-- | The flow that you want to add outputs to.
addFlowOutputs_flowArn :: Lens.Lens' AddFlowOutputs Prelude.Text
addFlowOutputs_flowArn :: Lens' AddFlowOutputs Text
addFlowOutputs_flowArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddFlowOutputs' {Text
flowArn :: Text
$sel:flowArn:AddFlowOutputs' :: AddFlowOutputs -> Text
flowArn} -> Text
flowArn) (\s :: AddFlowOutputs
s@AddFlowOutputs' {} Text
a -> AddFlowOutputs
s {$sel:flowArn:AddFlowOutputs' :: Text
flowArn = Text
a} :: AddFlowOutputs)

-- | A list of outputs that you want to add.
addFlowOutputs_outputs :: Lens.Lens' AddFlowOutputs [AddOutputRequest]
addFlowOutputs_outputs :: Lens' AddFlowOutputs [AddOutputRequest]
addFlowOutputs_outputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddFlowOutputs' {[AddOutputRequest]
outputs :: [AddOutputRequest]
$sel:outputs:AddFlowOutputs' :: AddFlowOutputs -> [AddOutputRequest]
outputs} -> [AddOutputRequest]
outputs) (\s :: AddFlowOutputs
s@AddFlowOutputs' {} [AddOutputRequest]
a -> AddFlowOutputs
s {$sel:outputs:AddFlowOutputs' :: [AddOutputRequest]
outputs = [AddOutputRequest]
a} :: AddFlowOutputs) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest AddFlowOutputs where
  type
    AWSResponse AddFlowOutputs =
      AddFlowOutputsResponse
  request :: (Service -> Service) -> AddFlowOutputs -> Request AddFlowOutputs
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AddFlowOutputs
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AddFlowOutputs)))
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 [Output] -> Int -> AddFlowOutputsResponse
AddFlowOutputsResponse'
            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
"outputs" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 AddFlowOutputs where
  hashWithSalt :: Int -> AddFlowOutputs -> Int
hashWithSalt Int
_salt AddFlowOutputs' {[AddOutputRequest]
Text
outputs :: [AddOutputRequest]
flowArn :: Text
$sel:outputs:AddFlowOutputs' :: AddFlowOutputs -> [AddOutputRequest]
$sel:flowArn:AddFlowOutputs' :: AddFlowOutputs -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
flowArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [AddOutputRequest]
outputs

instance Prelude.NFData AddFlowOutputs where
  rnf :: AddFlowOutputs -> ()
rnf AddFlowOutputs' {[AddOutputRequest]
Text
outputs :: [AddOutputRequest]
flowArn :: Text
$sel:outputs:AddFlowOutputs' :: AddFlowOutputs -> [AddOutputRequest]
$sel:flowArn:AddFlowOutputs' :: AddFlowOutputs -> 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 [AddOutputRequest]
outputs

instance Data.ToHeaders AddFlowOutputs where
  toHeaders :: AddFlowOutputs -> 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.ToJSON AddFlowOutputs where
  toJSON :: AddFlowOutputs -> Value
toJSON AddFlowOutputs' {[AddOutputRequest]
Text
outputs :: [AddOutputRequest]
flowArn :: Text
$sel:outputs:AddFlowOutputs' :: AddFlowOutputs -> [AddOutputRequest]
$sel:flowArn:AddFlowOutputs' :: AddFlowOutputs -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"outputs" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [AddOutputRequest]
outputs)]
      )

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

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

-- | /See:/ 'newAddFlowOutputsResponse' smart constructor.
data AddFlowOutputsResponse = AddFlowOutputsResponse'
  { -- | The ARN of the flow that these outputs were added to.
    AddFlowOutputsResponse -> Maybe Text
flowArn :: Prelude.Maybe Prelude.Text,
    -- | The details of the newly added outputs.
    AddFlowOutputsResponse -> Maybe [Output]
outputs :: Prelude.Maybe [Output],
    -- | The response's http status code.
    AddFlowOutputsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AddFlowOutputsResponse -> AddFlowOutputsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddFlowOutputsResponse -> AddFlowOutputsResponse -> Bool
$c/= :: AddFlowOutputsResponse -> AddFlowOutputsResponse -> Bool
== :: AddFlowOutputsResponse -> AddFlowOutputsResponse -> Bool
$c== :: AddFlowOutputsResponse -> AddFlowOutputsResponse -> Bool
Prelude.Eq, ReadPrec [AddFlowOutputsResponse]
ReadPrec AddFlowOutputsResponse
Int -> ReadS AddFlowOutputsResponse
ReadS [AddFlowOutputsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddFlowOutputsResponse]
$creadListPrec :: ReadPrec [AddFlowOutputsResponse]
readPrec :: ReadPrec AddFlowOutputsResponse
$creadPrec :: ReadPrec AddFlowOutputsResponse
readList :: ReadS [AddFlowOutputsResponse]
$creadList :: ReadS [AddFlowOutputsResponse]
readsPrec :: Int -> ReadS AddFlowOutputsResponse
$creadsPrec :: Int -> ReadS AddFlowOutputsResponse
Prelude.Read, Int -> AddFlowOutputsResponse -> ShowS
[AddFlowOutputsResponse] -> ShowS
AddFlowOutputsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddFlowOutputsResponse] -> ShowS
$cshowList :: [AddFlowOutputsResponse] -> ShowS
show :: AddFlowOutputsResponse -> String
$cshow :: AddFlowOutputsResponse -> String
showsPrec :: Int -> AddFlowOutputsResponse -> ShowS
$cshowsPrec :: Int -> AddFlowOutputsResponse -> ShowS
Prelude.Show, forall x. Rep AddFlowOutputsResponse x -> AddFlowOutputsResponse
forall x. AddFlowOutputsResponse -> Rep AddFlowOutputsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddFlowOutputsResponse x -> AddFlowOutputsResponse
$cfrom :: forall x. AddFlowOutputsResponse -> Rep AddFlowOutputsResponse x
Prelude.Generic)

-- |
-- Create a value of 'AddFlowOutputsResponse' 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', 'addFlowOutputsResponse_flowArn' - The ARN of the flow that these outputs were added to.
--
-- 'outputs', 'addFlowOutputsResponse_outputs' - The details of the newly added outputs.
--
-- 'httpStatus', 'addFlowOutputsResponse_httpStatus' - The response's http status code.
newAddFlowOutputsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AddFlowOutputsResponse
newAddFlowOutputsResponse :: Int -> AddFlowOutputsResponse
newAddFlowOutputsResponse Int
pHttpStatus_ =
  AddFlowOutputsResponse'
    { $sel:flowArn:AddFlowOutputsResponse' :: Maybe Text
flowArn = forall a. Maybe a
Prelude.Nothing,
      $sel:outputs:AddFlowOutputsResponse' :: Maybe [Output]
outputs = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AddFlowOutputsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the flow that these outputs were added to.
addFlowOutputsResponse_flowArn :: Lens.Lens' AddFlowOutputsResponse (Prelude.Maybe Prelude.Text)
addFlowOutputsResponse_flowArn :: Lens' AddFlowOutputsResponse (Maybe Text)
addFlowOutputsResponse_flowArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddFlowOutputsResponse' {Maybe Text
flowArn :: Maybe Text
$sel:flowArn:AddFlowOutputsResponse' :: AddFlowOutputsResponse -> Maybe Text
flowArn} -> Maybe Text
flowArn) (\s :: AddFlowOutputsResponse
s@AddFlowOutputsResponse' {} Maybe Text
a -> AddFlowOutputsResponse
s {$sel:flowArn:AddFlowOutputsResponse' :: Maybe Text
flowArn = Maybe Text
a} :: AddFlowOutputsResponse)

-- | The details of the newly added outputs.
addFlowOutputsResponse_outputs :: Lens.Lens' AddFlowOutputsResponse (Prelude.Maybe [Output])
addFlowOutputsResponse_outputs :: Lens' AddFlowOutputsResponse (Maybe [Output])
addFlowOutputsResponse_outputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddFlowOutputsResponse' {Maybe [Output]
outputs :: Maybe [Output]
$sel:outputs:AddFlowOutputsResponse' :: AddFlowOutputsResponse -> Maybe [Output]
outputs} -> Maybe [Output]
outputs) (\s :: AddFlowOutputsResponse
s@AddFlowOutputsResponse' {} Maybe [Output]
a -> AddFlowOutputsResponse
s {$sel:outputs:AddFlowOutputsResponse' :: Maybe [Output]
outputs = Maybe [Output]
a} :: AddFlowOutputsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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