{-# 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.IoTEvents.ListDetectorModels
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists the detector models you have created. Only the metadata associated
-- with each detector model is returned.
module Amazonka.IoTEvents.ListDetectorModels
  ( -- * Creating a Request
    ListDetectorModels (..),
    newListDetectorModels,

    -- * Request Lenses
    listDetectorModels_maxResults,
    listDetectorModels_nextToken,

    -- * Destructuring the Response
    ListDetectorModelsResponse (..),
    newListDetectorModelsResponse,

    -- * Response Lenses
    listDetectorModelsResponse_detectorModelSummaries,
    listDetectorModelsResponse_nextToken,
    listDetectorModelsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListDetectorModels' smart constructor.
data ListDetectorModels = ListDetectorModels'
  { -- | The maximum number of results to be returned per request.
    ListDetectorModels -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token that you can use to return the next set of results.
    ListDetectorModels -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListDetectorModels -> ListDetectorModels -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDetectorModels -> ListDetectorModels -> Bool
$c/= :: ListDetectorModels -> ListDetectorModels -> Bool
== :: ListDetectorModels -> ListDetectorModels -> Bool
$c== :: ListDetectorModels -> ListDetectorModels -> Bool
Prelude.Eq, ReadPrec [ListDetectorModels]
ReadPrec ListDetectorModels
Int -> ReadS ListDetectorModels
ReadS [ListDetectorModels]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDetectorModels]
$creadListPrec :: ReadPrec [ListDetectorModels]
readPrec :: ReadPrec ListDetectorModels
$creadPrec :: ReadPrec ListDetectorModels
readList :: ReadS [ListDetectorModels]
$creadList :: ReadS [ListDetectorModels]
readsPrec :: Int -> ReadS ListDetectorModels
$creadsPrec :: Int -> ReadS ListDetectorModels
Prelude.Read, Int -> ListDetectorModels -> ShowS
[ListDetectorModels] -> ShowS
ListDetectorModels -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDetectorModels] -> ShowS
$cshowList :: [ListDetectorModels] -> ShowS
show :: ListDetectorModels -> String
$cshow :: ListDetectorModels -> String
showsPrec :: Int -> ListDetectorModels -> ShowS
$cshowsPrec :: Int -> ListDetectorModels -> ShowS
Prelude.Show, forall x. Rep ListDetectorModels x -> ListDetectorModels
forall x. ListDetectorModels -> Rep ListDetectorModels x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDetectorModels x -> ListDetectorModels
$cfrom :: forall x. ListDetectorModels -> Rep ListDetectorModels x
Prelude.Generic)

-- |
-- Create a value of 'ListDetectorModels' 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', 'listDetectorModels_maxResults' - The maximum number of results to be returned per request.
--
-- 'nextToken', 'listDetectorModels_nextToken' - The token that you can use to return the next set of results.
newListDetectorModels ::
  ListDetectorModels
newListDetectorModels :: ListDetectorModels
newListDetectorModels =
  ListDetectorModels'
    { $sel:maxResults:ListDetectorModels' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDetectorModels' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results to be returned per request.
listDetectorModels_maxResults :: Lens.Lens' ListDetectorModels (Prelude.Maybe Prelude.Natural)
listDetectorModels_maxResults :: Lens' ListDetectorModels (Maybe Natural)
listDetectorModels_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDetectorModels' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDetectorModels' :: ListDetectorModels -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDetectorModels
s@ListDetectorModels' {} Maybe Natural
a -> ListDetectorModels
s {$sel:maxResults:ListDetectorModels' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDetectorModels)

-- | The token that you can use to return the next set of results.
listDetectorModels_nextToken :: Lens.Lens' ListDetectorModels (Prelude.Maybe Prelude.Text)
listDetectorModels_nextToken :: Lens' ListDetectorModels (Maybe Text)
listDetectorModels_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDetectorModels' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDetectorModels' :: ListDetectorModels -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDetectorModels
s@ListDetectorModels' {} Maybe Text
a -> ListDetectorModels
s {$sel:nextToken:ListDetectorModels' :: Maybe Text
nextToken = Maybe Text
a} :: ListDetectorModels)

instance Core.AWSRequest ListDetectorModels where
  type
    AWSResponse ListDetectorModels =
      ListDetectorModelsResponse
  request :: (Service -> Service)
-> ListDetectorModels -> Request ListDetectorModels
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 ListDetectorModels
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListDetectorModels)))
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 [DetectorModelSummary]
-> Maybe Text -> Int -> ListDetectorModelsResponse
ListDetectorModelsResponse'
            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
"detectorModelSummaries"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            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
"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))
      )

instance Prelude.Hashable ListDetectorModels where
  hashWithSalt :: Int -> ListDetectorModels -> Int
hashWithSalt Int
_salt ListDetectorModels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDetectorModels' :: ListDetectorModels -> Maybe Text
$sel:maxResults:ListDetectorModels' :: ListDetectorModels -> 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 ListDetectorModels where
  rnf :: ListDetectorModels -> ()
rnf ListDetectorModels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDetectorModels' :: ListDetectorModels -> Maybe Text
$sel:maxResults:ListDetectorModels' :: ListDetectorModels -> 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 ListDetectorModels where
  toHeaders :: ListDetectorModels -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery ListDetectorModels where
  toQuery :: ListDetectorModels -> QueryString
toQuery ListDetectorModels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDetectorModels' :: ListDetectorModels -> Maybe Text
$sel:maxResults:ListDetectorModels' :: ListDetectorModels -> 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:/ 'newListDetectorModelsResponse' smart constructor.
data ListDetectorModelsResponse = ListDetectorModelsResponse'
  { -- | Summary information about the detector models.
    ListDetectorModelsResponse -> Maybe [DetectorModelSummary]
detectorModelSummaries :: Prelude.Maybe [DetectorModelSummary],
    -- | The token that you can use to return the next set of results, or @null@
    -- if there are no more results.
    ListDetectorModelsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDetectorModelsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDetectorModelsResponse -> ListDetectorModelsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDetectorModelsResponse -> ListDetectorModelsResponse -> Bool
$c/= :: ListDetectorModelsResponse -> ListDetectorModelsResponse -> Bool
== :: ListDetectorModelsResponse -> ListDetectorModelsResponse -> Bool
$c== :: ListDetectorModelsResponse -> ListDetectorModelsResponse -> Bool
Prelude.Eq, ReadPrec [ListDetectorModelsResponse]
ReadPrec ListDetectorModelsResponse
Int -> ReadS ListDetectorModelsResponse
ReadS [ListDetectorModelsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDetectorModelsResponse]
$creadListPrec :: ReadPrec [ListDetectorModelsResponse]
readPrec :: ReadPrec ListDetectorModelsResponse
$creadPrec :: ReadPrec ListDetectorModelsResponse
readList :: ReadS [ListDetectorModelsResponse]
$creadList :: ReadS [ListDetectorModelsResponse]
readsPrec :: Int -> ReadS ListDetectorModelsResponse
$creadsPrec :: Int -> ReadS ListDetectorModelsResponse
Prelude.Read, Int -> ListDetectorModelsResponse -> ShowS
[ListDetectorModelsResponse] -> ShowS
ListDetectorModelsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDetectorModelsResponse] -> ShowS
$cshowList :: [ListDetectorModelsResponse] -> ShowS
show :: ListDetectorModelsResponse -> String
$cshow :: ListDetectorModelsResponse -> String
showsPrec :: Int -> ListDetectorModelsResponse -> ShowS
$cshowsPrec :: Int -> ListDetectorModelsResponse -> ShowS
Prelude.Show, forall x.
Rep ListDetectorModelsResponse x -> ListDetectorModelsResponse
forall x.
ListDetectorModelsResponse -> Rep ListDetectorModelsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListDetectorModelsResponse x -> ListDetectorModelsResponse
$cfrom :: forall x.
ListDetectorModelsResponse -> Rep ListDetectorModelsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDetectorModelsResponse' 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:
--
-- 'detectorModelSummaries', 'listDetectorModelsResponse_detectorModelSummaries' - Summary information about the detector models.
--
-- 'nextToken', 'listDetectorModelsResponse_nextToken' - The token that you can use to return the next set of results, or @null@
-- if there are no more results.
--
-- 'httpStatus', 'listDetectorModelsResponse_httpStatus' - The response's http status code.
newListDetectorModelsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDetectorModelsResponse
newListDetectorModelsResponse :: Int -> ListDetectorModelsResponse
newListDetectorModelsResponse Int
pHttpStatus_ =
  ListDetectorModelsResponse'
    { $sel:detectorModelSummaries:ListDetectorModelsResponse' :: Maybe [DetectorModelSummary]
detectorModelSummaries =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDetectorModelsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDetectorModelsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Summary information about the detector models.
listDetectorModelsResponse_detectorModelSummaries :: Lens.Lens' ListDetectorModelsResponse (Prelude.Maybe [DetectorModelSummary])
listDetectorModelsResponse_detectorModelSummaries :: Lens' ListDetectorModelsResponse (Maybe [DetectorModelSummary])
listDetectorModelsResponse_detectorModelSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDetectorModelsResponse' {Maybe [DetectorModelSummary]
detectorModelSummaries :: Maybe [DetectorModelSummary]
$sel:detectorModelSummaries:ListDetectorModelsResponse' :: ListDetectorModelsResponse -> Maybe [DetectorModelSummary]
detectorModelSummaries} -> Maybe [DetectorModelSummary]
detectorModelSummaries) (\s :: ListDetectorModelsResponse
s@ListDetectorModelsResponse' {} Maybe [DetectorModelSummary]
a -> ListDetectorModelsResponse
s {$sel:detectorModelSummaries:ListDetectorModelsResponse' :: Maybe [DetectorModelSummary]
detectorModelSummaries = Maybe [DetectorModelSummary]
a} :: ListDetectorModelsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token that you can use to return the next set of results, or @null@
-- if there are no more results.
listDetectorModelsResponse_nextToken :: Lens.Lens' ListDetectorModelsResponse (Prelude.Maybe Prelude.Text)
listDetectorModelsResponse_nextToken :: Lens' ListDetectorModelsResponse (Maybe Text)
listDetectorModelsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDetectorModelsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDetectorModelsResponse' :: ListDetectorModelsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDetectorModelsResponse
s@ListDetectorModelsResponse' {} Maybe Text
a -> ListDetectorModelsResponse
s {$sel:nextToken:ListDetectorModelsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDetectorModelsResponse)

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

instance Prelude.NFData ListDetectorModelsResponse where
  rnf :: ListDetectorModelsResponse -> ()
rnf ListDetectorModelsResponse' {Int
Maybe [DetectorModelSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
detectorModelSummaries :: Maybe [DetectorModelSummary]
$sel:httpStatus:ListDetectorModelsResponse' :: ListDetectorModelsResponse -> Int
$sel:nextToken:ListDetectorModelsResponse' :: ListDetectorModelsResponse -> Maybe Text
$sel:detectorModelSummaries:ListDetectorModelsResponse' :: ListDetectorModelsResponse -> Maybe [DetectorModelSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DetectorModelSummary]
detectorModelSummaries
      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 Int
httpStatus