{-# 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-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)
--
-- Stops a flow.
module Amazonka.MediaConnect.StopFlow
  ( -- * Creating a Request
    StopFlow (..),
    newStopFlow,

    -- * Request Lenses
    stopFlow_flowArn,

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

    -- * Response Lenses
    stopFlowResponse_status,
    stopFlowResponse_flowArn,
    stopFlowResponse_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:/ '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
(StopFlow -> StopFlow -> Bool)
-> (StopFlow -> StopFlow -> Bool) -> Eq StopFlow
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]
(Int -> ReadS StopFlow)
-> ReadS [StopFlow]
-> ReadPrec StopFlow
-> ReadPrec [StopFlow]
-> Read 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
(Int -> StopFlow -> ShowS)
-> (StopFlow -> String) -> ([StopFlow] -> ShowS) -> Show StopFlow
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. StopFlow -> Rep StopFlow x)
-> (forall x. Rep StopFlow x -> StopFlow) -> Generic StopFlow
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' :: Text -> StopFlow
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 :: (Text -> f Text) -> StopFlow -> f StopFlow
stopFlow_flowArn = (StopFlow -> Text)
-> (StopFlow -> Text -> StopFlow)
-> Lens StopFlow StopFlow Text Text
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 :: StopFlow -> Request StopFlow
request = Service -> StopFlow -> Request StopFlow
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopFlow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopFlow)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StopFlow))
-> Logger
-> Service
-> Proxy StopFlow
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopFlow)))
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 Status -> Maybe Text -> Int -> StopFlowResponse
StopFlowResponse'
            (Maybe Status -> Maybe Text -> Int -> StopFlowResponse)
-> Either String (Maybe Status)
-> Either String (Maybe Text -> Int -> StopFlowResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Status)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"status")
            Either String (Maybe Text -> Int -> StopFlowResponse)
-> Either String (Maybe Text)
-> Either String (Int -> StopFlowResponse)
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
"flowArn")
            Either String (Int -> StopFlowResponse)
-> Either String Int -> Either String StopFlowResponse
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 StopFlow

instance Prelude.NFData StopFlow

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

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

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

-- | /See:/ 'newStopFlowResponse' smart constructor.
data StopFlowResponse = StopFlowResponse'
  { -- | The status of the flow when the StopFlow process begins.
    StopFlowResponse -> Maybe Status
status :: Prelude.Maybe Status,
    -- | The ARN of the flow that you stopped.
    StopFlowResponse -> Maybe Text
flowArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StopFlowResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StopFlowResponse -> StopFlowResponse -> Bool
(StopFlowResponse -> StopFlowResponse -> Bool)
-> (StopFlowResponse -> StopFlowResponse -> Bool)
-> Eq StopFlowResponse
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]
(Int -> ReadS StopFlowResponse)
-> ReadS [StopFlowResponse]
-> ReadPrec StopFlowResponse
-> ReadPrec [StopFlowResponse]
-> Read 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
(Int -> StopFlowResponse -> ShowS)
-> (StopFlowResponse -> String)
-> ([StopFlowResponse] -> ShowS)
-> Show StopFlowResponse
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. StopFlowResponse -> Rep StopFlowResponse x)
-> (forall x. Rep StopFlowResponse x -> StopFlowResponse)
-> Generic StopFlowResponse
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:
--
-- 'status', 'stopFlowResponse_status' - The status of the flow when the StopFlow process begins.
--
-- 'flowArn', 'stopFlowResponse_flowArn' - The ARN of the flow that you stopped.
--
-- 'httpStatus', 'stopFlowResponse_httpStatus' - The response's http status code.
newStopFlowResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopFlowResponse
newStopFlowResponse :: Int -> StopFlowResponse
newStopFlowResponse Int
pHttpStatus_ =
  StopFlowResponse' :: Maybe Status -> Maybe Text -> Int -> StopFlowResponse
StopFlowResponse'
    { $sel:status:StopFlowResponse' :: Maybe Status
status = Maybe Status
forall a. Maybe a
Prelude.Nothing,
      $sel:flowArn:StopFlowResponse' :: Maybe Text
flowArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopFlowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the flow when the StopFlow process begins.
stopFlowResponse_status :: Lens.Lens' StopFlowResponse (Prelude.Maybe Status)
stopFlowResponse_status :: (Maybe Status -> f (Maybe Status))
-> StopFlowResponse -> f StopFlowResponse
stopFlowResponse_status = (StopFlowResponse -> Maybe Status)
-> (StopFlowResponse -> Maybe Status -> StopFlowResponse)
-> Lens
     StopFlowResponse StopFlowResponse (Maybe Status) (Maybe 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 ARN of the flow that you stopped.
stopFlowResponse_flowArn :: Lens.Lens' StopFlowResponse (Prelude.Maybe Prelude.Text)
stopFlowResponse_flowArn :: (Maybe Text -> f (Maybe Text))
-> StopFlowResponse -> f StopFlowResponse
stopFlowResponse_flowArn = (StopFlowResponse -> Maybe Text)
-> (StopFlowResponse -> Maybe Text -> StopFlowResponse)
-> Lens StopFlowResponse StopFlowResponse (Maybe Text) (Maybe Text)
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 response's http status code.
stopFlowResponse_httpStatus :: Lens.Lens' StopFlowResponse Prelude.Int
stopFlowResponse_httpStatus :: (Int -> f Int) -> StopFlowResponse -> f StopFlowResponse
stopFlowResponse_httpStatus = (StopFlowResponse -> Int)
-> (StopFlowResponse -> Int -> StopFlowResponse)
-> Lens StopFlowResponse StopFlowResponse Int Int
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