{-# 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.IoTSiteWise.ListAssociatedAssets
-- 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 a paginated list of associated assets.
--
-- You can use this operation to do the following:
--
-- -   List child assets associated to a parent asset by a hierarchy that
--     you specify.
--
-- -   List an asset\'s parent asset.
--
-- This operation returns paginated results.
module Amazonka.IoTSiteWise.ListAssociatedAssets
  ( -- * Creating a Request
    ListAssociatedAssets (..),
    newListAssociatedAssets,

    -- * Request Lenses
    listAssociatedAssets_hierarchyId,
    listAssociatedAssets_traversalDirection,
    listAssociatedAssets_nextToken,
    listAssociatedAssets_maxResults,
    listAssociatedAssets_assetId,

    -- * Destructuring the Response
    ListAssociatedAssetsResponse (..),
    newListAssociatedAssetsResponse,

    -- * Response Lenses
    listAssociatedAssetsResponse_nextToken,
    listAssociatedAssetsResponse_httpStatus,
    listAssociatedAssetsResponse_assetSummaries,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types
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:/ 'newListAssociatedAssets' smart constructor.
data ListAssociatedAssets = ListAssociatedAssets'
  { -- | The ID of the hierarchy by which child assets are associated to the
    -- asset. To find a hierarchy ID, use the
    -- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_DescribeAsset.html DescribeAsset>
    -- or
    -- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_DescribeAssetModel.html DescribeAssetModel>
    -- operations. This parameter is required if you choose @CHILD@ for
    -- @traversalDirection@.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/asset-hierarchies.html Asset hierarchies>
    -- in the /IoT SiteWise User Guide/.
    ListAssociatedAssets -> Maybe Text
hierarchyId :: Prelude.Maybe Prelude.Text,
    -- | The direction to list associated assets. Choose one of the following
    -- options:
    --
    -- -   @CHILD@ – The list includes all child assets associated to the
    --     asset. The @hierarchyId@ parameter is required if you choose
    --     @CHILD@.
    --
    -- -   @PARENT@ – The list includes the asset\'s parent asset.
    --
    -- Default: @CHILD@
    ListAssociatedAssets -> Maybe TraversalDirection
traversalDirection :: Prelude.Maybe TraversalDirection,
    -- | The token to be used for the next set of paginated results.
    ListAssociatedAssets -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return for each paginated request.
    --
    -- Default: 50
    ListAssociatedAssets -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ID of the asset to query.
    ListAssociatedAssets -> Text
assetId :: Prelude.Text
  }
  deriving (ListAssociatedAssets -> ListAssociatedAssets -> Bool
(ListAssociatedAssets -> ListAssociatedAssets -> Bool)
-> (ListAssociatedAssets -> ListAssociatedAssets -> Bool)
-> Eq ListAssociatedAssets
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAssociatedAssets -> ListAssociatedAssets -> Bool
$c/= :: ListAssociatedAssets -> ListAssociatedAssets -> Bool
== :: ListAssociatedAssets -> ListAssociatedAssets -> Bool
$c== :: ListAssociatedAssets -> ListAssociatedAssets -> Bool
Prelude.Eq, ReadPrec [ListAssociatedAssets]
ReadPrec ListAssociatedAssets
Int -> ReadS ListAssociatedAssets
ReadS [ListAssociatedAssets]
(Int -> ReadS ListAssociatedAssets)
-> ReadS [ListAssociatedAssets]
-> ReadPrec ListAssociatedAssets
-> ReadPrec [ListAssociatedAssets]
-> Read ListAssociatedAssets
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAssociatedAssets]
$creadListPrec :: ReadPrec [ListAssociatedAssets]
readPrec :: ReadPrec ListAssociatedAssets
$creadPrec :: ReadPrec ListAssociatedAssets
readList :: ReadS [ListAssociatedAssets]
$creadList :: ReadS [ListAssociatedAssets]
readsPrec :: Int -> ReadS ListAssociatedAssets
$creadsPrec :: Int -> ReadS ListAssociatedAssets
Prelude.Read, Int -> ListAssociatedAssets -> ShowS
[ListAssociatedAssets] -> ShowS
ListAssociatedAssets -> String
(Int -> ListAssociatedAssets -> ShowS)
-> (ListAssociatedAssets -> String)
-> ([ListAssociatedAssets] -> ShowS)
-> Show ListAssociatedAssets
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAssociatedAssets] -> ShowS
$cshowList :: [ListAssociatedAssets] -> ShowS
show :: ListAssociatedAssets -> String
$cshow :: ListAssociatedAssets -> String
showsPrec :: Int -> ListAssociatedAssets -> ShowS
$cshowsPrec :: Int -> ListAssociatedAssets -> ShowS
Prelude.Show, (forall x. ListAssociatedAssets -> Rep ListAssociatedAssets x)
-> (forall x. Rep ListAssociatedAssets x -> ListAssociatedAssets)
-> Generic ListAssociatedAssets
forall x. Rep ListAssociatedAssets x -> ListAssociatedAssets
forall x. ListAssociatedAssets -> Rep ListAssociatedAssets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAssociatedAssets x -> ListAssociatedAssets
$cfrom :: forall x. ListAssociatedAssets -> Rep ListAssociatedAssets x
Prelude.Generic)

-- |
-- Create a value of 'ListAssociatedAssets' 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:
--
-- 'hierarchyId', 'listAssociatedAssets_hierarchyId' - The ID of the hierarchy by which child assets are associated to the
-- asset. To find a hierarchy ID, use the
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_DescribeAsset.html DescribeAsset>
-- or
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_DescribeAssetModel.html DescribeAssetModel>
-- operations. This parameter is required if you choose @CHILD@ for
-- @traversalDirection@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/asset-hierarchies.html Asset hierarchies>
-- in the /IoT SiteWise User Guide/.
--
-- 'traversalDirection', 'listAssociatedAssets_traversalDirection' - The direction to list associated assets. Choose one of the following
-- options:
--
-- -   @CHILD@ – The list includes all child assets associated to the
--     asset. The @hierarchyId@ parameter is required if you choose
--     @CHILD@.
--
-- -   @PARENT@ – The list includes the asset\'s parent asset.
--
-- Default: @CHILD@
--
-- 'nextToken', 'listAssociatedAssets_nextToken' - The token to be used for the next set of paginated results.
--
-- 'maxResults', 'listAssociatedAssets_maxResults' - The maximum number of results to return for each paginated request.
--
-- Default: 50
--
-- 'assetId', 'listAssociatedAssets_assetId' - The ID of the asset to query.
newListAssociatedAssets ::
  -- | 'assetId'
  Prelude.Text ->
  ListAssociatedAssets
newListAssociatedAssets :: Text -> ListAssociatedAssets
newListAssociatedAssets Text
pAssetId_ =
  ListAssociatedAssets' :: Maybe Text
-> Maybe TraversalDirection
-> Maybe Text
-> Maybe Natural
-> Text
-> ListAssociatedAssets
ListAssociatedAssets'
    { $sel:hierarchyId:ListAssociatedAssets' :: Maybe Text
hierarchyId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:traversalDirection:ListAssociatedAssets' :: Maybe TraversalDirection
traversalDirection = Maybe TraversalDirection
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAssociatedAssets' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAssociatedAssets' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:assetId:ListAssociatedAssets' :: Text
assetId = Text
pAssetId_
    }

-- | The ID of the hierarchy by which child assets are associated to the
-- asset. To find a hierarchy ID, use the
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_DescribeAsset.html DescribeAsset>
-- or
-- <https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_DescribeAssetModel.html DescribeAssetModel>
-- operations. This parameter is required if you choose @CHILD@ for
-- @traversalDirection@.
--
-- For more information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/asset-hierarchies.html Asset hierarchies>
-- in the /IoT SiteWise User Guide/.
listAssociatedAssets_hierarchyId :: Lens.Lens' ListAssociatedAssets (Prelude.Maybe Prelude.Text)
listAssociatedAssets_hierarchyId :: (Maybe Text -> f (Maybe Text))
-> ListAssociatedAssets -> f ListAssociatedAssets
listAssociatedAssets_hierarchyId = (ListAssociatedAssets -> Maybe Text)
-> (ListAssociatedAssets -> Maybe Text -> ListAssociatedAssets)
-> Lens
     ListAssociatedAssets ListAssociatedAssets (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssociatedAssets' {Maybe Text
hierarchyId :: Maybe Text
$sel:hierarchyId:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe Text
hierarchyId} -> Maybe Text
hierarchyId) (\s :: ListAssociatedAssets
s@ListAssociatedAssets' {} Maybe Text
a -> ListAssociatedAssets
s {$sel:hierarchyId:ListAssociatedAssets' :: Maybe Text
hierarchyId = Maybe Text
a} :: ListAssociatedAssets)

-- | The direction to list associated assets. Choose one of the following
-- options:
--
-- -   @CHILD@ – The list includes all child assets associated to the
--     asset. The @hierarchyId@ parameter is required if you choose
--     @CHILD@.
--
-- -   @PARENT@ – The list includes the asset\'s parent asset.
--
-- Default: @CHILD@
listAssociatedAssets_traversalDirection :: Lens.Lens' ListAssociatedAssets (Prelude.Maybe TraversalDirection)
listAssociatedAssets_traversalDirection :: (Maybe TraversalDirection -> f (Maybe TraversalDirection))
-> ListAssociatedAssets -> f ListAssociatedAssets
listAssociatedAssets_traversalDirection = (ListAssociatedAssets -> Maybe TraversalDirection)
-> (ListAssociatedAssets
    -> Maybe TraversalDirection -> ListAssociatedAssets)
-> Lens
     ListAssociatedAssets
     ListAssociatedAssets
     (Maybe TraversalDirection)
     (Maybe TraversalDirection)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssociatedAssets' {Maybe TraversalDirection
traversalDirection :: Maybe TraversalDirection
$sel:traversalDirection:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe TraversalDirection
traversalDirection} -> Maybe TraversalDirection
traversalDirection) (\s :: ListAssociatedAssets
s@ListAssociatedAssets' {} Maybe TraversalDirection
a -> ListAssociatedAssets
s {$sel:traversalDirection:ListAssociatedAssets' :: Maybe TraversalDirection
traversalDirection = Maybe TraversalDirection
a} :: ListAssociatedAssets)

-- | The token to be used for the next set of paginated results.
listAssociatedAssets_nextToken :: Lens.Lens' ListAssociatedAssets (Prelude.Maybe Prelude.Text)
listAssociatedAssets_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAssociatedAssets -> f ListAssociatedAssets
listAssociatedAssets_nextToken = (ListAssociatedAssets -> Maybe Text)
-> (ListAssociatedAssets -> Maybe Text -> ListAssociatedAssets)
-> Lens
     ListAssociatedAssets ListAssociatedAssets (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssociatedAssets' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAssociatedAssets
s@ListAssociatedAssets' {} Maybe Text
a -> ListAssociatedAssets
s {$sel:nextToken:ListAssociatedAssets' :: Maybe Text
nextToken = Maybe Text
a} :: ListAssociatedAssets)

-- | The maximum number of results to return for each paginated request.
--
-- Default: 50
listAssociatedAssets_maxResults :: Lens.Lens' ListAssociatedAssets (Prelude.Maybe Prelude.Natural)
listAssociatedAssets_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAssociatedAssets -> f ListAssociatedAssets
listAssociatedAssets_maxResults = (ListAssociatedAssets -> Maybe Natural)
-> (ListAssociatedAssets -> Maybe Natural -> ListAssociatedAssets)
-> Lens
     ListAssociatedAssets
     ListAssociatedAssets
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssociatedAssets' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAssociatedAssets
s@ListAssociatedAssets' {} Maybe Natural
a -> ListAssociatedAssets
s {$sel:maxResults:ListAssociatedAssets' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAssociatedAssets)

-- | The ID of the asset to query.
listAssociatedAssets_assetId :: Lens.Lens' ListAssociatedAssets Prelude.Text
listAssociatedAssets_assetId :: (Text -> f Text) -> ListAssociatedAssets -> f ListAssociatedAssets
listAssociatedAssets_assetId = (ListAssociatedAssets -> Text)
-> (ListAssociatedAssets -> Text -> ListAssociatedAssets)
-> Lens ListAssociatedAssets ListAssociatedAssets Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssociatedAssets' {Text
assetId :: Text
$sel:assetId:ListAssociatedAssets' :: ListAssociatedAssets -> Text
assetId} -> Text
assetId) (\s :: ListAssociatedAssets
s@ListAssociatedAssets' {} Text
a -> ListAssociatedAssets
s {$sel:assetId:ListAssociatedAssets' :: Text
assetId = Text
a} :: ListAssociatedAssets)

instance Core.AWSPager ListAssociatedAssets where
  page :: ListAssociatedAssets
-> AWSResponse ListAssociatedAssets -> Maybe ListAssociatedAssets
page ListAssociatedAssets
rq AWSResponse ListAssociatedAssets
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAssociatedAssets
ListAssociatedAssetsResponse
rs
            ListAssociatedAssetsResponse
-> Getting (First Text) ListAssociatedAssetsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAssociatedAssetsResponse
-> Const (First Text) ListAssociatedAssetsResponse
Lens' ListAssociatedAssetsResponse (Maybe Text)
listAssociatedAssetsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAssociatedAssetsResponse
 -> Const (First Text) ListAssociatedAssetsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAssociatedAssetsResponse 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 ListAssociatedAssets
forall a. Maybe a
Prelude.Nothing
    | [AssociatedAssetsSummary] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAssociatedAssets
ListAssociatedAssetsResponse
rs
            ListAssociatedAssetsResponse
-> Getting
     [AssociatedAssetsSummary]
     ListAssociatedAssetsResponse
     [AssociatedAssetsSummary]
-> [AssociatedAssetsSummary]
forall s a. s -> Getting a s a -> a
Lens.^. Getting
  [AssociatedAssetsSummary]
  ListAssociatedAssetsResponse
  [AssociatedAssetsSummary]
Lens' ListAssociatedAssetsResponse [AssociatedAssetsSummary]
listAssociatedAssetsResponse_assetSummaries
        ) =
      Maybe ListAssociatedAssets
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListAssociatedAssets -> Maybe ListAssociatedAssets
forall a. a -> Maybe a
Prelude.Just (ListAssociatedAssets -> Maybe ListAssociatedAssets)
-> ListAssociatedAssets -> Maybe ListAssociatedAssets
forall a b. (a -> b) -> a -> b
Prelude.$
        ListAssociatedAssets
rq
          ListAssociatedAssets
-> (ListAssociatedAssets -> ListAssociatedAssets)
-> ListAssociatedAssets
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListAssociatedAssets -> Identity ListAssociatedAssets
Lens
  ListAssociatedAssets ListAssociatedAssets (Maybe Text) (Maybe Text)
listAssociatedAssets_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListAssociatedAssets -> Identity ListAssociatedAssets)
-> Maybe Text -> ListAssociatedAssets -> ListAssociatedAssets
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAssociatedAssets
ListAssociatedAssetsResponse
rs
          ListAssociatedAssetsResponse
-> Getting (First Text) ListAssociatedAssetsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListAssociatedAssetsResponse
-> Const (First Text) ListAssociatedAssetsResponse
Lens' ListAssociatedAssetsResponse (Maybe Text)
listAssociatedAssetsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListAssociatedAssetsResponse
 -> Const (First Text) ListAssociatedAssetsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListAssociatedAssetsResponse 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 ListAssociatedAssets where
  type
    AWSResponse ListAssociatedAssets =
      ListAssociatedAssetsResponse
  request :: ListAssociatedAssets -> Request ListAssociatedAssets
request = Service -> ListAssociatedAssets -> Request ListAssociatedAssets
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAssociatedAssets
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAssociatedAssets)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListAssociatedAssets))
-> Logger
-> Service
-> Proxy ListAssociatedAssets
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAssociatedAssets)))
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
-> Int -> [AssociatedAssetsSummary] -> ListAssociatedAssetsResponse
ListAssociatedAssetsResponse'
            (Maybe Text
 -> Int
 -> [AssociatedAssetsSummary]
 -> ListAssociatedAssetsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Int -> [AssociatedAssetsSummary] -> ListAssociatedAssetsResponse)
forall (f :: * -> *) a b. Functor 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 -> [AssociatedAssetsSummary] -> ListAssociatedAssetsResponse)
-> Either String Int
-> Either
     String ([AssociatedAssetsSummary] -> ListAssociatedAssetsResponse)
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))
            Either
  String ([AssociatedAssetsSummary] -> ListAssociatedAssetsResponse)
-> Either String [AssociatedAssetsSummary]
-> Either String ListAssociatedAssetsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe [AssociatedAssetsSummary])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"assetSummaries"
                            Either String (Maybe [AssociatedAssetsSummary])
-> [AssociatedAssetsSummary]
-> Either String [AssociatedAssetsSummary]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [AssociatedAssetsSummary]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable ListAssociatedAssets

instance Prelude.NFData ListAssociatedAssets

instance Core.ToHeaders ListAssociatedAssets where
  toHeaders :: ListAssociatedAssets -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListAssociatedAssets -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath ListAssociatedAssets where
  toPath :: ListAssociatedAssets -> ByteString
toPath ListAssociatedAssets' {Maybe Natural
Maybe Text
Maybe TraversalDirection
Text
assetId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
traversalDirection :: Maybe TraversalDirection
hierarchyId :: Maybe Text
$sel:assetId:ListAssociatedAssets' :: ListAssociatedAssets -> Text
$sel:maxResults:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe Natural
$sel:nextToken:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe Text
$sel:traversalDirection:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe TraversalDirection
$sel:hierarchyId:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/assets/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
assetId, ByteString
"/hierarchies"]

instance Core.ToQuery ListAssociatedAssets where
  toQuery :: ListAssociatedAssets -> QueryString
toQuery ListAssociatedAssets' {Maybe Natural
Maybe Text
Maybe TraversalDirection
Text
assetId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
traversalDirection :: Maybe TraversalDirection
hierarchyId :: Maybe Text
$sel:assetId:ListAssociatedAssets' :: ListAssociatedAssets -> Text
$sel:maxResults:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe Natural
$sel:nextToken:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe Text
$sel:traversalDirection:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe TraversalDirection
$sel:hierarchyId:ListAssociatedAssets' :: ListAssociatedAssets -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"hierarchyId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
hierarchyId,
        ByteString
"traversalDirection" ByteString -> Maybe TraversalDirection -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe TraversalDirection
traversalDirection,
        ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"maxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults
      ]

-- | /See:/ 'newListAssociatedAssetsResponse' smart constructor.
data ListAssociatedAssetsResponse = ListAssociatedAssetsResponse'
  { -- | The token for the next set of results, or null if there are no
    -- additional results.
    ListAssociatedAssetsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAssociatedAssetsResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list that summarizes the associated assets.
    ListAssociatedAssetsResponse -> [AssociatedAssetsSummary]
assetSummaries :: [AssociatedAssetsSummary]
  }
  deriving (ListAssociatedAssetsResponse
-> ListAssociatedAssetsResponse -> Bool
(ListAssociatedAssetsResponse
 -> ListAssociatedAssetsResponse -> Bool)
-> (ListAssociatedAssetsResponse
    -> ListAssociatedAssetsResponse -> Bool)
-> Eq ListAssociatedAssetsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAssociatedAssetsResponse
-> ListAssociatedAssetsResponse -> Bool
$c/= :: ListAssociatedAssetsResponse
-> ListAssociatedAssetsResponse -> Bool
== :: ListAssociatedAssetsResponse
-> ListAssociatedAssetsResponse -> Bool
$c== :: ListAssociatedAssetsResponse
-> ListAssociatedAssetsResponse -> Bool
Prelude.Eq, ReadPrec [ListAssociatedAssetsResponse]
ReadPrec ListAssociatedAssetsResponse
Int -> ReadS ListAssociatedAssetsResponse
ReadS [ListAssociatedAssetsResponse]
(Int -> ReadS ListAssociatedAssetsResponse)
-> ReadS [ListAssociatedAssetsResponse]
-> ReadPrec ListAssociatedAssetsResponse
-> ReadPrec [ListAssociatedAssetsResponse]
-> Read ListAssociatedAssetsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAssociatedAssetsResponse]
$creadListPrec :: ReadPrec [ListAssociatedAssetsResponse]
readPrec :: ReadPrec ListAssociatedAssetsResponse
$creadPrec :: ReadPrec ListAssociatedAssetsResponse
readList :: ReadS [ListAssociatedAssetsResponse]
$creadList :: ReadS [ListAssociatedAssetsResponse]
readsPrec :: Int -> ReadS ListAssociatedAssetsResponse
$creadsPrec :: Int -> ReadS ListAssociatedAssetsResponse
Prelude.Read, Int -> ListAssociatedAssetsResponse -> ShowS
[ListAssociatedAssetsResponse] -> ShowS
ListAssociatedAssetsResponse -> String
(Int -> ListAssociatedAssetsResponse -> ShowS)
-> (ListAssociatedAssetsResponse -> String)
-> ([ListAssociatedAssetsResponse] -> ShowS)
-> Show ListAssociatedAssetsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAssociatedAssetsResponse] -> ShowS
$cshowList :: [ListAssociatedAssetsResponse] -> ShowS
show :: ListAssociatedAssetsResponse -> String
$cshow :: ListAssociatedAssetsResponse -> String
showsPrec :: Int -> ListAssociatedAssetsResponse -> ShowS
$cshowsPrec :: Int -> ListAssociatedAssetsResponse -> ShowS
Prelude.Show, (forall x.
 ListAssociatedAssetsResponse -> Rep ListAssociatedAssetsResponse x)
-> (forall x.
    Rep ListAssociatedAssetsResponse x -> ListAssociatedAssetsResponse)
-> Generic ListAssociatedAssetsResponse
forall x.
Rep ListAssociatedAssetsResponse x -> ListAssociatedAssetsResponse
forall x.
ListAssociatedAssetsResponse -> Rep ListAssociatedAssetsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAssociatedAssetsResponse x -> ListAssociatedAssetsResponse
$cfrom :: forall x.
ListAssociatedAssetsResponse -> Rep ListAssociatedAssetsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAssociatedAssetsResponse' 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', 'listAssociatedAssetsResponse_nextToken' - The token for the next set of results, or null if there are no
-- additional results.
--
-- 'httpStatus', 'listAssociatedAssetsResponse_httpStatus' - The response's http status code.
--
-- 'assetSummaries', 'listAssociatedAssetsResponse_assetSummaries' - A list that summarizes the associated assets.
newListAssociatedAssetsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAssociatedAssetsResponse
newListAssociatedAssetsResponse :: Int -> ListAssociatedAssetsResponse
newListAssociatedAssetsResponse Int
pHttpStatus_ =
  ListAssociatedAssetsResponse' :: Maybe Text
-> Int -> [AssociatedAssetsSummary] -> ListAssociatedAssetsResponse
ListAssociatedAssetsResponse'
    { $sel:nextToken:ListAssociatedAssetsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAssociatedAssetsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:assetSummaries:ListAssociatedAssetsResponse' :: [AssociatedAssetsSummary]
assetSummaries = [AssociatedAssetsSummary]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The token for the next set of results, or null if there are no
-- additional results.
listAssociatedAssetsResponse_nextToken :: Lens.Lens' ListAssociatedAssetsResponse (Prelude.Maybe Prelude.Text)
listAssociatedAssetsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAssociatedAssetsResponse -> f ListAssociatedAssetsResponse
listAssociatedAssetsResponse_nextToken = (ListAssociatedAssetsResponse -> Maybe Text)
-> (ListAssociatedAssetsResponse
    -> Maybe Text -> ListAssociatedAssetsResponse)
-> Lens' ListAssociatedAssetsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssociatedAssetsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAssociatedAssetsResponse' :: ListAssociatedAssetsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAssociatedAssetsResponse
s@ListAssociatedAssetsResponse' {} Maybe Text
a -> ListAssociatedAssetsResponse
s {$sel:nextToken:ListAssociatedAssetsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAssociatedAssetsResponse)

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

-- | A list that summarizes the associated assets.
listAssociatedAssetsResponse_assetSummaries :: Lens.Lens' ListAssociatedAssetsResponse [AssociatedAssetsSummary]
listAssociatedAssetsResponse_assetSummaries :: ([AssociatedAssetsSummary] -> f [AssociatedAssetsSummary])
-> ListAssociatedAssetsResponse -> f ListAssociatedAssetsResponse
listAssociatedAssetsResponse_assetSummaries = (ListAssociatedAssetsResponse -> [AssociatedAssetsSummary])
-> (ListAssociatedAssetsResponse
    -> [AssociatedAssetsSummary] -> ListAssociatedAssetsResponse)
-> Lens' ListAssociatedAssetsResponse [AssociatedAssetsSummary]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssociatedAssetsResponse' {[AssociatedAssetsSummary]
assetSummaries :: [AssociatedAssetsSummary]
$sel:assetSummaries:ListAssociatedAssetsResponse' :: ListAssociatedAssetsResponse -> [AssociatedAssetsSummary]
assetSummaries} -> [AssociatedAssetsSummary]
assetSummaries) (\s :: ListAssociatedAssetsResponse
s@ListAssociatedAssetsResponse' {} [AssociatedAssetsSummary]
a -> ListAssociatedAssetsResponse
s {$sel:assetSummaries:ListAssociatedAssetsResponse' :: [AssociatedAssetsSummary]
assetSummaries = [AssociatedAssetsSummary]
a} :: ListAssociatedAssetsResponse) (([AssociatedAssetsSummary] -> f [AssociatedAssetsSummary])
 -> ListAssociatedAssetsResponse -> f ListAssociatedAssetsResponse)
-> (([AssociatedAssetsSummary] -> f [AssociatedAssetsSummary])
    -> [AssociatedAssetsSummary] -> f [AssociatedAssetsSummary])
-> ([AssociatedAssetsSummary] -> f [AssociatedAssetsSummary])
-> ListAssociatedAssetsResponse
-> f ListAssociatedAssetsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([AssociatedAssetsSummary] -> f [AssociatedAssetsSummary])
-> [AssociatedAssetsSummary] -> f [AssociatedAssetsSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListAssociatedAssetsResponse