{-# 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.DataPipeline.DeactivatePipeline
-- 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 specified running pipeline. The pipeline is set to the
-- @DEACTIVATING@ state until the deactivation process completes.
--
-- To resume a deactivated pipeline, use ActivatePipeline. By default, the
-- pipeline resumes from the last completed execution. Optionally, you can
-- specify the date and time to resume the pipeline.
module Amazonka.DataPipeline.DeactivatePipeline
  ( -- * Creating a Request
    DeactivatePipeline (..),
    newDeactivatePipeline,

    -- * Request Lenses
    deactivatePipeline_cancelActive,
    deactivatePipeline_pipelineId,

    -- * Destructuring the Response
    DeactivatePipelineResponse (..),
    newDeactivatePipelineResponse,

    -- * Response Lenses
    deactivatePipelineResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DataPipeline.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Contains the parameters for DeactivatePipeline.
--
-- /See:/ 'newDeactivatePipeline' smart constructor.
data DeactivatePipeline = DeactivatePipeline'
  { -- | Indicates whether to cancel any running objects. The default is true,
    -- which sets the state of any running objects to @CANCELED@. If this value
    -- is false, the pipeline is deactivated after all running objects finish.
    DeactivatePipeline -> Maybe Bool
cancelActive :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the pipeline.
    DeactivatePipeline -> Text
pipelineId :: Prelude.Text
  }
  deriving (DeactivatePipeline -> DeactivatePipeline -> Bool
(DeactivatePipeline -> DeactivatePipeline -> Bool)
-> (DeactivatePipeline -> DeactivatePipeline -> Bool)
-> Eq DeactivatePipeline
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeactivatePipeline -> DeactivatePipeline -> Bool
$c/= :: DeactivatePipeline -> DeactivatePipeline -> Bool
== :: DeactivatePipeline -> DeactivatePipeline -> Bool
$c== :: DeactivatePipeline -> DeactivatePipeline -> Bool
Prelude.Eq, ReadPrec [DeactivatePipeline]
ReadPrec DeactivatePipeline
Int -> ReadS DeactivatePipeline
ReadS [DeactivatePipeline]
(Int -> ReadS DeactivatePipeline)
-> ReadS [DeactivatePipeline]
-> ReadPrec DeactivatePipeline
-> ReadPrec [DeactivatePipeline]
-> Read DeactivatePipeline
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeactivatePipeline]
$creadListPrec :: ReadPrec [DeactivatePipeline]
readPrec :: ReadPrec DeactivatePipeline
$creadPrec :: ReadPrec DeactivatePipeline
readList :: ReadS [DeactivatePipeline]
$creadList :: ReadS [DeactivatePipeline]
readsPrec :: Int -> ReadS DeactivatePipeline
$creadsPrec :: Int -> ReadS DeactivatePipeline
Prelude.Read, Int -> DeactivatePipeline -> ShowS
[DeactivatePipeline] -> ShowS
DeactivatePipeline -> String
(Int -> DeactivatePipeline -> ShowS)
-> (DeactivatePipeline -> String)
-> ([DeactivatePipeline] -> ShowS)
-> Show DeactivatePipeline
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeactivatePipeline] -> ShowS
$cshowList :: [DeactivatePipeline] -> ShowS
show :: DeactivatePipeline -> String
$cshow :: DeactivatePipeline -> String
showsPrec :: Int -> DeactivatePipeline -> ShowS
$cshowsPrec :: Int -> DeactivatePipeline -> ShowS
Prelude.Show, (forall x. DeactivatePipeline -> Rep DeactivatePipeline x)
-> (forall x. Rep DeactivatePipeline x -> DeactivatePipeline)
-> Generic DeactivatePipeline
forall x. Rep DeactivatePipeline x -> DeactivatePipeline
forall x. DeactivatePipeline -> Rep DeactivatePipeline x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeactivatePipeline x -> DeactivatePipeline
$cfrom :: forall x. DeactivatePipeline -> Rep DeactivatePipeline x
Prelude.Generic)

-- |
-- Create a value of 'DeactivatePipeline' 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:
--
-- 'cancelActive', 'deactivatePipeline_cancelActive' - Indicates whether to cancel any running objects. The default is true,
-- which sets the state of any running objects to @CANCELED@. If this value
-- is false, the pipeline is deactivated after all running objects finish.
--
-- 'pipelineId', 'deactivatePipeline_pipelineId' - The ID of the pipeline.
newDeactivatePipeline ::
  -- | 'pipelineId'
  Prelude.Text ->
  DeactivatePipeline
newDeactivatePipeline :: Text -> DeactivatePipeline
newDeactivatePipeline Text
pPipelineId_ =
  DeactivatePipeline' :: Maybe Bool -> Text -> DeactivatePipeline
DeactivatePipeline'
    { $sel:cancelActive:DeactivatePipeline' :: Maybe Bool
cancelActive = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineId:DeactivatePipeline' :: Text
pipelineId = Text
pPipelineId_
    }

-- | Indicates whether to cancel any running objects. The default is true,
-- which sets the state of any running objects to @CANCELED@. If this value
-- is false, the pipeline is deactivated after all running objects finish.
deactivatePipeline_cancelActive :: Lens.Lens' DeactivatePipeline (Prelude.Maybe Prelude.Bool)
deactivatePipeline_cancelActive :: (Maybe Bool -> f (Maybe Bool))
-> DeactivatePipeline -> f DeactivatePipeline
deactivatePipeline_cancelActive = (DeactivatePipeline -> Maybe Bool)
-> (DeactivatePipeline -> Maybe Bool -> DeactivatePipeline)
-> Lens
     DeactivatePipeline DeactivatePipeline (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeactivatePipeline' {Maybe Bool
cancelActive :: Maybe Bool
$sel:cancelActive:DeactivatePipeline' :: DeactivatePipeline -> Maybe Bool
cancelActive} -> Maybe Bool
cancelActive) (\s :: DeactivatePipeline
s@DeactivatePipeline' {} Maybe Bool
a -> DeactivatePipeline
s {$sel:cancelActive:DeactivatePipeline' :: Maybe Bool
cancelActive = Maybe Bool
a} :: DeactivatePipeline)

-- | The ID of the pipeline.
deactivatePipeline_pipelineId :: Lens.Lens' DeactivatePipeline Prelude.Text
deactivatePipeline_pipelineId :: (Text -> f Text) -> DeactivatePipeline -> f DeactivatePipeline
deactivatePipeline_pipelineId = (DeactivatePipeline -> Text)
-> (DeactivatePipeline -> Text -> DeactivatePipeline)
-> Lens DeactivatePipeline DeactivatePipeline Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeactivatePipeline' {Text
pipelineId :: Text
$sel:pipelineId:DeactivatePipeline' :: DeactivatePipeline -> Text
pipelineId} -> Text
pipelineId) (\s :: DeactivatePipeline
s@DeactivatePipeline' {} Text
a -> DeactivatePipeline
s {$sel:pipelineId:DeactivatePipeline' :: Text
pipelineId = Text
a} :: DeactivatePipeline)

instance Core.AWSRequest DeactivatePipeline where
  type
    AWSResponse DeactivatePipeline =
      DeactivatePipelineResponse
  request :: DeactivatePipeline -> Request DeactivatePipeline
request = Service -> DeactivatePipeline -> Request DeactivatePipeline
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeactivatePipeline
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeactivatePipeline)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeactivatePipeline))
-> Logger
-> Service
-> Proxy DeactivatePipeline
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeactivatePipeline)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeactivatePipelineResponse
DeactivatePipelineResponse'
            (Int -> DeactivatePipelineResponse)
-> Either String Int -> Either String DeactivatePipelineResponse
forall (f :: * -> *) a b. Functor 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 DeactivatePipeline

instance Prelude.NFData DeactivatePipeline

instance Core.ToHeaders DeactivatePipeline where
  toHeaders :: DeactivatePipeline -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeactivatePipeline -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DataPipeline.DeactivatePipeline" ::
                          Prelude.ByteString
                      ),
            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 DeactivatePipeline where
  toJSON :: DeactivatePipeline -> Value
toJSON DeactivatePipeline' {Maybe Bool
Text
pipelineId :: Text
cancelActive :: Maybe Bool
$sel:pipelineId:DeactivatePipeline' :: DeactivatePipeline -> Text
$sel:cancelActive:DeactivatePipeline' :: DeactivatePipeline -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"cancelActive" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
cancelActive,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"pipelineId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
pipelineId)
          ]
      )

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

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

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

-- |
-- Create a value of 'DeactivatePipelineResponse' 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:
--
-- 'httpStatus', 'deactivatePipelineResponse_httpStatus' - The response's http status code.
newDeactivatePipelineResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeactivatePipelineResponse
newDeactivatePipelineResponse :: Int -> DeactivatePipelineResponse
newDeactivatePipelineResponse Int
pHttpStatus_ =
  DeactivatePipelineResponse' :: Int -> DeactivatePipelineResponse
DeactivatePipelineResponse'
    { $sel:httpStatus:DeactivatePipelineResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeactivatePipelineResponse