{-# 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.Proton.ListComponentOutputs
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Get a list of component Infrastructure as Code (IaC) outputs.
--
-- For more information about components, see
-- <https://docs.aws.amazon.com/proton/latest/userguide/ag-components.html Proton components>
-- in the /Proton User Guide/.
--
-- This operation returns paginated results.
module Amazonka.Proton.ListComponentOutputs
  ( -- * Creating a Request
    ListComponentOutputs (..),
    newListComponentOutputs,

    -- * Request Lenses
    listComponentOutputs_nextToken,
    listComponentOutputs_componentName,

    -- * Destructuring the Response
    ListComponentOutputsResponse (..),
    newListComponentOutputsResponse,

    -- * Response Lenses
    listComponentOutputsResponse_nextToken,
    listComponentOutputsResponse_httpStatus,
    listComponentOutputsResponse_outputs,
  )
where

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

-- | /See:/ 'newListComponentOutputs' smart constructor.
data ListComponentOutputs = ListComponentOutputs'
  { -- | A token that indicates the location of the next output in the array of
    -- outputs, after the list of outputs that was previously requested.
    ListComponentOutputs -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the component whose outputs you want.
    ListComponentOutputs -> Text
componentName :: Prelude.Text
  }
  deriving (ListComponentOutputs -> ListComponentOutputs -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListComponentOutputs -> ListComponentOutputs -> Bool
$c/= :: ListComponentOutputs -> ListComponentOutputs -> Bool
== :: ListComponentOutputs -> ListComponentOutputs -> Bool
$c== :: ListComponentOutputs -> ListComponentOutputs -> Bool
Prelude.Eq, ReadPrec [ListComponentOutputs]
ReadPrec ListComponentOutputs
Int -> ReadS ListComponentOutputs
ReadS [ListComponentOutputs]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListComponentOutputs]
$creadListPrec :: ReadPrec [ListComponentOutputs]
readPrec :: ReadPrec ListComponentOutputs
$creadPrec :: ReadPrec ListComponentOutputs
readList :: ReadS [ListComponentOutputs]
$creadList :: ReadS [ListComponentOutputs]
readsPrec :: Int -> ReadS ListComponentOutputs
$creadsPrec :: Int -> ReadS ListComponentOutputs
Prelude.Read, Int -> ListComponentOutputs -> ShowS
[ListComponentOutputs] -> ShowS
ListComponentOutputs -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListComponentOutputs] -> ShowS
$cshowList :: [ListComponentOutputs] -> ShowS
show :: ListComponentOutputs -> String
$cshow :: ListComponentOutputs -> String
showsPrec :: Int -> ListComponentOutputs -> ShowS
$cshowsPrec :: Int -> ListComponentOutputs -> ShowS
Prelude.Show, forall x. Rep ListComponentOutputs x -> ListComponentOutputs
forall x. ListComponentOutputs -> Rep ListComponentOutputs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListComponentOutputs x -> ListComponentOutputs
$cfrom :: forall x. ListComponentOutputs -> Rep ListComponentOutputs x
Prelude.Generic)

-- |
-- Create a value of 'ListComponentOutputs' 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:
--
-- 'nextToken', 'listComponentOutputs_nextToken' - A token that indicates the location of the next output in the array of
-- outputs, after the list of outputs that was previously requested.
--
-- 'componentName', 'listComponentOutputs_componentName' - The name of the component whose outputs you want.
newListComponentOutputs ::
  -- | 'componentName'
  Prelude.Text ->
  ListComponentOutputs
newListComponentOutputs :: Text -> ListComponentOutputs
newListComponentOutputs Text
pComponentName_ =
  ListComponentOutputs'
    { $sel:nextToken:ListComponentOutputs' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:componentName:ListComponentOutputs' :: Text
componentName = Text
pComponentName_
    }

-- | A token that indicates the location of the next output in the array of
-- outputs, after the list of outputs that was previously requested.
listComponentOutputs_nextToken :: Lens.Lens' ListComponentOutputs (Prelude.Maybe Prelude.Text)
listComponentOutputs_nextToken :: Lens' ListComponentOutputs (Maybe Text)
listComponentOutputs_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListComponentOutputs' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListComponentOutputs' :: ListComponentOutputs -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListComponentOutputs
s@ListComponentOutputs' {} Maybe Text
a -> ListComponentOutputs
s {$sel:nextToken:ListComponentOutputs' :: Maybe Text
nextToken = Maybe Text
a} :: ListComponentOutputs)

-- | The name of the component whose outputs you want.
listComponentOutputs_componentName :: Lens.Lens' ListComponentOutputs Prelude.Text
listComponentOutputs_componentName :: Lens' ListComponentOutputs Text
listComponentOutputs_componentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListComponentOutputs' {Text
componentName :: Text
$sel:componentName:ListComponentOutputs' :: ListComponentOutputs -> Text
componentName} -> Text
componentName) (\s :: ListComponentOutputs
s@ListComponentOutputs' {} Text
a -> ListComponentOutputs
s {$sel:componentName:ListComponentOutputs' :: Text
componentName = Text
a} :: ListComponentOutputs)

instance Core.AWSPager ListComponentOutputs where
  page :: ListComponentOutputs
-> AWSResponse ListComponentOutputs -> Maybe ListComponentOutputs
page ListComponentOutputs
rq AWSResponse ListComponentOutputs
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListComponentOutputs
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListComponentOutputsResponse (Maybe Text)
listComponentOutputsResponse_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 ListComponentOutputs
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListComponentOutputsResponse [Output]
listComponentOutputsResponse_outputs) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListComponentOutputs
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListComponentOutputs (Maybe Text)
listComponentOutputs_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListComponentOutputs
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListComponentOutputsResponse (Maybe Text)
listComponentOutputsResponse_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 ListComponentOutputs where
  type
    AWSResponse ListComponentOutputs =
      ListComponentOutputsResponse
  request :: (Service -> Service)
-> ListComponentOutputs -> Request ListComponentOutputs
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 ListComponentOutputs
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListComponentOutputs)))
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 Text
-> Int -> [Sensitive Output] -> ListComponentOutputsResponse
ListComponentOutputsResponse'
            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
"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))
            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
"outputs" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

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

instance Prelude.NFData ListComponentOutputs where
  rnf :: ListComponentOutputs -> ()
rnf ListComponentOutputs' {Maybe Text
Text
componentName :: Text
nextToken :: Maybe Text
$sel:componentName:ListComponentOutputs' :: ListComponentOutputs -> Text
$sel:nextToken:ListComponentOutputs' :: ListComponentOutputs -> Maybe Text
..} =
    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 Text
componentName

instance Data.ToHeaders ListComponentOutputs where
  toHeaders :: ListComponentOutputs -> 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
"AwsProton20200720.ListComponentOutputs" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

-- | /See:/ 'newListComponentOutputsResponse' smart constructor.
data ListComponentOutputsResponse = ListComponentOutputsResponse'
  { -- | A token that indicates the location of the next output in the array of
    -- outputs, after the list of outputs that was previously requested.
    ListComponentOutputsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListComponentOutputsResponse -> Int
httpStatus :: Prelude.Int,
    -- | An array of component Infrastructure as Code (IaC) outputs.
    ListComponentOutputsResponse -> [Sensitive Output]
outputs :: [Data.Sensitive Output]
  }
  deriving (ListComponentOutputsResponse
-> ListComponentOutputsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListComponentOutputsResponse
-> ListComponentOutputsResponse -> Bool
$c/= :: ListComponentOutputsResponse
-> ListComponentOutputsResponse -> Bool
== :: ListComponentOutputsResponse
-> ListComponentOutputsResponse -> Bool
$c== :: ListComponentOutputsResponse
-> ListComponentOutputsResponse -> Bool
Prelude.Eq, Int -> ListComponentOutputsResponse -> ShowS
[ListComponentOutputsResponse] -> ShowS
ListComponentOutputsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListComponentOutputsResponse] -> ShowS
$cshowList :: [ListComponentOutputsResponse] -> ShowS
show :: ListComponentOutputsResponse -> String
$cshow :: ListComponentOutputsResponse -> String
showsPrec :: Int -> ListComponentOutputsResponse -> ShowS
$cshowsPrec :: Int -> ListComponentOutputsResponse -> ShowS
Prelude.Show, forall x.
Rep ListComponentOutputsResponse x -> ListComponentOutputsResponse
forall x.
ListComponentOutputsResponse -> Rep ListComponentOutputsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListComponentOutputsResponse x -> ListComponentOutputsResponse
$cfrom :: forall x.
ListComponentOutputsResponse -> Rep ListComponentOutputsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListComponentOutputsResponse' 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:
--
-- 'nextToken', 'listComponentOutputsResponse_nextToken' - A token that indicates the location of the next output in the array of
-- outputs, after the list of outputs that was previously requested.
--
-- 'httpStatus', 'listComponentOutputsResponse_httpStatus' - The response's http status code.
--
-- 'outputs', 'listComponentOutputsResponse_outputs' - An array of component Infrastructure as Code (IaC) outputs.
newListComponentOutputsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListComponentOutputsResponse
newListComponentOutputsResponse :: Int -> ListComponentOutputsResponse
newListComponentOutputsResponse Int
pHttpStatus_ =
  ListComponentOutputsResponse'
    { $sel:nextToken:ListComponentOutputsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListComponentOutputsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:outputs:ListComponentOutputsResponse' :: [Sensitive Output]
outputs = forall a. Monoid a => a
Prelude.mempty
    }

-- | A token that indicates the location of the next output in the array of
-- outputs, after the list of outputs that was previously requested.
listComponentOutputsResponse_nextToken :: Lens.Lens' ListComponentOutputsResponse (Prelude.Maybe Prelude.Text)
listComponentOutputsResponse_nextToken :: Lens' ListComponentOutputsResponse (Maybe Text)
listComponentOutputsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListComponentOutputsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListComponentOutputsResponse' :: ListComponentOutputsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListComponentOutputsResponse
s@ListComponentOutputsResponse' {} Maybe Text
a -> ListComponentOutputsResponse
s {$sel:nextToken:ListComponentOutputsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListComponentOutputsResponse)

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

-- | An array of component Infrastructure as Code (IaC) outputs.
listComponentOutputsResponse_outputs :: Lens.Lens' ListComponentOutputsResponse [Output]
listComponentOutputsResponse_outputs :: Lens' ListComponentOutputsResponse [Output]
listComponentOutputsResponse_outputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListComponentOutputsResponse' {[Sensitive Output]
outputs :: [Sensitive Output]
$sel:outputs:ListComponentOutputsResponse' :: ListComponentOutputsResponse -> [Sensitive Output]
outputs} -> [Sensitive Output]
outputs) (\s :: ListComponentOutputsResponse
s@ListComponentOutputsResponse' {} [Sensitive Output]
a -> ListComponentOutputsResponse
s {$sel:outputs:ListComponentOutputsResponse' :: [Sensitive Output]
outputs = [Sensitive Output]
a} :: ListComponentOutputsResponse) 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 ListComponentOutputsResponse where
  rnf :: ListComponentOutputsResponse -> ()
rnf ListComponentOutputsResponse' {Int
[Sensitive Output]
Maybe Text
outputs :: [Sensitive Output]
httpStatus :: Int
nextToken :: Maybe Text
$sel:outputs:ListComponentOutputsResponse' :: ListComponentOutputsResponse -> [Sensitive Output]
$sel:httpStatus:ListComponentOutputsResponse' :: ListComponentOutputsResponse -> Int
$sel:nextToken:ListComponentOutputsResponse' :: ListComponentOutputsResponse -> Maybe Text
..} =
    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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Sensitive Output]
outputs