{-# 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.Omics.ListRunGroups
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves a list of run groups.
--
-- This operation returns paginated results.
module Amazonka.Omics.ListRunGroups
  ( -- * Creating a Request
    ListRunGroups (..),
    newListRunGroups,

    -- * Request Lenses
    listRunGroups_maxResults,
    listRunGroups_name,
    listRunGroups_startingToken,

    -- * Destructuring the Response
    ListRunGroupsResponse (..),
    newListRunGroupsResponse,

    -- * Response Lenses
    listRunGroupsResponse_items,
    listRunGroupsResponse_nextToken,
    listRunGroupsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Omics.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListRunGroups' smart constructor.
data ListRunGroups = ListRunGroups'
  { -- | The maximum number of run groups to return in one page of results.
    ListRunGroups -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The run groups\' name.
    ListRunGroups -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Specify the pagination token from a previous request to retrieve the
    -- next page of results.
    ListRunGroups -> Maybe Text
startingToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListRunGroups -> ListRunGroups -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRunGroups -> ListRunGroups -> Bool
$c/= :: ListRunGroups -> ListRunGroups -> Bool
== :: ListRunGroups -> ListRunGroups -> Bool
$c== :: ListRunGroups -> ListRunGroups -> Bool
Prelude.Eq, ReadPrec [ListRunGroups]
ReadPrec ListRunGroups
Int -> ReadS ListRunGroups
ReadS [ListRunGroups]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRunGroups]
$creadListPrec :: ReadPrec [ListRunGroups]
readPrec :: ReadPrec ListRunGroups
$creadPrec :: ReadPrec ListRunGroups
readList :: ReadS [ListRunGroups]
$creadList :: ReadS [ListRunGroups]
readsPrec :: Int -> ReadS ListRunGroups
$creadsPrec :: Int -> ReadS ListRunGroups
Prelude.Read, Int -> ListRunGroups -> ShowS
[ListRunGroups] -> ShowS
ListRunGroups -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRunGroups] -> ShowS
$cshowList :: [ListRunGroups] -> ShowS
show :: ListRunGroups -> String
$cshow :: ListRunGroups -> String
showsPrec :: Int -> ListRunGroups -> ShowS
$cshowsPrec :: Int -> ListRunGroups -> ShowS
Prelude.Show, forall x. Rep ListRunGroups x -> ListRunGroups
forall x. ListRunGroups -> Rep ListRunGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListRunGroups x -> ListRunGroups
$cfrom :: forall x. ListRunGroups -> Rep ListRunGroups x
Prelude.Generic)

-- |
-- Create a value of 'ListRunGroups' 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', 'listRunGroups_maxResults' - The maximum number of run groups to return in one page of results.
--
-- 'name', 'listRunGroups_name' - The run groups\' name.
--
-- 'startingToken', 'listRunGroups_startingToken' - Specify the pagination token from a previous request to retrieve the
-- next page of results.
newListRunGroups ::
  ListRunGroups
newListRunGroups :: ListRunGroups
newListRunGroups =
  ListRunGroups'
    { $sel:maxResults:ListRunGroups' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ListRunGroups' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:startingToken:ListRunGroups' :: Maybe Text
startingToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of run groups to return in one page of results.
listRunGroups_maxResults :: Lens.Lens' ListRunGroups (Prelude.Maybe Prelude.Natural)
listRunGroups_maxResults :: Lens' ListRunGroups (Maybe Natural)
listRunGroups_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRunGroups' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListRunGroups' :: ListRunGroups -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListRunGroups
s@ListRunGroups' {} Maybe Natural
a -> ListRunGroups
s {$sel:maxResults:ListRunGroups' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListRunGroups)

-- | The run groups\' name.
listRunGroups_name :: Lens.Lens' ListRunGroups (Prelude.Maybe Prelude.Text)
listRunGroups_name :: Lens' ListRunGroups (Maybe Text)
listRunGroups_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRunGroups' {Maybe Text
name :: Maybe Text
$sel:name:ListRunGroups' :: ListRunGroups -> Maybe Text
name} -> Maybe Text
name) (\s :: ListRunGroups
s@ListRunGroups' {} Maybe Text
a -> ListRunGroups
s {$sel:name:ListRunGroups' :: Maybe Text
name = Maybe Text
a} :: ListRunGroups)

-- | Specify the pagination token from a previous request to retrieve the
-- next page of results.
listRunGroups_startingToken :: Lens.Lens' ListRunGroups (Prelude.Maybe Prelude.Text)
listRunGroups_startingToken :: Lens' ListRunGroups (Maybe Text)
listRunGroups_startingToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRunGroups' {Maybe Text
startingToken :: Maybe Text
$sel:startingToken:ListRunGroups' :: ListRunGroups -> Maybe Text
startingToken} -> Maybe Text
startingToken) (\s :: ListRunGroups
s@ListRunGroups' {} Maybe Text
a -> ListRunGroups
s {$sel:startingToken:ListRunGroups' :: Maybe Text
startingToken = Maybe Text
a} :: ListRunGroups)

instance Core.AWSPager ListRunGroups where
  page :: ListRunGroups -> AWSResponse ListRunGroups -> Maybe ListRunGroups
page ListRunGroups
rq AWSResponse ListRunGroups
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListRunGroups
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRunGroupsResponse (Maybe Text)
listRunGroupsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListRunGroups
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRunGroupsResponse (Maybe [RunGroupListItem])
listRunGroupsResponse_items
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListRunGroups
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListRunGroups (Maybe Text)
listRunGroups_startingToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListRunGroups
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRunGroupsResponse (Maybe Text)
listRunGroupsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListRunGroups where
  type
    AWSResponse ListRunGroups =
      ListRunGroupsResponse
  request :: (Service -> Service) -> ListRunGroups -> Request ListRunGroups
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListRunGroups
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListRunGroups)))
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 [RunGroupListItem]
-> Maybe Text -> Int -> ListRunGroupsResponse
ListRunGroupsResponse'
            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
"items" 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.<*> (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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListRunGroups where
  hashWithSalt :: Int -> ListRunGroups -> Int
hashWithSalt Int
_salt ListRunGroups' {Maybe Natural
Maybe Text
startingToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:startingToken:ListRunGroups' :: ListRunGroups -> Maybe Text
$sel:name:ListRunGroups' :: ListRunGroups -> Maybe Text
$sel:maxResults:ListRunGroups' :: ListRunGroups -> 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
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
startingToken

instance Prelude.NFData ListRunGroups where
  rnf :: ListRunGroups -> ()
rnf ListRunGroups' {Maybe Natural
Maybe Text
startingToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:startingToken:ListRunGroups' :: ListRunGroups -> Maybe Text
$sel:name:ListRunGroups' :: ListRunGroups -> Maybe Text
$sel:maxResults:ListRunGroups' :: ListRunGroups -> 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
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
startingToken

instance Data.ToHeaders ListRunGroups where
  toHeaders :: ListRunGroups -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Data.ToQuery ListRunGroups where
  toQuery :: ListRunGroups -> QueryString
toQuery ListRunGroups' {Maybe Natural
Maybe Text
startingToken :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:startingToken:ListRunGroups' :: ListRunGroups -> Maybe Text
$sel:name:ListRunGroups' :: ListRunGroups -> Maybe Text
$sel:maxResults:ListRunGroups' :: ListRunGroups -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"name" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
name,
        ByteString
"startingToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
startingToken
      ]

-- | /See:/ 'newListRunGroupsResponse' smart constructor.
data ListRunGroupsResponse = ListRunGroupsResponse'
  { -- | A list of groups.
    ListRunGroupsResponse -> Maybe [RunGroupListItem]
items :: Prelude.Maybe [RunGroupListItem],
    -- | A pagination token that\'s included if more results are available.
    ListRunGroupsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListRunGroupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListRunGroupsResponse -> ListRunGroupsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRunGroupsResponse -> ListRunGroupsResponse -> Bool
$c/= :: ListRunGroupsResponse -> ListRunGroupsResponse -> Bool
== :: ListRunGroupsResponse -> ListRunGroupsResponse -> Bool
$c== :: ListRunGroupsResponse -> ListRunGroupsResponse -> Bool
Prelude.Eq, ReadPrec [ListRunGroupsResponse]
ReadPrec ListRunGroupsResponse
Int -> ReadS ListRunGroupsResponse
ReadS [ListRunGroupsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRunGroupsResponse]
$creadListPrec :: ReadPrec [ListRunGroupsResponse]
readPrec :: ReadPrec ListRunGroupsResponse
$creadPrec :: ReadPrec ListRunGroupsResponse
readList :: ReadS [ListRunGroupsResponse]
$creadList :: ReadS [ListRunGroupsResponse]
readsPrec :: Int -> ReadS ListRunGroupsResponse
$creadsPrec :: Int -> ReadS ListRunGroupsResponse
Prelude.Read, Int -> ListRunGroupsResponse -> ShowS
[ListRunGroupsResponse] -> ShowS
ListRunGroupsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRunGroupsResponse] -> ShowS
$cshowList :: [ListRunGroupsResponse] -> ShowS
show :: ListRunGroupsResponse -> String
$cshow :: ListRunGroupsResponse -> String
showsPrec :: Int -> ListRunGroupsResponse -> ShowS
$cshowsPrec :: Int -> ListRunGroupsResponse -> ShowS
Prelude.Show, forall x. Rep ListRunGroupsResponse x -> ListRunGroupsResponse
forall x. ListRunGroupsResponse -> Rep ListRunGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListRunGroupsResponse x -> ListRunGroupsResponse
$cfrom :: forall x. ListRunGroupsResponse -> Rep ListRunGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListRunGroupsResponse' 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:
--
-- 'items', 'listRunGroupsResponse_items' - A list of groups.
--
-- 'nextToken', 'listRunGroupsResponse_nextToken' - A pagination token that\'s included if more results are available.
--
-- 'httpStatus', 'listRunGroupsResponse_httpStatus' - The response's http status code.
newListRunGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListRunGroupsResponse
newListRunGroupsResponse :: Int -> ListRunGroupsResponse
newListRunGroupsResponse Int
pHttpStatus_ =
  ListRunGroupsResponse'
    { $sel:items:ListRunGroupsResponse' :: Maybe [RunGroupListItem]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListRunGroupsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListRunGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of groups.
listRunGroupsResponse_items :: Lens.Lens' ListRunGroupsResponse (Prelude.Maybe [RunGroupListItem])
listRunGroupsResponse_items :: Lens' ListRunGroupsResponse (Maybe [RunGroupListItem])
listRunGroupsResponse_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRunGroupsResponse' {Maybe [RunGroupListItem]
items :: Maybe [RunGroupListItem]
$sel:items:ListRunGroupsResponse' :: ListRunGroupsResponse -> Maybe [RunGroupListItem]
items} -> Maybe [RunGroupListItem]
items) (\s :: ListRunGroupsResponse
s@ListRunGroupsResponse' {} Maybe [RunGroupListItem]
a -> ListRunGroupsResponse
s {$sel:items:ListRunGroupsResponse' :: Maybe [RunGroupListItem]
items = Maybe [RunGroupListItem]
a} :: ListRunGroupsResponse) 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

-- | A pagination token that\'s included if more results are available.
listRunGroupsResponse_nextToken :: Lens.Lens' ListRunGroupsResponse (Prelude.Maybe Prelude.Text)
listRunGroupsResponse_nextToken :: Lens' ListRunGroupsResponse (Maybe Text)
listRunGroupsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRunGroupsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRunGroupsResponse' :: ListRunGroupsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRunGroupsResponse
s@ListRunGroupsResponse' {} Maybe Text
a -> ListRunGroupsResponse
s {$sel:nextToken:ListRunGroupsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListRunGroupsResponse)

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

instance Prelude.NFData ListRunGroupsResponse where
  rnf :: ListRunGroupsResponse -> ()
rnf ListRunGroupsResponse' {Int
Maybe [RunGroupListItem]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
items :: Maybe [RunGroupListItem]
$sel:httpStatus:ListRunGroupsResponse' :: ListRunGroupsResponse -> Int
$sel:nextToken:ListRunGroupsResponse' :: ListRunGroupsResponse -> Maybe Text
$sel:items:ListRunGroupsResponse' :: ListRunGroupsResponse -> Maybe [RunGroupListItem]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [RunGroupListItem]
items
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Int
httpStatus