{-# 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.DataPipeline.ListPipelines
-- 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 the pipeline identifiers for all active pipelines that you have
-- permission to access.
--
-- This operation returns paginated results.
module Amazonka.DataPipeline.ListPipelines
  ( -- * Creating a Request
    ListPipelines (..),
    newListPipelines,

    -- * Request Lenses
    listPipelines_marker,

    -- * Destructuring the Response
    ListPipelinesResponse (..),
    newListPipelinesResponse,

    -- * Response Lenses
    listPipelinesResponse_hasMoreResults,
    listPipelinesResponse_marker,
    listPipelinesResponse_httpStatus,
    listPipelinesResponse_pipelineIdList,
  )
where

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

-- | Contains the parameters for ListPipelines.
--
-- /See:/ 'newListPipelines' smart constructor.
data ListPipelines = ListPipelines'
  { -- | The starting point for the results to be returned. For the first call,
    -- this value should be empty. As long as there are more results, continue
    -- to call @ListPipelines@ with the marker value from the previous call to
    -- retrieve the next set of results.
    ListPipelines -> Maybe Text
marker :: Prelude.Maybe Prelude.Text
  }
  deriving (ListPipelines -> ListPipelines -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPipelines -> ListPipelines -> Bool
$c/= :: ListPipelines -> ListPipelines -> Bool
== :: ListPipelines -> ListPipelines -> Bool
$c== :: ListPipelines -> ListPipelines -> Bool
Prelude.Eq, ReadPrec [ListPipelines]
ReadPrec ListPipelines
Int -> ReadS ListPipelines
ReadS [ListPipelines]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPipelines]
$creadListPrec :: ReadPrec [ListPipelines]
readPrec :: ReadPrec ListPipelines
$creadPrec :: ReadPrec ListPipelines
readList :: ReadS [ListPipelines]
$creadList :: ReadS [ListPipelines]
readsPrec :: Int -> ReadS ListPipelines
$creadsPrec :: Int -> ReadS ListPipelines
Prelude.Read, Int -> ListPipelines -> ShowS
[ListPipelines] -> ShowS
ListPipelines -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPipelines] -> ShowS
$cshowList :: [ListPipelines] -> ShowS
show :: ListPipelines -> String
$cshow :: ListPipelines -> String
showsPrec :: Int -> ListPipelines -> ShowS
$cshowsPrec :: Int -> ListPipelines -> ShowS
Prelude.Show, forall x. Rep ListPipelines x -> ListPipelines
forall x. ListPipelines -> Rep ListPipelines x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPipelines x -> ListPipelines
$cfrom :: forall x. ListPipelines -> Rep ListPipelines x
Prelude.Generic)

-- |
-- Create a value of 'ListPipelines' 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:
--
-- 'marker', 'listPipelines_marker' - The starting point for the results to be returned. For the first call,
-- this value should be empty. As long as there are more results, continue
-- to call @ListPipelines@ with the marker value from the previous call to
-- retrieve the next set of results.
newListPipelines ::
  ListPipelines
newListPipelines :: ListPipelines
newListPipelines =
  ListPipelines' {$sel:marker:ListPipelines' :: Maybe Text
marker = forall a. Maybe a
Prelude.Nothing}

-- | The starting point for the results to be returned. For the first call,
-- this value should be empty. As long as there are more results, continue
-- to call @ListPipelines@ with the marker value from the previous call to
-- retrieve the next set of results.
listPipelines_marker :: Lens.Lens' ListPipelines (Prelude.Maybe Prelude.Text)
listPipelines_marker :: Lens' ListPipelines (Maybe Text)
listPipelines_marker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPipelines' {Maybe Text
marker :: Maybe Text
$sel:marker:ListPipelines' :: ListPipelines -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListPipelines
s@ListPipelines' {} Maybe Text
a -> ListPipelines
s {$sel:marker:ListPipelines' :: Maybe Text
marker = Maybe Text
a} :: ListPipelines)

instance Core.AWSPager ListPipelines where
  page :: ListPipelines -> AWSResponse ListPipelines -> Maybe ListPipelines
page ListPipelines
rq AWSResponse ListPipelines
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPipelines
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPipelinesResponse (Maybe Bool)
listPipelinesResponse_hasMoreResults
            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. Maybe a -> Bool
Prelude.isNothing
        ( AWSResponse ListPipelines
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPipelinesResponse (Maybe Text)
listPipelinesResponse_marker
            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.$ ListPipelines
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListPipelines (Maybe Text)
listPipelines_marker
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListPipelines
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPipelinesResponse (Maybe Text)
listPipelinesResponse_marker
          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 ListPipelines where
  type
    AWSResponse ListPipelines =
      ListPipelinesResponse
  request :: (Service -> Service) -> ListPipelines -> Request ListPipelines
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 ListPipelines
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPipelines)))
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 Bool
-> Maybe Text -> Int -> [PipelineIdName] -> ListPipelinesResponse
ListPipelinesResponse'
            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
"hasMoreResults")
            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
"marker")
            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))
            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
"pipelineIdList"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
      )

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

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

instance Data.ToHeaders ListPipelines where
  toHeaders :: ListPipelines -> 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
"DataPipeline.ListPipelines" :: 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 ListPipelines where
  toJSON :: ListPipelines -> Value
toJSON ListPipelines' {Maybe Text
marker :: Maybe Text
$sel:marker:ListPipelines' :: ListPipelines -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"marker" 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
marker]
      )

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

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

-- | Contains the output of ListPipelines.
--
-- /See:/ 'newListPipelinesResponse' smart constructor.
data ListPipelinesResponse = ListPipelinesResponse'
  { -- | Indicates whether there are more results that can be obtained by a
    -- subsequent call.
    ListPipelinesResponse -> Maybe Bool
hasMoreResults :: Prelude.Maybe Prelude.Bool,
    -- | The starting point for the next page of results. To view the next page
    -- of results, call @ListPipelinesOutput@ again with this marker value. If
    -- the value is null, there are no more results.
    ListPipelinesResponse -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListPipelinesResponse -> Int
httpStatus :: Prelude.Int,
    -- | The pipeline identifiers. If you require additional information about
    -- the pipelines, you can use these identifiers to call DescribePipelines
    -- and GetPipelineDefinition.
    ListPipelinesResponse -> [PipelineIdName]
pipelineIdList :: [PipelineIdName]
  }
  deriving (ListPipelinesResponse -> ListPipelinesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPipelinesResponse -> ListPipelinesResponse -> Bool
$c/= :: ListPipelinesResponse -> ListPipelinesResponse -> Bool
== :: ListPipelinesResponse -> ListPipelinesResponse -> Bool
$c== :: ListPipelinesResponse -> ListPipelinesResponse -> Bool
Prelude.Eq, ReadPrec [ListPipelinesResponse]
ReadPrec ListPipelinesResponse
Int -> ReadS ListPipelinesResponse
ReadS [ListPipelinesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPipelinesResponse]
$creadListPrec :: ReadPrec [ListPipelinesResponse]
readPrec :: ReadPrec ListPipelinesResponse
$creadPrec :: ReadPrec ListPipelinesResponse
readList :: ReadS [ListPipelinesResponse]
$creadList :: ReadS [ListPipelinesResponse]
readsPrec :: Int -> ReadS ListPipelinesResponse
$creadsPrec :: Int -> ReadS ListPipelinesResponse
Prelude.Read, Int -> ListPipelinesResponse -> ShowS
[ListPipelinesResponse] -> ShowS
ListPipelinesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPipelinesResponse] -> ShowS
$cshowList :: [ListPipelinesResponse] -> ShowS
show :: ListPipelinesResponse -> String
$cshow :: ListPipelinesResponse -> String
showsPrec :: Int -> ListPipelinesResponse -> ShowS
$cshowsPrec :: Int -> ListPipelinesResponse -> ShowS
Prelude.Show, forall x. Rep ListPipelinesResponse x -> ListPipelinesResponse
forall x. ListPipelinesResponse -> Rep ListPipelinesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPipelinesResponse x -> ListPipelinesResponse
$cfrom :: forall x. ListPipelinesResponse -> Rep ListPipelinesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPipelinesResponse' 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:
--
-- 'hasMoreResults', 'listPipelinesResponse_hasMoreResults' - Indicates whether there are more results that can be obtained by a
-- subsequent call.
--
-- 'marker', 'listPipelinesResponse_marker' - The starting point for the next page of results. To view the next page
-- of results, call @ListPipelinesOutput@ again with this marker value. If
-- the value is null, there are no more results.
--
-- 'httpStatus', 'listPipelinesResponse_httpStatus' - The response's http status code.
--
-- 'pipelineIdList', 'listPipelinesResponse_pipelineIdList' - The pipeline identifiers. If you require additional information about
-- the pipelines, you can use these identifiers to call DescribePipelines
-- and GetPipelineDefinition.
newListPipelinesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPipelinesResponse
newListPipelinesResponse :: Int -> ListPipelinesResponse
newListPipelinesResponse Int
pHttpStatus_ =
  ListPipelinesResponse'
    { $sel:hasMoreResults:ListPipelinesResponse' :: Maybe Bool
hasMoreResults =
        forall a. Maybe a
Prelude.Nothing,
      $sel:marker:ListPipelinesResponse' :: Maybe Text
marker = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPipelinesResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:pipelineIdList:ListPipelinesResponse' :: [PipelineIdName]
pipelineIdList = forall a. Monoid a => a
Prelude.mempty
    }

-- | Indicates whether there are more results that can be obtained by a
-- subsequent call.
listPipelinesResponse_hasMoreResults :: Lens.Lens' ListPipelinesResponse (Prelude.Maybe Prelude.Bool)
listPipelinesResponse_hasMoreResults :: Lens' ListPipelinesResponse (Maybe Bool)
listPipelinesResponse_hasMoreResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPipelinesResponse' {Maybe Bool
hasMoreResults :: Maybe Bool
$sel:hasMoreResults:ListPipelinesResponse' :: ListPipelinesResponse -> Maybe Bool
hasMoreResults} -> Maybe Bool
hasMoreResults) (\s :: ListPipelinesResponse
s@ListPipelinesResponse' {} Maybe Bool
a -> ListPipelinesResponse
s {$sel:hasMoreResults:ListPipelinesResponse' :: Maybe Bool
hasMoreResults = Maybe Bool
a} :: ListPipelinesResponse)

-- | The starting point for the next page of results. To view the next page
-- of results, call @ListPipelinesOutput@ again with this marker value. If
-- the value is null, there are no more results.
listPipelinesResponse_marker :: Lens.Lens' ListPipelinesResponse (Prelude.Maybe Prelude.Text)
listPipelinesResponse_marker :: Lens' ListPipelinesResponse (Maybe Text)
listPipelinesResponse_marker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPipelinesResponse' {Maybe Text
marker :: Maybe Text
$sel:marker:ListPipelinesResponse' :: ListPipelinesResponse -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListPipelinesResponse
s@ListPipelinesResponse' {} Maybe Text
a -> ListPipelinesResponse
s {$sel:marker:ListPipelinesResponse' :: Maybe Text
marker = Maybe Text
a} :: ListPipelinesResponse)

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

-- | The pipeline identifiers. If you require additional information about
-- the pipelines, you can use these identifiers to call DescribePipelines
-- and GetPipelineDefinition.
listPipelinesResponse_pipelineIdList :: Lens.Lens' ListPipelinesResponse [PipelineIdName]
listPipelinesResponse_pipelineIdList :: Lens' ListPipelinesResponse [PipelineIdName]
listPipelinesResponse_pipelineIdList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPipelinesResponse' {[PipelineIdName]
pipelineIdList :: [PipelineIdName]
$sel:pipelineIdList:ListPipelinesResponse' :: ListPipelinesResponse -> [PipelineIdName]
pipelineIdList} -> [PipelineIdName]
pipelineIdList) (\s :: ListPipelinesResponse
s@ListPipelinesResponse' {} [PipelineIdName]
a -> ListPipelinesResponse
s {$sel:pipelineIdList:ListPipelinesResponse' :: [PipelineIdName]
pipelineIdList = [PipelineIdName]
a} :: ListPipelinesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListPipelinesResponse where
  rnf :: ListPipelinesResponse -> ()
rnf ListPipelinesResponse' {Int
[PipelineIdName]
Maybe Bool
Maybe Text
pipelineIdList :: [PipelineIdName]
httpStatus :: Int
marker :: Maybe Text
hasMoreResults :: Maybe Bool
$sel:pipelineIdList:ListPipelinesResponse' :: ListPipelinesResponse -> [PipelineIdName]
$sel:httpStatus:ListPipelinesResponse' :: ListPipelinesResponse -> Int
$sel:marker:ListPipelinesResponse' :: ListPipelinesResponse -> Maybe Text
$sel:hasMoreResults:ListPipelinesResponse' :: ListPipelinesResponse -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
hasMoreResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
marker
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 [PipelineIdName]
pipelineIdList