{-# 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.StepFunctions.UpdateMapRun
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates an in-progress Map Run\'s configuration to include changes to
-- the settings that control maximum concurrency and Map Run failure.
module Amazonka.StepFunctions.UpdateMapRun
  ( -- * Creating a Request
    UpdateMapRun (..),
    newUpdateMapRun,

    -- * Request Lenses
    updateMapRun_maxConcurrency,
    updateMapRun_toleratedFailureCount,
    updateMapRun_toleratedFailurePercentage,
    updateMapRun_mapRunArn,

    -- * Destructuring the Response
    UpdateMapRunResponse (..),
    newUpdateMapRunResponse,

    -- * Response Lenses
    updateMapRunResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.StepFunctions.Types

-- | /See:/ 'newUpdateMapRun' smart constructor.
data UpdateMapRun = UpdateMapRun'
  { -- | The maximum number of child workflow executions that can be specified to
    -- run in parallel for the Map Run at the same time.
    UpdateMapRun -> Maybe Natural
maxConcurrency :: Prelude.Maybe Prelude.Natural,
    -- | The maximum number of failed items before the Map Run fails.
    UpdateMapRun -> Maybe Natural
toleratedFailureCount :: Prelude.Maybe Prelude.Natural,
    -- | The maximum percentage of failed items before the Map Run fails.
    UpdateMapRun -> Maybe Double
toleratedFailurePercentage :: Prelude.Maybe Prelude.Double,
    -- | The Amazon Resource Name (ARN) of a Map Run.
    UpdateMapRun -> Text
mapRunArn :: Prelude.Text
  }
  deriving (UpdateMapRun -> UpdateMapRun -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateMapRun -> UpdateMapRun -> Bool
$c/= :: UpdateMapRun -> UpdateMapRun -> Bool
== :: UpdateMapRun -> UpdateMapRun -> Bool
$c== :: UpdateMapRun -> UpdateMapRun -> Bool
Prelude.Eq, ReadPrec [UpdateMapRun]
ReadPrec UpdateMapRun
Int -> ReadS UpdateMapRun
ReadS [UpdateMapRun]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateMapRun]
$creadListPrec :: ReadPrec [UpdateMapRun]
readPrec :: ReadPrec UpdateMapRun
$creadPrec :: ReadPrec UpdateMapRun
readList :: ReadS [UpdateMapRun]
$creadList :: ReadS [UpdateMapRun]
readsPrec :: Int -> ReadS UpdateMapRun
$creadsPrec :: Int -> ReadS UpdateMapRun
Prelude.Read, Int -> UpdateMapRun -> ShowS
[UpdateMapRun] -> ShowS
UpdateMapRun -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateMapRun] -> ShowS
$cshowList :: [UpdateMapRun] -> ShowS
show :: UpdateMapRun -> String
$cshow :: UpdateMapRun -> String
showsPrec :: Int -> UpdateMapRun -> ShowS
$cshowsPrec :: Int -> UpdateMapRun -> ShowS
Prelude.Show, forall x. Rep UpdateMapRun x -> UpdateMapRun
forall x. UpdateMapRun -> Rep UpdateMapRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateMapRun x -> UpdateMapRun
$cfrom :: forall x. UpdateMapRun -> Rep UpdateMapRun x
Prelude.Generic)

-- |
-- Create a value of 'UpdateMapRun' 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:
--
-- 'maxConcurrency', 'updateMapRun_maxConcurrency' - The maximum number of child workflow executions that can be specified to
-- run in parallel for the Map Run at the same time.
--
-- 'toleratedFailureCount', 'updateMapRun_toleratedFailureCount' - The maximum number of failed items before the Map Run fails.
--
-- 'toleratedFailurePercentage', 'updateMapRun_toleratedFailurePercentage' - The maximum percentage of failed items before the Map Run fails.
--
-- 'mapRunArn', 'updateMapRun_mapRunArn' - The Amazon Resource Name (ARN) of a Map Run.
newUpdateMapRun ::
  -- | 'mapRunArn'
  Prelude.Text ->
  UpdateMapRun
newUpdateMapRun :: Text -> UpdateMapRun
newUpdateMapRun Text
pMapRunArn_ =
  UpdateMapRun'
    { $sel:maxConcurrency:UpdateMapRun' :: Maybe Natural
maxConcurrency = forall a. Maybe a
Prelude.Nothing,
      $sel:toleratedFailureCount:UpdateMapRun' :: Maybe Natural
toleratedFailureCount = forall a. Maybe a
Prelude.Nothing,
      $sel:toleratedFailurePercentage:UpdateMapRun' :: Maybe Double
toleratedFailurePercentage = forall a. Maybe a
Prelude.Nothing,
      $sel:mapRunArn:UpdateMapRun' :: Text
mapRunArn = Text
pMapRunArn_
    }

-- | The maximum number of child workflow executions that can be specified to
-- run in parallel for the Map Run at the same time.
updateMapRun_maxConcurrency :: Lens.Lens' UpdateMapRun (Prelude.Maybe Prelude.Natural)
updateMapRun_maxConcurrency :: Lens' UpdateMapRun (Maybe Natural)
updateMapRun_maxConcurrency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMapRun' {Maybe Natural
maxConcurrency :: Maybe Natural
$sel:maxConcurrency:UpdateMapRun' :: UpdateMapRun -> Maybe Natural
maxConcurrency} -> Maybe Natural
maxConcurrency) (\s :: UpdateMapRun
s@UpdateMapRun' {} Maybe Natural
a -> UpdateMapRun
s {$sel:maxConcurrency:UpdateMapRun' :: Maybe Natural
maxConcurrency = Maybe Natural
a} :: UpdateMapRun)

-- | The maximum number of failed items before the Map Run fails.
updateMapRun_toleratedFailureCount :: Lens.Lens' UpdateMapRun (Prelude.Maybe Prelude.Natural)
updateMapRun_toleratedFailureCount :: Lens' UpdateMapRun (Maybe Natural)
updateMapRun_toleratedFailureCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMapRun' {Maybe Natural
toleratedFailureCount :: Maybe Natural
$sel:toleratedFailureCount:UpdateMapRun' :: UpdateMapRun -> Maybe Natural
toleratedFailureCount} -> Maybe Natural
toleratedFailureCount) (\s :: UpdateMapRun
s@UpdateMapRun' {} Maybe Natural
a -> UpdateMapRun
s {$sel:toleratedFailureCount:UpdateMapRun' :: Maybe Natural
toleratedFailureCount = Maybe Natural
a} :: UpdateMapRun)

-- | The maximum percentage of failed items before the Map Run fails.
updateMapRun_toleratedFailurePercentage :: Lens.Lens' UpdateMapRun (Prelude.Maybe Prelude.Double)
updateMapRun_toleratedFailurePercentage :: Lens' UpdateMapRun (Maybe Double)
updateMapRun_toleratedFailurePercentage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMapRun' {Maybe Double
toleratedFailurePercentage :: Maybe Double
$sel:toleratedFailurePercentage:UpdateMapRun' :: UpdateMapRun -> Maybe Double
toleratedFailurePercentage} -> Maybe Double
toleratedFailurePercentage) (\s :: UpdateMapRun
s@UpdateMapRun' {} Maybe Double
a -> UpdateMapRun
s {$sel:toleratedFailurePercentage:UpdateMapRun' :: Maybe Double
toleratedFailurePercentage = Maybe Double
a} :: UpdateMapRun)

-- | The Amazon Resource Name (ARN) of a Map Run.
updateMapRun_mapRunArn :: Lens.Lens' UpdateMapRun Prelude.Text
updateMapRun_mapRunArn :: Lens' UpdateMapRun Text
updateMapRun_mapRunArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMapRun' {Text
mapRunArn :: Text
$sel:mapRunArn:UpdateMapRun' :: UpdateMapRun -> Text
mapRunArn} -> Text
mapRunArn) (\s :: UpdateMapRun
s@UpdateMapRun' {} Text
a -> UpdateMapRun
s {$sel:mapRunArn:UpdateMapRun' :: Text
mapRunArn = Text
a} :: UpdateMapRun)

instance Core.AWSRequest UpdateMapRun where
  type AWSResponse UpdateMapRun = UpdateMapRunResponse
  request :: (Service -> Service) -> UpdateMapRun -> Request UpdateMapRun
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateMapRun
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateMapRun)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateMapRunResponse
UpdateMapRunResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateMapRun where
  hashWithSalt :: Int -> UpdateMapRun -> Int
hashWithSalt Int
_salt UpdateMapRun' {Maybe Double
Maybe Natural
Text
mapRunArn :: Text
toleratedFailurePercentage :: Maybe Double
toleratedFailureCount :: Maybe Natural
maxConcurrency :: Maybe Natural
$sel:mapRunArn:UpdateMapRun' :: UpdateMapRun -> Text
$sel:toleratedFailurePercentage:UpdateMapRun' :: UpdateMapRun -> Maybe Double
$sel:toleratedFailureCount:UpdateMapRun' :: UpdateMapRun -> Maybe Natural
$sel:maxConcurrency:UpdateMapRun' :: UpdateMapRun -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxConcurrency
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
toleratedFailureCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
toleratedFailurePercentage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
mapRunArn

instance Prelude.NFData UpdateMapRun where
  rnf :: UpdateMapRun -> ()
rnf UpdateMapRun' {Maybe Double
Maybe Natural
Text
mapRunArn :: Text
toleratedFailurePercentage :: Maybe Double
toleratedFailureCount :: Maybe Natural
maxConcurrency :: Maybe Natural
$sel:mapRunArn:UpdateMapRun' :: UpdateMapRun -> Text
$sel:toleratedFailurePercentage:UpdateMapRun' :: UpdateMapRun -> Maybe Double
$sel:toleratedFailureCount:UpdateMapRun' :: UpdateMapRun -> Maybe Natural
$sel:maxConcurrency:UpdateMapRun' :: UpdateMapRun -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxConcurrency
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
toleratedFailureCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
toleratedFailurePercentage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
mapRunArn

instance Data.ToHeaders UpdateMapRun where
  toHeaders :: UpdateMapRun -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSStepFunctions.UpdateMapRun" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateMapRun where
  toJSON :: UpdateMapRun -> Value
toJSON UpdateMapRun' {Maybe Double
Maybe Natural
Text
mapRunArn :: Text
toleratedFailurePercentage :: Maybe Double
toleratedFailureCount :: Maybe Natural
maxConcurrency :: Maybe Natural
$sel:mapRunArn:UpdateMapRun' :: UpdateMapRun -> Text
$sel:toleratedFailurePercentage:UpdateMapRun' :: UpdateMapRun -> Maybe Double
$sel:toleratedFailureCount:UpdateMapRun' :: UpdateMapRun -> Maybe Natural
$sel:maxConcurrency:UpdateMapRun' :: UpdateMapRun -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxConcurrency" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxConcurrency,
            (Key
"toleratedFailureCount" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
toleratedFailureCount,
            (Key
"toleratedFailurePercentage" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
toleratedFailurePercentage,
            forall a. a -> Maybe a
Prelude.Just (Key
"mapRunArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
mapRunArn)
          ]
      )

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

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

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

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

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

instance Prelude.NFData UpdateMapRunResponse where
  rnf :: UpdateMapRunResponse -> ()
rnf UpdateMapRunResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateMapRunResponse' :: UpdateMapRunResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus