{-# 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.Athena.GetWorkGroup
-- 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 information about the workgroup with the specified name.
module Amazonka.Athena.GetWorkGroup
  ( -- * Creating a Request
    GetWorkGroup (..),
    newGetWorkGroup,

    -- * Request Lenses
    getWorkGroup_workGroup,

    -- * Destructuring the Response
    GetWorkGroupResponse (..),
    newGetWorkGroupResponse,

    -- * Response Lenses
    getWorkGroupResponse_workGroup,
    getWorkGroupResponse_httpStatus,
  )
where

import Amazonka.Athena.Types
import qualified Amazonka.Core as Core
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:/ 'newGetWorkGroup' smart constructor.
data GetWorkGroup = GetWorkGroup'
  { -- | The name of the workgroup.
    GetWorkGroup -> Text
workGroup :: Prelude.Text
  }
  deriving (GetWorkGroup -> GetWorkGroup -> Bool
(GetWorkGroup -> GetWorkGroup -> Bool)
-> (GetWorkGroup -> GetWorkGroup -> Bool) -> Eq GetWorkGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetWorkGroup -> GetWorkGroup -> Bool
$c/= :: GetWorkGroup -> GetWorkGroup -> Bool
== :: GetWorkGroup -> GetWorkGroup -> Bool
$c== :: GetWorkGroup -> GetWorkGroup -> Bool
Prelude.Eq, ReadPrec [GetWorkGroup]
ReadPrec GetWorkGroup
Int -> ReadS GetWorkGroup
ReadS [GetWorkGroup]
(Int -> ReadS GetWorkGroup)
-> ReadS [GetWorkGroup]
-> ReadPrec GetWorkGroup
-> ReadPrec [GetWorkGroup]
-> Read GetWorkGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetWorkGroup]
$creadListPrec :: ReadPrec [GetWorkGroup]
readPrec :: ReadPrec GetWorkGroup
$creadPrec :: ReadPrec GetWorkGroup
readList :: ReadS [GetWorkGroup]
$creadList :: ReadS [GetWorkGroup]
readsPrec :: Int -> ReadS GetWorkGroup
$creadsPrec :: Int -> ReadS GetWorkGroup
Prelude.Read, Int -> GetWorkGroup -> ShowS
[GetWorkGroup] -> ShowS
GetWorkGroup -> String
(Int -> GetWorkGroup -> ShowS)
-> (GetWorkGroup -> String)
-> ([GetWorkGroup] -> ShowS)
-> Show GetWorkGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetWorkGroup] -> ShowS
$cshowList :: [GetWorkGroup] -> ShowS
show :: GetWorkGroup -> String
$cshow :: GetWorkGroup -> String
showsPrec :: Int -> GetWorkGroup -> ShowS
$cshowsPrec :: Int -> GetWorkGroup -> ShowS
Prelude.Show, (forall x. GetWorkGroup -> Rep GetWorkGroup x)
-> (forall x. Rep GetWorkGroup x -> GetWorkGroup)
-> Generic GetWorkGroup
forall x. Rep GetWorkGroup x -> GetWorkGroup
forall x. GetWorkGroup -> Rep GetWorkGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetWorkGroup x -> GetWorkGroup
$cfrom :: forall x. GetWorkGroup -> Rep GetWorkGroup x
Prelude.Generic)

-- |
-- Create a value of 'GetWorkGroup' 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:
--
-- 'workGroup', 'getWorkGroup_workGroup' - The name of the workgroup.
newGetWorkGroup ::
  -- | 'workGroup'
  Prelude.Text ->
  GetWorkGroup
newGetWorkGroup :: Text -> GetWorkGroup
newGetWorkGroup Text
pWorkGroup_ =
  GetWorkGroup' :: Text -> GetWorkGroup
GetWorkGroup' {$sel:workGroup:GetWorkGroup' :: Text
workGroup = Text
pWorkGroup_}

-- | The name of the workgroup.
getWorkGroup_workGroup :: Lens.Lens' GetWorkGroup Prelude.Text
getWorkGroup_workGroup :: (Text -> f Text) -> GetWorkGroup -> f GetWorkGroup
getWorkGroup_workGroup = (GetWorkGroup -> Text)
-> (GetWorkGroup -> Text -> GetWorkGroup)
-> Lens GetWorkGroup GetWorkGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkGroup' {Text
workGroup :: Text
$sel:workGroup:GetWorkGroup' :: GetWorkGroup -> Text
workGroup} -> Text
workGroup) (\s :: GetWorkGroup
s@GetWorkGroup' {} Text
a -> GetWorkGroup
s {$sel:workGroup:GetWorkGroup' :: Text
workGroup = Text
a} :: GetWorkGroup)

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

instance Prelude.NFData GetWorkGroup

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

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

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

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

-- |
-- Create a value of 'GetWorkGroupResponse' 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:
--
-- 'workGroup', 'getWorkGroupResponse_workGroup' - Information about the workgroup.
--
-- 'httpStatus', 'getWorkGroupResponse_httpStatus' - The response's http status code.
newGetWorkGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetWorkGroupResponse
newGetWorkGroupResponse :: Int -> GetWorkGroupResponse
newGetWorkGroupResponse Int
pHttpStatus_ =
  GetWorkGroupResponse' :: Maybe WorkGroup -> Int -> GetWorkGroupResponse
GetWorkGroupResponse'
    { $sel:workGroup:GetWorkGroupResponse' :: Maybe WorkGroup
workGroup = Maybe WorkGroup
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetWorkGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the workgroup.
getWorkGroupResponse_workGroup :: Lens.Lens' GetWorkGroupResponse (Prelude.Maybe WorkGroup)
getWorkGroupResponse_workGroup :: (Maybe WorkGroup -> f (Maybe WorkGroup))
-> GetWorkGroupResponse -> f GetWorkGroupResponse
getWorkGroupResponse_workGroup = (GetWorkGroupResponse -> Maybe WorkGroup)
-> (GetWorkGroupResponse
    -> Maybe WorkGroup -> GetWorkGroupResponse)
-> Lens
     GetWorkGroupResponse
     GetWorkGroupResponse
     (Maybe WorkGroup)
     (Maybe WorkGroup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkGroupResponse' {Maybe WorkGroup
workGroup :: Maybe WorkGroup
$sel:workGroup:GetWorkGroupResponse' :: GetWorkGroupResponse -> Maybe WorkGroup
workGroup} -> Maybe WorkGroup
workGroup) (\s :: GetWorkGroupResponse
s@GetWorkGroupResponse' {} Maybe WorkGroup
a -> GetWorkGroupResponse
s {$sel:workGroup:GetWorkGroupResponse' :: Maybe WorkGroup
workGroup = Maybe WorkGroup
a} :: GetWorkGroupResponse)

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

instance Prelude.NFData GetWorkGroupResponse