{-# 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.RemoveAutoScalingPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes an automatic scaling policy from a specified instance group
-- within an EMR cluster.
module Amazonka.EMR.RemoveAutoScalingPolicy
  ( -- * Creating a Request
    RemoveAutoScalingPolicy (..),
    newRemoveAutoScalingPolicy,

    -- * Request Lenses
    removeAutoScalingPolicy_clusterId,
    removeAutoScalingPolicy_instanceGroupId,

    -- * Destructuring the Response
    RemoveAutoScalingPolicyResponse (..),
    newRemoveAutoScalingPolicyResponse,

    -- * Response Lenses
    removeAutoScalingPolicyResponse_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:/ 'newRemoveAutoScalingPolicy' smart constructor.
data RemoveAutoScalingPolicy = RemoveAutoScalingPolicy'
  { -- | Specifies the ID of a cluster. The instance group to which the automatic
    -- scaling policy is applied is within this cluster.
    RemoveAutoScalingPolicy -> Text
clusterId :: Prelude.Text,
    -- | Specifies the ID of the instance group to which the scaling policy is
    -- applied.
    RemoveAutoScalingPolicy -> Text
instanceGroupId :: Prelude.Text
  }
  deriving (RemoveAutoScalingPolicy -> RemoveAutoScalingPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveAutoScalingPolicy -> RemoveAutoScalingPolicy -> Bool
$c/= :: RemoveAutoScalingPolicy -> RemoveAutoScalingPolicy -> Bool
== :: RemoveAutoScalingPolicy -> RemoveAutoScalingPolicy -> Bool
$c== :: RemoveAutoScalingPolicy -> RemoveAutoScalingPolicy -> Bool
Prelude.Eq, ReadPrec [RemoveAutoScalingPolicy]
ReadPrec RemoveAutoScalingPolicy
Int -> ReadS RemoveAutoScalingPolicy
ReadS [RemoveAutoScalingPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveAutoScalingPolicy]
$creadListPrec :: ReadPrec [RemoveAutoScalingPolicy]
readPrec :: ReadPrec RemoveAutoScalingPolicy
$creadPrec :: ReadPrec RemoveAutoScalingPolicy
readList :: ReadS [RemoveAutoScalingPolicy]
$creadList :: ReadS [RemoveAutoScalingPolicy]
readsPrec :: Int -> ReadS RemoveAutoScalingPolicy
$creadsPrec :: Int -> ReadS RemoveAutoScalingPolicy
Prelude.Read, Int -> RemoveAutoScalingPolicy -> ShowS
[RemoveAutoScalingPolicy] -> ShowS
RemoveAutoScalingPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveAutoScalingPolicy] -> ShowS
$cshowList :: [RemoveAutoScalingPolicy] -> ShowS
show :: RemoveAutoScalingPolicy -> String
$cshow :: RemoveAutoScalingPolicy -> String
showsPrec :: Int -> RemoveAutoScalingPolicy -> ShowS
$cshowsPrec :: Int -> RemoveAutoScalingPolicy -> ShowS
Prelude.Show, forall x. Rep RemoveAutoScalingPolicy x -> RemoveAutoScalingPolicy
forall x. RemoveAutoScalingPolicy -> Rep RemoveAutoScalingPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoveAutoScalingPolicy x -> RemoveAutoScalingPolicy
$cfrom :: forall x. RemoveAutoScalingPolicy -> Rep RemoveAutoScalingPolicy x
Prelude.Generic)

-- |
-- Create a value of 'RemoveAutoScalingPolicy' 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', 'removeAutoScalingPolicy_clusterId' - Specifies the ID of a cluster. The instance group to which the automatic
-- scaling policy is applied is within this cluster.
--
-- 'instanceGroupId', 'removeAutoScalingPolicy_instanceGroupId' - Specifies the ID of the instance group to which the scaling policy is
-- applied.
newRemoveAutoScalingPolicy ::
  -- | 'clusterId'
  Prelude.Text ->
  -- | 'instanceGroupId'
  Prelude.Text ->
  RemoveAutoScalingPolicy
newRemoveAutoScalingPolicy :: Text -> Text -> RemoveAutoScalingPolicy
newRemoveAutoScalingPolicy
  Text
pClusterId_
  Text
pInstanceGroupId_ =
    RemoveAutoScalingPolicy'
      { $sel:clusterId:RemoveAutoScalingPolicy' :: Text
clusterId = Text
pClusterId_,
        $sel:instanceGroupId:RemoveAutoScalingPolicy' :: Text
instanceGroupId = Text
pInstanceGroupId_
      }

-- | Specifies the ID of a cluster. The instance group to which the automatic
-- scaling policy is applied is within this cluster.
removeAutoScalingPolicy_clusterId :: Lens.Lens' RemoveAutoScalingPolicy Prelude.Text
removeAutoScalingPolicy_clusterId :: Lens' RemoveAutoScalingPolicy Text
removeAutoScalingPolicy_clusterId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveAutoScalingPolicy' {Text
clusterId :: Text
$sel:clusterId:RemoveAutoScalingPolicy' :: RemoveAutoScalingPolicy -> Text
clusterId} -> Text
clusterId) (\s :: RemoveAutoScalingPolicy
s@RemoveAutoScalingPolicy' {} Text
a -> RemoveAutoScalingPolicy
s {$sel:clusterId:RemoveAutoScalingPolicy' :: Text
clusterId = Text
a} :: RemoveAutoScalingPolicy)

-- | Specifies the ID of the instance group to which the scaling policy is
-- applied.
removeAutoScalingPolicy_instanceGroupId :: Lens.Lens' RemoveAutoScalingPolicy Prelude.Text
removeAutoScalingPolicy_instanceGroupId :: Lens' RemoveAutoScalingPolicy Text
removeAutoScalingPolicy_instanceGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveAutoScalingPolicy' {Text
instanceGroupId :: Text
$sel:instanceGroupId:RemoveAutoScalingPolicy' :: RemoveAutoScalingPolicy -> Text
instanceGroupId} -> Text
instanceGroupId) (\s :: RemoveAutoScalingPolicy
s@RemoveAutoScalingPolicy' {} Text
a -> RemoveAutoScalingPolicy
s {$sel:instanceGroupId:RemoveAutoScalingPolicy' :: Text
instanceGroupId = Text
a} :: RemoveAutoScalingPolicy)

instance Core.AWSRequest RemoveAutoScalingPolicy where
  type
    AWSResponse RemoveAutoScalingPolicy =
      RemoveAutoScalingPolicyResponse
  request :: (Service -> Service)
-> RemoveAutoScalingPolicy -> Request RemoveAutoScalingPolicy
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 RemoveAutoScalingPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveAutoScalingPolicy)))
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 -> RemoveAutoScalingPolicyResponse
RemoveAutoScalingPolicyResponse'
            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 RemoveAutoScalingPolicy where
  hashWithSalt :: Int -> RemoveAutoScalingPolicy -> Int
hashWithSalt Int
_salt RemoveAutoScalingPolicy' {Text
instanceGroupId :: Text
clusterId :: Text
$sel:instanceGroupId:RemoveAutoScalingPolicy' :: RemoveAutoScalingPolicy -> Text
$sel:clusterId:RemoveAutoScalingPolicy' :: RemoveAutoScalingPolicy -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceGroupId

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

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

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

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

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

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

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

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