{-# 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.AppFlow.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)
--
-- Deactivates the existing flow. For on-demand flows, this operation
-- returns an @unsupportedOperationException@ error message. For schedule
-- and event-triggered flows, this operation deactivates the flow.
module Amazonka.AppFlow.StopFlow
  ( -- * Creating a Request
    StopFlow (..),
    newStopFlow,

    -- * Request Lenses
    stopFlow_flowName,

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

    -- * Response Lenses
    stopFlowResponse_flowArn,
    stopFlowResponse_flowStatus,
    stopFlowResponse_httpStatus,
  )
where

import Amazonka.AppFlow.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 specified name of the flow. Spaces are not allowed. Use underscores
    -- (_) or hyphens (-) only.
    StopFlow -> Text
flowName :: 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:
--
-- 'flowName', 'stopFlow_flowName' - The specified name of the flow. Spaces are not allowed. Use underscores
-- (_) or hyphens (-) only.
newStopFlow ::
  -- | 'flowName'
  Prelude.Text ->
  StopFlow
newStopFlow :: Text -> StopFlow
newStopFlow Text
pFlowName_ =
  StopFlow' {$sel:flowName:StopFlow' :: Text
flowName = Text
pFlowName_}

-- | The specified name of the flow. Spaces are not allowed. Use underscores
-- (_) or hyphens (-) only.
stopFlow_flowName :: Lens.Lens' StopFlow Prelude.Text
stopFlow_flowName :: Lens' StopFlow Text
stopFlow_flowName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopFlow' {Text
flowName :: Text
$sel:flowName:StopFlow' :: StopFlow -> Text
flowName} -> Text
flowName) (\s :: StopFlow
s@StopFlow' {} Text
a -> StopFlow
s {$sel:flowName:StopFlow' :: Text
flowName = 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 FlowStatus -> 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
"flowStatus")
            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
flowName :: Text
$sel:flowName:StopFlow' :: StopFlow -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
flowName

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

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 StopFlow' {Text
flowName :: Text
$sel:flowName:StopFlow' :: StopFlow -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"flowName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
flowName)]
      )

instance Data.ToPath StopFlow where
  toPath :: StopFlow -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/stop-flow"

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 flow\'s Amazon Resource Name (ARN).
    StopFlowResponse -> Maybe Text
flowArn :: Prelude.Maybe Prelude.Text,
    -- | Indicates the current status of the flow.
    StopFlowResponse -> Maybe FlowStatus
flowStatus :: Prelude.Maybe FlowStatus,
    -- | 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 flow\'s Amazon Resource Name (ARN).
--
-- 'flowStatus', 'stopFlowResponse_flowStatus' - Indicates the current status of the flow.
--
-- '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:flowStatus:StopFlowResponse' :: Maybe FlowStatus
flowStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StopFlowResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The flow\'s Amazon Resource Name (ARN).
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)

-- | Indicates the current status of the flow.
stopFlowResponse_flowStatus :: Lens.Lens' StopFlowResponse (Prelude.Maybe FlowStatus)
stopFlowResponse_flowStatus :: Lens' StopFlowResponse (Maybe FlowStatus)
stopFlowResponse_flowStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopFlowResponse' {Maybe FlowStatus
flowStatus :: Maybe FlowStatus
$sel:flowStatus:StopFlowResponse' :: StopFlowResponse -> Maybe FlowStatus
flowStatus} -> Maybe FlowStatus
flowStatus) (\s :: StopFlowResponse
s@StopFlowResponse' {} Maybe FlowStatus
a -> StopFlowResponse
s {$sel:flowStatus:StopFlowResponse' :: Maybe FlowStatus
flowStatus = Maybe FlowStatus
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 FlowStatus
httpStatus :: Int
flowStatus :: Maybe FlowStatus
flowArn :: Maybe Text
$sel:httpStatus:StopFlowResponse' :: StopFlowResponse -> Int
$sel:flowStatus:StopFlowResponse' :: StopFlowResponse -> Maybe FlowStatus
$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 FlowStatus
flowStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus