{-# 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.EMR.ModifyCluster
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Modifies the number of steps that can be executed concurrently for the
-- cluster specified using ClusterID.
module Amazonka.EMR.ModifyCluster
  ( -- * Creating a Request
    ModifyCluster (..),
    newModifyCluster,

    -- * Request Lenses
    modifyCluster_stepConcurrencyLevel,
    modifyCluster_clusterId,

    -- * Destructuring the Response
    ModifyClusterResponse (..),
    newModifyClusterResponse,

    -- * Response Lenses
    modifyClusterResponse_stepConcurrencyLevel,
    modifyClusterResponse_httpStatus,
  )
where

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

-- | /See:/ 'newModifyCluster' smart constructor.
data ModifyCluster = ModifyCluster'
  { -- | The number of steps that can be executed concurrently. You can specify a
    -- minimum of 1 step and a maximum of 256 steps. We recommend that you do
    -- not change this parameter while steps are running or the
    -- @ActionOnFailure@ setting may not behave as expected. For more
    -- information see Step$ActionOnFailure.
    ModifyCluster -> Maybe Int
stepConcurrencyLevel :: Prelude.Maybe Prelude.Int,
    -- | The unique identifier of the cluster.
    ModifyCluster -> Text
clusterId :: Prelude.Text
  }
  deriving (ModifyCluster -> ModifyCluster -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyCluster -> ModifyCluster -> Bool
$c/= :: ModifyCluster -> ModifyCluster -> Bool
== :: ModifyCluster -> ModifyCluster -> Bool
$c== :: ModifyCluster -> ModifyCluster -> Bool
Prelude.Eq, ReadPrec [ModifyCluster]
ReadPrec ModifyCluster
Int -> ReadS ModifyCluster
ReadS [ModifyCluster]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyCluster]
$creadListPrec :: ReadPrec [ModifyCluster]
readPrec :: ReadPrec ModifyCluster
$creadPrec :: ReadPrec ModifyCluster
readList :: ReadS [ModifyCluster]
$creadList :: ReadS [ModifyCluster]
readsPrec :: Int -> ReadS ModifyCluster
$creadsPrec :: Int -> ReadS ModifyCluster
Prelude.Read, Int -> ModifyCluster -> ShowS
[ModifyCluster] -> ShowS
ModifyCluster -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyCluster] -> ShowS
$cshowList :: [ModifyCluster] -> ShowS
show :: ModifyCluster -> String
$cshow :: ModifyCluster -> String
showsPrec :: Int -> ModifyCluster -> ShowS
$cshowsPrec :: Int -> ModifyCluster -> ShowS
Prelude.Show, forall x. Rep ModifyCluster x -> ModifyCluster
forall x. ModifyCluster -> Rep ModifyCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyCluster x -> ModifyCluster
$cfrom :: forall x. ModifyCluster -> Rep ModifyCluster x
Prelude.Generic)

-- |
-- Create a value of 'ModifyCluster' 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:
--
-- 'stepConcurrencyLevel', 'modifyCluster_stepConcurrencyLevel' - The number of steps that can be executed concurrently. You can specify a
-- minimum of 1 step and a maximum of 256 steps. We recommend that you do
-- not change this parameter while steps are running or the
-- @ActionOnFailure@ setting may not behave as expected. For more
-- information see Step$ActionOnFailure.
--
-- 'clusterId', 'modifyCluster_clusterId' - The unique identifier of the cluster.
newModifyCluster ::
  -- | 'clusterId'
  Prelude.Text ->
  ModifyCluster
newModifyCluster :: Text -> ModifyCluster
newModifyCluster Text
pClusterId_ =
  ModifyCluster'
    { $sel:stepConcurrencyLevel:ModifyCluster' :: Maybe Int
stepConcurrencyLevel =
        forall a. Maybe a
Prelude.Nothing,
      $sel:clusterId:ModifyCluster' :: Text
clusterId = Text
pClusterId_
    }

-- | The number of steps that can be executed concurrently. You can specify a
-- minimum of 1 step and a maximum of 256 steps. We recommend that you do
-- not change this parameter while steps are running or the
-- @ActionOnFailure@ setting may not behave as expected. For more
-- information see Step$ActionOnFailure.
modifyCluster_stepConcurrencyLevel :: Lens.Lens' ModifyCluster (Prelude.Maybe Prelude.Int)
modifyCluster_stepConcurrencyLevel :: Lens' ModifyCluster (Maybe Int)
modifyCluster_stepConcurrencyLevel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyCluster' {Maybe Int
stepConcurrencyLevel :: Maybe Int
$sel:stepConcurrencyLevel:ModifyCluster' :: ModifyCluster -> Maybe Int
stepConcurrencyLevel} -> Maybe Int
stepConcurrencyLevel) (\s :: ModifyCluster
s@ModifyCluster' {} Maybe Int
a -> ModifyCluster
s {$sel:stepConcurrencyLevel:ModifyCluster' :: Maybe Int
stepConcurrencyLevel = Maybe Int
a} :: ModifyCluster)

-- | The unique identifier of the cluster.
modifyCluster_clusterId :: Lens.Lens' ModifyCluster Prelude.Text
modifyCluster_clusterId :: Lens' ModifyCluster Text
modifyCluster_clusterId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyCluster' {Text
clusterId :: Text
$sel:clusterId:ModifyCluster' :: ModifyCluster -> Text
clusterId} -> Text
clusterId) (\s :: ModifyCluster
s@ModifyCluster' {} Text
a -> ModifyCluster
s {$sel:clusterId:ModifyCluster' :: Text
clusterId = Text
a} :: ModifyCluster)

instance Core.AWSRequest ModifyCluster where
  type
    AWSResponse ModifyCluster =
      ModifyClusterResponse
  request :: (Service -> Service) -> ModifyCluster -> Request ModifyCluster
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 ModifyCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ModifyCluster)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Int -> Int -> ModifyClusterResponse
ModifyClusterResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"StepConcurrencyLevel")
            forall (f :: * -> *) a b. Applicative f => 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 ModifyCluster where
  hashWithSalt :: Int -> ModifyCluster -> Int
hashWithSalt Int
_salt ModifyCluster' {Maybe Int
Text
clusterId :: Text
stepConcurrencyLevel :: Maybe Int
$sel:clusterId:ModifyCluster' :: ModifyCluster -> Text
$sel:stepConcurrencyLevel:ModifyCluster' :: ModifyCluster -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
stepConcurrencyLevel
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterId

instance Prelude.NFData ModifyCluster where
  rnf :: ModifyCluster -> ()
rnf ModifyCluster' {Maybe Int
Text
clusterId :: Text
stepConcurrencyLevel :: Maybe Int
$sel:clusterId:ModifyCluster' :: ModifyCluster -> Text
$sel:stepConcurrencyLevel:ModifyCluster' :: ModifyCluster -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
stepConcurrencyLevel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
clusterId

instance Data.ToHeaders ModifyCluster where
  toHeaders :: ModifyCluster -> 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
"ElasticMapReduce.ModifyCluster" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ModifyCluster where
  toJSON :: ModifyCluster -> Value
toJSON ModifyCluster' {Maybe Int
Text
clusterId :: Text
stepConcurrencyLevel :: Maybe Int
$sel:clusterId:ModifyCluster' :: ModifyCluster -> Text
$sel:stepConcurrencyLevel:ModifyCluster' :: ModifyCluster -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"StepConcurrencyLevel" 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 Int
stepConcurrencyLevel,
            forall a. a -> Maybe a
Prelude.Just (Key
"ClusterId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clusterId)
          ]
      )

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

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

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

-- |
-- Create a value of 'ModifyClusterResponse' 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:
--
-- 'stepConcurrencyLevel', 'modifyClusterResponse_stepConcurrencyLevel' - The number of steps that can be executed concurrently.
--
-- 'httpStatus', 'modifyClusterResponse_httpStatus' - The response's http status code.
newModifyClusterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ModifyClusterResponse
newModifyClusterResponse :: Int -> ModifyClusterResponse
newModifyClusterResponse Int
pHttpStatus_ =
  ModifyClusterResponse'
    { $sel:stepConcurrencyLevel:ModifyClusterResponse' :: Maybe Int
stepConcurrencyLevel =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ModifyClusterResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The number of steps that can be executed concurrently.
modifyClusterResponse_stepConcurrencyLevel :: Lens.Lens' ModifyClusterResponse (Prelude.Maybe Prelude.Int)
modifyClusterResponse_stepConcurrencyLevel :: Lens' ModifyClusterResponse (Maybe Int)
modifyClusterResponse_stepConcurrencyLevel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyClusterResponse' {Maybe Int
stepConcurrencyLevel :: Maybe Int
$sel:stepConcurrencyLevel:ModifyClusterResponse' :: ModifyClusterResponse -> Maybe Int
stepConcurrencyLevel} -> Maybe Int
stepConcurrencyLevel) (\s :: ModifyClusterResponse
s@ModifyClusterResponse' {} Maybe Int
a -> ModifyClusterResponse
s {$sel:stepConcurrencyLevel:ModifyClusterResponse' :: Maybe Int
stepConcurrencyLevel = Maybe Int
a} :: ModifyClusterResponse)

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

instance Prelude.NFData ModifyClusterResponse where
  rnf :: ModifyClusterResponse -> ()
rnf ModifyClusterResponse' {Int
Maybe Int
httpStatus :: Int
stepConcurrencyLevel :: Maybe Int
$sel:httpStatus:ModifyClusterResponse' :: ModifyClusterResponse -> Int
$sel:stepConcurrencyLevel:ModifyClusterResponse' :: ModifyClusterResponse -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
stepConcurrencyLevel
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus