{-# 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-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)
--
-- 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 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:/ '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
(RemoveAutoScalingPolicy -> RemoveAutoScalingPolicy -> Bool)
-> (RemoveAutoScalingPolicy -> RemoveAutoScalingPolicy -> Bool)
-> Eq RemoveAutoScalingPolicy
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]
(Int -> ReadS RemoveAutoScalingPolicy)
-> ReadS [RemoveAutoScalingPolicy]
-> ReadPrec RemoveAutoScalingPolicy
-> ReadPrec [RemoveAutoScalingPolicy]
-> Read 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
(Int -> RemoveAutoScalingPolicy -> ShowS)
-> (RemoveAutoScalingPolicy -> String)
-> ([RemoveAutoScalingPolicy] -> ShowS)
-> Show RemoveAutoScalingPolicy
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.
 RemoveAutoScalingPolicy -> Rep RemoveAutoScalingPolicy x)
-> (forall x.
    Rep RemoveAutoScalingPolicy x -> RemoveAutoScalingPolicy)
-> Generic RemoveAutoScalingPolicy
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' :: Text -> Text -> RemoveAutoScalingPolicy
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 :: (Text -> f Text)
-> RemoveAutoScalingPolicy -> f RemoveAutoScalingPolicy
removeAutoScalingPolicy_clusterId = (RemoveAutoScalingPolicy -> Text)
-> (RemoveAutoScalingPolicy -> Text -> RemoveAutoScalingPolicy)
-> Lens RemoveAutoScalingPolicy RemoveAutoScalingPolicy Text Text
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 :: (Text -> f Text)
-> RemoveAutoScalingPolicy -> f RemoveAutoScalingPolicy
removeAutoScalingPolicy_instanceGroupId = (RemoveAutoScalingPolicy -> Text)
-> (RemoveAutoScalingPolicy -> Text -> RemoveAutoScalingPolicy)
-> Lens RemoveAutoScalingPolicy RemoveAutoScalingPolicy Text Text
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 :: RemoveAutoScalingPolicy -> Request RemoveAutoScalingPolicy
request = Service
-> RemoveAutoScalingPolicy -> Request RemoveAutoScalingPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RemoveAutoScalingPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveAutoScalingPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse RemoveAutoScalingPolicy))
-> Logger
-> Service
-> Proxy RemoveAutoScalingPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveAutoScalingPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> RemoveAutoScalingPolicyResponse
RemoveAutoScalingPolicyResponse'
            (Int -> RemoveAutoScalingPolicyResponse)
-> Either String Int
-> Either String RemoveAutoScalingPolicyResponse
forall (f :: * -> *) a b. Functor 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 RemoveAutoScalingPolicy

instance Prelude.NFData RemoveAutoScalingPolicy

instance Core.ToHeaders RemoveAutoScalingPolicy where
  toHeaders :: RemoveAutoScalingPolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RemoveAutoScalingPolicy -> 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.RemoveAutoScalingPolicy" ::
                          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 RemoveAutoScalingPolicy where
  toJSON :: RemoveAutoScalingPolicy -> Value
toJSON RemoveAutoScalingPolicy' {Text
instanceGroupId :: Text
clusterId :: Text
$sel:instanceGroupId:RemoveAutoScalingPolicy' :: RemoveAutoScalingPolicy -> Text
$sel:clusterId:RemoveAutoScalingPolicy' :: RemoveAutoScalingPolicy -> 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
"InstanceGroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceGroupId)
          ]
      )

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

instance Core.ToQuery RemoveAutoScalingPolicy where
  toQuery :: RemoveAutoScalingPolicy -> QueryString
toQuery = QueryString -> RemoveAutoScalingPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(RemoveAutoScalingPolicyResponse
 -> RemoveAutoScalingPolicyResponse -> Bool)
-> (RemoveAutoScalingPolicyResponse
    -> RemoveAutoScalingPolicyResponse -> Bool)
-> Eq RemoveAutoScalingPolicyResponse
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]
(Int -> ReadS RemoveAutoScalingPolicyResponse)
-> ReadS [RemoveAutoScalingPolicyResponse]
-> ReadPrec RemoveAutoScalingPolicyResponse
-> ReadPrec [RemoveAutoScalingPolicyResponse]
-> Read 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
(Int -> RemoveAutoScalingPolicyResponse -> ShowS)
-> (RemoveAutoScalingPolicyResponse -> String)
-> ([RemoveAutoScalingPolicyResponse] -> ShowS)
-> Show RemoveAutoScalingPolicyResponse
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.
 RemoveAutoScalingPolicyResponse
 -> Rep RemoveAutoScalingPolicyResponse x)
-> (forall x.
    Rep RemoveAutoScalingPolicyResponse x
    -> RemoveAutoScalingPolicyResponse)
-> Generic RemoveAutoScalingPolicyResponse
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' :: Int -> RemoveAutoScalingPolicyResponse
RemoveAutoScalingPolicyResponse'
    { $sel:httpStatus:RemoveAutoScalingPolicyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
removeAutoScalingPolicyResponse_httpStatus :: Lens.Lens' RemoveAutoScalingPolicyResponse Prelude.Int
removeAutoScalingPolicyResponse_httpStatus :: (Int -> f Int)
-> RemoveAutoScalingPolicyResponse
-> f RemoveAutoScalingPolicyResponse
removeAutoScalingPolicyResponse_httpStatus = (RemoveAutoScalingPolicyResponse -> Int)
-> (RemoveAutoScalingPolicyResponse
    -> Int -> RemoveAutoScalingPolicyResponse)
-> Lens
     RemoveAutoScalingPolicyResponse
     RemoveAutoScalingPolicyResponse
     Int
     Int
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