{-# 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-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)
--
-- 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_nextToken,
    listDetectorModels_maxResults,

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

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

import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.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:/ 'newListDetectorModels' smart constructor.
data ListDetectorModels = ListDetectorModels'
  { -- | The token that you can use to return the next set of results.
    ListDetectorModels -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to be returned per request.
    ListDetectorModels -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListDetectorModels -> ListDetectorModels -> Bool
(ListDetectorModels -> ListDetectorModels -> Bool)
-> (ListDetectorModels -> ListDetectorModels -> Bool)
-> Eq ListDetectorModels
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]
(Int -> ReadS ListDetectorModels)
-> ReadS [ListDetectorModels]
-> ReadPrec ListDetectorModels
-> ReadPrec [ListDetectorModels]
-> Read 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
(Int -> ListDetectorModels -> ShowS)
-> (ListDetectorModels -> String)
-> ([ListDetectorModels] -> ShowS)
-> Show ListDetectorModels
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. ListDetectorModels -> Rep ListDetectorModels x)
-> (forall x. Rep ListDetectorModels x -> ListDetectorModels)
-> Generic ListDetectorModels
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:
--
-- 'nextToken', 'listDetectorModels_nextToken' - The token that you can use to return the next set of results.
--
-- 'maxResults', 'listDetectorModels_maxResults' - The maximum number of results to be returned per request.
newListDetectorModels ::
  ListDetectorModels
newListDetectorModels :: ListDetectorModels
newListDetectorModels =
  ListDetectorModels' :: Maybe Text -> Maybe Natural -> ListDetectorModels
ListDetectorModels'
    { $sel:nextToken:ListDetectorModels' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListDetectorModels' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The token that you can use to return the next set of results.
listDetectorModels_nextToken :: Lens.Lens' ListDetectorModels (Prelude.Maybe Prelude.Text)
listDetectorModels_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDetectorModels -> f ListDetectorModels
listDetectorModels_nextToken = (ListDetectorModels -> Maybe Text)
-> (ListDetectorModels -> Maybe Text -> ListDetectorModels)
-> Lens
     ListDetectorModels ListDetectorModels (Maybe Text) (Maybe Text)
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)

-- | The maximum number of results to be returned per request.
listDetectorModels_maxResults :: Lens.Lens' ListDetectorModels (Prelude.Maybe Prelude.Natural)
listDetectorModels_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListDetectorModels -> f ListDetectorModels
listDetectorModels_maxResults = (ListDetectorModels -> Maybe Natural)
-> (ListDetectorModels -> Maybe Natural -> ListDetectorModels)
-> Lens
     ListDetectorModels
     ListDetectorModels
     (Maybe Natural)
     (Maybe Natural)
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)

instance Core.AWSRequest ListDetectorModels where
  type
    AWSResponse ListDetectorModels =
      ListDetectorModelsResponse
  request :: ListDetectorModels -> Request ListDetectorModels
request = Service -> ListDetectorModels -> Request ListDetectorModels
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListDetectorModels
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListDetectorModels)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListDetectorModels))
-> Logger
-> Service
-> Proxy ListDetectorModels
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListDetectorModels)))
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
-> Maybe [DetectorModelSummary]
-> Int
-> ListDetectorModelsResponse
ListDetectorModelsResponse'
            (Maybe Text
 -> Maybe [DetectorModelSummary]
 -> Int
 -> ListDetectorModelsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [DetectorModelSummary] -> Int -> ListDetectorModelsResponse)
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
  (Maybe [DetectorModelSummary] -> Int -> ListDetectorModelsResponse)
-> Either String (Maybe [DetectorModelSummary])
-> Either String (Int -> ListDetectorModelsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [DetectorModelSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"detectorModelSummaries"
                            Either String (Maybe (Maybe [DetectorModelSummary]))
-> Maybe [DetectorModelSummary]
-> Either String (Maybe [DetectorModelSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [DetectorModelSummary]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> ListDetectorModelsResponse)
-> Either String Int -> Either String ListDetectorModelsResponse
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))
      )

instance Prelude.Hashable ListDetectorModels

instance Prelude.NFData ListDetectorModels

instance Core.ToHeaders ListDetectorModels where
  toHeaders :: ListDetectorModels -> ResponseHeaders
toHeaders = ResponseHeaders -> ListDetectorModels -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery ListDetectorModels where
  toQuery :: ListDetectorModels -> QueryString
toQuery ListDetectorModels' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListDetectorModels' :: ListDetectorModels -> Maybe Natural
$sel:nextToken:ListDetectorModels' :: ListDetectorModels -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ 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:/ 'newListDetectorModelsResponse' smart constructor.
data ListDetectorModelsResponse = ListDetectorModelsResponse'
  { -- | 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,
    -- | Summary information about the detector models.
    ListDetectorModelsResponse -> Maybe [DetectorModelSummary]
detectorModelSummaries :: Prelude.Maybe [DetectorModelSummary],
    -- | The response's http status code.
    ListDetectorModelsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDetectorModelsResponse -> ListDetectorModelsResponse -> Bool
(ListDetectorModelsResponse -> ListDetectorModelsResponse -> Bool)
-> (ListDetectorModelsResponse
    -> ListDetectorModelsResponse -> Bool)
-> Eq ListDetectorModelsResponse
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]
(Int -> ReadS ListDetectorModelsResponse)
-> ReadS [ListDetectorModelsResponse]
-> ReadPrec ListDetectorModelsResponse
-> ReadPrec [ListDetectorModelsResponse]
-> Read 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
(Int -> ListDetectorModelsResponse -> ShowS)
-> (ListDetectorModelsResponse -> String)
-> ([ListDetectorModelsResponse] -> ShowS)
-> Show ListDetectorModelsResponse
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.
 ListDetectorModelsResponse -> Rep ListDetectorModelsResponse x)
-> (forall x.
    Rep ListDetectorModelsResponse x -> ListDetectorModelsResponse)
-> Generic ListDetectorModelsResponse
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:
--
-- 'nextToken', 'listDetectorModelsResponse_nextToken' - The token that you can use to return the next set of results, or @null@
-- if there are no more results.
--
-- 'detectorModelSummaries', 'listDetectorModelsResponse_detectorModelSummaries' - Summary information about the detector models.
--
-- 'httpStatus', 'listDetectorModelsResponse_httpStatus' - The response's http status code.
newListDetectorModelsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDetectorModelsResponse
newListDetectorModelsResponse :: Int -> ListDetectorModelsResponse
newListDetectorModelsResponse Int
pHttpStatus_ =
  ListDetectorModelsResponse' :: Maybe Text
-> Maybe [DetectorModelSummary]
-> Int
-> ListDetectorModelsResponse
ListDetectorModelsResponse'
    { $sel:nextToken:ListDetectorModelsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorModelSummaries:ListDetectorModelsResponse' :: Maybe [DetectorModelSummary]
detectorModelSummaries = Maybe [DetectorModelSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDetectorModelsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ListDetectorModelsResponse -> f ListDetectorModelsResponse
listDetectorModelsResponse_nextToken = (ListDetectorModelsResponse -> Maybe Text)
-> (ListDetectorModelsResponse
    -> Maybe Text -> ListDetectorModelsResponse)
-> Lens
     ListDetectorModelsResponse
     ListDetectorModelsResponse
     (Maybe Text)
     (Maybe Text)
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)

-- | Summary information about the detector models.
listDetectorModelsResponse_detectorModelSummaries :: Lens.Lens' ListDetectorModelsResponse (Prelude.Maybe [DetectorModelSummary])
listDetectorModelsResponse_detectorModelSummaries :: (Maybe [DetectorModelSummary] -> f (Maybe [DetectorModelSummary]))
-> ListDetectorModelsResponse -> f ListDetectorModelsResponse
listDetectorModelsResponse_detectorModelSummaries = (ListDetectorModelsResponse -> Maybe [DetectorModelSummary])
-> (ListDetectorModelsResponse
    -> Maybe [DetectorModelSummary] -> ListDetectorModelsResponse)
-> Lens
     ListDetectorModelsResponse
     ListDetectorModelsResponse
     (Maybe [DetectorModelSummary])
     (Maybe [DetectorModelSummary])
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) ((Maybe [DetectorModelSummary] -> f (Maybe [DetectorModelSummary]))
 -> ListDetectorModelsResponse -> f ListDetectorModelsResponse)
-> ((Maybe [DetectorModelSummary]
     -> f (Maybe [DetectorModelSummary]))
    -> Maybe [DetectorModelSummary]
    -> f (Maybe [DetectorModelSummary]))
-> (Maybe [DetectorModelSummary]
    -> f (Maybe [DetectorModelSummary]))
-> ListDetectorModelsResponse
-> f ListDetectorModelsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DetectorModelSummary]
  [DetectorModelSummary]
  [DetectorModelSummary]
  [DetectorModelSummary]
-> Iso
     (Maybe [DetectorModelSummary])
     (Maybe [DetectorModelSummary])
     (Maybe [DetectorModelSummary])
     (Maybe [DetectorModelSummary])
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 AnIso
  [DetectorModelSummary]
  [DetectorModelSummary]
  [DetectorModelSummary]
  [DetectorModelSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
listDetectorModelsResponse_httpStatus :: Lens.Lens' ListDetectorModelsResponse Prelude.Int
listDetectorModelsResponse_httpStatus :: (Int -> f Int)
-> ListDetectorModelsResponse -> f ListDetectorModelsResponse
listDetectorModelsResponse_httpStatus = (ListDetectorModelsResponse -> Int)
-> (ListDetectorModelsResponse
    -> Int -> ListDetectorModelsResponse)
-> Lens
     ListDetectorModelsResponse ListDetectorModelsResponse Int Int
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