{-# 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.DescribeCluster
-- 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)
--
-- Provides cluster-level details including status, hardware and software
-- configuration, VPC settings, and so on.
module Amazonka.EMR.DescribeCluster
  ( -- * Creating a Request
    DescribeCluster (..),
    newDescribeCluster,

    -- * Request Lenses
    describeCluster_clusterId,

    -- * Destructuring the Response
    DescribeClusterResponse (..),
    newDescribeClusterResponse,

    -- * Response Lenses
    describeClusterResponse_httpStatus,
    describeClusterResponse_cluster,
  )
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

-- | This input determines which cluster to describe.
--
-- /See:/ 'newDescribeCluster' smart constructor.
data DescribeCluster = DescribeCluster'
  { -- | The identifier of the cluster to describe.
    DescribeCluster -> Text
clusterId :: Prelude.Text
  }
  deriving (DescribeCluster -> DescribeCluster -> Bool
(DescribeCluster -> DescribeCluster -> Bool)
-> (DescribeCluster -> DescribeCluster -> Bool)
-> Eq DescribeCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCluster -> DescribeCluster -> Bool
$c/= :: DescribeCluster -> DescribeCluster -> Bool
== :: DescribeCluster -> DescribeCluster -> Bool
$c== :: DescribeCluster -> DescribeCluster -> Bool
Prelude.Eq, ReadPrec [DescribeCluster]
ReadPrec DescribeCluster
Int -> ReadS DescribeCluster
ReadS [DescribeCluster]
(Int -> ReadS DescribeCluster)
-> ReadS [DescribeCluster]
-> ReadPrec DescribeCluster
-> ReadPrec [DescribeCluster]
-> Read DescribeCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCluster]
$creadListPrec :: ReadPrec [DescribeCluster]
readPrec :: ReadPrec DescribeCluster
$creadPrec :: ReadPrec DescribeCluster
readList :: ReadS [DescribeCluster]
$creadList :: ReadS [DescribeCluster]
readsPrec :: Int -> ReadS DescribeCluster
$creadsPrec :: Int -> ReadS DescribeCluster
Prelude.Read, Int -> DescribeCluster -> ShowS
[DescribeCluster] -> ShowS
DescribeCluster -> String
(Int -> DescribeCluster -> ShowS)
-> (DescribeCluster -> String)
-> ([DescribeCluster] -> ShowS)
-> Show DescribeCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCluster] -> ShowS
$cshowList :: [DescribeCluster] -> ShowS
show :: DescribeCluster -> String
$cshow :: DescribeCluster -> String
showsPrec :: Int -> DescribeCluster -> ShowS
$cshowsPrec :: Int -> DescribeCluster -> ShowS
Prelude.Show, (forall x. DescribeCluster -> Rep DescribeCluster x)
-> (forall x. Rep DescribeCluster x -> DescribeCluster)
-> Generic DescribeCluster
forall x. Rep DescribeCluster x -> DescribeCluster
forall x. DescribeCluster -> Rep DescribeCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeCluster x -> DescribeCluster
$cfrom :: forall x. DescribeCluster -> Rep DescribeCluster x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCluster' 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', 'describeCluster_clusterId' - The identifier of the cluster to describe.
newDescribeCluster ::
  -- | 'clusterId'
  Prelude.Text ->
  DescribeCluster
newDescribeCluster :: Text -> DescribeCluster
newDescribeCluster Text
pClusterId_ =
  DescribeCluster' :: Text -> DescribeCluster
DescribeCluster' {$sel:clusterId:DescribeCluster' :: Text
clusterId = Text
pClusterId_}

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

instance Core.AWSRequest DescribeCluster where
  type
    AWSResponse DescribeCluster =
      DescribeClusterResponse
  request :: DescribeCluster -> Request DescribeCluster
request = Service -> DescribeCluster -> Request DescribeCluster
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeCluster)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeCluster))
-> Logger
-> Service
-> Proxy DescribeCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeCluster)))
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 ->
          Int -> Cluster -> DescribeClusterResponse
DescribeClusterResponse'
            (Int -> Cluster -> DescribeClusterResponse)
-> Either String Int
-> Either String (Cluster -> DescribeClusterResponse)
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))
            Either String (Cluster -> DescribeClusterResponse)
-> Either String Cluster -> Either String DescribeClusterResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Cluster
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Cluster")
      )

instance Prelude.Hashable DescribeCluster

instance Prelude.NFData DescribeCluster

instance Core.ToHeaders DescribeCluster where
  toHeaders :: DescribeCluster -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeCluster -> 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.DescribeCluster" ::
                          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 DescribeCluster where
  toJSON :: DescribeCluster -> Value
toJSON DescribeCluster' {Text
clusterId :: Text
$sel:clusterId:DescribeCluster' :: DescribeCluster -> 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 DescribeCluster where
  toPath :: DescribeCluster -> ByteString
toPath = ByteString -> DescribeCluster -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DescribeClusterResponse' 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', 'describeClusterResponse_httpStatus' - The response's http status code.
--
-- 'cluster', 'describeClusterResponse_cluster' - This output contains the details for the requested cluster.
newDescribeClusterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'cluster'
  Cluster ->
  DescribeClusterResponse
newDescribeClusterResponse :: Int -> Cluster -> DescribeClusterResponse
newDescribeClusterResponse Int
pHttpStatus_ Cluster
pCluster_ =
  DescribeClusterResponse' :: Int -> Cluster -> DescribeClusterResponse
DescribeClusterResponse'
    { $sel:httpStatus:DescribeClusterResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:cluster:DescribeClusterResponse' :: Cluster
cluster = Cluster
pCluster_
    }

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

-- | This output contains the details for the requested cluster.
describeClusterResponse_cluster :: Lens.Lens' DescribeClusterResponse Cluster
describeClusterResponse_cluster :: (Cluster -> f Cluster)
-> DescribeClusterResponse -> f DescribeClusterResponse
describeClusterResponse_cluster = (DescribeClusterResponse -> Cluster)
-> (DescribeClusterResponse -> Cluster -> DescribeClusterResponse)
-> Lens
     DescribeClusterResponse DescribeClusterResponse Cluster Cluster
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeClusterResponse' {Cluster
cluster :: Cluster
$sel:cluster:DescribeClusterResponse' :: DescribeClusterResponse -> Cluster
cluster} -> Cluster
cluster) (\s :: DescribeClusterResponse
s@DescribeClusterResponse' {} Cluster
a -> DescribeClusterResponse
s {$sel:cluster:DescribeClusterResponse' :: Cluster
cluster = Cluster
a} :: DescribeClusterResponse)

instance Prelude.NFData DescribeClusterResponse