{-# 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.CodeBuild.ListBuildBatchesForProject
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the identifiers of the build batches for a specific project.
--
-- This operation returns paginated results.
module Amazonka.CodeBuild.ListBuildBatchesForProject
  ( -- * Creating a Request
    ListBuildBatchesForProject (..),
    newListBuildBatchesForProject,

    -- * Request Lenses
    listBuildBatchesForProject_sortOrder,
    listBuildBatchesForProject_nextToken,
    listBuildBatchesForProject_projectName,
    listBuildBatchesForProject_filter,
    listBuildBatchesForProject_maxResults,

    -- * Destructuring the Response
    ListBuildBatchesForProjectResponse (..),
    newListBuildBatchesForProjectResponse,

    -- * Response Lenses
    listBuildBatchesForProjectResponse_ids,
    listBuildBatchesForProjectResponse_nextToken,
    listBuildBatchesForProjectResponse_httpStatus,
  )
where

import Amazonka.CodeBuild.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListBuildBatchesForProject' smart constructor.
data ListBuildBatchesForProject = ListBuildBatchesForProject'
  { -- | Specifies the sort order of the returned items. Valid values include:
    --
    -- -   @ASCENDING@: List the batch build identifiers in ascending order by
    --     identifier.
    --
    -- -   @DESCENDING@: List the batch build identifiers in descending order
    --     by identifier.
    ListBuildBatchesForProject -> Maybe SortOrderType
sortOrder :: Prelude.Maybe SortOrderType,
    -- | The @nextToken@ value returned from a previous call to
    -- @ListBuildBatchesForProject@. This specifies the next item to return. To
    -- return the beginning of the list, exclude this parameter.
    ListBuildBatchesForProject -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the project.
    ListBuildBatchesForProject -> Maybe Text
projectName :: Prelude.Maybe Prelude.Text,
    -- | A @BuildBatchFilter@ object that specifies the filters for the search.
    ListBuildBatchesForProject -> Maybe BuildBatchFilter
filter' :: Prelude.Maybe BuildBatchFilter,
    -- | The maximum number of results to return.
    ListBuildBatchesForProject -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListBuildBatchesForProject -> ListBuildBatchesForProject -> Bool
(ListBuildBatchesForProject -> ListBuildBatchesForProject -> Bool)
-> (ListBuildBatchesForProject
    -> ListBuildBatchesForProject -> Bool)
-> Eq ListBuildBatchesForProject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBuildBatchesForProject -> ListBuildBatchesForProject -> Bool
$c/= :: ListBuildBatchesForProject -> ListBuildBatchesForProject -> Bool
== :: ListBuildBatchesForProject -> ListBuildBatchesForProject -> Bool
$c== :: ListBuildBatchesForProject -> ListBuildBatchesForProject -> Bool
Prelude.Eq, ReadPrec [ListBuildBatchesForProject]
ReadPrec ListBuildBatchesForProject
Int -> ReadS ListBuildBatchesForProject
ReadS [ListBuildBatchesForProject]
(Int -> ReadS ListBuildBatchesForProject)
-> ReadS [ListBuildBatchesForProject]
-> ReadPrec ListBuildBatchesForProject
-> ReadPrec [ListBuildBatchesForProject]
-> Read ListBuildBatchesForProject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBuildBatchesForProject]
$creadListPrec :: ReadPrec [ListBuildBatchesForProject]
readPrec :: ReadPrec ListBuildBatchesForProject
$creadPrec :: ReadPrec ListBuildBatchesForProject
readList :: ReadS [ListBuildBatchesForProject]
$creadList :: ReadS [ListBuildBatchesForProject]
readsPrec :: Int -> ReadS ListBuildBatchesForProject
$creadsPrec :: Int -> ReadS ListBuildBatchesForProject
Prelude.Read, Int -> ListBuildBatchesForProject -> ShowS
[ListBuildBatchesForProject] -> ShowS
ListBuildBatchesForProject -> String
(Int -> ListBuildBatchesForProject -> ShowS)
-> (ListBuildBatchesForProject -> String)
-> ([ListBuildBatchesForProject] -> ShowS)
-> Show ListBuildBatchesForProject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBuildBatchesForProject] -> ShowS
$cshowList :: [ListBuildBatchesForProject] -> ShowS
show :: ListBuildBatchesForProject -> String
$cshow :: ListBuildBatchesForProject -> String
showsPrec :: Int -> ListBuildBatchesForProject -> ShowS
$cshowsPrec :: Int -> ListBuildBatchesForProject -> ShowS
Prelude.Show, (forall x.
 ListBuildBatchesForProject -> Rep ListBuildBatchesForProject x)
-> (forall x.
    Rep ListBuildBatchesForProject x -> ListBuildBatchesForProject)
-> Generic ListBuildBatchesForProject
forall x.
Rep ListBuildBatchesForProject x -> ListBuildBatchesForProject
forall x.
ListBuildBatchesForProject -> Rep ListBuildBatchesForProject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListBuildBatchesForProject x -> ListBuildBatchesForProject
$cfrom :: forall x.
ListBuildBatchesForProject -> Rep ListBuildBatchesForProject x
Prelude.Generic)

-- |
-- Create a value of 'ListBuildBatchesForProject' 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:
--
-- 'sortOrder', 'listBuildBatchesForProject_sortOrder' - Specifies the sort order of the returned items. Valid values include:
--
-- -   @ASCENDING@: List the batch build identifiers in ascending order by
--     identifier.
--
-- -   @DESCENDING@: List the batch build identifiers in descending order
--     by identifier.
--
-- 'nextToken', 'listBuildBatchesForProject_nextToken' - The @nextToken@ value returned from a previous call to
-- @ListBuildBatchesForProject@. This specifies the next item to return. To
-- return the beginning of the list, exclude this parameter.
--
-- 'projectName', 'listBuildBatchesForProject_projectName' - The name of the project.
--
-- 'filter'', 'listBuildBatchesForProject_filter' - A @BuildBatchFilter@ object that specifies the filters for the search.
--
-- 'maxResults', 'listBuildBatchesForProject_maxResults' - The maximum number of results to return.
newListBuildBatchesForProject ::
  ListBuildBatchesForProject
newListBuildBatchesForProject :: ListBuildBatchesForProject
newListBuildBatchesForProject =
  ListBuildBatchesForProject' :: Maybe SortOrderType
-> Maybe Text
-> Maybe Text
-> Maybe BuildBatchFilter
-> Maybe Natural
-> ListBuildBatchesForProject
ListBuildBatchesForProject'
    { $sel:sortOrder:ListBuildBatchesForProject' :: Maybe SortOrderType
sortOrder =
        Maybe SortOrderType
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBuildBatchesForProject' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:projectName:ListBuildBatchesForProject' :: Maybe Text
projectName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filter':ListBuildBatchesForProject' :: Maybe BuildBatchFilter
filter' = Maybe BuildBatchFilter
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListBuildBatchesForProject' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the sort order of the returned items. Valid values include:
--
-- -   @ASCENDING@: List the batch build identifiers in ascending order by
--     identifier.
--
-- -   @DESCENDING@: List the batch build identifiers in descending order
--     by identifier.
listBuildBatchesForProject_sortOrder :: Lens.Lens' ListBuildBatchesForProject (Prelude.Maybe SortOrderType)
listBuildBatchesForProject_sortOrder :: (Maybe SortOrderType -> f (Maybe SortOrderType))
-> ListBuildBatchesForProject -> f ListBuildBatchesForProject
listBuildBatchesForProject_sortOrder = (ListBuildBatchesForProject -> Maybe SortOrderType)
-> (ListBuildBatchesForProject
    -> Maybe SortOrderType -> ListBuildBatchesForProject)
-> Lens
     ListBuildBatchesForProject
     ListBuildBatchesForProject
     (Maybe SortOrderType)
     (Maybe SortOrderType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBuildBatchesForProject' {Maybe SortOrderType
sortOrder :: Maybe SortOrderType
$sel:sortOrder:ListBuildBatchesForProject' :: ListBuildBatchesForProject -> Maybe SortOrderType
sortOrder} -> Maybe SortOrderType
sortOrder) (\s :: ListBuildBatchesForProject
s@ListBuildBatchesForProject' {} Maybe SortOrderType
a -> ListBuildBatchesForProject
s {$sel:sortOrder:ListBuildBatchesForProject' :: Maybe SortOrderType
sortOrder = Maybe SortOrderType
a} :: ListBuildBatchesForProject)

-- | The @nextToken@ value returned from a previous call to
-- @ListBuildBatchesForProject@. This specifies the next item to return. To
-- return the beginning of the list, exclude this parameter.
listBuildBatchesForProject_nextToken :: Lens.Lens' ListBuildBatchesForProject (Prelude.Maybe Prelude.Text)
listBuildBatchesForProject_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListBuildBatchesForProject -> f ListBuildBatchesForProject
listBuildBatchesForProject_nextToken = (ListBuildBatchesForProject -> Maybe Text)
-> (ListBuildBatchesForProject
    -> Maybe Text -> ListBuildBatchesForProject)
-> Lens
     ListBuildBatchesForProject
     ListBuildBatchesForProject
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBuildBatchesForProject' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListBuildBatchesForProject' :: ListBuildBatchesForProject -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListBuildBatchesForProject
s@ListBuildBatchesForProject' {} Maybe Text
a -> ListBuildBatchesForProject
s {$sel:nextToken:ListBuildBatchesForProject' :: Maybe Text
nextToken = Maybe Text
a} :: ListBuildBatchesForProject)

-- | The name of the project.
listBuildBatchesForProject_projectName :: Lens.Lens' ListBuildBatchesForProject (Prelude.Maybe Prelude.Text)
listBuildBatchesForProject_projectName :: (Maybe Text -> f (Maybe Text))
-> ListBuildBatchesForProject -> f ListBuildBatchesForProject
listBuildBatchesForProject_projectName = (ListBuildBatchesForProject -> Maybe Text)
-> (ListBuildBatchesForProject
    -> Maybe Text -> ListBuildBatchesForProject)
-> Lens
     ListBuildBatchesForProject
     ListBuildBatchesForProject
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBuildBatchesForProject' {Maybe Text
projectName :: Maybe Text
$sel:projectName:ListBuildBatchesForProject' :: ListBuildBatchesForProject -> Maybe Text
projectName} -> Maybe Text
projectName) (\s :: ListBuildBatchesForProject
s@ListBuildBatchesForProject' {} Maybe Text
a -> ListBuildBatchesForProject
s {$sel:projectName:ListBuildBatchesForProject' :: Maybe Text
projectName = Maybe Text
a} :: ListBuildBatchesForProject)

-- | A @BuildBatchFilter@ object that specifies the filters for the search.
listBuildBatchesForProject_filter :: Lens.Lens' ListBuildBatchesForProject (Prelude.Maybe BuildBatchFilter)
listBuildBatchesForProject_filter :: (Maybe BuildBatchFilter -> f (Maybe BuildBatchFilter))
-> ListBuildBatchesForProject -> f ListBuildBatchesForProject
listBuildBatchesForProject_filter = (ListBuildBatchesForProject -> Maybe BuildBatchFilter)
-> (ListBuildBatchesForProject
    -> Maybe BuildBatchFilter -> ListBuildBatchesForProject)
-> Lens
     ListBuildBatchesForProject
     ListBuildBatchesForProject
     (Maybe BuildBatchFilter)
     (Maybe BuildBatchFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBuildBatchesForProject' {Maybe BuildBatchFilter
filter' :: Maybe BuildBatchFilter
$sel:filter':ListBuildBatchesForProject' :: ListBuildBatchesForProject -> Maybe BuildBatchFilter
filter'} -> Maybe BuildBatchFilter
filter') (\s :: ListBuildBatchesForProject
s@ListBuildBatchesForProject' {} Maybe BuildBatchFilter
a -> ListBuildBatchesForProject
s {$sel:filter':ListBuildBatchesForProject' :: Maybe BuildBatchFilter
filter' = Maybe BuildBatchFilter
a} :: ListBuildBatchesForProject)

-- | The maximum number of results to return.
listBuildBatchesForProject_maxResults :: Lens.Lens' ListBuildBatchesForProject (Prelude.Maybe Prelude.Natural)
listBuildBatchesForProject_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListBuildBatchesForProject -> f ListBuildBatchesForProject
listBuildBatchesForProject_maxResults = (ListBuildBatchesForProject -> Maybe Natural)
-> (ListBuildBatchesForProject
    -> Maybe Natural -> ListBuildBatchesForProject)
-> Lens
     ListBuildBatchesForProject
     ListBuildBatchesForProject
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBuildBatchesForProject' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListBuildBatchesForProject' :: ListBuildBatchesForProject -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListBuildBatchesForProject
s@ListBuildBatchesForProject' {} Maybe Natural
a -> ListBuildBatchesForProject
s {$sel:maxResults:ListBuildBatchesForProject' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListBuildBatchesForProject)

instance Core.AWSPager ListBuildBatchesForProject where
  page :: ListBuildBatchesForProject
-> AWSResponse ListBuildBatchesForProject
-> Maybe ListBuildBatchesForProject
page ListBuildBatchesForProject
rq AWSResponse ListBuildBatchesForProject
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListBuildBatchesForProject
ListBuildBatchesForProjectResponse
rs
            ListBuildBatchesForProjectResponse
-> Getting (First Text) ListBuildBatchesForProjectResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListBuildBatchesForProjectResponse
-> Const (First Text) ListBuildBatchesForProjectResponse
Lens' ListBuildBatchesForProjectResponse (Maybe Text)
listBuildBatchesForProjectResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListBuildBatchesForProjectResponse
 -> Const (First Text) ListBuildBatchesForProjectResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListBuildBatchesForProjectResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListBuildBatchesForProject
forall a. Maybe a
Prelude.Nothing
    | Maybe [Text] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListBuildBatchesForProject
ListBuildBatchesForProjectResponse
rs
            ListBuildBatchesForProjectResponse
-> Getting (First [Text]) ListBuildBatchesForProjectResponse [Text]
-> Maybe [Text]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> ListBuildBatchesForProjectResponse
-> Const (First [Text]) ListBuildBatchesForProjectResponse
Lens' ListBuildBatchesForProjectResponse (Maybe [Text])
listBuildBatchesForProjectResponse_ids
              ((Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
 -> ListBuildBatchesForProjectResponse
 -> Const (First [Text]) ListBuildBatchesForProjectResponse)
-> (([Text] -> Const (First [Text]) [Text])
    -> Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> Getting (First [Text]) ListBuildBatchesForProjectResponse [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> Const (First [Text]) [Text])
-> Maybe [Text] -> Const (First [Text]) (Maybe [Text])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListBuildBatchesForProject
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListBuildBatchesForProject -> Maybe ListBuildBatchesForProject
forall a. a -> Maybe a
Prelude.Just (ListBuildBatchesForProject -> Maybe ListBuildBatchesForProject)
-> ListBuildBatchesForProject -> Maybe ListBuildBatchesForProject
forall a b. (a -> b) -> a -> b
Prelude.$
        ListBuildBatchesForProject
rq
          ListBuildBatchesForProject
-> (ListBuildBatchesForProject -> ListBuildBatchesForProject)
-> ListBuildBatchesForProject
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListBuildBatchesForProject
-> Identity ListBuildBatchesForProject
Lens
  ListBuildBatchesForProject
  ListBuildBatchesForProject
  (Maybe Text)
  (Maybe Text)
listBuildBatchesForProject_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListBuildBatchesForProject
 -> Identity ListBuildBatchesForProject)
-> Maybe Text
-> ListBuildBatchesForProject
-> ListBuildBatchesForProject
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListBuildBatchesForProject
ListBuildBatchesForProjectResponse
rs
          ListBuildBatchesForProjectResponse
-> Getting (First Text) ListBuildBatchesForProjectResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListBuildBatchesForProjectResponse
-> Const (First Text) ListBuildBatchesForProjectResponse
Lens' ListBuildBatchesForProjectResponse (Maybe Text)
listBuildBatchesForProjectResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListBuildBatchesForProjectResponse
 -> Const (First Text) ListBuildBatchesForProjectResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListBuildBatchesForProjectResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListBuildBatchesForProject where
  type
    AWSResponse ListBuildBatchesForProject =
      ListBuildBatchesForProjectResponse
  request :: ListBuildBatchesForProject -> Request ListBuildBatchesForProject
request = Service
-> ListBuildBatchesForProject -> Request ListBuildBatchesForProject
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListBuildBatchesForProject
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListBuildBatchesForProject)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListBuildBatchesForProject))
-> Logger
-> Service
-> Proxy ListBuildBatchesForProject
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListBuildBatchesForProject)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Text]
-> Maybe Text -> Int -> ListBuildBatchesForProjectResponse
ListBuildBatchesForProjectResponse'
            (Maybe [Text]
 -> Maybe Text -> Int -> ListBuildBatchesForProjectResponse)
-> Either String (Maybe [Text])
-> Either
     String (Maybe Text -> Int -> ListBuildBatchesForProjectResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ids" Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String (Maybe Text -> Int -> ListBuildBatchesForProjectResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListBuildBatchesForProjectResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either String (Int -> ListBuildBatchesForProjectResponse)
-> Either String Int
-> Either String ListBuildBatchesForProjectResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListBuildBatchesForProject

instance Prelude.NFData ListBuildBatchesForProject

instance Core.ToHeaders ListBuildBatchesForProject where
  toHeaders :: ListBuildBatchesForProject -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListBuildBatchesForProject -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"CodeBuild_20161006.ListBuildBatchesForProject" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListBuildBatchesForProject where
  toJSON :: ListBuildBatchesForProject -> Value
toJSON ListBuildBatchesForProject' {Maybe Natural
Maybe Text
Maybe SortOrderType
Maybe BuildBatchFilter
maxResults :: Maybe Natural
filter' :: Maybe BuildBatchFilter
projectName :: Maybe Text
nextToken :: Maybe Text
sortOrder :: Maybe SortOrderType
$sel:maxResults:ListBuildBatchesForProject' :: ListBuildBatchesForProject -> Maybe Natural
$sel:filter':ListBuildBatchesForProject' :: ListBuildBatchesForProject -> Maybe BuildBatchFilter
$sel:projectName:ListBuildBatchesForProject' :: ListBuildBatchesForProject -> Maybe Text
$sel:nextToken:ListBuildBatchesForProject' :: ListBuildBatchesForProject -> Maybe Text
$sel:sortOrder:ListBuildBatchesForProject' :: ListBuildBatchesForProject -> Maybe SortOrderType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"sortOrder" Text -> SortOrderType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SortOrderType -> Pair) -> Maybe SortOrderType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SortOrderType
sortOrder,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"projectName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
projectName,
            (Text
"filter" Text -> BuildBatchFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (BuildBatchFilter -> Pair) -> Maybe BuildBatchFilter -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BuildBatchFilter
filter',
            (Text
"maxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )

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

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

-- | /See:/ 'newListBuildBatchesForProjectResponse' smart constructor.
data ListBuildBatchesForProjectResponse = ListBuildBatchesForProjectResponse'
  { -- | An array of strings that contains the batch build identifiers.
    ListBuildBatchesForProjectResponse -> Maybe [Text]
ids :: Prelude.Maybe [Prelude.Text],
    -- | If there are more items to return, this contains a token that is passed
    -- to a subsequent call to @ListBuildBatchesForProject@ to retrieve the
    -- next set of items.
    ListBuildBatchesForProjectResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListBuildBatchesForProjectResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListBuildBatchesForProjectResponse
-> ListBuildBatchesForProjectResponse -> Bool
(ListBuildBatchesForProjectResponse
 -> ListBuildBatchesForProjectResponse -> Bool)
-> (ListBuildBatchesForProjectResponse
    -> ListBuildBatchesForProjectResponse -> Bool)
-> Eq ListBuildBatchesForProjectResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBuildBatchesForProjectResponse
-> ListBuildBatchesForProjectResponse -> Bool
$c/= :: ListBuildBatchesForProjectResponse
-> ListBuildBatchesForProjectResponse -> Bool
== :: ListBuildBatchesForProjectResponse
-> ListBuildBatchesForProjectResponse -> Bool
$c== :: ListBuildBatchesForProjectResponse
-> ListBuildBatchesForProjectResponse -> Bool
Prelude.Eq, ReadPrec [ListBuildBatchesForProjectResponse]
ReadPrec ListBuildBatchesForProjectResponse
Int -> ReadS ListBuildBatchesForProjectResponse
ReadS [ListBuildBatchesForProjectResponse]
(Int -> ReadS ListBuildBatchesForProjectResponse)
-> ReadS [ListBuildBatchesForProjectResponse]
-> ReadPrec ListBuildBatchesForProjectResponse
-> ReadPrec [ListBuildBatchesForProjectResponse]
-> Read ListBuildBatchesForProjectResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBuildBatchesForProjectResponse]
$creadListPrec :: ReadPrec [ListBuildBatchesForProjectResponse]
readPrec :: ReadPrec ListBuildBatchesForProjectResponse
$creadPrec :: ReadPrec ListBuildBatchesForProjectResponse
readList :: ReadS [ListBuildBatchesForProjectResponse]
$creadList :: ReadS [ListBuildBatchesForProjectResponse]
readsPrec :: Int -> ReadS ListBuildBatchesForProjectResponse
$creadsPrec :: Int -> ReadS ListBuildBatchesForProjectResponse
Prelude.Read, Int -> ListBuildBatchesForProjectResponse -> ShowS
[ListBuildBatchesForProjectResponse] -> ShowS
ListBuildBatchesForProjectResponse -> String
(Int -> ListBuildBatchesForProjectResponse -> ShowS)
-> (ListBuildBatchesForProjectResponse -> String)
-> ([ListBuildBatchesForProjectResponse] -> ShowS)
-> Show ListBuildBatchesForProjectResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBuildBatchesForProjectResponse] -> ShowS
$cshowList :: [ListBuildBatchesForProjectResponse] -> ShowS
show :: ListBuildBatchesForProjectResponse -> String
$cshow :: ListBuildBatchesForProjectResponse -> String
showsPrec :: Int -> ListBuildBatchesForProjectResponse -> ShowS
$cshowsPrec :: Int -> ListBuildBatchesForProjectResponse -> ShowS
Prelude.Show, (forall x.
 ListBuildBatchesForProjectResponse
 -> Rep ListBuildBatchesForProjectResponse x)
-> (forall x.
    Rep ListBuildBatchesForProjectResponse x
    -> ListBuildBatchesForProjectResponse)
-> Generic ListBuildBatchesForProjectResponse
forall x.
Rep ListBuildBatchesForProjectResponse x
-> ListBuildBatchesForProjectResponse
forall x.
ListBuildBatchesForProjectResponse
-> Rep ListBuildBatchesForProjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListBuildBatchesForProjectResponse x
-> ListBuildBatchesForProjectResponse
$cfrom :: forall x.
ListBuildBatchesForProjectResponse
-> Rep ListBuildBatchesForProjectResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListBuildBatchesForProjectResponse' 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:
--
-- 'ids', 'listBuildBatchesForProjectResponse_ids' - An array of strings that contains the batch build identifiers.
--
-- 'nextToken', 'listBuildBatchesForProjectResponse_nextToken' - If there are more items to return, this contains a token that is passed
-- to a subsequent call to @ListBuildBatchesForProject@ to retrieve the
-- next set of items.
--
-- 'httpStatus', 'listBuildBatchesForProjectResponse_httpStatus' - The response's http status code.
newListBuildBatchesForProjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListBuildBatchesForProjectResponse
newListBuildBatchesForProjectResponse :: Int -> ListBuildBatchesForProjectResponse
newListBuildBatchesForProjectResponse Int
pHttpStatus_ =
  ListBuildBatchesForProjectResponse' :: Maybe [Text]
-> Maybe Text -> Int -> ListBuildBatchesForProjectResponse
ListBuildBatchesForProjectResponse'
    { $sel:ids:ListBuildBatchesForProjectResponse' :: Maybe [Text]
ids =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListBuildBatchesForProjectResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListBuildBatchesForProjectResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of strings that contains the batch build identifiers.
listBuildBatchesForProjectResponse_ids :: Lens.Lens' ListBuildBatchesForProjectResponse (Prelude.Maybe [Prelude.Text])
listBuildBatchesForProjectResponse_ids :: (Maybe [Text] -> f (Maybe [Text]))
-> ListBuildBatchesForProjectResponse
-> f ListBuildBatchesForProjectResponse
listBuildBatchesForProjectResponse_ids = (ListBuildBatchesForProjectResponse -> Maybe [Text])
-> (ListBuildBatchesForProjectResponse
    -> Maybe [Text] -> ListBuildBatchesForProjectResponse)
-> Lens' ListBuildBatchesForProjectResponse (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBuildBatchesForProjectResponse' {Maybe [Text]
ids :: Maybe [Text]
$sel:ids:ListBuildBatchesForProjectResponse' :: ListBuildBatchesForProjectResponse -> Maybe [Text]
ids} -> Maybe [Text]
ids) (\s :: ListBuildBatchesForProjectResponse
s@ListBuildBatchesForProjectResponse' {} Maybe [Text]
a -> ListBuildBatchesForProjectResponse
s {$sel:ids:ListBuildBatchesForProjectResponse' :: Maybe [Text]
ids = Maybe [Text]
a} :: ListBuildBatchesForProjectResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListBuildBatchesForProjectResponse
 -> f ListBuildBatchesForProjectResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListBuildBatchesForProjectResponse
-> f ListBuildBatchesForProjectResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If there are more items to return, this contains a token that is passed
-- to a subsequent call to @ListBuildBatchesForProject@ to retrieve the
-- next set of items.
listBuildBatchesForProjectResponse_nextToken :: Lens.Lens' ListBuildBatchesForProjectResponse (Prelude.Maybe Prelude.Text)
listBuildBatchesForProjectResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListBuildBatchesForProjectResponse
-> f ListBuildBatchesForProjectResponse
listBuildBatchesForProjectResponse_nextToken = (ListBuildBatchesForProjectResponse -> Maybe Text)
-> (ListBuildBatchesForProjectResponse
    -> Maybe Text -> ListBuildBatchesForProjectResponse)
-> Lens' ListBuildBatchesForProjectResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBuildBatchesForProjectResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListBuildBatchesForProjectResponse' :: ListBuildBatchesForProjectResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListBuildBatchesForProjectResponse
s@ListBuildBatchesForProjectResponse' {} Maybe Text
a -> ListBuildBatchesForProjectResponse
s {$sel:nextToken:ListBuildBatchesForProjectResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListBuildBatchesForProjectResponse)

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

instance
  Prelude.NFData
    ListBuildBatchesForProjectResponse