{-# 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.ElastiCache.BatchStopUpdateAction
-- 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)
--
-- Stop the service update. For more information on service updates and
-- stopping them, see
-- <https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/stopping-self-service-updates.html Stopping Service Updates>.
module Amazonka.ElastiCache.BatchStopUpdateAction
  ( -- * Creating a Request
    BatchStopUpdateAction (..),
    newBatchStopUpdateAction,

    -- * Request Lenses
    batchStopUpdateAction_cacheClusterIds,
    batchStopUpdateAction_replicationGroupIds,
    batchStopUpdateAction_serviceUpdateName,

    -- * Destructuring the Response
    UpdateActionResultsMessage (..),
    newUpdateActionResultsMessage,

    -- * Response Lenses
    updateActionResultsMessage_unprocessedUpdateActions,
    updateActionResultsMessage_processedUpdateActions,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ElastiCache.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

-- | /See:/ 'newBatchStopUpdateAction' smart constructor.
data BatchStopUpdateAction = BatchStopUpdateAction'
  { -- | The cache cluster IDs
    BatchStopUpdateAction -> Maybe [Text]
cacheClusterIds :: Prelude.Maybe [Prelude.Text],
    -- | The replication group IDs
    BatchStopUpdateAction -> Maybe [Text]
replicationGroupIds :: Prelude.Maybe [Prelude.Text],
    -- | The unique ID of the service update
    BatchStopUpdateAction -> Text
serviceUpdateName :: Prelude.Text
  }
  deriving (BatchStopUpdateAction -> BatchStopUpdateAction -> Bool
(BatchStopUpdateAction -> BatchStopUpdateAction -> Bool)
-> (BatchStopUpdateAction -> BatchStopUpdateAction -> Bool)
-> Eq BatchStopUpdateAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchStopUpdateAction -> BatchStopUpdateAction -> Bool
$c/= :: BatchStopUpdateAction -> BatchStopUpdateAction -> Bool
== :: BatchStopUpdateAction -> BatchStopUpdateAction -> Bool
$c== :: BatchStopUpdateAction -> BatchStopUpdateAction -> Bool
Prelude.Eq, ReadPrec [BatchStopUpdateAction]
ReadPrec BatchStopUpdateAction
Int -> ReadS BatchStopUpdateAction
ReadS [BatchStopUpdateAction]
(Int -> ReadS BatchStopUpdateAction)
-> ReadS [BatchStopUpdateAction]
-> ReadPrec BatchStopUpdateAction
-> ReadPrec [BatchStopUpdateAction]
-> Read BatchStopUpdateAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchStopUpdateAction]
$creadListPrec :: ReadPrec [BatchStopUpdateAction]
readPrec :: ReadPrec BatchStopUpdateAction
$creadPrec :: ReadPrec BatchStopUpdateAction
readList :: ReadS [BatchStopUpdateAction]
$creadList :: ReadS [BatchStopUpdateAction]
readsPrec :: Int -> ReadS BatchStopUpdateAction
$creadsPrec :: Int -> ReadS BatchStopUpdateAction
Prelude.Read, Int -> BatchStopUpdateAction -> ShowS
[BatchStopUpdateAction] -> ShowS
BatchStopUpdateAction -> String
(Int -> BatchStopUpdateAction -> ShowS)
-> (BatchStopUpdateAction -> String)
-> ([BatchStopUpdateAction] -> ShowS)
-> Show BatchStopUpdateAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchStopUpdateAction] -> ShowS
$cshowList :: [BatchStopUpdateAction] -> ShowS
show :: BatchStopUpdateAction -> String
$cshow :: BatchStopUpdateAction -> String
showsPrec :: Int -> BatchStopUpdateAction -> ShowS
$cshowsPrec :: Int -> BatchStopUpdateAction -> ShowS
Prelude.Show, (forall x. BatchStopUpdateAction -> Rep BatchStopUpdateAction x)
-> (forall x. Rep BatchStopUpdateAction x -> BatchStopUpdateAction)
-> Generic BatchStopUpdateAction
forall x. Rep BatchStopUpdateAction x -> BatchStopUpdateAction
forall x. BatchStopUpdateAction -> Rep BatchStopUpdateAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchStopUpdateAction x -> BatchStopUpdateAction
$cfrom :: forall x. BatchStopUpdateAction -> Rep BatchStopUpdateAction x
Prelude.Generic)

-- |
-- Create a value of 'BatchStopUpdateAction' 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:
--
-- 'cacheClusterIds', 'batchStopUpdateAction_cacheClusterIds' - The cache cluster IDs
--
-- 'replicationGroupIds', 'batchStopUpdateAction_replicationGroupIds' - The replication group IDs
--
-- 'serviceUpdateName', 'batchStopUpdateAction_serviceUpdateName' - The unique ID of the service update
newBatchStopUpdateAction ::
  -- | 'serviceUpdateName'
  Prelude.Text ->
  BatchStopUpdateAction
newBatchStopUpdateAction :: Text -> BatchStopUpdateAction
newBatchStopUpdateAction Text
pServiceUpdateName_ =
  BatchStopUpdateAction' :: Maybe [Text] -> Maybe [Text] -> Text -> BatchStopUpdateAction
BatchStopUpdateAction'
    { $sel:cacheClusterIds:BatchStopUpdateAction' :: Maybe [Text]
cacheClusterIds =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationGroupIds:BatchStopUpdateAction' :: Maybe [Text]
replicationGroupIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceUpdateName:BatchStopUpdateAction' :: Text
serviceUpdateName = Text
pServiceUpdateName_
    }

-- | The cache cluster IDs
batchStopUpdateAction_cacheClusterIds :: Lens.Lens' BatchStopUpdateAction (Prelude.Maybe [Prelude.Text])
batchStopUpdateAction_cacheClusterIds :: (Maybe [Text] -> f (Maybe [Text]))
-> BatchStopUpdateAction -> f BatchStopUpdateAction
batchStopUpdateAction_cacheClusterIds = (BatchStopUpdateAction -> Maybe [Text])
-> (BatchStopUpdateAction -> Maybe [Text] -> BatchStopUpdateAction)
-> Lens
     BatchStopUpdateAction
     BatchStopUpdateAction
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStopUpdateAction' {Maybe [Text]
cacheClusterIds :: Maybe [Text]
$sel:cacheClusterIds:BatchStopUpdateAction' :: BatchStopUpdateAction -> Maybe [Text]
cacheClusterIds} -> Maybe [Text]
cacheClusterIds) (\s :: BatchStopUpdateAction
s@BatchStopUpdateAction' {} Maybe [Text]
a -> BatchStopUpdateAction
s {$sel:cacheClusterIds:BatchStopUpdateAction' :: Maybe [Text]
cacheClusterIds = Maybe [Text]
a} :: BatchStopUpdateAction) ((Maybe [Text] -> f (Maybe [Text]))
 -> BatchStopUpdateAction -> f BatchStopUpdateAction)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> BatchStopUpdateAction
-> f BatchStopUpdateAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The replication group IDs
batchStopUpdateAction_replicationGroupIds :: Lens.Lens' BatchStopUpdateAction (Prelude.Maybe [Prelude.Text])
batchStopUpdateAction_replicationGroupIds :: (Maybe [Text] -> f (Maybe [Text]))
-> BatchStopUpdateAction -> f BatchStopUpdateAction
batchStopUpdateAction_replicationGroupIds = (BatchStopUpdateAction -> Maybe [Text])
-> (BatchStopUpdateAction -> Maybe [Text] -> BatchStopUpdateAction)
-> Lens
     BatchStopUpdateAction
     BatchStopUpdateAction
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStopUpdateAction' {Maybe [Text]
replicationGroupIds :: Maybe [Text]
$sel:replicationGroupIds:BatchStopUpdateAction' :: BatchStopUpdateAction -> Maybe [Text]
replicationGroupIds} -> Maybe [Text]
replicationGroupIds) (\s :: BatchStopUpdateAction
s@BatchStopUpdateAction' {} Maybe [Text]
a -> BatchStopUpdateAction
s {$sel:replicationGroupIds:BatchStopUpdateAction' :: Maybe [Text]
replicationGroupIds = Maybe [Text]
a} :: BatchStopUpdateAction) ((Maybe [Text] -> f (Maybe [Text]))
 -> BatchStopUpdateAction -> f BatchStopUpdateAction)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> BatchStopUpdateAction
-> f BatchStopUpdateAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique ID of the service update
batchStopUpdateAction_serviceUpdateName :: Lens.Lens' BatchStopUpdateAction Prelude.Text
batchStopUpdateAction_serviceUpdateName :: (Text -> f Text)
-> BatchStopUpdateAction -> f BatchStopUpdateAction
batchStopUpdateAction_serviceUpdateName = (BatchStopUpdateAction -> Text)
-> (BatchStopUpdateAction -> Text -> BatchStopUpdateAction)
-> Lens BatchStopUpdateAction BatchStopUpdateAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchStopUpdateAction' {Text
serviceUpdateName :: Text
$sel:serviceUpdateName:BatchStopUpdateAction' :: BatchStopUpdateAction -> Text
serviceUpdateName} -> Text
serviceUpdateName) (\s :: BatchStopUpdateAction
s@BatchStopUpdateAction' {} Text
a -> BatchStopUpdateAction
s {$sel:serviceUpdateName:BatchStopUpdateAction' :: Text
serviceUpdateName = Text
a} :: BatchStopUpdateAction)

instance Core.AWSRequest BatchStopUpdateAction where
  type
    AWSResponse BatchStopUpdateAction =
      UpdateActionResultsMessage
  request :: BatchStopUpdateAction -> Request BatchStopUpdateAction
request = Service -> BatchStopUpdateAction -> Request BatchStopUpdateAction
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchStopUpdateAction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchStopUpdateAction)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse BatchStopUpdateAction))
-> Logger
-> Service
-> Proxy BatchStopUpdateAction
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchStopUpdateAction)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"BatchStopUpdateActionResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String UpdateActionResultsMessage
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable BatchStopUpdateAction

instance Prelude.NFData BatchStopUpdateAction

instance Core.ToHeaders BatchStopUpdateAction where
  toHeaders :: BatchStopUpdateAction -> ResponseHeaders
toHeaders = ResponseHeaders -> BatchStopUpdateAction -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery BatchStopUpdateAction where
  toQuery :: BatchStopUpdateAction -> QueryString
toQuery BatchStopUpdateAction' {Maybe [Text]
Text
serviceUpdateName :: Text
replicationGroupIds :: Maybe [Text]
cacheClusterIds :: Maybe [Text]
$sel:serviceUpdateName:BatchStopUpdateAction' :: BatchStopUpdateAction -> Text
$sel:replicationGroupIds:BatchStopUpdateAction' :: BatchStopUpdateAction -> Maybe [Text]
$sel:cacheClusterIds:BatchStopUpdateAction' :: BatchStopUpdateAction -> Maybe [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"BatchStopUpdateAction" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-02-02" :: Prelude.ByteString),
        ByteString
"CacheClusterIds"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
cacheClusterIds
            ),
        ByteString
"ReplicationGroupIds"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
replicationGroupIds
            ),
        ByteString
"ServiceUpdateName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
serviceUpdateName
      ]