{-# 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.ModifyInstanceGroups
-- 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)
--
-- ModifyInstanceGroups modifies the number of nodes and configuration
-- settings of an instance group. The input parameters include the new
-- target instance count for the group and the instance group ID. The call
-- will either succeed or fail atomically.
module Amazonka.EMR.ModifyInstanceGroups
  ( -- * Creating a Request
    ModifyInstanceGroups (..),
    newModifyInstanceGroups,

    -- * Request Lenses
    modifyInstanceGroups_clusterId,
    modifyInstanceGroups_instanceGroups,

    -- * Destructuring the Response
    ModifyInstanceGroupsResponse (..),
    newModifyInstanceGroupsResponse,
  )
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

-- | Change the size of some instance groups.
--
-- /See:/ 'newModifyInstanceGroups' smart constructor.
data ModifyInstanceGroups = ModifyInstanceGroups'
  { -- | The ID of the cluster to which the instance group belongs.
    ModifyInstanceGroups -> Maybe Text
clusterId :: Prelude.Maybe Prelude.Text,
    -- | Instance groups to change.
    ModifyInstanceGroups -> Maybe [InstanceGroupModifyConfig]
instanceGroups :: Prelude.Maybe [InstanceGroupModifyConfig]
  }
  deriving (ModifyInstanceGroups -> ModifyInstanceGroups -> Bool
(ModifyInstanceGroups -> ModifyInstanceGroups -> Bool)
-> (ModifyInstanceGroups -> ModifyInstanceGroups -> Bool)
-> Eq ModifyInstanceGroups
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyInstanceGroups -> ModifyInstanceGroups -> Bool
$c/= :: ModifyInstanceGroups -> ModifyInstanceGroups -> Bool
== :: ModifyInstanceGroups -> ModifyInstanceGroups -> Bool
$c== :: ModifyInstanceGroups -> ModifyInstanceGroups -> Bool
Prelude.Eq, ReadPrec [ModifyInstanceGroups]
ReadPrec ModifyInstanceGroups
Int -> ReadS ModifyInstanceGroups
ReadS [ModifyInstanceGroups]
(Int -> ReadS ModifyInstanceGroups)
-> ReadS [ModifyInstanceGroups]
-> ReadPrec ModifyInstanceGroups
-> ReadPrec [ModifyInstanceGroups]
-> Read ModifyInstanceGroups
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyInstanceGroups]
$creadListPrec :: ReadPrec [ModifyInstanceGroups]
readPrec :: ReadPrec ModifyInstanceGroups
$creadPrec :: ReadPrec ModifyInstanceGroups
readList :: ReadS [ModifyInstanceGroups]
$creadList :: ReadS [ModifyInstanceGroups]
readsPrec :: Int -> ReadS ModifyInstanceGroups
$creadsPrec :: Int -> ReadS ModifyInstanceGroups
Prelude.Read, Int -> ModifyInstanceGroups -> ShowS
[ModifyInstanceGroups] -> ShowS
ModifyInstanceGroups -> String
(Int -> ModifyInstanceGroups -> ShowS)
-> (ModifyInstanceGroups -> String)
-> ([ModifyInstanceGroups] -> ShowS)
-> Show ModifyInstanceGroups
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyInstanceGroups] -> ShowS
$cshowList :: [ModifyInstanceGroups] -> ShowS
show :: ModifyInstanceGroups -> String
$cshow :: ModifyInstanceGroups -> String
showsPrec :: Int -> ModifyInstanceGroups -> ShowS
$cshowsPrec :: Int -> ModifyInstanceGroups -> ShowS
Prelude.Show, (forall x. ModifyInstanceGroups -> Rep ModifyInstanceGroups x)
-> (forall x. Rep ModifyInstanceGroups x -> ModifyInstanceGroups)
-> Generic ModifyInstanceGroups
forall x. Rep ModifyInstanceGroups x -> ModifyInstanceGroups
forall x. ModifyInstanceGroups -> Rep ModifyInstanceGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyInstanceGroups x -> ModifyInstanceGroups
$cfrom :: forall x. ModifyInstanceGroups -> Rep ModifyInstanceGroups x
Prelude.Generic)

-- |
-- Create a value of 'ModifyInstanceGroups' 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:
--
-- 'clusterId', 'modifyInstanceGroups_clusterId' - The ID of the cluster to which the instance group belongs.
--
-- 'instanceGroups', 'modifyInstanceGroups_instanceGroups' - Instance groups to change.
newModifyInstanceGroups ::
  ModifyInstanceGroups
newModifyInstanceGroups :: ModifyInstanceGroups
newModifyInstanceGroups =
  ModifyInstanceGroups' :: Maybe Text
-> Maybe [InstanceGroupModifyConfig] -> ModifyInstanceGroups
ModifyInstanceGroups'
    { $sel:clusterId:ModifyInstanceGroups' :: Maybe Text
clusterId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceGroups:ModifyInstanceGroups' :: Maybe [InstanceGroupModifyConfig]
instanceGroups = Maybe [InstanceGroupModifyConfig]
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the cluster to which the instance group belongs.
modifyInstanceGroups_clusterId :: Lens.Lens' ModifyInstanceGroups (Prelude.Maybe Prelude.Text)
modifyInstanceGroups_clusterId :: (Maybe Text -> f (Maybe Text))
-> ModifyInstanceGroups -> f ModifyInstanceGroups
modifyInstanceGroups_clusterId = (ModifyInstanceGroups -> Maybe Text)
-> (ModifyInstanceGroups -> Maybe Text -> ModifyInstanceGroups)
-> Lens
     ModifyInstanceGroups ModifyInstanceGroups (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyInstanceGroups' {Maybe Text
clusterId :: Maybe Text
$sel:clusterId:ModifyInstanceGroups' :: ModifyInstanceGroups -> Maybe Text
clusterId} -> Maybe Text
clusterId) (\s :: ModifyInstanceGroups
s@ModifyInstanceGroups' {} Maybe Text
a -> ModifyInstanceGroups
s {$sel:clusterId:ModifyInstanceGroups' :: Maybe Text
clusterId = Maybe Text
a} :: ModifyInstanceGroups)

-- | Instance groups to change.
modifyInstanceGroups_instanceGroups :: Lens.Lens' ModifyInstanceGroups (Prelude.Maybe [InstanceGroupModifyConfig])
modifyInstanceGroups_instanceGroups :: (Maybe [InstanceGroupModifyConfig]
 -> f (Maybe [InstanceGroupModifyConfig]))
-> ModifyInstanceGroups -> f ModifyInstanceGroups
modifyInstanceGroups_instanceGroups = (ModifyInstanceGroups -> Maybe [InstanceGroupModifyConfig])
-> (ModifyInstanceGroups
    -> Maybe [InstanceGroupModifyConfig] -> ModifyInstanceGroups)
-> Lens
     ModifyInstanceGroups
     ModifyInstanceGroups
     (Maybe [InstanceGroupModifyConfig])
     (Maybe [InstanceGroupModifyConfig])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyInstanceGroups' {Maybe [InstanceGroupModifyConfig]
instanceGroups :: Maybe [InstanceGroupModifyConfig]
$sel:instanceGroups:ModifyInstanceGroups' :: ModifyInstanceGroups -> Maybe [InstanceGroupModifyConfig]
instanceGroups} -> Maybe [InstanceGroupModifyConfig]
instanceGroups) (\s :: ModifyInstanceGroups
s@ModifyInstanceGroups' {} Maybe [InstanceGroupModifyConfig]
a -> ModifyInstanceGroups
s {$sel:instanceGroups:ModifyInstanceGroups' :: Maybe [InstanceGroupModifyConfig]
instanceGroups = Maybe [InstanceGroupModifyConfig]
a} :: ModifyInstanceGroups) ((Maybe [InstanceGroupModifyConfig]
  -> f (Maybe [InstanceGroupModifyConfig]))
 -> ModifyInstanceGroups -> f ModifyInstanceGroups)
-> ((Maybe [InstanceGroupModifyConfig]
     -> f (Maybe [InstanceGroupModifyConfig]))
    -> Maybe [InstanceGroupModifyConfig]
    -> f (Maybe [InstanceGroupModifyConfig]))
-> (Maybe [InstanceGroupModifyConfig]
    -> f (Maybe [InstanceGroupModifyConfig]))
-> ModifyInstanceGroups
-> f ModifyInstanceGroups
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [InstanceGroupModifyConfig]
  [InstanceGroupModifyConfig]
  [InstanceGroupModifyConfig]
  [InstanceGroupModifyConfig]
-> Iso
     (Maybe [InstanceGroupModifyConfig])
     (Maybe [InstanceGroupModifyConfig])
     (Maybe [InstanceGroupModifyConfig])
     (Maybe [InstanceGroupModifyConfig])
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
  [InstanceGroupModifyConfig]
  [InstanceGroupModifyConfig]
  [InstanceGroupModifyConfig]
  [InstanceGroupModifyConfig]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ModifyInstanceGroups

instance Prelude.NFData ModifyInstanceGroups

instance Core.ToHeaders ModifyInstanceGroups where
  toHeaders :: ModifyInstanceGroups -> [Header]
toHeaders =
    [Header] -> ModifyInstanceGroups -> [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
"ElasticMapReduce.ModifyInstanceGroups" ::
                          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 ModifyInstanceGroups where
  toJSON :: ModifyInstanceGroups -> Value
toJSON ModifyInstanceGroups' {Maybe [InstanceGroupModifyConfig]
Maybe Text
instanceGroups :: Maybe [InstanceGroupModifyConfig]
clusterId :: Maybe Text
$sel:instanceGroups:ModifyInstanceGroups' :: ModifyInstanceGroups -> Maybe [InstanceGroupModifyConfig]
$sel:clusterId:ModifyInstanceGroups' :: ModifyInstanceGroups -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ClusterId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clusterId,
            (Text
"InstanceGroups" Text -> [InstanceGroupModifyConfig] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([InstanceGroupModifyConfig] -> Pair)
-> Maybe [InstanceGroupModifyConfig] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [InstanceGroupModifyConfig]
instanceGroups
          ]
      )

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

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

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

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

instance Prelude.NFData ModifyInstanceGroupsResponse