{-# 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.ListAlarmModels
-- 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 alarm models that you created. The operation returns only the
-- metadata associated with each alarm model.
module Amazonka.IoTEvents.ListAlarmModels
  ( -- * Creating a Request
    ListAlarmModels (..),
    newListAlarmModels,

    -- * Request Lenses
    listAlarmModels_maxResults,
    listAlarmModels_nextToken,

    -- * Destructuring the Response
    ListAlarmModelsResponse (..),
    newListAlarmModelsResponse,

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

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

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

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

instance Core.AWSRequest ListAlarmModels where
  type
    AWSResponse ListAlarmModels =
      ListAlarmModelsResponse
  request :: (Service -> Service) -> ListAlarmModels -> Request ListAlarmModels
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 ListAlarmModels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAlarmModels)))
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 [AlarmModelSummary]
-> Maybe Text -> Int -> ListAlarmModelsResponse
ListAlarmModelsResponse'
            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
"alarmModelSummaries"
                            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 ListAlarmModels where
  hashWithSalt :: Int -> ListAlarmModels -> Int
hashWithSalt Int
_salt ListAlarmModels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAlarmModels' :: ListAlarmModels -> Maybe Text
$sel:maxResults:ListAlarmModels' :: ListAlarmModels -> 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 ListAlarmModels where
  rnf :: ListAlarmModels -> ()
rnf ListAlarmModels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAlarmModels' :: ListAlarmModels -> Maybe Text
$sel:maxResults:ListAlarmModels' :: ListAlarmModels -> 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 ListAlarmModels where
  toHeaders :: ListAlarmModels -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

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

-- |
-- Create a value of 'ListAlarmModelsResponse' 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:
--
-- 'alarmModelSummaries', 'listAlarmModelsResponse_alarmModelSummaries' - A list that summarizes each alarm model.
--
-- 'nextToken', 'listAlarmModelsResponse_nextToken' - The token that you can use to return the next set of results, or @null@
-- if there are no more results.
--
-- 'httpStatus', 'listAlarmModelsResponse_httpStatus' - The response's http status code.
newListAlarmModelsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAlarmModelsResponse
newListAlarmModelsResponse :: Int -> ListAlarmModelsResponse
newListAlarmModelsResponse Int
pHttpStatus_ =
  ListAlarmModelsResponse'
    { $sel:alarmModelSummaries:ListAlarmModelsResponse' :: Maybe [AlarmModelSummary]
alarmModelSummaries =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAlarmModelsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAlarmModelsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list that summarizes each alarm model.
listAlarmModelsResponse_alarmModelSummaries :: Lens.Lens' ListAlarmModelsResponse (Prelude.Maybe [AlarmModelSummary])
listAlarmModelsResponse_alarmModelSummaries :: Lens' ListAlarmModelsResponse (Maybe [AlarmModelSummary])
listAlarmModelsResponse_alarmModelSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlarmModelsResponse' {Maybe [AlarmModelSummary]
alarmModelSummaries :: Maybe [AlarmModelSummary]
$sel:alarmModelSummaries:ListAlarmModelsResponse' :: ListAlarmModelsResponse -> Maybe [AlarmModelSummary]
alarmModelSummaries} -> Maybe [AlarmModelSummary]
alarmModelSummaries) (\s :: ListAlarmModelsResponse
s@ListAlarmModelsResponse' {} Maybe [AlarmModelSummary]
a -> ListAlarmModelsResponse
s {$sel:alarmModelSummaries:ListAlarmModelsResponse' :: Maybe [AlarmModelSummary]
alarmModelSummaries = Maybe [AlarmModelSummary]
a} :: ListAlarmModelsResponse) 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.
listAlarmModelsResponse_nextToken :: Lens.Lens' ListAlarmModelsResponse (Prelude.Maybe Prelude.Text)
listAlarmModelsResponse_nextToken :: Lens' ListAlarmModelsResponse (Maybe Text)
listAlarmModelsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlarmModelsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAlarmModelsResponse' :: ListAlarmModelsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAlarmModelsResponse
s@ListAlarmModelsResponse' {} Maybe Text
a -> ListAlarmModelsResponse
s {$sel:nextToken:ListAlarmModelsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAlarmModelsResponse)

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

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