{-# 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.GetAutoTerminationPolicy
-- 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)
--
-- Returns the auto-termination policy for an Amazon EMR cluster.
module Amazonka.EMR.GetAutoTerminationPolicy
  ( -- * Creating a Request
    GetAutoTerminationPolicy (..),
    newGetAutoTerminationPolicy,

    -- * Request Lenses
    getAutoTerminationPolicy_clusterId,

    -- * Destructuring the Response
    GetAutoTerminationPolicyResponse (..),
    newGetAutoTerminationPolicyResponse,

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

-- |
-- Create a value of 'GetAutoTerminationPolicy' 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', 'getAutoTerminationPolicy_clusterId' - Specifies the ID of the Amazon EMR cluster for which the
-- auto-termination policy will be fetched.
newGetAutoTerminationPolicy ::
  -- | 'clusterId'
  Prelude.Text ->
  GetAutoTerminationPolicy
newGetAutoTerminationPolicy :: Text -> GetAutoTerminationPolicy
newGetAutoTerminationPolicy Text
pClusterId_ =
  GetAutoTerminationPolicy' :: Text -> GetAutoTerminationPolicy
GetAutoTerminationPolicy' {$sel:clusterId:GetAutoTerminationPolicy' :: Text
clusterId = Text
pClusterId_}

-- | Specifies the ID of the Amazon EMR cluster for which the
-- auto-termination policy will be fetched.
getAutoTerminationPolicy_clusterId :: Lens.Lens' GetAutoTerminationPolicy Prelude.Text
getAutoTerminationPolicy_clusterId :: (Text -> f Text)
-> GetAutoTerminationPolicy -> f GetAutoTerminationPolicy
getAutoTerminationPolicy_clusterId = (GetAutoTerminationPolicy -> Text)
-> (GetAutoTerminationPolicy -> Text -> GetAutoTerminationPolicy)
-> Lens GetAutoTerminationPolicy GetAutoTerminationPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAutoTerminationPolicy' {Text
clusterId :: Text
$sel:clusterId:GetAutoTerminationPolicy' :: GetAutoTerminationPolicy -> Text
clusterId} -> Text
clusterId) (\s :: GetAutoTerminationPolicy
s@GetAutoTerminationPolicy' {} Text
a -> GetAutoTerminationPolicy
s {$sel:clusterId:GetAutoTerminationPolicy' :: Text
clusterId = Text
a} :: GetAutoTerminationPolicy)

instance Core.AWSRequest GetAutoTerminationPolicy where
  type
    AWSResponse GetAutoTerminationPolicy =
      GetAutoTerminationPolicyResponse
  request :: GetAutoTerminationPolicy -> Request GetAutoTerminationPolicy
request = Service
-> GetAutoTerminationPolicy -> Request GetAutoTerminationPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAutoTerminationPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAutoTerminationPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetAutoTerminationPolicy))
-> Logger
-> Service
-> Proxy GetAutoTerminationPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetAutoTerminationPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe AutoTerminationPolicy
-> Int -> GetAutoTerminationPolicyResponse
GetAutoTerminationPolicyResponse'
            (Maybe AutoTerminationPolicy
 -> Int -> GetAutoTerminationPolicyResponse)
-> Either String (Maybe AutoTerminationPolicy)
-> Either String (Int -> GetAutoTerminationPolicyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe AutoTerminationPolicy)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AutoTerminationPolicy")
            Either String (Int -> GetAutoTerminationPolicyResponse)
-> Either String Int
-> Either String GetAutoTerminationPolicyResponse
forall (f :: * -> *) a b. Applicative f => 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 GetAutoTerminationPolicy

instance Prelude.NFData GetAutoTerminationPolicy

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

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

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

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

-- |
-- Create a value of 'GetAutoTerminationPolicyResponse' 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:
--
-- 'autoTerminationPolicy', 'getAutoTerminationPolicyResponse_autoTerminationPolicy' - Specifies the auto-termination policy that is attached to an Amazon EMR
-- cluster.
--
-- 'httpStatus', 'getAutoTerminationPolicyResponse_httpStatus' - The response's http status code.
newGetAutoTerminationPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAutoTerminationPolicyResponse
newGetAutoTerminationPolicyResponse :: Int -> GetAutoTerminationPolicyResponse
newGetAutoTerminationPolicyResponse Int
pHttpStatus_ =
  GetAutoTerminationPolicyResponse' :: Maybe AutoTerminationPolicy
-> Int -> GetAutoTerminationPolicyResponse
GetAutoTerminationPolicyResponse'
    { $sel:autoTerminationPolicy:GetAutoTerminationPolicyResponse' :: Maybe AutoTerminationPolicy
autoTerminationPolicy =
        Maybe AutoTerminationPolicy
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAutoTerminationPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Specifies the auto-termination policy that is attached to an Amazon EMR
-- cluster.
getAutoTerminationPolicyResponse_autoTerminationPolicy :: Lens.Lens' GetAutoTerminationPolicyResponse (Prelude.Maybe AutoTerminationPolicy)
getAutoTerminationPolicyResponse_autoTerminationPolicy :: (Maybe AutoTerminationPolicy -> f (Maybe AutoTerminationPolicy))
-> GetAutoTerminationPolicyResponse
-> f GetAutoTerminationPolicyResponse
getAutoTerminationPolicyResponse_autoTerminationPolicy = (GetAutoTerminationPolicyResponse -> Maybe AutoTerminationPolicy)
-> (GetAutoTerminationPolicyResponse
    -> Maybe AutoTerminationPolicy -> GetAutoTerminationPolicyResponse)
-> Lens
     GetAutoTerminationPolicyResponse
     GetAutoTerminationPolicyResponse
     (Maybe AutoTerminationPolicy)
     (Maybe AutoTerminationPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAutoTerminationPolicyResponse' {Maybe AutoTerminationPolicy
autoTerminationPolicy :: Maybe AutoTerminationPolicy
$sel:autoTerminationPolicy:GetAutoTerminationPolicyResponse' :: GetAutoTerminationPolicyResponse -> Maybe AutoTerminationPolicy
autoTerminationPolicy} -> Maybe AutoTerminationPolicy
autoTerminationPolicy) (\s :: GetAutoTerminationPolicyResponse
s@GetAutoTerminationPolicyResponse' {} Maybe AutoTerminationPolicy
a -> GetAutoTerminationPolicyResponse
s {$sel:autoTerminationPolicy:GetAutoTerminationPolicyResponse' :: Maybe AutoTerminationPolicy
autoTerminationPolicy = Maybe AutoTerminationPolicy
a} :: GetAutoTerminationPolicyResponse)

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

instance
  Prelude.NFData
    GetAutoTerminationPolicyResponse