{-# 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.ListProjectAssets
-- 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 a paginated list of assets associated with an IoT SiteWise
-- Monitor project.
--
-- This operation returns paginated results.
module Amazonka.IoTSiteWise.ListProjectAssets
  ( -- * Creating a Request
    ListProjectAssets (..),
    newListProjectAssets,

    -- * Request Lenses
    listProjectAssets_maxResults,
    listProjectAssets_nextToken,
    listProjectAssets_projectId,

    -- * Destructuring the Response
    ListProjectAssetsResponse (..),
    newListProjectAssetsResponse,

    -- * Response Lenses
    listProjectAssetsResponse_nextToken,
    listProjectAssetsResponse_httpStatus,
    listProjectAssetsResponse_assetIds,
  )
where

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

-- | /See:/ 'newListProjectAssets' smart constructor.
data ListProjectAssets = ListProjectAssets'
  { -- | The maximum number of results to return for each paginated request.
    --
    -- Default: 50
    ListProjectAssets -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token to be used for the next set of paginated results.
    ListProjectAssets -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The ID of the project.
    ListProjectAssets -> Text
projectId :: Prelude.Text
  }
  deriving (ListProjectAssets -> ListProjectAssets -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListProjectAssets -> ListProjectAssets -> Bool
$c/= :: ListProjectAssets -> ListProjectAssets -> Bool
== :: ListProjectAssets -> ListProjectAssets -> Bool
$c== :: ListProjectAssets -> ListProjectAssets -> Bool
Prelude.Eq, ReadPrec [ListProjectAssets]
ReadPrec ListProjectAssets
Int -> ReadS ListProjectAssets
ReadS [ListProjectAssets]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListProjectAssets]
$creadListPrec :: ReadPrec [ListProjectAssets]
readPrec :: ReadPrec ListProjectAssets
$creadPrec :: ReadPrec ListProjectAssets
readList :: ReadS [ListProjectAssets]
$creadList :: ReadS [ListProjectAssets]
readsPrec :: Int -> ReadS ListProjectAssets
$creadsPrec :: Int -> ReadS ListProjectAssets
Prelude.Read, Int -> ListProjectAssets -> ShowS
[ListProjectAssets] -> ShowS
ListProjectAssets -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListProjectAssets] -> ShowS
$cshowList :: [ListProjectAssets] -> ShowS
show :: ListProjectAssets -> String
$cshow :: ListProjectAssets -> String
showsPrec :: Int -> ListProjectAssets -> ShowS
$cshowsPrec :: Int -> ListProjectAssets -> ShowS
Prelude.Show, forall x. Rep ListProjectAssets x -> ListProjectAssets
forall x. ListProjectAssets -> Rep ListProjectAssets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListProjectAssets x -> ListProjectAssets
$cfrom :: forall x. ListProjectAssets -> Rep ListProjectAssets x
Prelude.Generic)

-- |
-- Create a value of 'ListProjectAssets' 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:
--
-- 'maxResults', 'listProjectAssets_maxResults' - The maximum number of results to return for each paginated request.
--
-- Default: 50
--
-- 'nextToken', 'listProjectAssets_nextToken' - The token to be used for the next set of paginated results.
--
-- 'projectId', 'listProjectAssets_projectId' - The ID of the project.
newListProjectAssets ::
  -- | 'projectId'
  Prelude.Text ->
  ListProjectAssets
newListProjectAssets :: Text -> ListProjectAssets
newListProjectAssets Text
pProjectId_ =
  ListProjectAssets'
    { $sel:maxResults:ListProjectAssets' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListProjectAssets' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:projectId:ListProjectAssets' :: Text
projectId = Text
pProjectId_
    }

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

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

-- | The ID of the project.
listProjectAssets_projectId :: Lens.Lens' ListProjectAssets Prelude.Text
listProjectAssets_projectId :: Lens' ListProjectAssets Text
listProjectAssets_projectId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProjectAssets' {Text
projectId :: Text
$sel:projectId:ListProjectAssets' :: ListProjectAssets -> Text
projectId} -> Text
projectId) (\s :: ListProjectAssets
s@ListProjectAssets' {} Text
a -> ListProjectAssets
s {$sel:projectId:ListProjectAssets' :: Text
projectId = Text
a} :: ListProjectAssets)

instance Core.AWSPager ListProjectAssets where
  page :: ListProjectAssets
-> AWSResponse ListProjectAssets -> Maybe ListProjectAssets
page ListProjectAssets
rq AWSResponse ListProjectAssets
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListProjectAssets
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListProjectAssetsResponse (Maybe Text)
listProjectAssetsResponse_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 ListProjectAssets
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListProjectAssetsResponse [Text]
listProjectAssetsResponse_assetIds) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListProjectAssets
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListProjectAssets (Maybe Text)
listProjectAssets_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListProjectAssets
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListProjectAssetsResponse (Maybe Text)
listProjectAssetsResponse_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 ListProjectAssets where
  type
    AWSResponse ListProjectAssets =
      ListProjectAssetsResponse
  request :: (Service -> Service)
-> ListProjectAssets -> Request ListProjectAssets
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListProjectAssets
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListProjectAssets)))
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 -> [Text] -> ListProjectAssetsResponse
ListProjectAssetsResponse'
            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
"assetIds" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListProjectAssets where
  hashWithSalt :: Int -> ListProjectAssets -> Int
hashWithSalt Int
_salt ListProjectAssets' {Maybe Natural
Maybe Text
Text
projectId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:projectId:ListProjectAssets' :: ListProjectAssets -> Text
$sel:nextToken:ListProjectAssets' :: ListProjectAssets -> Maybe Text
$sel:maxResults:ListProjectAssets' :: ListProjectAssets -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
projectId

instance Prelude.NFData ListProjectAssets where
  rnf :: ListProjectAssets -> ()
rnf ListProjectAssets' {Maybe Natural
Maybe Text
Text
projectId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:projectId:ListProjectAssets' :: ListProjectAssets -> Text
$sel:nextToken:ListProjectAssets' :: ListProjectAssets -> Maybe Text
$sel:maxResults:ListProjectAssets' :: ListProjectAssets -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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
projectId

instance Data.ToHeaders ListProjectAssets where
  toHeaders :: ListProjectAssets -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath ListProjectAssets where
  toPath :: ListProjectAssets -> ByteString
toPath ListProjectAssets' {Maybe Natural
Maybe Text
Text
projectId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:projectId:ListProjectAssets' :: ListProjectAssets -> Text
$sel:nextToken:ListProjectAssets' :: ListProjectAssets -> Maybe Text
$sel:maxResults:ListProjectAssets' :: ListProjectAssets -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/projects/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
projectId, ByteString
"/assets"]

instance Data.ToQuery ListProjectAssets where
  toQuery :: ListProjectAssets -> QueryString
toQuery ListProjectAssets' {Maybe Natural
Maybe Text
Text
projectId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:projectId:ListProjectAssets' :: ListProjectAssets -> Text
$sel:nextToken:ListProjectAssets' :: ListProjectAssets -> Maybe Text
$sel:maxResults:ListProjectAssets' :: ListProjectAssets -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

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

-- |
-- Create a value of 'ListProjectAssetsResponse' 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', 'listProjectAssetsResponse_nextToken' - The token for the next set of results, or null if there are no
-- additional results.
--
-- 'httpStatus', 'listProjectAssetsResponse_httpStatus' - The response's http status code.
--
-- 'assetIds', 'listProjectAssetsResponse_assetIds' - A list that contains the IDs of each asset associated with the project.
newListProjectAssetsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListProjectAssetsResponse
newListProjectAssetsResponse :: Int -> ListProjectAssetsResponse
newListProjectAssetsResponse Int
pHttpStatus_ =
  ListProjectAssetsResponse'
    { $sel:nextToken:ListProjectAssetsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListProjectAssetsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:assetIds:ListProjectAssetsResponse' :: [Text]
assetIds = forall a. Monoid a => a
Prelude.mempty
    }

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

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

-- | A list that contains the IDs of each asset associated with the project.
listProjectAssetsResponse_assetIds :: Lens.Lens' ListProjectAssetsResponse [Prelude.Text]
listProjectAssetsResponse_assetIds :: Lens' ListProjectAssetsResponse [Text]
listProjectAssetsResponse_assetIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProjectAssetsResponse' {[Text]
assetIds :: [Text]
$sel:assetIds:ListProjectAssetsResponse' :: ListProjectAssetsResponse -> [Text]
assetIds} -> [Text]
assetIds) (\s :: ListProjectAssetsResponse
s@ListProjectAssetsResponse' {} [Text]
a -> ListProjectAssetsResponse
s {$sel:assetIds:ListProjectAssetsResponse' :: [Text]
assetIds = [Text]
a} :: ListProjectAssetsResponse) 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 ListProjectAssetsResponse where
  rnf :: ListProjectAssetsResponse -> ()
rnf ListProjectAssetsResponse' {Int
[Text]
Maybe Text
assetIds :: [Text]
httpStatus :: Int
nextToken :: Maybe Text
$sel:assetIds:ListProjectAssetsResponse' :: ListProjectAssetsResponse -> [Text]
$sel:httpStatus:ListProjectAssetsResponse' :: ListProjectAssetsResponse -> Int
$sel:nextToken:ListProjectAssetsResponse' :: ListProjectAssetsResponse -> 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 [Text]
assetIds