{-# 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.UpdateFlow
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates flow
module Amazonka.MediaConnect.UpdateFlow
  ( -- * Creating a Request
    UpdateFlow (..),
    newUpdateFlow,

    -- * Request Lenses
    updateFlow_maintenance,
    updateFlow_sourceFailoverConfig,
    updateFlow_flowArn,

    -- * Destructuring the Response
    UpdateFlowResponse (..),
    newUpdateFlowResponse,

    -- * Response Lenses
    updateFlowResponse_flow,
    updateFlowResponse_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 update flow.
--
-- /See:/ 'newUpdateFlow' smart constructor.
data UpdateFlow = UpdateFlow'
  { UpdateFlow -> Maybe UpdateMaintenance
maintenance :: Prelude.Maybe UpdateMaintenance,
    UpdateFlow -> Maybe UpdateFailoverConfig
sourceFailoverConfig :: Prelude.Maybe UpdateFailoverConfig,
    -- | The flow that you want to update.
    UpdateFlow -> Text
flowArn :: Prelude.Text
  }
  deriving (UpdateFlow -> UpdateFlow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateFlow -> UpdateFlow -> Bool
$c/= :: UpdateFlow -> UpdateFlow -> Bool
== :: UpdateFlow -> UpdateFlow -> Bool
$c== :: UpdateFlow -> UpdateFlow -> Bool
Prelude.Eq, ReadPrec [UpdateFlow]
ReadPrec UpdateFlow
Int -> ReadS UpdateFlow
ReadS [UpdateFlow]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateFlow]
$creadListPrec :: ReadPrec [UpdateFlow]
readPrec :: ReadPrec UpdateFlow
$creadPrec :: ReadPrec UpdateFlow
readList :: ReadS [UpdateFlow]
$creadList :: ReadS [UpdateFlow]
readsPrec :: Int -> ReadS UpdateFlow
$creadsPrec :: Int -> ReadS UpdateFlow
Prelude.Read, Int -> UpdateFlow -> ShowS
[UpdateFlow] -> ShowS
UpdateFlow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateFlow] -> ShowS
$cshowList :: [UpdateFlow] -> ShowS
show :: UpdateFlow -> String
$cshow :: UpdateFlow -> String
showsPrec :: Int -> UpdateFlow -> ShowS
$cshowsPrec :: Int -> UpdateFlow -> ShowS
Prelude.Show, forall x. Rep UpdateFlow x -> UpdateFlow
forall x. UpdateFlow -> Rep UpdateFlow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateFlow x -> UpdateFlow
$cfrom :: forall x. UpdateFlow -> Rep UpdateFlow x
Prelude.Generic)

-- |
-- Create a value of 'UpdateFlow' 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:
--
-- 'maintenance', 'updateFlow_maintenance' - Undocumented member.
--
-- 'sourceFailoverConfig', 'updateFlow_sourceFailoverConfig' - Undocumented member.
--
-- 'flowArn', 'updateFlow_flowArn' - The flow that you want to update.
newUpdateFlow ::
  -- | 'flowArn'
  Prelude.Text ->
  UpdateFlow
newUpdateFlow :: Text -> UpdateFlow
newUpdateFlow Text
pFlowArn_ =
  UpdateFlow'
    { $sel:maintenance:UpdateFlow' :: Maybe UpdateMaintenance
maintenance = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceFailoverConfig:UpdateFlow' :: Maybe UpdateFailoverConfig
sourceFailoverConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:flowArn:UpdateFlow' :: Text
flowArn = Text
pFlowArn_
    }

-- | Undocumented member.
updateFlow_maintenance :: Lens.Lens' UpdateFlow (Prelude.Maybe UpdateMaintenance)
updateFlow_maintenance :: Lens' UpdateFlow (Maybe UpdateMaintenance)
updateFlow_maintenance = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFlow' {Maybe UpdateMaintenance
maintenance :: Maybe UpdateMaintenance
$sel:maintenance:UpdateFlow' :: UpdateFlow -> Maybe UpdateMaintenance
maintenance} -> Maybe UpdateMaintenance
maintenance) (\s :: UpdateFlow
s@UpdateFlow' {} Maybe UpdateMaintenance
a -> UpdateFlow
s {$sel:maintenance:UpdateFlow' :: Maybe UpdateMaintenance
maintenance = Maybe UpdateMaintenance
a} :: UpdateFlow)

-- | Undocumented member.
updateFlow_sourceFailoverConfig :: Lens.Lens' UpdateFlow (Prelude.Maybe UpdateFailoverConfig)
updateFlow_sourceFailoverConfig :: Lens' UpdateFlow (Maybe UpdateFailoverConfig)
updateFlow_sourceFailoverConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFlow' {Maybe UpdateFailoverConfig
sourceFailoverConfig :: Maybe UpdateFailoverConfig
$sel:sourceFailoverConfig:UpdateFlow' :: UpdateFlow -> Maybe UpdateFailoverConfig
sourceFailoverConfig} -> Maybe UpdateFailoverConfig
sourceFailoverConfig) (\s :: UpdateFlow
s@UpdateFlow' {} Maybe UpdateFailoverConfig
a -> UpdateFlow
s {$sel:sourceFailoverConfig:UpdateFlow' :: Maybe UpdateFailoverConfig
sourceFailoverConfig = Maybe UpdateFailoverConfig
a} :: UpdateFlow)

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

instance Core.AWSRequest UpdateFlow where
  type AWSResponse UpdateFlow = UpdateFlowResponse
  request :: (Service -> Service) -> UpdateFlow -> Request UpdateFlow
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateFlow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateFlow)))
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 Flow -> Int -> UpdateFlowResponse
UpdateFlowResponse'
            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
"flow")
            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 UpdateFlow where
  hashWithSalt :: Int -> UpdateFlow -> Int
hashWithSalt Int
_salt UpdateFlow' {Maybe UpdateFailoverConfig
Maybe UpdateMaintenance
Text
flowArn :: Text
sourceFailoverConfig :: Maybe UpdateFailoverConfig
maintenance :: Maybe UpdateMaintenance
$sel:flowArn:UpdateFlow' :: UpdateFlow -> Text
$sel:sourceFailoverConfig:UpdateFlow' :: UpdateFlow -> Maybe UpdateFailoverConfig
$sel:maintenance:UpdateFlow' :: UpdateFlow -> Maybe UpdateMaintenance
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpdateMaintenance
maintenance
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpdateFailoverConfig
sourceFailoverConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
flowArn

instance Prelude.NFData UpdateFlow where
  rnf :: UpdateFlow -> ()
rnf UpdateFlow' {Maybe UpdateFailoverConfig
Maybe UpdateMaintenance
Text
flowArn :: Text
sourceFailoverConfig :: Maybe UpdateFailoverConfig
maintenance :: Maybe UpdateMaintenance
$sel:flowArn:UpdateFlow' :: UpdateFlow -> Text
$sel:sourceFailoverConfig:UpdateFlow' :: UpdateFlow -> Maybe UpdateFailoverConfig
$sel:maintenance:UpdateFlow' :: UpdateFlow -> Maybe UpdateMaintenance
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe UpdateMaintenance
maintenance
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UpdateFailoverConfig
sourceFailoverConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
flowArn

instance Data.ToHeaders UpdateFlow where
  toHeaders :: UpdateFlow -> 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 UpdateFlow where
  toJSON :: UpdateFlow -> Value
toJSON UpdateFlow' {Maybe UpdateFailoverConfig
Maybe UpdateMaintenance
Text
flowArn :: Text
sourceFailoverConfig :: Maybe UpdateFailoverConfig
maintenance :: Maybe UpdateMaintenance
$sel:flowArn:UpdateFlow' :: UpdateFlow -> Text
$sel:sourceFailoverConfig:UpdateFlow' :: UpdateFlow -> Maybe UpdateFailoverConfig
$sel:maintenance:UpdateFlow' :: UpdateFlow -> Maybe UpdateMaintenance
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maintenance" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateMaintenance
maintenance,
            (Key
"sourceFailoverConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateFailoverConfig
sourceFailoverConfig
          ]
      )

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

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

-- | /See:/ 'newUpdateFlowResponse' smart constructor.
data UpdateFlowResponse = UpdateFlowResponse'
  { UpdateFlowResponse -> Maybe Flow
flow :: Prelude.Maybe Flow,
    -- | The response's http status code.
    UpdateFlowResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateFlowResponse -> UpdateFlowResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateFlowResponse -> UpdateFlowResponse -> Bool
$c/= :: UpdateFlowResponse -> UpdateFlowResponse -> Bool
== :: UpdateFlowResponse -> UpdateFlowResponse -> Bool
$c== :: UpdateFlowResponse -> UpdateFlowResponse -> Bool
Prelude.Eq, ReadPrec [UpdateFlowResponse]
ReadPrec UpdateFlowResponse
Int -> ReadS UpdateFlowResponse
ReadS [UpdateFlowResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateFlowResponse]
$creadListPrec :: ReadPrec [UpdateFlowResponse]
readPrec :: ReadPrec UpdateFlowResponse
$creadPrec :: ReadPrec UpdateFlowResponse
readList :: ReadS [UpdateFlowResponse]
$creadList :: ReadS [UpdateFlowResponse]
readsPrec :: Int -> ReadS UpdateFlowResponse
$creadsPrec :: Int -> ReadS UpdateFlowResponse
Prelude.Read, Int -> UpdateFlowResponse -> ShowS
[UpdateFlowResponse] -> ShowS
UpdateFlowResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateFlowResponse] -> ShowS
$cshowList :: [UpdateFlowResponse] -> ShowS
show :: UpdateFlowResponse -> String
$cshow :: UpdateFlowResponse -> String
showsPrec :: Int -> UpdateFlowResponse -> ShowS
$cshowsPrec :: Int -> UpdateFlowResponse -> ShowS
Prelude.Show, forall x. Rep UpdateFlowResponse x -> UpdateFlowResponse
forall x. UpdateFlowResponse -> Rep UpdateFlowResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateFlowResponse x -> UpdateFlowResponse
$cfrom :: forall x. UpdateFlowResponse -> Rep UpdateFlowResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateFlowResponse' 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:
--
-- 'flow', 'updateFlowResponse_flow' - Undocumented member.
--
-- 'httpStatus', 'updateFlowResponse_httpStatus' - The response's http status code.
newUpdateFlowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateFlowResponse
newUpdateFlowResponse :: Int -> UpdateFlowResponse
newUpdateFlowResponse Int
pHttpStatus_ =
  UpdateFlowResponse'
    { $sel:flow:UpdateFlowResponse' :: Maybe Flow
flow = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateFlowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
updateFlowResponse_flow :: Lens.Lens' UpdateFlowResponse (Prelude.Maybe Flow)
updateFlowResponse_flow :: Lens' UpdateFlowResponse (Maybe Flow)
updateFlowResponse_flow = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateFlowResponse' {Maybe Flow
flow :: Maybe Flow
$sel:flow:UpdateFlowResponse' :: UpdateFlowResponse -> Maybe Flow
flow} -> Maybe Flow
flow) (\s :: UpdateFlowResponse
s@UpdateFlowResponse' {} Maybe Flow
a -> UpdateFlowResponse
s {$sel:flow:UpdateFlowResponse' :: Maybe Flow
flow = Maybe Flow
a} :: UpdateFlowResponse)

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

instance Prelude.NFData UpdateFlowResponse where
  rnf :: UpdateFlowResponse -> ()
rnf UpdateFlowResponse' {Int
Maybe Flow
httpStatus :: Int
flow :: Maybe Flow
$sel:httpStatus:UpdateFlowResponse' :: UpdateFlowResponse -> Int
$sel:flow:UpdateFlowResponse' :: UpdateFlowResponse -> Maybe Flow
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Flow
flow
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus