{-# 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.ListAssetModels
-- 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 summaries of all asset models.
--
-- This operation returns paginated results.
module Amazonka.IoTSiteWise.ListAssetModels
  ( -- * Creating a Request
    ListAssetModels (..),
    newListAssetModels,

    -- * Request Lenses
    listAssetModels_maxResults,
    listAssetModels_nextToken,

    -- * Destructuring the Response
    ListAssetModelsResponse (..),
    newListAssetModelsResponse,

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

-- |
-- Create a value of 'ListAssetModels' 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', 'listAssetModels_maxResults' - The maximum number of results to return for each paginated request.
--
-- Default: 50
--
-- 'nextToken', 'listAssetModels_nextToken' - The token to be used for the next set of paginated results.
newListAssetModels ::
  ListAssetModels
newListAssetModels :: ListAssetModels
newListAssetModels =
  ListAssetModels'
    { $sel:maxResults:ListAssetModels' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAssetModels' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Prelude.Hashable ListAssetModels where
  hashWithSalt :: Int -> ListAssetModels -> Int
hashWithSalt Int
_salt ListAssetModels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAssetModels' :: ListAssetModels -> Maybe Text
$sel:maxResults:ListAssetModels' :: ListAssetModels -> 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

instance Prelude.NFData ListAssetModels where
  rnf :: ListAssetModels -> ()
rnf ListAssetModels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAssetModels' :: ListAssetModels -> Maybe Text
$sel:maxResults:ListAssetModels' :: ListAssetModels -> 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

instance Data.ToHeaders ListAssetModels where
  toHeaders :: ListAssetModels -> 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 ListAssetModels where
  toPath :: ListAssetModels -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/asset-models"

instance Data.ToQuery ListAssetModels where
  toQuery :: ListAssetModels -> QueryString
toQuery ListAssetModels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAssetModels' :: ListAssetModels -> Maybe Text
$sel:maxResults:ListAssetModels' :: ListAssetModels -> 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:/ 'newListAssetModelsResponse' smart constructor.
data ListAssetModelsResponse = ListAssetModelsResponse'
  { -- | The token for the next set of results, or null if there are no
    -- additional results.
    ListAssetModelsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAssetModelsResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list that summarizes each asset model.
    ListAssetModelsResponse -> [AssetModelSummary]
assetModelSummaries :: [AssetModelSummary]
  }
  deriving (ListAssetModelsResponse -> ListAssetModelsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAssetModelsResponse -> ListAssetModelsResponse -> Bool
$c/= :: ListAssetModelsResponse -> ListAssetModelsResponse -> Bool
== :: ListAssetModelsResponse -> ListAssetModelsResponse -> Bool
$c== :: ListAssetModelsResponse -> ListAssetModelsResponse -> Bool
Prelude.Eq, ReadPrec [ListAssetModelsResponse]
ReadPrec ListAssetModelsResponse
Int -> ReadS ListAssetModelsResponse
ReadS [ListAssetModelsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAssetModelsResponse]
$creadListPrec :: ReadPrec [ListAssetModelsResponse]
readPrec :: ReadPrec ListAssetModelsResponse
$creadPrec :: ReadPrec ListAssetModelsResponse
readList :: ReadS [ListAssetModelsResponse]
$creadList :: ReadS [ListAssetModelsResponse]
readsPrec :: Int -> ReadS ListAssetModelsResponse
$creadsPrec :: Int -> ReadS ListAssetModelsResponse
Prelude.Read, Int -> ListAssetModelsResponse -> ShowS
[ListAssetModelsResponse] -> ShowS
ListAssetModelsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAssetModelsResponse] -> ShowS
$cshowList :: [ListAssetModelsResponse] -> ShowS
show :: ListAssetModelsResponse -> String
$cshow :: ListAssetModelsResponse -> String
showsPrec :: Int -> ListAssetModelsResponse -> ShowS
$cshowsPrec :: Int -> ListAssetModelsResponse -> ShowS
Prelude.Show, forall x. Rep ListAssetModelsResponse x -> ListAssetModelsResponse
forall x. ListAssetModelsResponse -> Rep ListAssetModelsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAssetModelsResponse x -> ListAssetModelsResponse
$cfrom :: forall x. ListAssetModelsResponse -> Rep ListAssetModelsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAssetModelsResponse' 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', 'listAssetModelsResponse_nextToken' - The token for the next set of results, or null if there are no
-- additional results.
--
-- 'httpStatus', 'listAssetModelsResponse_httpStatus' - The response's http status code.
--
-- 'assetModelSummaries', 'listAssetModelsResponse_assetModelSummaries' - A list that summarizes each asset model.
newListAssetModelsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAssetModelsResponse
newListAssetModelsResponse :: Int -> ListAssetModelsResponse
newListAssetModelsResponse Int
pHttpStatus_ =
  ListAssetModelsResponse'
    { $sel:nextToken:ListAssetModelsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAssetModelsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:assetModelSummaries:ListAssetModelsResponse' :: [AssetModelSummary]
assetModelSummaries = forall a. Monoid a => a
Prelude.mempty
    }

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

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

-- | A list that summarizes each asset model.
listAssetModelsResponse_assetModelSummaries :: Lens.Lens' ListAssetModelsResponse [AssetModelSummary]
listAssetModelsResponse_assetModelSummaries :: Lens' ListAssetModelsResponse [AssetModelSummary]
listAssetModelsResponse_assetModelSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAssetModelsResponse' {[AssetModelSummary]
assetModelSummaries :: [AssetModelSummary]
$sel:assetModelSummaries:ListAssetModelsResponse' :: ListAssetModelsResponse -> [AssetModelSummary]
assetModelSummaries} -> [AssetModelSummary]
assetModelSummaries) (\s :: ListAssetModelsResponse
s@ListAssetModelsResponse' {} [AssetModelSummary]
a -> ListAssetModelsResponse
s {$sel:assetModelSummaries:ListAssetModelsResponse' :: [AssetModelSummary]
assetModelSummaries = [AssetModelSummary]
a} :: ListAssetModelsResponse) 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 ListAssetModelsResponse where
  rnf :: ListAssetModelsResponse -> ()
rnf ListAssetModelsResponse' {Int
[AssetModelSummary]
Maybe Text
assetModelSummaries :: [AssetModelSummary]
httpStatus :: Int
nextToken :: Maybe Text
$sel:assetModelSummaries:ListAssetModelsResponse' :: ListAssetModelsResponse -> [AssetModelSummary]
$sel:httpStatus:ListAssetModelsResponse' :: ListAssetModelsResponse -> Int
$sel:nextToken:ListAssetModelsResponse' :: ListAssetModelsResponse -> 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 [AssetModelSummary]
assetModelSummaries