{-# 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.ListWorkGroups
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists available workgroups for the account.
module Amazonka.Athena.ListWorkGroups
  ( -- * Creating a Request
    ListWorkGroups (..),
    newListWorkGroups,

    -- * Request Lenses
    listWorkGroups_maxResults,
    listWorkGroups_nextToken,

    -- * Destructuring the Response
    ListWorkGroupsResponse (..),
    newListWorkGroupsResponse,

    -- * Response Lenses
    listWorkGroupsResponse_nextToken,
    listWorkGroupsResponse_workGroups,
    listWorkGroupsResponse_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:/ 'newListWorkGroups' smart constructor.
data ListWorkGroups = ListWorkGroups'
  { -- | The maximum number of workgroups to return in this request.
    ListWorkGroups -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A token generated by the Athena service that specifies where to continue
    -- pagination if a previous request was truncated. To obtain the next set
    -- of pages, pass in the @NextToken@ from the response object of the
    -- previous page call.
    ListWorkGroups -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListWorkGroups -> ListWorkGroups -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListWorkGroups -> ListWorkGroups -> Bool
$c/= :: ListWorkGroups -> ListWorkGroups -> Bool
== :: ListWorkGroups -> ListWorkGroups -> Bool
$c== :: ListWorkGroups -> ListWorkGroups -> Bool
Prelude.Eq, ReadPrec [ListWorkGroups]
ReadPrec ListWorkGroups
Int -> ReadS ListWorkGroups
ReadS [ListWorkGroups]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListWorkGroups]
$creadListPrec :: ReadPrec [ListWorkGroups]
readPrec :: ReadPrec ListWorkGroups
$creadPrec :: ReadPrec ListWorkGroups
readList :: ReadS [ListWorkGroups]
$creadList :: ReadS [ListWorkGroups]
readsPrec :: Int -> ReadS ListWorkGroups
$creadsPrec :: Int -> ReadS ListWorkGroups
Prelude.Read, Int -> ListWorkGroups -> ShowS
[ListWorkGroups] -> ShowS
ListWorkGroups -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListWorkGroups] -> ShowS
$cshowList :: [ListWorkGroups] -> ShowS
show :: ListWorkGroups -> String
$cshow :: ListWorkGroups -> String
showsPrec :: Int -> ListWorkGroups -> ShowS
$cshowsPrec :: Int -> ListWorkGroups -> ShowS
Prelude.Show, forall x. Rep ListWorkGroups x -> ListWorkGroups
forall x. ListWorkGroups -> Rep ListWorkGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListWorkGroups x -> ListWorkGroups
$cfrom :: forall x. ListWorkGroups -> Rep ListWorkGroups x
Prelude.Generic)

-- |
-- Create a value of 'ListWorkGroups' 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:
--
-- 'maxResults', 'listWorkGroups_maxResults' - The maximum number of workgroups to return in this request.
--
-- 'nextToken', 'listWorkGroups_nextToken' - A token generated by the Athena service that specifies where to continue
-- pagination if a previous request was truncated. To obtain the next set
-- of pages, pass in the @NextToken@ from the response object of the
-- previous page call.
newListWorkGroups ::
  ListWorkGroups
newListWorkGroups :: ListWorkGroups
newListWorkGroups =
  ListWorkGroups'
    { $sel:maxResults:ListWorkGroups' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListWorkGroups' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of workgroups to return in this request.
listWorkGroups_maxResults :: Lens.Lens' ListWorkGroups (Prelude.Maybe Prelude.Natural)
listWorkGroups_maxResults :: Lens' ListWorkGroups (Maybe Natural)
listWorkGroups_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkGroups' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListWorkGroups' :: ListWorkGroups -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListWorkGroups
s@ListWorkGroups' {} Maybe Natural
a -> ListWorkGroups
s {$sel:maxResults:ListWorkGroups' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListWorkGroups)

-- | A token generated by the Athena service that specifies where to continue
-- pagination if a previous request was truncated. To obtain the next set
-- of pages, pass in the @NextToken@ from the response object of the
-- previous page call.
listWorkGroups_nextToken :: Lens.Lens' ListWorkGroups (Prelude.Maybe Prelude.Text)
listWorkGroups_nextToken :: Lens' ListWorkGroups (Maybe Text)
listWorkGroups_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkGroups' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListWorkGroups' :: ListWorkGroups -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListWorkGroups
s@ListWorkGroups' {} Maybe Text
a -> ListWorkGroups
s {$sel:nextToken:ListWorkGroups' :: Maybe Text
nextToken = Maybe Text
a} :: ListWorkGroups)

instance Core.AWSRequest ListWorkGroups where
  type
    AWSResponse ListWorkGroups =
      ListWorkGroupsResponse
  request :: (Service -> Service) -> ListWorkGroups -> Request ListWorkGroups
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 ListWorkGroups
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListWorkGroups)))
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 Text
-> Maybe [WorkGroupSummary] -> Int -> ListWorkGroupsResponse
ListWorkGroupsResponse'
            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
"NextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"WorkGroups" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 ListWorkGroups where
  hashWithSalt :: Int -> ListWorkGroups -> Int
hashWithSalt Int
_salt ListWorkGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListWorkGroups' :: ListWorkGroups -> Maybe Text
$sel:maxResults:ListWorkGroups' :: ListWorkGroups -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListWorkGroups where
  rnf :: ListWorkGroups -> ()
rnf ListWorkGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListWorkGroups' :: ListWorkGroups -> Maybe Text
$sel:maxResults:ListWorkGroups' :: ListWorkGroups -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListWorkGroups where
  toHeaders :: ListWorkGroups -> 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.ListWorkGroups" ::
                          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 ListWorkGroups where
  toJSON :: ListWorkGroups -> Value
toJSON ListWorkGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListWorkGroups' :: ListWorkGroups -> Maybe Text
$sel:maxResults:ListWorkGroups' :: ListWorkGroups -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
          ]
      )

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

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

-- | /See:/ 'newListWorkGroupsResponse' smart constructor.
data ListWorkGroupsResponse = ListWorkGroupsResponse'
  { -- | A token generated by the Athena service that specifies where to continue
    -- pagination if a previous request was truncated. To obtain the next set
    -- of pages, pass in the @NextToken@ from the response object of the
    -- previous page call.
    ListWorkGroupsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of WorkGroupSummary objects that include the names, descriptions,
    -- creation times, and states for each workgroup.
    ListWorkGroupsResponse -> Maybe [WorkGroupSummary]
workGroups :: Prelude.Maybe [WorkGroupSummary],
    -- | The response's http status code.
    ListWorkGroupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListWorkGroupsResponse -> ListWorkGroupsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListWorkGroupsResponse -> ListWorkGroupsResponse -> Bool
$c/= :: ListWorkGroupsResponse -> ListWorkGroupsResponse -> Bool
== :: ListWorkGroupsResponse -> ListWorkGroupsResponse -> Bool
$c== :: ListWorkGroupsResponse -> ListWorkGroupsResponse -> Bool
Prelude.Eq, ReadPrec [ListWorkGroupsResponse]
ReadPrec ListWorkGroupsResponse
Int -> ReadS ListWorkGroupsResponse
ReadS [ListWorkGroupsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListWorkGroupsResponse]
$creadListPrec :: ReadPrec [ListWorkGroupsResponse]
readPrec :: ReadPrec ListWorkGroupsResponse
$creadPrec :: ReadPrec ListWorkGroupsResponse
readList :: ReadS [ListWorkGroupsResponse]
$creadList :: ReadS [ListWorkGroupsResponse]
readsPrec :: Int -> ReadS ListWorkGroupsResponse
$creadsPrec :: Int -> ReadS ListWorkGroupsResponse
Prelude.Read, Int -> ListWorkGroupsResponse -> ShowS
[ListWorkGroupsResponse] -> ShowS
ListWorkGroupsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListWorkGroupsResponse] -> ShowS
$cshowList :: [ListWorkGroupsResponse] -> ShowS
show :: ListWorkGroupsResponse -> String
$cshow :: ListWorkGroupsResponse -> String
showsPrec :: Int -> ListWorkGroupsResponse -> ShowS
$cshowsPrec :: Int -> ListWorkGroupsResponse -> ShowS
Prelude.Show, forall x. Rep ListWorkGroupsResponse x -> ListWorkGroupsResponse
forall x. ListWorkGroupsResponse -> Rep ListWorkGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListWorkGroupsResponse x -> ListWorkGroupsResponse
$cfrom :: forall x. ListWorkGroupsResponse -> Rep ListWorkGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListWorkGroupsResponse' 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:
--
-- 'nextToken', 'listWorkGroupsResponse_nextToken' - A token generated by the Athena service that specifies where to continue
-- pagination if a previous request was truncated. To obtain the next set
-- of pages, pass in the @NextToken@ from the response object of the
-- previous page call.
--
-- 'workGroups', 'listWorkGroupsResponse_workGroups' - A list of WorkGroupSummary objects that include the names, descriptions,
-- creation times, and states for each workgroup.
--
-- 'httpStatus', 'listWorkGroupsResponse_httpStatus' - The response's http status code.
newListWorkGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListWorkGroupsResponse
newListWorkGroupsResponse :: Int -> ListWorkGroupsResponse
newListWorkGroupsResponse Int
pHttpStatus_ =
  ListWorkGroupsResponse'
    { $sel:nextToken:ListWorkGroupsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:workGroups:ListWorkGroupsResponse' :: Maybe [WorkGroupSummary]
workGroups = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListWorkGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A token generated by the Athena service that specifies where to continue
-- pagination if a previous request was truncated. To obtain the next set
-- of pages, pass in the @NextToken@ from the response object of the
-- previous page call.
listWorkGroupsResponse_nextToken :: Lens.Lens' ListWorkGroupsResponse (Prelude.Maybe Prelude.Text)
listWorkGroupsResponse_nextToken :: Lens' ListWorkGroupsResponse (Maybe Text)
listWorkGroupsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkGroupsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListWorkGroupsResponse' :: ListWorkGroupsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListWorkGroupsResponse
s@ListWorkGroupsResponse' {} Maybe Text
a -> ListWorkGroupsResponse
s {$sel:nextToken:ListWorkGroupsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListWorkGroupsResponse)

-- | A list of WorkGroupSummary objects that include the names, descriptions,
-- creation times, and states for each workgroup.
listWorkGroupsResponse_workGroups :: Lens.Lens' ListWorkGroupsResponse (Prelude.Maybe [WorkGroupSummary])
listWorkGroupsResponse_workGroups :: Lens' ListWorkGroupsResponse (Maybe [WorkGroupSummary])
listWorkGroupsResponse_workGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListWorkGroupsResponse' {Maybe [WorkGroupSummary]
workGroups :: Maybe [WorkGroupSummary]
$sel:workGroups:ListWorkGroupsResponse' :: ListWorkGroupsResponse -> Maybe [WorkGroupSummary]
workGroups} -> Maybe [WorkGroupSummary]
workGroups) (\s :: ListWorkGroupsResponse
s@ListWorkGroupsResponse' {} Maybe [WorkGroupSummary]
a -> ListWorkGroupsResponse
s {$sel:workGroups:ListWorkGroupsResponse' :: Maybe [WorkGroupSummary]
workGroups = Maybe [WorkGroupSummary]
a} :: ListWorkGroupsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListWorkGroupsResponse where
  rnf :: ListWorkGroupsResponse -> ()
rnf ListWorkGroupsResponse' {Int
Maybe [WorkGroupSummary]
Maybe Text
httpStatus :: Int
workGroups :: Maybe [WorkGroupSummary]
nextToken :: Maybe Text
$sel:httpStatus:ListWorkGroupsResponse' :: ListWorkGroupsResponse -> Int
$sel:workGroups:ListWorkGroupsResponse' :: ListWorkGroupsResponse -> Maybe [WorkGroupSummary]
$sel:nextToken:ListWorkGroupsResponse' :: ListWorkGroupsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [WorkGroupSummary]
workGroups
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus