{-# 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-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)
--
-- 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 Amazonka.EMR.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:/ '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
(ModifyCluster -> ModifyCluster -> Bool)
-> (ModifyCluster -> ModifyCluster -> Bool) -> Eq ModifyCluster
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]
(Int -> ReadS ModifyCluster)
-> ReadS [ModifyCluster]
-> ReadPrec ModifyCluster
-> ReadPrec [ModifyCluster]
-> Read 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
(Int -> ModifyCluster -> ShowS)
-> (ModifyCluster -> String)
-> ([ModifyCluster] -> ShowS)
-> Show ModifyCluster
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. ModifyCluster -> Rep ModifyCluster x)
-> (forall x. Rep ModifyCluster x -> ModifyCluster)
-> Generic ModifyCluster
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' :: Maybe Int -> Text -> ModifyCluster
ModifyCluster'
    { $sel:stepConcurrencyLevel:ModifyCluster' :: Maybe Int
stepConcurrencyLevel =
        Maybe Int
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 :: (Maybe Int -> f (Maybe Int)) -> ModifyCluster -> f ModifyCluster
modifyCluster_stepConcurrencyLevel = (ModifyCluster -> Maybe Int)
-> (ModifyCluster -> Maybe Int -> ModifyCluster)
-> Lens ModifyCluster ModifyCluster (Maybe Int) (Maybe Int)
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 :: (Text -> f Text) -> ModifyCluster -> f ModifyCluster
modifyCluster_clusterId = (ModifyCluster -> Text)
-> (ModifyCluster -> Text -> ModifyCluster)
-> Lens ModifyCluster ModifyCluster Text Text
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 :: ModifyCluster -> Request ModifyCluster
request = Service -> ModifyCluster -> Request ModifyCluster
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ModifyCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ModifyCluster)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ModifyCluster))
-> Logger
-> Service
-> Proxy ModifyCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ModifyCluster)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Int -> Int -> ModifyClusterResponse
ModifyClusterResponse'
            (Maybe Int -> Int -> ModifyClusterResponse)
-> Either String (Maybe Int)
-> Either String (Int -> ModifyClusterResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Int)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"StepConcurrencyLevel")
            Either String (Int -> ModifyClusterResponse)
-> Either String Int -> Either String ModifyClusterResponse
forall (f :: * -> *) a b. Applicative f => 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 ModifyCluster

instance Prelude.NFData ModifyCluster

instance Core.ToHeaders ModifyCluster where
  toHeaders :: ModifyCluster -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ModifyCluster -> 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
"ElasticMapReduce.ModifyCluster" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StepConcurrencyLevel" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
stepConcurrencyLevel,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ClusterId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clusterId)
          ]
      )

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

instance Core.ToQuery ModifyCluster where
  toQuery :: ModifyCluster -> QueryString
toQuery = QueryString -> ModifyCluster -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(ModifyClusterResponse -> ModifyClusterResponse -> Bool)
-> (ModifyClusterResponse -> ModifyClusterResponse -> Bool)
-> Eq ModifyClusterResponse
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]
(Int -> ReadS ModifyClusterResponse)
-> ReadS [ModifyClusterResponse]
-> ReadPrec ModifyClusterResponse
-> ReadPrec [ModifyClusterResponse]
-> Read 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
(Int -> ModifyClusterResponse -> ShowS)
-> (ModifyClusterResponse -> String)
-> ([ModifyClusterResponse] -> ShowS)
-> Show ModifyClusterResponse
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. ModifyClusterResponse -> Rep ModifyClusterResponse x)
-> (forall x. Rep ModifyClusterResponse x -> ModifyClusterResponse)
-> Generic ModifyClusterResponse
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' :: Maybe Int -> Int -> ModifyClusterResponse
ModifyClusterResponse'
    { $sel:stepConcurrencyLevel:ModifyClusterResponse' :: Maybe Int
stepConcurrencyLevel =
        Maybe Int
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 :: (Maybe Int -> f (Maybe Int))
-> ModifyClusterResponse -> f ModifyClusterResponse
modifyClusterResponse_stepConcurrencyLevel = (ModifyClusterResponse -> Maybe Int)
-> (ModifyClusterResponse -> Maybe Int -> ModifyClusterResponse)
-> Lens
     ModifyClusterResponse ModifyClusterResponse (Maybe Int) (Maybe Int)
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 :: (Int -> f Int) -> ModifyClusterResponse -> f ModifyClusterResponse
modifyClusterResponse_httpStatus = (ModifyClusterResponse -> Int)
-> (ModifyClusterResponse -> Int -> ModifyClusterResponse)
-> Lens ModifyClusterResponse ModifyClusterResponse Int Int
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