{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$sel:workGroup:GetWorkGroup' :: Text
workGroup = Text
pWorkGroup_}

-- | The name of the workgroup.
getWorkGroup_workGroup :: Lens.Lens' GetWorkGroup Prelude.Text
getWorkGroup_workGroup :: Lens' GetWorkGroup Text
getWorkGroup_workGroup = 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 :: (Service -> Service) -> GetWorkGroup -> Request GetWorkGroup
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 GetWorkGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetWorkGroup)))
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 WorkGroup -> Int -> GetWorkGroupResponse
GetWorkGroupResponse'
            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
"WorkGroup")
            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 GetWorkGroup where
  hashWithSalt :: Int -> GetWorkGroup -> Int
hashWithSalt Int
_salt GetWorkGroup' {Text
workGroup :: Text
$sel:workGroup:GetWorkGroup' :: GetWorkGroup -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
workGroup

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

instance Data.ToHeaders GetWorkGroup where
  toHeaders :: GetWorkGroup -> 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
"AmazonAthena.GetWorkGroup" :: 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 GetWorkGroup where
  toJSON :: GetWorkGroup -> Value
toJSON GetWorkGroup' {Text
workGroup :: Text
$sel:workGroup:GetWorkGroup' :: GetWorkGroup -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"WorkGroup" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
workGroup)]
      )

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

instance Data.ToQuery GetWorkGroup where
  toQuery :: GetWorkGroup -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:workGroup:GetWorkGroupResponse' :: Maybe WorkGroup
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 :: Lens' GetWorkGroupResponse (Maybe WorkGroup)
getWorkGroupResponse_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 :: Lens' GetWorkGroupResponse Int
getWorkGroupResponse_httpStatus = 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 where
  rnf :: GetWorkGroupResponse -> ()
rnf GetWorkGroupResponse' {Int
Maybe WorkGroup
httpStatus :: Int
workGroup :: Maybe WorkGroup
$sel:httpStatus:GetWorkGroupResponse' :: GetWorkGroupResponse -> Int
$sel:workGroup:GetWorkGroupResponse' :: GetWorkGroupResponse -> Maybe WorkGroup
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe WorkGroup
workGroup
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus