{-# 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.DescribePipelines
-- 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 metadata about one or more pipelines. The information
-- retrieved includes the name of the pipeline, the pipeline identifier,
-- its current state, and the user account that owns the pipeline. Using
-- account credentials, you can retrieve metadata about pipelines that you
-- or your IAM users have created. If you are using an IAM user account,
-- you can retrieve metadata about only those pipelines for which you have
-- read permissions.
--
-- To retrieve the full pipeline definition instead of metadata about the
-- pipeline, call GetPipelineDefinition.
module Amazonka.DataPipeline.DescribePipelines
  ( -- * Creating a Request
    DescribePipelines (..),
    newDescribePipelines,

    -- * Request Lenses
    describePipelines_pipelineIds,

    -- * Destructuring the Response
    DescribePipelinesResponse (..),
    newDescribePipelinesResponse,

    -- * Response Lenses
    describePipelinesResponse_httpStatus,
    describePipelinesResponse_pipelineDescriptionList,
  )
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 DescribePipelines.
--
-- /See:/ 'newDescribePipelines' smart constructor.
data DescribePipelines = DescribePipelines'
  { -- | The IDs of the pipelines to describe. You can pass as many as 25
    -- identifiers in a single call. To obtain pipeline IDs, call
    -- ListPipelines.
    DescribePipelines -> [Text]
pipelineIds :: [Prelude.Text]
  }
  deriving (DescribePipelines -> DescribePipelines -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribePipelines -> DescribePipelines -> Bool
$c/= :: DescribePipelines -> DescribePipelines -> Bool
== :: DescribePipelines -> DescribePipelines -> Bool
$c== :: DescribePipelines -> DescribePipelines -> Bool
Prelude.Eq, ReadPrec [DescribePipelines]
ReadPrec DescribePipelines
Int -> ReadS DescribePipelines
ReadS [DescribePipelines]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribePipelines]
$creadListPrec :: ReadPrec [DescribePipelines]
readPrec :: ReadPrec DescribePipelines
$creadPrec :: ReadPrec DescribePipelines
readList :: ReadS [DescribePipelines]
$creadList :: ReadS [DescribePipelines]
readsPrec :: Int -> ReadS DescribePipelines
$creadsPrec :: Int -> ReadS DescribePipelines
Prelude.Read, Int -> DescribePipelines -> ShowS
[DescribePipelines] -> ShowS
DescribePipelines -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribePipelines] -> ShowS
$cshowList :: [DescribePipelines] -> ShowS
show :: DescribePipelines -> String
$cshow :: DescribePipelines -> String
showsPrec :: Int -> DescribePipelines -> ShowS
$cshowsPrec :: Int -> DescribePipelines -> ShowS
Prelude.Show, forall x. Rep DescribePipelines x -> DescribePipelines
forall x. DescribePipelines -> Rep DescribePipelines x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribePipelines x -> DescribePipelines
$cfrom :: forall x. DescribePipelines -> Rep DescribePipelines x
Prelude.Generic)

-- |
-- Create a value of 'DescribePipelines' 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:
--
-- 'pipelineIds', 'describePipelines_pipelineIds' - The IDs of the pipelines to describe. You can pass as many as 25
-- identifiers in a single call. To obtain pipeline IDs, call
-- ListPipelines.
newDescribePipelines ::
  DescribePipelines
newDescribePipelines :: DescribePipelines
newDescribePipelines =
  DescribePipelines' {$sel:pipelineIds:DescribePipelines' :: [Text]
pipelineIds = forall a. Monoid a => a
Prelude.mempty}

-- | The IDs of the pipelines to describe. You can pass as many as 25
-- identifiers in a single call. To obtain pipeline IDs, call
-- ListPipelines.
describePipelines_pipelineIds :: Lens.Lens' DescribePipelines [Prelude.Text]
describePipelines_pipelineIds :: Lens' DescribePipelines [Text]
describePipelines_pipelineIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePipelines' {[Text]
pipelineIds :: [Text]
$sel:pipelineIds:DescribePipelines' :: DescribePipelines -> [Text]
pipelineIds} -> [Text]
pipelineIds) (\s :: DescribePipelines
s@DescribePipelines' {} [Text]
a -> DescribePipelines
s {$sel:pipelineIds:DescribePipelines' :: [Text]
pipelineIds = [Text]
a} :: DescribePipelines) 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 Core.AWSRequest DescribePipelines where
  type
    AWSResponse DescribePipelines =
      DescribePipelinesResponse
  request :: (Service -> Service)
-> DescribePipelines -> Request DescribePipelines
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 DescribePipelines
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribePipelines)))
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 ->
          Int -> [PipelineDescription] -> DescribePipelinesResponse
DescribePipelinesResponse'
            forall (f :: * -> *) a b. Functor 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
"pipelineDescriptionList"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable DescribePipelines where
  hashWithSalt :: Int -> DescribePipelines -> Int
hashWithSalt Int
_salt DescribePipelines' {[Text]
pipelineIds :: [Text]
$sel:pipelineIds:DescribePipelines' :: DescribePipelines -> [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
pipelineIds

instance Prelude.NFData DescribePipelines where
  rnf :: DescribePipelines -> ()
rnf DescribePipelines' {[Text]
pipelineIds :: [Text]
$sel:pipelineIds:DescribePipelines' :: DescribePipelines -> [Text]
..} = forall a. NFData a => a -> ()
Prelude.rnf [Text]
pipelineIds

instance Data.ToHeaders DescribePipelines where
  toHeaders :: DescribePipelines -> 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.DescribePipelines" ::
                          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 DescribePipelines where
  toJSON :: DescribePipelines -> Value
toJSON DescribePipelines' {[Text]
pipelineIds :: [Text]
$sel:pipelineIds:DescribePipelines' :: DescribePipelines -> [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"pipelineIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
pipelineIds)]
      )

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

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

-- | Contains the output of DescribePipelines.
--
-- /See:/ 'newDescribePipelinesResponse' smart constructor.
data DescribePipelinesResponse = DescribePipelinesResponse'
  { -- | The response's http status code.
    DescribePipelinesResponse -> Int
httpStatus :: Prelude.Int,
    -- | An array of descriptions for the specified pipelines.
    DescribePipelinesResponse -> [PipelineDescription]
pipelineDescriptionList :: [PipelineDescription]
  }
  deriving (DescribePipelinesResponse -> DescribePipelinesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribePipelinesResponse -> DescribePipelinesResponse -> Bool
$c/= :: DescribePipelinesResponse -> DescribePipelinesResponse -> Bool
== :: DescribePipelinesResponse -> DescribePipelinesResponse -> Bool
$c== :: DescribePipelinesResponse -> DescribePipelinesResponse -> Bool
Prelude.Eq, ReadPrec [DescribePipelinesResponse]
ReadPrec DescribePipelinesResponse
Int -> ReadS DescribePipelinesResponse
ReadS [DescribePipelinesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribePipelinesResponse]
$creadListPrec :: ReadPrec [DescribePipelinesResponse]
readPrec :: ReadPrec DescribePipelinesResponse
$creadPrec :: ReadPrec DescribePipelinesResponse
readList :: ReadS [DescribePipelinesResponse]
$creadList :: ReadS [DescribePipelinesResponse]
readsPrec :: Int -> ReadS DescribePipelinesResponse
$creadsPrec :: Int -> ReadS DescribePipelinesResponse
Prelude.Read, Int -> DescribePipelinesResponse -> ShowS
[DescribePipelinesResponse] -> ShowS
DescribePipelinesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribePipelinesResponse] -> ShowS
$cshowList :: [DescribePipelinesResponse] -> ShowS
show :: DescribePipelinesResponse -> String
$cshow :: DescribePipelinesResponse -> String
showsPrec :: Int -> DescribePipelinesResponse -> ShowS
$cshowsPrec :: Int -> DescribePipelinesResponse -> ShowS
Prelude.Show, forall x.
Rep DescribePipelinesResponse x -> DescribePipelinesResponse
forall x.
DescribePipelinesResponse -> Rep DescribePipelinesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribePipelinesResponse x -> DescribePipelinesResponse
$cfrom :: forall x.
DescribePipelinesResponse -> Rep DescribePipelinesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribePipelinesResponse' 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:
--
-- 'httpStatus', 'describePipelinesResponse_httpStatus' - The response's http status code.
--
-- 'pipelineDescriptionList', 'describePipelinesResponse_pipelineDescriptionList' - An array of descriptions for the specified pipelines.
newDescribePipelinesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribePipelinesResponse
newDescribePipelinesResponse :: Int -> DescribePipelinesResponse
newDescribePipelinesResponse Int
pHttpStatus_ =
  DescribePipelinesResponse'
    { $sel:httpStatus:DescribePipelinesResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:pipelineDescriptionList:DescribePipelinesResponse' :: [PipelineDescription]
pipelineDescriptionList = forall a. Monoid a => a
Prelude.mempty
    }

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

-- | An array of descriptions for the specified pipelines.
describePipelinesResponse_pipelineDescriptionList :: Lens.Lens' DescribePipelinesResponse [PipelineDescription]
describePipelinesResponse_pipelineDescriptionList :: Lens' DescribePipelinesResponse [PipelineDescription]
describePipelinesResponse_pipelineDescriptionList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePipelinesResponse' {[PipelineDescription]
pipelineDescriptionList :: [PipelineDescription]
$sel:pipelineDescriptionList:DescribePipelinesResponse' :: DescribePipelinesResponse -> [PipelineDescription]
pipelineDescriptionList} -> [PipelineDescription]
pipelineDescriptionList) (\s :: DescribePipelinesResponse
s@DescribePipelinesResponse' {} [PipelineDescription]
a -> DescribePipelinesResponse
s {$sel:pipelineDescriptionList:DescribePipelinesResponse' :: [PipelineDescription]
pipelineDescriptionList = [PipelineDescription]
a} :: DescribePipelinesResponse) 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 DescribePipelinesResponse where
  rnf :: DescribePipelinesResponse -> ()
rnf DescribePipelinesResponse' {Int
[PipelineDescription]
pipelineDescriptionList :: [PipelineDescription]
httpStatus :: Int
$sel:pipelineDescriptionList:DescribePipelinesResponse' :: DescribePipelinesResponse -> [PipelineDescription]
$sel:httpStatus:DescribePipelinesResponse' :: DescribePipelinesResponse -> Int
..} =
    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 [PipelineDescription]
pipelineDescriptionList