{-# 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.GetManagedScalingPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Fetches the attached managed scaling policy for an Amazon EMR cluster.
module Amazonka.EMR.GetManagedScalingPolicy
  ( -- * Creating a Request
    GetManagedScalingPolicy (..),
    newGetManagedScalingPolicy,

    -- * Request Lenses
    getManagedScalingPolicy_clusterId,

    -- * Destructuring the Response
    GetManagedScalingPolicyResponse (..),
    newGetManagedScalingPolicyResponse,

    -- * Response Lenses
    getManagedScalingPolicyResponse_managedScalingPolicy,
    getManagedScalingPolicyResponse_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:/ 'newGetManagedScalingPolicy' smart constructor.
data GetManagedScalingPolicy = GetManagedScalingPolicy'
  { -- | Specifies the ID of the cluster for which the managed scaling policy
    -- will be fetched.
    GetManagedScalingPolicy -> Text
clusterId :: Prelude.Text
  }
  deriving (GetManagedScalingPolicy -> GetManagedScalingPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetManagedScalingPolicy -> GetManagedScalingPolicy -> Bool
$c/= :: GetManagedScalingPolicy -> GetManagedScalingPolicy -> Bool
== :: GetManagedScalingPolicy -> GetManagedScalingPolicy -> Bool
$c== :: GetManagedScalingPolicy -> GetManagedScalingPolicy -> Bool
Prelude.Eq, ReadPrec [GetManagedScalingPolicy]
ReadPrec GetManagedScalingPolicy
Int -> ReadS GetManagedScalingPolicy
ReadS [GetManagedScalingPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetManagedScalingPolicy]
$creadListPrec :: ReadPrec [GetManagedScalingPolicy]
readPrec :: ReadPrec GetManagedScalingPolicy
$creadPrec :: ReadPrec GetManagedScalingPolicy
readList :: ReadS [GetManagedScalingPolicy]
$creadList :: ReadS [GetManagedScalingPolicy]
readsPrec :: Int -> ReadS GetManagedScalingPolicy
$creadsPrec :: Int -> ReadS GetManagedScalingPolicy
Prelude.Read, Int -> GetManagedScalingPolicy -> ShowS
[GetManagedScalingPolicy] -> ShowS
GetManagedScalingPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetManagedScalingPolicy] -> ShowS
$cshowList :: [GetManagedScalingPolicy] -> ShowS
show :: GetManagedScalingPolicy -> String
$cshow :: GetManagedScalingPolicy -> String
showsPrec :: Int -> GetManagedScalingPolicy -> ShowS
$cshowsPrec :: Int -> GetManagedScalingPolicy -> ShowS
Prelude.Show, forall x. Rep GetManagedScalingPolicy x -> GetManagedScalingPolicy
forall x. GetManagedScalingPolicy -> Rep GetManagedScalingPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetManagedScalingPolicy x -> GetManagedScalingPolicy
$cfrom :: forall x. GetManagedScalingPolicy -> Rep GetManagedScalingPolicy x
Prelude.Generic)

-- |
-- Create a value of 'GetManagedScalingPolicy' 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', 'getManagedScalingPolicy_clusterId' - Specifies the ID of the cluster for which the managed scaling policy
-- will be fetched.
newGetManagedScalingPolicy ::
  -- | 'clusterId'
  Prelude.Text ->
  GetManagedScalingPolicy
newGetManagedScalingPolicy :: Text -> GetManagedScalingPolicy
newGetManagedScalingPolicy Text
pClusterId_ =
  GetManagedScalingPolicy' {$sel:clusterId:GetManagedScalingPolicy' :: Text
clusterId = Text
pClusterId_}

-- | Specifies the ID of the cluster for which the managed scaling policy
-- will be fetched.
getManagedScalingPolicy_clusterId :: Lens.Lens' GetManagedScalingPolicy Prelude.Text
getManagedScalingPolicy_clusterId :: Lens' GetManagedScalingPolicy Text
getManagedScalingPolicy_clusterId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetManagedScalingPolicy' {Text
clusterId :: Text
$sel:clusterId:GetManagedScalingPolicy' :: GetManagedScalingPolicy -> Text
clusterId} -> Text
clusterId) (\s :: GetManagedScalingPolicy
s@GetManagedScalingPolicy' {} Text
a -> GetManagedScalingPolicy
s {$sel:clusterId:GetManagedScalingPolicy' :: Text
clusterId = Text
a} :: GetManagedScalingPolicy)

instance Core.AWSRequest GetManagedScalingPolicy where
  type
    AWSResponse GetManagedScalingPolicy =
      GetManagedScalingPolicyResponse
  request :: (Service -> Service)
-> GetManagedScalingPolicy -> Request GetManagedScalingPolicy
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 GetManagedScalingPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetManagedScalingPolicy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ManagedScalingPolicy
-> Int -> GetManagedScalingPolicyResponse
GetManagedScalingPolicyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ManagedScalingPolicy")
            forall (f :: * -> *) a b. Applicative f => 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 GetManagedScalingPolicy where
  hashWithSalt :: Int -> GetManagedScalingPolicy -> Int
hashWithSalt Int
_salt GetManagedScalingPolicy' {Text
clusterId :: Text
$sel:clusterId:GetManagedScalingPolicy' :: GetManagedScalingPolicy -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterId

instance Prelude.NFData GetManagedScalingPolicy where
  rnf :: GetManagedScalingPolicy -> ()
rnf GetManagedScalingPolicy' {Text
clusterId :: Text
$sel:clusterId:GetManagedScalingPolicy' :: GetManagedScalingPolicy -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
clusterId

instance Data.ToHeaders GetManagedScalingPolicy where
  toHeaders :: GetManagedScalingPolicy -> 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.GetManagedScalingPolicy" ::
                          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 GetManagedScalingPolicy where
  toJSON :: GetManagedScalingPolicy -> Value
toJSON GetManagedScalingPolicy' {Text
clusterId :: Text
$sel:clusterId:GetManagedScalingPolicy' :: GetManagedScalingPolicy -> 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)]
      )

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

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

-- | /See:/ 'newGetManagedScalingPolicyResponse' smart constructor.
data GetManagedScalingPolicyResponse = GetManagedScalingPolicyResponse'
  { -- | Specifies the managed scaling policy that is attached to an Amazon EMR
    -- cluster.
    GetManagedScalingPolicyResponse -> Maybe ManagedScalingPolicy
managedScalingPolicy :: Prelude.Maybe ManagedScalingPolicy,
    -- | The response's http status code.
    GetManagedScalingPolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetManagedScalingPolicyResponse
-> GetManagedScalingPolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetManagedScalingPolicyResponse
-> GetManagedScalingPolicyResponse -> Bool
$c/= :: GetManagedScalingPolicyResponse
-> GetManagedScalingPolicyResponse -> Bool
== :: GetManagedScalingPolicyResponse
-> GetManagedScalingPolicyResponse -> Bool
$c== :: GetManagedScalingPolicyResponse
-> GetManagedScalingPolicyResponse -> Bool
Prelude.Eq, ReadPrec [GetManagedScalingPolicyResponse]
ReadPrec GetManagedScalingPolicyResponse
Int -> ReadS GetManagedScalingPolicyResponse
ReadS [GetManagedScalingPolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetManagedScalingPolicyResponse]
$creadListPrec :: ReadPrec [GetManagedScalingPolicyResponse]
readPrec :: ReadPrec GetManagedScalingPolicyResponse
$creadPrec :: ReadPrec GetManagedScalingPolicyResponse
readList :: ReadS [GetManagedScalingPolicyResponse]
$creadList :: ReadS [GetManagedScalingPolicyResponse]
readsPrec :: Int -> ReadS GetManagedScalingPolicyResponse
$creadsPrec :: Int -> ReadS GetManagedScalingPolicyResponse
Prelude.Read, Int -> GetManagedScalingPolicyResponse -> ShowS
[GetManagedScalingPolicyResponse] -> ShowS
GetManagedScalingPolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetManagedScalingPolicyResponse] -> ShowS
$cshowList :: [GetManagedScalingPolicyResponse] -> ShowS
show :: GetManagedScalingPolicyResponse -> String
$cshow :: GetManagedScalingPolicyResponse -> String
showsPrec :: Int -> GetManagedScalingPolicyResponse -> ShowS
$cshowsPrec :: Int -> GetManagedScalingPolicyResponse -> ShowS
Prelude.Show, forall x.
Rep GetManagedScalingPolicyResponse x
-> GetManagedScalingPolicyResponse
forall x.
GetManagedScalingPolicyResponse
-> Rep GetManagedScalingPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetManagedScalingPolicyResponse x
-> GetManagedScalingPolicyResponse
$cfrom :: forall x.
GetManagedScalingPolicyResponse
-> Rep GetManagedScalingPolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetManagedScalingPolicyResponse' 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:
--
-- 'managedScalingPolicy', 'getManagedScalingPolicyResponse_managedScalingPolicy' - Specifies the managed scaling policy that is attached to an Amazon EMR
-- cluster.
--
-- 'httpStatus', 'getManagedScalingPolicyResponse_httpStatus' - The response's http status code.
newGetManagedScalingPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetManagedScalingPolicyResponse
newGetManagedScalingPolicyResponse :: Int -> GetManagedScalingPolicyResponse
newGetManagedScalingPolicyResponse Int
pHttpStatus_ =
  GetManagedScalingPolicyResponse'
    { $sel:managedScalingPolicy:GetManagedScalingPolicyResponse' :: Maybe ManagedScalingPolicy
managedScalingPolicy =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetManagedScalingPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Specifies the managed scaling policy that is attached to an Amazon EMR
-- cluster.
getManagedScalingPolicyResponse_managedScalingPolicy :: Lens.Lens' GetManagedScalingPolicyResponse (Prelude.Maybe ManagedScalingPolicy)
getManagedScalingPolicyResponse_managedScalingPolicy :: Lens' GetManagedScalingPolicyResponse (Maybe ManagedScalingPolicy)
getManagedScalingPolicyResponse_managedScalingPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetManagedScalingPolicyResponse' {Maybe ManagedScalingPolicy
managedScalingPolicy :: Maybe ManagedScalingPolicy
$sel:managedScalingPolicy:GetManagedScalingPolicyResponse' :: GetManagedScalingPolicyResponse -> Maybe ManagedScalingPolicy
managedScalingPolicy} -> Maybe ManagedScalingPolicy
managedScalingPolicy) (\s :: GetManagedScalingPolicyResponse
s@GetManagedScalingPolicyResponse' {} Maybe ManagedScalingPolicy
a -> GetManagedScalingPolicyResponse
s {$sel:managedScalingPolicy:GetManagedScalingPolicyResponse' :: Maybe ManagedScalingPolicy
managedScalingPolicy = Maybe ManagedScalingPolicy
a} :: GetManagedScalingPolicyResponse)

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

instance
  Prelude.NFData
    GetManagedScalingPolicyResponse
  where
  rnf :: GetManagedScalingPolicyResponse -> ()
rnf GetManagedScalingPolicyResponse' {Int
Maybe ManagedScalingPolicy
httpStatus :: Int
managedScalingPolicy :: Maybe ManagedScalingPolicy
$sel:httpStatus:GetManagedScalingPolicyResponse' :: GetManagedScalingPolicyResponse -> Int
$sel:managedScalingPolicy:GetManagedScalingPolicyResponse' :: GetManagedScalingPolicyResponse -> Maybe ManagedScalingPolicy
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ManagedScalingPolicy
managedScalingPolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus