{-# 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.ActivatePipeline
-- 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)
--
-- Validates the specified pipeline and starts processing pipeline tasks.
-- If the pipeline does not pass validation, activation fails.
--
-- If you need to pause the pipeline to investigate an issue with a
-- component, such as a data source or script, call DeactivatePipeline.
--
-- To activate a finished pipeline, modify the end date for the pipeline
-- and then activate it.
module Amazonka.DataPipeline.ActivatePipeline
  ( -- * Creating a Request
    ActivatePipeline (..),
    newActivatePipeline,

    -- * Request Lenses
    activatePipeline_startTimestamp,
    activatePipeline_parameterValues,
    activatePipeline_pipelineId,

    -- * Destructuring the Response
    ActivatePipelineResponse (..),
    newActivatePipelineResponse,

    -- * Response Lenses
    activatePipelineResponse_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 ActivatePipeline.
--
-- /See:/ 'newActivatePipeline' smart constructor.
data ActivatePipeline = ActivatePipeline'
  { -- | The date and time to resume the pipeline. By default, the pipeline
    -- resumes from the last completed execution.
    ActivatePipeline -> Maybe POSIX
startTimestamp :: Prelude.Maybe Core.POSIX,
    -- | A list of parameter values to pass to the pipeline at activation.
    ActivatePipeline -> Maybe [ParameterValue]
parameterValues :: Prelude.Maybe [ParameterValue],
    -- | The ID of the pipeline.
    ActivatePipeline -> Text
pipelineId :: Prelude.Text
  }
  deriving (ActivatePipeline -> ActivatePipeline -> Bool
(ActivatePipeline -> ActivatePipeline -> Bool)
-> (ActivatePipeline -> ActivatePipeline -> Bool)
-> Eq ActivatePipeline
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActivatePipeline -> ActivatePipeline -> Bool
$c/= :: ActivatePipeline -> ActivatePipeline -> Bool
== :: ActivatePipeline -> ActivatePipeline -> Bool
$c== :: ActivatePipeline -> ActivatePipeline -> Bool
Prelude.Eq, ReadPrec [ActivatePipeline]
ReadPrec ActivatePipeline
Int -> ReadS ActivatePipeline
ReadS [ActivatePipeline]
(Int -> ReadS ActivatePipeline)
-> ReadS [ActivatePipeline]
-> ReadPrec ActivatePipeline
-> ReadPrec [ActivatePipeline]
-> Read ActivatePipeline
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActivatePipeline]
$creadListPrec :: ReadPrec [ActivatePipeline]
readPrec :: ReadPrec ActivatePipeline
$creadPrec :: ReadPrec ActivatePipeline
readList :: ReadS [ActivatePipeline]
$creadList :: ReadS [ActivatePipeline]
readsPrec :: Int -> ReadS ActivatePipeline
$creadsPrec :: Int -> ReadS ActivatePipeline
Prelude.Read, Int -> ActivatePipeline -> ShowS
[ActivatePipeline] -> ShowS
ActivatePipeline -> String
(Int -> ActivatePipeline -> ShowS)
-> (ActivatePipeline -> String)
-> ([ActivatePipeline] -> ShowS)
-> Show ActivatePipeline
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActivatePipeline] -> ShowS
$cshowList :: [ActivatePipeline] -> ShowS
show :: ActivatePipeline -> String
$cshow :: ActivatePipeline -> String
showsPrec :: Int -> ActivatePipeline -> ShowS
$cshowsPrec :: Int -> ActivatePipeline -> ShowS
Prelude.Show, (forall x. ActivatePipeline -> Rep ActivatePipeline x)
-> (forall x. Rep ActivatePipeline x -> ActivatePipeline)
-> Generic ActivatePipeline
forall x. Rep ActivatePipeline x -> ActivatePipeline
forall x. ActivatePipeline -> Rep ActivatePipeline x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActivatePipeline x -> ActivatePipeline
$cfrom :: forall x. ActivatePipeline -> Rep ActivatePipeline x
Prelude.Generic)

-- |
-- Create a value of 'ActivatePipeline' 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:
--
-- 'startTimestamp', 'activatePipeline_startTimestamp' - The date and time to resume the pipeline. By default, the pipeline
-- resumes from the last completed execution.
--
-- 'parameterValues', 'activatePipeline_parameterValues' - A list of parameter values to pass to the pipeline at activation.
--
-- 'pipelineId', 'activatePipeline_pipelineId' - The ID of the pipeline.
newActivatePipeline ::
  -- | 'pipelineId'
  Prelude.Text ->
  ActivatePipeline
newActivatePipeline :: Text -> ActivatePipeline
newActivatePipeline Text
pPipelineId_ =
  ActivatePipeline' :: Maybe POSIX -> Maybe [ParameterValue] -> Text -> ActivatePipeline
ActivatePipeline'
    { $sel:startTimestamp:ActivatePipeline' :: Maybe POSIX
startTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:parameterValues:ActivatePipeline' :: Maybe [ParameterValue]
parameterValues = Maybe [ParameterValue]
forall a. Maybe a
Prelude.Nothing,
      $sel:pipelineId:ActivatePipeline' :: Text
pipelineId = Text
pPipelineId_
    }

-- | The date and time to resume the pipeline. By default, the pipeline
-- resumes from the last completed execution.
activatePipeline_startTimestamp :: Lens.Lens' ActivatePipeline (Prelude.Maybe Prelude.UTCTime)
activatePipeline_startTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ActivatePipeline -> f ActivatePipeline
activatePipeline_startTimestamp = (ActivatePipeline -> Maybe POSIX)
-> (ActivatePipeline -> Maybe POSIX -> ActivatePipeline)
-> Lens
     ActivatePipeline ActivatePipeline (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivatePipeline' {Maybe POSIX
startTimestamp :: Maybe POSIX
$sel:startTimestamp:ActivatePipeline' :: ActivatePipeline -> Maybe POSIX
startTimestamp} -> Maybe POSIX
startTimestamp) (\s :: ActivatePipeline
s@ActivatePipeline' {} Maybe POSIX
a -> ActivatePipeline
s {$sel:startTimestamp:ActivatePipeline' :: Maybe POSIX
startTimestamp = Maybe POSIX
a} :: ActivatePipeline) ((Maybe POSIX -> f (Maybe POSIX))
 -> ActivatePipeline -> f ActivatePipeline)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ActivatePipeline
-> f ActivatePipeline
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A list of parameter values to pass to the pipeline at activation.
activatePipeline_parameterValues :: Lens.Lens' ActivatePipeline (Prelude.Maybe [ParameterValue])
activatePipeline_parameterValues :: (Maybe [ParameterValue] -> f (Maybe [ParameterValue]))
-> ActivatePipeline -> f ActivatePipeline
activatePipeline_parameterValues = (ActivatePipeline -> Maybe [ParameterValue])
-> (ActivatePipeline -> Maybe [ParameterValue] -> ActivatePipeline)
-> Lens
     ActivatePipeline
     ActivatePipeline
     (Maybe [ParameterValue])
     (Maybe [ParameterValue])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivatePipeline' {Maybe [ParameterValue]
parameterValues :: Maybe [ParameterValue]
$sel:parameterValues:ActivatePipeline' :: ActivatePipeline -> Maybe [ParameterValue]
parameterValues} -> Maybe [ParameterValue]
parameterValues) (\s :: ActivatePipeline
s@ActivatePipeline' {} Maybe [ParameterValue]
a -> ActivatePipeline
s {$sel:parameterValues:ActivatePipeline' :: Maybe [ParameterValue]
parameterValues = Maybe [ParameterValue]
a} :: ActivatePipeline) ((Maybe [ParameterValue] -> f (Maybe [ParameterValue]))
 -> ActivatePipeline -> f ActivatePipeline)
-> ((Maybe [ParameterValue] -> f (Maybe [ParameterValue]))
    -> Maybe [ParameterValue] -> f (Maybe [ParameterValue]))
-> (Maybe [ParameterValue] -> f (Maybe [ParameterValue]))
-> ActivatePipeline
-> f ActivatePipeline
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ParameterValue] [ParameterValue] [ParameterValue] [ParameterValue]
-> Iso
     (Maybe [ParameterValue])
     (Maybe [ParameterValue])
     (Maybe [ParameterValue])
     (Maybe [ParameterValue])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ParameterValue] [ParameterValue] [ParameterValue] [ParameterValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Core.AWSRequest ActivatePipeline where
  type
    AWSResponse ActivatePipeline =
      ActivatePipelineResponse
  request :: ActivatePipeline -> Request ActivatePipeline
request = Service -> ActivatePipeline -> Request ActivatePipeline
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ActivatePipeline
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ActivatePipeline)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse ActivatePipeline))
-> Logger
-> Service
-> Proxy ActivatePipeline
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ActivatePipeline)))
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 -> ActivatePipelineResponse
ActivatePipelineResponse'
            (Int -> ActivatePipelineResponse)
-> Either String Int -> Either String ActivatePipelineResponse
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 ActivatePipeline

instance Prelude.NFData ActivatePipeline

instance Core.ToHeaders ActivatePipeline where
  toHeaders :: ActivatePipeline -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ActivatePipeline -> 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.ActivatePipeline" ::
                          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 ActivatePipeline where
  toJSON :: ActivatePipeline -> Value
toJSON ActivatePipeline' {Maybe [ParameterValue]
Maybe POSIX
Text
pipelineId :: Text
parameterValues :: Maybe [ParameterValue]
startTimestamp :: Maybe POSIX
$sel:pipelineId:ActivatePipeline' :: ActivatePipeline -> Text
$sel:parameterValues:ActivatePipeline' :: ActivatePipeline -> Maybe [ParameterValue]
$sel:startTimestamp:ActivatePipeline' :: ActivatePipeline -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"startTimestamp" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
startTimestamp,
            (Text
"parameterValues" Text -> [ParameterValue] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ParameterValue] -> Pair) -> Maybe [ParameterValue] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ParameterValue]
parameterValues,
            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 ActivatePipeline where
  toPath :: ActivatePipeline -> ByteString
toPath = ByteString -> ActivatePipeline -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData ActivatePipelineResponse