{-# 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.SetStatus
-- 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)
--
-- Requests that the status of the specified physical or logical pipeline
-- objects be updated in the specified pipeline. This update might not
-- occur immediately, but is eventually consistent. The status that can be
-- set depends on the type of object (for example, DataNode or Activity).
-- You cannot perform this operation on @FINISHED@ pipelines and attempting
-- to do so returns @InvalidRequestException@.
module Amazonka.DataPipeline.SetStatus
  ( -- * Creating a Request
    SetStatus (..),
    newSetStatus,

    -- * Request Lenses
    setStatus_pipelineId,
    setStatus_objectIds,
    setStatus_status,

    -- * Destructuring the Response
    SetStatusResponse (..),
    newSetStatusResponse,
  )
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 SetStatus.
--
-- /See:/ 'newSetStatus' smart constructor.
data SetStatus = SetStatus'
  { -- | The ID of the pipeline that contains the objects.
    SetStatus -> Text
pipelineId :: Prelude.Text,
    -- | The IDs of the objects. The corresponding objects can be either physical
    -- or components, but not a mix of both types.
    SetStatus -> [Text]
objectIds :: [Prelude.Text],
    -- | The status to be set on all the objects specified in @objectIds@. For
    -- components, use @PAUSE@ or @RESUME@. For instances, use @TRY_CANCEL@,
    -- @RERUN@, or @MARK_FINISHED@.
    SetStatus -> Text
status :: Prelude.Text
  }
  deriving (SetStatus -> SetStatus -> Bool
(SetStatus -> SetStatus -> Bool)
-> (SetStatus -> SetStatus -> Bool) -> Eq SetStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetStatus -> SetStatus -> Bool
$c/= :: SetStatus -> SetStatus -> Bool
== :: SetStatus -> SetStatus -> Bool
$c== :: SetStatus -> SetStatus -> Bool
Prelude.Eq, ReadPrec [SetStatus]
ReadPrec SetStatus
Int -> ReadS SetStatus
ReadS [SetStatus]
(Int -> ReadS SetStatus)
-> ReadS [SetStatus]
-> ReadPrec SetStatus
-> ReadPrec [SetStatus]
-> Read SetStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetStatus]
$creadListPrec :: ReadPrec [SetStatus]
readPrec :: ReadPrec SetStatus
$creadPrec :: ReadPrec SetStatus
readList :: ReadS [SetStatus]
$creadList :: ReadS [SetStatus]
readsPrec :: Int -> ReadS SetStatus
$creadsPrec :: Int -> ReadS SetStatus
Prelude.Read, Int -> SetStatus -> ShowS
[SetStatus] -> ShowS
SetStatus -> String
(Int -> SetStatus -> ShowS)
-> (SetStatus -> String)
-> ([SetStatus] -> ShowS)
-> Show SetStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetStatus] -> ShowS
$cshowList :: [SetStatus] -> ShowS
show :: SetStatus -> String
$cshow :: SetStatus -> String
showsPrec :: Int -> SetStatus -> ShowS
$cshowsPrec :: Int -> SetStatus -> ShowS
Prelude.Show, (forall x. SetStatus -> Rep SetStatus x)
-> (forall x. Rep SetStatus x -> SetStatus) -> Generic SetStatus
forall x. Rep SetStatus x -> SetStatus
forall x. SetStatus -> Rep SetStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetStatus x -> SetStatus
$cfrom :: forall x. SetStatus -> Rep SetStatus x
Prelude.Generic)

-- |
-- Create a value of 'SetStatus' 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:
--
-- 'pipelineId', 'setStatus_pipelineId' - The ID of the pipeline that contains the objects.
--
-- 'objectIds', 'setStatus_objectIds' - The IDs of the objects. The corresponding objects can be either physical
-- or components, but not a mix of both types.
--
-- 'status', 'setStatus_status' - The status to be set on all the objects specified in @objectIds@. For
-- components, use @PAUSE@ or @RESUME@. For instances, use @TRY_CANCEL@,
-- @RERUN@, or @MARK_FINISHED@.
newSetStatus ::
  -- | 'pipelineId'
  Prelude.Text ->
  -- | 'status'
  Prelude.Text ->
  SetStatus
newSetStatus :: Text -> Text -> SetStatus
newSetStatus Text
pPipelineId_ Text
pStatus_ =
  SetStatus' :: Text -> [Text] -> Text -> SetStatus
SetStatus'
    { $sel:pipelineId:SetStatus' :: Text
pipelineId = Text
pPipelineId_,
      $sel:objectIds:SetStatus' :: [Text]
objectIds = [Text]
forall a. Monoid a => a
Prelude.mempty,
      $sel:status:SetStatus' :: Text
status = Text
pStatus_
    }

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

-- | The IDs of the objects. The corresponding objects can be either physical
-- or components, but not a mix of both types.
setStatus_objectIds :: Lens.Lens' SetStatus [Prelude.Text]
setStatus_objectIds :: ([Text] -> f [Text]) -> SetStatus -> f SetStatus
setStatus_objectIds = (SetStatus -> [Text])
-> (SetStatus -> [Text] -> SetStatus)
-> Lens SetStatus SetStatus [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetStatus' {[Text]
objectIds :: [Text]
$sel:objectIds:SetStatus' :: SetStatus -> [Text]
objectIds} -> [Text]
objectIds) (\s :: SetStatus
s@SetStatus' {} [Text]
a -> SetStatus
s {$sel:objectIds:SetStatus' :: [Text]
objectIds = [Text]
a} :: SetStatus) (([Text] -> f [Text]) -> SetStatus -> f SetStatus)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> SetStatus
-> f SetStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The status to be set on all the objects specified in @objectIds@. For
-- components, use @PAUSE@ or @RESUME@. For instances, use @TRY_CANCEL@,
-- @RERUN@, or @MARK_FINISHED@.
setStatus_status :: Lens.Lens' SetStatus Prelude.Text
setStatus_status :: (Text -> f Text) -> SetStatus -> f SetStatus
setStatus_status = (SetStatus -> Text)
-> (SetStatus -> Text -> SetStatus)
-> Lens SetStatus SetStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetStatus' {Text
status :: Text
$sel:status:SetStatus' :: SetStatus -> Text
status} -> Text
status) (\s :: SetStatus
s@SetStatus' {} Text
a -> SetStatus
s {$sel:status:SetStatus' :: Text
status = Text
a} :: SetStatus)

instance Core.AWSRequest SetStatus where
  type AWSResponse SetStatus = SetStatusResponse
  request :: SetStatus -> Request SetStatus
request = Service -> SetStatus -> Request SetStatus
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SetStatus
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SetStatus)))
response = AWSResponse SetStatus
-> Logger
-> Service
-> Proxy SetStatus
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SetStatus)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse SetStatus
SetStatusResponse
SetStatusResponse'

instance Prelude.Hashable SetStatus

instance Prelude.NFData SetStatus

instance Core.ToHeaders SetStatus where
  toHeaders :: SetStatus -> [Header]
toHeaders =
    [Header] -> SetStatus -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# (ByteString
"DataPipeline.SetStatus" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON SetStatus where
  toJSON :: SetStatus -> Value
toJSON SetStatus' {[Text]
Text
status :: Text
objectIds :: [Text]
pipelineId :: Text
$sel:status:SetStatus' :: SetStatus -> Text
$sel:objectIds:SetStatus' :: SetStatus -> [Text]
$sel:pipelineId:SetStatus' :: SetStatus -> 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
"pipelineId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
pipelineId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"objectIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
objectIds),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"status" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
status)
          ]
      )

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

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

-- | /See:/ 'newSetStatusResponse' smart constructor.
data SetStatusResponse = SetStatusResponse'
  {
  }
  deriving (SetStatusResponse -> SetStatusResponse -> Bool
(SetStatusResponse -> SetStatusResponse -> Bool)
-> (SetStatusResponse -> SetStatusResponse -> Bool)
-> Eq SetStatusResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetStatusResponse -> SetStatusResponse -> Bool
$c/= :: SetStatusResponse -> SetStatusResponse -> Bool
== :: SetStatusResponse -> SetStatusResponse -> Bool
$c== :: SetStatusResponse -> SetStatusResponse -> Bool
Prelude.Eq, ReadPrec [SetStatusResponse]
ReadPrec SetStatusResponse
Int -> ReadS SetStatusResponse
ReadS [SetStatusResponse]
(Int -> ReadS SetStatusResponse)
-> ReadS [SetStatusResponse]
-> ReadPrec SetStatusResponse
-> ReadPrec [SetStatusResponse]
-> Read SetStatusResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetStatusResponse]
$creadListPrec :: ReadPrec [SetStatusResponse]
readPrec :: ReadPrec SetStatusResponse
$creadPrec :: ReadPrec SetStatusResponse
readList :: ReadS [SetStatusResponse]
$creadList :: ReadS [SetStatusResponse]
readsPrec :: Int -> ReadS SetStatusResponse
$creadsPrec :: Int -> ReadS SetStatusResponse
Prelude.Read, Int -> SetStatusResponse -> ShowS
[SetStatusResponse] -> ShowS
SetStatusResponse -> String
(Int -> SetStatusResponse -> ShowS)
-> (SetStatusResponse -> String)
-> ([SetStatusResponse] -> ShowS)
-> Show SetStatusResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetStatusResponse] -> ShowS
$cshowList :: [SetStatusResponse] -> ShowS
show :: SetStatusResponse -> String
$cshow :: SetStatusResponse -> String
showsPrec :: Int -> SetStatusResponse -> ShowS
$cshowsPrec :: Int -> SetStatusResponse -> ShowS
Prelude.Show, (forall x. SetStatusResponse -> Rep SetStatusResponse x)
-> (forall x. Rep SetStatusResponse x -> SetStatusResponse)
-> Generic SetStatusResponse
forall x. Rep SetStatusResponse x -> SetStatusResponse
forall x. SetStatusResponse -> Rep SetStatusResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetStatusResponse x -> SetStatusResponse
$cfrom :: forall x. SetStatusResponse -> Rep SetStatusResponse x
Prelude.Generic)

-- |
-- Create a value of 'SetStatusResponse' 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.
newSetStatusResponse ::
  SetStatusResponse
newSetStatusResponse :: SetStatusResponse
newSetStatusResponse = SetStatusResponse
SetStatusResponse'

instance Prelude.NFData SetStatusResponse