{-# 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.ListRuns
-- 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 runs.
--
-- This operation returns paginated results.
module Amazonka.Omics.ListRuns
  ( -- * Creating a Request
    ListRuns (..),
    newListRuns,

    -- * Request Lenses
    listRuns_maxResults,
    listRuns_name,
    listRuns_runGroupId,
    listRuns_startingToken,

    -- * Destructuring the Response
    ListRunsResponse (..),
    newListRunsResponse,

    -- * Response Lenses
    listRunsResponse_items,
    listRunsResponse_nextToken,
    listRunsResponse_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:/ 'newListRuns' smart constructor.
data ListRuns = ListRuns'
  { -- | The maximum number of runs to return in one page of results.
    ListRuns -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | Filter the list by run name.
    ListRuns -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Filter the list by run group ID.
    ListRuns -> Maybe Text
runGroupId :: Prelude.Maybe Prelude.Text,
    -- | Specify the pagination token from a previous request to retrieve the
    -- next page of results.
    ListRuns -> Maybe Text
startingToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListRuns -> ListRuns -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListRuns -> ListRuns -> Bool
$c/= :: ListRuns -> ListRuns -> Bool
== :: ListRuns -> ListRuns -> Bool
$c== :: ListRuns -> ListRuns -> Bool
Prelude.Eq, ReadPrec [ListRuns]
ReadPrec ListRuns
Int -> ReadS ListRuns
ReadS [ListRuns]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListRuns]
$creadListPrec :: ReadPrec [ListRuns]
readPrec :: ReadPrec ListRuns
$creadPrec :: ReadPrec ListRuns
readList :: ReadS [ListRuns]
$creadList :: ReadS [ListRuns]
readsPrec :: Int -> ReadS ListRuns
$creadsPrec :: Int -> ReadS ListRuns
Prelude.Read, Int -> ListRuns -> ShowS
[ListRuns] -> ShowS
ListRuns -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListRuns] -> ShowS
$cshowList :: [ListRuns] -> ShowS
show :: ListRuns -> String
$cshow :: ListRuns -> String
showsPrec :: Int -> ListRuns -> ShowS
$cshowsPrec :: Int -> ListRuns -> ShowS
Prelude.Show, forall x. Rep ListRuns x -> ListRuns
forall x. ListRuns -> Rep ListRuns x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListRuns x -> ListRuns
$cfrom :: forall x. ListRuns -> Rep ListRuns x
Prelude.Generic)

-- |
-- Create a value of 'ListRuns' 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', 'listRuns_maxResults' - The maximum number of runs to return in one page of results.
--
-- 'name', 'listRuns_name' - Filter the list by run name.
--
-- 'runGroupId', 'listRuns_runGroupId' - Filter the list by run group ID.
--
-- 'startingToken', 'listRuns_startingToken' - Specify the pagination token from a previous request to retrieve the
-- next page of results.
newListRuns ::
  ListRuns
newListRuns :: ListRuns
newListRuns =
  ListRuns'
    { $sel:maxResults:ListRuns' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ListRuns' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:runGroupId:ListRuns' :: Maybe Text
runGroupId = forall a. Maybe a
Prelude.Nothing,
      $sel:startingToken:ListRuns' :: Maybe Text
startingToken = forall a. Maybe a
Prelude.Nothing
    }

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

-- | Filter the list by run name.
listRuns_name :: Lens.Lens' ListRuns (Prelude.Maybe Prelude.Text)
listRuns_name :: Lens' ListRuns (Maybe Text)
listRuns_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRuns' {Maybe Text
name :: Maybe Text
$sel:name:ListRuns' :: ListRuns -> Maybe Text
name} -> Maybe Text
name) (\s :: ListRuns
s@ListRuns' {} Maybe Text
a -> ListRuns
s {$sel:name:ListRuns' :: Maybe Text
name = Maybe Text
a} :: ListRuns)

-- | Filter the list by run group ID.
listRuns_runGroupId :: Lens.Lens' ListRuns (Prelude.Maybe Prelude.Text)
listRuns_runGroupId :: Lens' ListRuns (Maybe Text)
listRuns_runGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRuns' {Maybe Text
runGroupId :: Maybe Text
$sel:runGroupId:ListRuns' :: ListRuns -> Maybe Text
runGroupId} -> Maybe Text
runGroupId) (\s :: ListRuns
s@ListRuns' {} Maybe Text
a -> ListRuns
s {$sel:runGroupId:ListRuns' :: Maybe Text
runGroupId = Maybe Text
a} :: ListRuns)

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

instance Core.AWSPager ListRuns where
  page :: ListRuns -> AWSResponse ListRuns -> Maybe ListRuns
page ListRuns
rq AWSResponse ListRuns
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListRuns
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRunsResponse (Maybe Text)
listRunsResponse_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 ListRuns
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRunsResponse (Maybe [RunListItem])
listRunsResponse_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.$ ListRuns
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListRuns (Maybe Text)
listRuns_startingToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListRuns
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListRunsResponse (Maybe Text)
listRunsResponse_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 ListRuns where
  type AWSResponse ListRuns = ListRunsResponse
  request :: (Service -> Service) -> ListRuns -> Request ListRuns
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 ListRuns
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListRuns)))
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 [RunListItem] -> Maybe Text -> Int -> ListRunsResponse
ListRunsResponse'
            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 ListRuns where
  hashWithSalt :: Int -> ListRuns -> Int
hashWithSalt Int
_salt ListRuns' {Maybe Natural
Maybe Text
startingToken :: Maybe Text
runGroupId :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:startingToken:ListRuns' :: ListRuns -> Maybe Text
$sel:runGroupId:ListRuns' :: ListRuns -> Maybe Text
$sel:name:ListRuns' :: ListRuns -> Maybe Text
$sel:maxResults:ListRuns' :: ListRuns -> 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
runGroupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
startingToken

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

instance Data.ToHeaders ListRuns where
  toHeaders :: ListRuns -> 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 ListRuns where
  toPath :: ListRuns -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/run"

instance Data.ToQuery ListRuns where
  toQuery :: ListRuns -> QueryString
toQuery ListRuns' {Maybe Natural
Maybe Text
startingToken :: Maybe Text
runGroupId :: Maybe Text
name :: Maybe Text
maxResults :: Maybe Natural
$sel:startingToken:ListRuns' :: ListRuns -> Maybe Text
$sel:runGroupId:ListRuns' :: ListRuns -> Maybe Text
$sel:name:ListRuns' :: ListRuns -> Maybe Text
$sel:maxResults:ListRuns' :: ListRuns -> 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
"runGroupId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
runGroupId,
        ByteString
"startingToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
startingToken
      ]

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

-- |
-- Create a value of 'ListRunsResponse' 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', 'listRunsResponse_items' - A list of runs.
--
-- 'nextToken', 'listRunsResponse_nextToken' - A pagination token that\'s included if more results are available.
--
-- 'httpStatus', 'listRunsResponse_httpStatus' - The response's http status code.
newListRunsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListRunsResponse
newListRunsResponse :: Int -> ListRunsResponse
newListRunsResponse Int
pHttpStatus_ =
  ListRunsResponse'
    { $sel:items:ListRunsResponse' :: Maybe [RunListItem]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListRunsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListRunsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of runs.
listRunsResponse_items :: Lens.Lens' ListRunsResponse (Prelude.Maybe [RunListItem])
listRunsResponse_items :: Lens' ListRunsResponse (Maybe [RunListItem])
listRunsResponse_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRunsResponse' {Maybe [RunListItem]
items :: Maybe [RunListItem]
$sel:items:ListRunsResponse' :: ListRunsResponse -> Maybe [RunListItem]
items} -> Maybe [RunListItem]
items) (\s :: ListRunsResponse
s@ListRunsResponse' {} Maybe [RunListItem]
a -> ListRunsResponse
s {$sel:items:ListRunsResponse' :: Maybe [RunListItem]
items = Maybe [RunListItem]
a} :: ListRunsResponse) 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.
listRunsResponse_nextToken :: Lens.Lens' ListRunsResponse (Prelude.Maybe Prelude.Text)
listRunsResponse_nextToken :: Lens' ListRunsResponse (Maybe Text)
listRunsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListRunsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListRunsResponse' :: ListRunsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListRunsResponse
s@ListRunsResponse' {} Maybe Text
a -> ListRunsResponse
s {$sel:nextToken:ListRunsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListRunsResponse)

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

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