{-# 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.ModifyInstanceFleet
-- 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 target On-Demand and target Spot capacities for the
-- instance fleet with the specified InstanceFleetID within the cluster
-- specified using ClusterID. The call either succeeds or fails atomically.
--
-- The instance fleet configuration is available only in Amazon EMR
-- versions 4.8.0 and later, excluding 5.0.x versions.
module Amazonka.EMR.ModifyInstanceFleet
  ( -- * Creating a Request
    ModifyInstanceFleet (..),
    newModifyInstanceFleet,

    -- * Request Lenses
    modifyInstanceFleet_clusterId,
    modifyInstanceFleet_instanceFleet,

    -- * Destructuring the Response
    ModifyInstanceFleetResponse (..),
    newModifyInstanceFleetResponse,
  )
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:/ 'newModifyInstanceFleet' smart constructor.
data ModifyInstanceFleet = ModifyInstanceFleet'
  { -- | The unique identifier of the cluster.
    ModifyInstanceFleet -> Text
clusterId :: Prelude.Text,
    -- | The configuration parameters of the instance fleet.
    ModifyInstanceFleet -> InstanceFleetModifyConfig
instanceFleet :: InstanceFleetModifyConfig
  }
  deriving (ModifyInstanceFleet -> ModifyInstanceFleet -> Bool
(ModifyInstanceFleet -> ModifyInstanceFleet -> Bool)
-> (ModifyInstanceFleet -> ModifyInstanceFleet -> Bool)
-> Eq ModifyInstanceFleet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyInstanceFleet -> ModifyInstanceFleet -> Bool
$c/= :: ModifyInstanceFleet -> ModifyInstanceFleet -> Bool
== :: ModifyInstanceFleet -> ModifyInstanceFleet -> Bool
$c== :: ModifyInstanceFleet -> ModifyInstanceFleet -> Bool
Prelude.Eq, ReadPrec [ModifyInstanceFleet]
ReadPrec ModifyInstanceFleet
Int -> ReadS ModifyInstanceFleet
ReadS [ModifyInstanceFleet]
(Int -> ReadS ModifyInstanceFleet)
-> ReadS [ModifyInstanceFleet]
-> ReadPrec ModifyInstanceFleet
-> ReadPrec [ModifyInstanceFleet]
-> Read ModifyInstanceFleet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyInstanceFleet]
$creadListPrec :: ReadPrec [ModifyInstanceFleet]
readPrec :: ReadPrec ModifyInstanceFleet
$creadPrec :: ReadPrec ModifyInstanceFleet
readList :: ReadS [ModifyInstanceFleet]
$creadList :: ReadS [ModifyInstanceFleet]
readsPrec :: Int -> ReadS ModifyInstanceFleet
$creadsPrec :: Int -> ReadS ModifyInstanceFleet
Prelude.Read, Int -> ModifyInstanceFleet -> ShowS
[ModifyInstanceFleet] -> ShowS
ModifyInstanceFleet -> String
(Int -> ModifyInstanceFleet -> ShowS)
-> (ModifyInstanceFleet -> String)
-> ([ModifyInstanceFleet] -> ShowS)
-> Show ModifyInstanceFleet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyInstanceFleet] -> ShowS
$cshowList :: [ModifyInstanceFleet] -> ShowS
show :: ModifyInstanceFleet -> String
$cshow :: ModifyInstanceFleet -> String
showsPrec :: Int -> ModifyInstanceFleet -> ShowS
$cshowsPrec :: Int -> ModifyInstanceFleet -> ShowS
Prelude.Show, (forall x. ModifyInstanceFleet -> Rep ModifyInstanceFleet x)
-> (forall x. Rep ModifyInstanceFleet x -> ModifyInstanceFleet)
-> Generic ModifyInstanceFleet
forall x. Rep ModifyInstanceFleet x -> ModifyInstanceFleet
forall x. ModifyInstanceFleet -> Rep ModifyInstanceFleet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyInstanceFleet x -> ModifyInstanceFleet
$cfrom :: forall x. ModifyInstanceFleet -> Rep ModifyInstanceFleet x
Prelude.Generic)

-- |
-- Create a value of 'ModifyInstanceFleet' 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', 'modifyInstanceFleet_clusterId' - The unique identifier of the cluster.
--
-- 'instanceFleet', 'modifyInstanceFleet_instanceFleet' - The configuration parameters of the instance fleet.
newModifyInstanceFleet ::
  -- | 'clusterId'
  Prelude.Text ->
  -- | 'instanceFleet'
  InstanceFleetModifyConfig ->
  ModifyInstanceFleet
newModifyInstanceFleet :: Text -> InstanceFleetModifyConfig -> ModifyInstanceFleet
newModifyInstanceFleet Text
pClusterId_ InstanceFleetModifyConfig
pInstanceFleet_ =
  ModifyInstanceFleet' :: Text -> InstanceFleetModifyConfig -> ModifyInstanceFleet
ModifyInstanceFleet'
    { $sel:clusterId:ModifyInstanceFleet' :: Text
clusterId = Text
pClusterId_,
      $sel:instanceFleet:ModifyInstanceFleet' :: InstanceFleetModifyConfig
instanceFleet = InstanceFleetModifyConfig
pInstanceFleet_
    }

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

-- | The configuration parameters of the instance fleet.
modifyInstanceFleet_instanceFleet :: Lens.Lens' ModifyInstanceFleet InstanceFleetModifyConfig
modifyInstanceFleet_instanceFleet :: (InstanceFleetModifyConfig -> f InstanceFleetModifyConfig)
-> ModifyInstanceFleet -> f ModifyInstanceFleet
modifyInstanceFleet_instanceFleet = (ModifyInstanceFleet -> InstanceFleetModifyConfig)
-> (ModifyInstanceFleet
    -> InstanceFleetModifyConfig -> ModifyInstanceFleet)
-> Lens
     ModifyInstanceFleet
     ModifyInstanceFleet
     InstanceFleetModifyConfig
     InstanceFleetModifyConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyInstanceFleet' {InstanceFleetModifyConfig
instanceFleet :: InstanceFleetModifyConfig
$sel:instanceFleet:ModifyInstanceFleet' :: ModifyInstanceFleet -> InstanceFleetModifyConfig
instanceFleet} -> InstanceFleetModifyConfig
instanceFleet) (\s :: ModifyInstanceFleet
s@ModifyInstanceFleet' {} InstanceFleetModifyConfig
a -> ModifyInstanceFleet
s {$sel:instanceFleet:ModifyInstanceFleet' :: InstanceFleetModifyConfig
instanceFleet = InstanceFleetModifyConfig
a} :: ModifyInstanceFleet)

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

instance Prelude.Hashable ModifyInstanceFleet

instance Prelude.NFData ModifyInstanceFleet

instance Core.ToHeaders ModifyInstanceFleet where
  toHeaders :: ModifyInstanceFleet -> [Header]
toHeaders =
    [Header] -> ModifyInstanceFleet -> [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.ModifyInstanceFleet" ::
                          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 ModifyInstanceFleet where
  toJSON :: ModifyInstanceFleet -> Value
toJSON ModifyInstanceFleet' {Text
InstanceFleetModifyConfig
instanceFleet :: InstanceFleetModifyConfig
clusterId :: Text
$sel:instanceFleet:ModifyInstanceFleet' :: ModifyInstanceFleet -> InstanceFleetModifyConfig
$sel:clusterId:ModifyInstanceFleet' :: ModifyInstanceFleet -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"InstanceFleet" Text -> InstanceFleetModifyConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InstanceFleetModifyConfig
instanceFleet)
          ]
      )

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

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

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

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

instance Prelude.NFData ModifyInstanceFleetResponse