{-# 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.RedshiftServerLess.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 a specific workgroup.
module Amazonka.RedshiftServerLess.GetWorkgroup
  ( -- * Creating a Request
    GetWorkgroup (..),
    newGetWorkgroup,

    -- * Request Lenses
    getWorkgroup_workgroupName,

    -- * Destructuring the Response
    GetWorkgroupResponse (..),
    newGetWorkgroupResponse,

    -- * Response Lenses
    getWorkgroupResponse_httpStatus,
    getWorkgroupResponse_workgroup,
  )
where

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 Amazonka.RedshiftServerLess.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetWorkgroup' smart constructor.
data GetWorkgroup = GetWorkgroup'
  { -- | The name of the workgroup to return information for.
    GetWorkgroup -> Text
workgroupName :: 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:
--
-- 'workgroupName', 'getWorkgroup_workgroupName' - The name of the workgroup to return information for.
newGetWorkgroup ::
  -- | 'workgroupName'
  Prelude.Text ->
  GetWorkgroup
newGetWorkgroup :: Text -> GetWorkgroup
newGetWorkgroup Text
pWorkgroupName_ =
  GetWorkgroup' {$sel:workgroupName:GetWorkgroup' :: Text
workgroupName = Text
pWorkgroupName_}

-- | The name of the workgroup to return information for.
getWorkgroup_workgroupName :: Lens.Lens' GetWorkgroup Prelude.Text
getWorkgroup_workgroupName :: Lens' GetWorkgroup Text
getWorkgroup_workgroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkgroup' {Text
workgroupName :: Text
$sel:workgroupName:GetWorkgroup' :: GetWorkgroup -> Text
workgroupName} -> Text
workgroupName) (\s :: GetWorkgroup
s@GetWorkgroup' {} Text
a -> GetWorkgroup
s {$sel:workgroupName:GetWorkgroup' :: Text
workgroupName = 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 ->
          Int -> Workgroup -> GetWorkgroupResponse
GetWorkgroupResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"workgroup")
      )

instance Prelude.Hashable GetWorkgroup where
  hashWithSalt :: Int -> GetWorkgroup -> Int
hashWithSalt Int
_salt GetWorkgroup' {Text
workgroupName :: Text
$sel:workgroupName:GetWorkgroup' :: GetWorkgroup -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
workgroupName

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

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
"RedshiftServerless.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
workgroupName :: Text
$sel:workgroupName:GetWorkgroup' :: GetWorkgroup -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"workgroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
workgroupName)
          ]
      )

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'
  { -- | The response's http status code.
    GetWorkgroupResponse -> Int
httpStatus :: Prelude.Int,
    -- | The returned workgroup object.
    GetWorkgroupResponse -> Workgroup
workgroup :: Workgroup
  }
  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:
--
-- 'httpStatus', 'getWorkgroupResponse_httpStatus' - The response's http status code.
--
-- 'workgroup', 'getWorkgroupResponse_workgroup' - The returned workgroup object.
newGetWorkgroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'workgroup'
  Workgroup ->
  GetWorkgroupResponse
newGetWorkgroupResponse :: Int -> Workgroup -> GetWorkgroupResponse
newGetWorkgroupResponse Int
pHttpStatus_ Workgroup
pWorkgroup_ =
  GetWorkgroupResponse'
    { $sel:httpStatus:GetWorkgroupResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:workgroup:GetWorkgroupResponse' :: Workgroup
workgroup = Workgroup
pWorkgroup_
    }

-- | 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)

-- | The returned workgroup object.
getWorkgroupResponse_workgroup :: Lens.Lens' GetWorkgroupResponse Workgroup
getWorkgroupResponse_workgroup :: Lens' GetWorkgroupResponse Workgroup
getWorkgroupResponse_workgroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetWorkgroupResponse' {Workgroup
workgroup :: Workgroup
$sel:workgroup:GetWorkgroupResponse' :: GetWorkgroupResponse -> Workgroup
workgroup} -> Workgroup
workgroup) (\s :: GetWorkgroupResponse
s@GetWorkgroupResponse' {} Workgroup
a -> GetWorkgroupResponse
s {$sel:workgroup:GetWorkgroupResponse' :: Workgroup
workgroup = Workgroup
a} :: GetWorkgroupResponse)

instance Prelude.NFData GetWorkgroupResponse where
  rnf :: GetWorkgroupResponse -> ()
rnf GetWorkgroupResponse' {Int
Workgroup
workgroup :: Workgroup
httpStatus :: Int
$sel:workgroup:GetWorkgroupResponse' :: GetWorkgroupResponse -> Workgroup
$sel:httpStatus:GetWorkgroupResponse' :: GetWorkgroupResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Workgroup
workgroup