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

    -- * Request Lenses
    stopFlow_flowArn,

    -- * Destructuring the Response
    StopFlowResponse (..),
    newStopFlowResponse,

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

-- |
-- Create a value of 'StopFlow' 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', 'stopFlow_flowArn' - The ARN of the flow that you want to stop.
newStopFlow ::
  -- | 'flowArn'
  Prelude.Text ->
  StopFlow
newStopFlow :: Text -> StopFlow
newStopFlow Text
pFlowArn_ =
  StopFlow' {$sel:flowArn:StopFlow' :: Text
flowArn = Text
pFlowArn_}

-- | The ARN of the flow that you want to stop.
stopFlow_flowArn :: Lens.Lens' StopFlow Prelude.Text
stopFlow_flowArn :: Lens' StopFlow Text
stopFlow_flowArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopFlow' {Text
flowArn :: Text
$sel:flowArn:StopFlow' :: StopFlow -> Text
flowArn} -> Text
flowArn) (\s :: StopFlow
s@StopFlow' {} Text
a -> StopFlow
s {$sel:flowArn:StopFlow' :: Text
flowArn = Text
a} :: StopFlow)

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

instance Prelude.NFData StopFlow where
  rnf :: StopFlow -> ()
rnf StopFlow' {Text
flowArn :: Text
$sel:flowArn:StopFlow' :: StopFlow -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
flowArn

instance Data.ToHeaders StopFlow where
  toHeaders :: StopFlow -> 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 StopFlow where
  toJSON :: StopFlow -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

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

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

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

-- |
-- Create a value of 'StopFlowResponse' 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', 'stopFlowResponse_flowArn' - The ARN of the flow that you stopped.
--
-- 'status', 'stopFlowResponse_status' - The status of the flow when the StopFlow process begins.
--
-- 'httpStatus', 'stopFlowResponse_httpStatus' - The response's http status code.
newStopFlowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopFlowResponse
newStopFlowResponse :: Int -> StopFlowResponse
newStopFlowResponse Int
pHttpStatus_ =
  StopFlowResponse'
    { $sel:flowArn:StopFlowResponse' :: Maybe Text
flowArn = forall a. Maybe a
Prelude.Nothing,
      $sel:status:StopFlowResponse' :: Maybe Status
status = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopFlowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the flow that you stopped.
stopFlowResponse_flowArn :: Lens.Lens' StopFlowResponse (Prelude.Maybe Prelude.Text)
stopFlowResponse_flowArn :: Lens' StopFlowResponse (Maybe Text)
stopFlowResponse_flowArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopFlowResponse' {Maybe Text
flowArn :: Maybe Text
$sel:flowArn:StopFlowResponse' :: StopFlowResponse -> Maybe Text
flowArn} -> Maybe Text
flowArn) (\s :: StopFlowResponse
s@StopFlowResponse' {} Maybe Text
a -> StopFlowResponse
s {$sel:flowArn:StopFlowResponse' :: Maybe Text
flowArn = Maybe Text
a} :: StopFlowResponse)

-- | The status of the flow when the StopFlow process begins.
stopFlowResponse_status :: Lens.Lens' StopFlowResponse (Prelude.Maybe Status)
stopFlowResponse_status :: Lens' StopFlowResponse (Maybe Status)
stopFlowResponse_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopFlowResponse' {Maybe Status
status :: Maybe Status
$sel:status:StopFlowResponse' :: StopFlowResponse -> Maybe Status
status} -> Maybe Status
status) (\s :: StopFlowResponse
s@StopFlowResponse' {} Maybe Status
a -> StopFlowResponse
s {$sel:status:StopFlowResponse' :: Maybe Status
status = Maybe Status
a} :: StopFlowResponse)

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

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