{-# 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.DescribeStudio
-- 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 details for the specified Amazon EMR Studio including ID, Name,
-- VPC, Studio access URL, and so on.
module Amazonka.EMR.DescribeStudio
  ( -- * Creating a Request
    DescribeStudio (..),
    newDescribeStudio,

    -- * Request Lenses
    describeStudio_studioId,

    -- * Destructuring the Response
    DescribeStudioResponse (..),
    newDescribeStudioResponse,

    -- * Response Lenses
    describeStudioResponse_studio,
    describeStudioResponse_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:/ 'newDescribeStudio' smart constructor.
data DescribeStudio = DescribeStudio'
  { -- | The Amazon EMR Studio ID.
    DescribeStudio -> Text
studioId :: Prelude.Text
  }
  deriving (DescribeStudio -> DescribeStudio -> Bool
(DescribeStudio -> DescribeStudio -> Bool)
-> (DescribeStudio -> DescribeStudio -> Bool) -> Eq DescribeStudio
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeStudio -> DescribeStudio -> Bool
$c/= :: DescribeStudio -> DescribeStudio -> Bool
== :: DescribeStudio -> DescribeStudio -> Bool
$c== :: DescribeStudio -> DescribeStudio -> Bool
Prelude.Eq, ReadPrec [DescribeStudio]
ReadPrec DescribeStudio
Int -> ReadS DescribeStudio
ReadS [DescribeStudio]
(Int -> ReadS DescribeStudio)
-> ReadS [DescribeStudio]
-> ReadPrec DescribeStudio
-> ReadPrec [DescribeStudio]
-> Read DescribeStudio
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeStudio]
$creadListPrec :: ReadPrec [DescribeStudio]
readPrec :: ReadPrec DescribeStudio
$creadPrec :: ReadPrec DescribeStudio
readList :: ReadS [DescribeStudio]
$creadList :: ReadS [DescribeStudio]
readsPrec :: Int -> ReadS DescribeStudio
$creadsPrec :: Int -> ReadS DescribeStudio
Prelude.Read, Int -> DescribeStudio -> ShowS
[DescribeStudio] -> ShowS
DescribeStudio -> String
(Int -> DescribeStudio -> ShowS)
-> (DescribeStudio -> String)
-> ([DescribeStudio] -> ShowS)
-> Show DescribeStudio
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeStudio] -> ShowS
$cshowList :: [DescribeStudio] -> ShowS
show :: DescribeStudio -> String
$cshow :: DescribeStudio -> String
showsPrec :: Int -> DescribeStudio -> ShowS
$cshowsPrec :: Int -> DescribeStudio -> ShowS
Prelude.Show, (forall x. DescribeStudio -> Rep DescribeStudio x)
-> (forall x. Rep DescribeStudio x -> DescribeStudio)
-> Generic DescribeStudio
forall x. Rep DescribeStudio x -> DescribeStudio
forall x. DescribeStudio -> Rep DescribeStudio x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeStudio x -> DescribeStudio
$cfrom :: forall x. DescribeStudio -> Rep DescribeStudio x
Prelude.Generic)

-- |
-- Create a value of 'DescribeStudio' 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:
--
-- 'studioId', 'describeStudio_studioId' - The Amazon EMR Studio ID.
newDescribeStudio ::
  -- | 'studioId'
  Prelude.Text ->
  DescribeStudio
newDescribeStudio :: Text -> DescribeStudio
newDescribeStudio Text
pStudioId_ =
  DescribeStudio' :: Text -> DescribeStudio
DescribeStudio' {$sel:studioId:DescribeStudio' :: Text
studioId = Text
pStudioId_}

-- | The Amazon EMR Studio ID.
describeStudio_studioId :: Lens.Lens' DescribeStudio Prelude.Text
describeStudio_studioId :: (Text -> f Text) -> DescribeStudio -> f DescribeStudio
describeStudio_studioId = (DescribeStudio -> Text)
-> (DescribeStudio -> Text -> DescribeStudio)
-> Lens DescribeStudio DescribeStudio Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStudio' {Text
studioId :: Text
$sel:studioId:DescribeStudio' :: DescribeStudio -> Text
studioId} -> Text
studioId) (\s :: DescribeStudio
s@DescribeStudio' {} Text
a -> DescribeStudio
s {$sel:studioId:DescribeStudio' :: Text
studioId = Text
a} :: DescribeStudio)

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

instance Prelude.NFData DescribeStudio

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

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

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

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

-- |
-- Create a value of 'DescribeStudioResponse' 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:
--
-- 'studio', 'describeStudioResponse_studio' - The Amazon EMR Studio details.
--
-- 'httpStatus', 'describeStudioResponse_httpStatus' - The response's http status code.
newDescribeStudioResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeStudioResponse
newDescribeStudioResponse :: Int -> DescribeStudioResponse
newDescribeStudioResponse Int
pHttpStatus_ =
  DescribeStudioResponse' :: Maybe Studio -> Int -> DescribeStudioResponse
DescribeStudioResponse'
    { $sel:studio:DescribeStudioResponse' :: Maybe Studio
studio = Maybe Studio
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeStudioResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon EMR Studio details.
describeStudioResponse_studio :: Lens.Lens' DescribeStudioResponse (Prelude.Maybe Studio)
describeStudioResponse_studio :: (Maybe Studio -> f (Maybe Studio))
-> DescribeStudioResponse -> f DescribeStudioResponse
describeStudioResponse_studio = (DescribeStudioResponse -> Maybe Studio)
-> (DescribeStudioResponse
    -> Maybe Studio -> DescribeStudioResponse)
-> Lens
     DescribeStudioResponse
     DescribeStudioResponse
     (Maybe Studio)
     (Maybe Studio)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeStudioResponse' {Maybe Studio
studio :: Maybe Studio
$sel:studio:DescribeStudioResponse' :: DescribeStudioResponse -> Maybe Studio
studio} -> Maybe Studio
studio) (\s :: DescribeStudioResponse
s@DescribeStudioResponse' {} Maybe Studio
a -> DescribeStudioResponse
s {$sel:studio:DescribeStudioResponse' :: Maybe Studio
studio = Maybe Studio
a} :: DescribeStudioResponse)

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

instance Prelude.NFData DescribeStudioResponse