{-# 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-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)
--
-- 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.Lens as Lens
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
(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:
--
-- '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' :: Text -> StopFlow
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 :: (Text -> f Text) -> StopFlow -> f StopFlow
stopFlow_flowName = (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
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 :: 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 Text -> Maybe FlowStatus -> Int -> StopFlowResponse
StopFlowResponse'
            (Maybe Text -> Maybe FlowStatus -> Int -> StopFlowResponse)
-> Either String (Maybe Text)
-> Either String (Maybe FlowStatus -> Int -> StopFlowResponse)
forall (f :: * -> *) a b. Functor 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 (Maybe FlowStatus -> Int -> StopFlowResponse)
-> Either String (Maybe FlowStatus)
-> 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 FlowStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"flowStatus")
            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 StopFlow' {Text
flowName :: Text
$sel:flowName:StopFlow' :: StopFlow -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"flowName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
flowName)]
      )

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

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 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
(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:
--
-- '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' :: Maybe Text -> Maybe FlowStatus -> Int -> StopFlowResponse
StopFlowResponse'
    { $sel:flowArn:StopFlowResponse' :: Maybe Text
flowArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:flowStatus:StopFlowResponse' :: Maybe FlowStatus
flowStatus = Maybe 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 :: (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)

-- | Indicates the current status of the flow.
stopFlowResponse_flowStatus :: Lens.Lens' StopFlowResponse (Prelude.Maybe FlowStatus)
stopFlowResponse_flowStatus :: (Maybe FlowStatus -> f (Maybe FlowStatus))
-> StopFlowResponse -> f StopFlowResponse
stopFlowResponse_flowStatus = (StopFlowResponse -> Maybe FlowStatus)
-> (StopFlowResponse -> Maybe FlowStatus -> StopFlowResponse)
-> Lens
     StopFlowResponse
     StopFlowResponse
     (Maybe FlowStatus)
     (Maybe 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 :: (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