{-# 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.IoTEventsData.ListAlarms
-- 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 one or more alarms. The operation returns only the metadata
-- associated with each alarm.
module Amazonka.IoTEventsData.ListAlarms
  ( -- * Creating a Request
    ListAlarms (..),
    newListAlarms,

    -- * Request Lenses
    listAlarms_maxResults,
    listAlarms_nextToken,
    listAlarms_alarmModelName,

    -- * Destructuring the Response
    ListAlarmsResponse (..),
    newListAlarmsResponse,

    -- * Response Lenses
    listAlarmsResponse_alarmSummaries,
    listAlarmsResponse_nextToken,
    listAlarmsResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'ListAlarms' 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', 'listAlarms_maxResults' - The maximum number of results to be returned per request.
--
-- 'nextToken', 'listAlarms_nextToken' - The token that you can use to return the next set of results.
--
-- 'alarmModelName', 'listAlarms_alarmModelName' - The name of the alarm model.
newListAlarms ::
  -- | 'alarmModelName'
  Prelude.Text ->
  ListAlarms
newListAlarms :: Text -> ListAlarms
newListAlarms Text
pAlarmModelName_ =
  ListAlarms'
    { $sel:maxResults:ListAlarms' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAlarms' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:alarmModelName:ListAlarms' :: Text
alarmModelName = Text
pAlarmModelName_
    }

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

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

-- | The name of the alarm model.
listAlarms_alarmModelName :: Lens.Lens' ListAlarms Prelude.Text
listAlarms_alarmModelName :: Lens' ListAlarms Text
listAlarms_alarmModelName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlarms' {Text
alarmModelName :: Text
$sel:alarmModelName:ListAlarms' :: ListAlarms -> Text
alarmModelName} -> Text
alarmModelName) (\s :: ListAlarms
s@ListAlarms' {} Text
a -> ListAlarms
s {$sel:alarmModelName:ListAlarms' :: Text
alarmModelName = Text
a} :: ListAlarms)

instance Core.AWSRequest ListAlarms where
  type AWSResponse ListAlarms = ListAlarmsResponse
  request :: (Service -> Service) -> ListAlarms -> Request ListAlarms
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 ListAlarms
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAlarms)))
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 [AlarmSummary] -> Maybe Text -> Int -> ListAlarmsResponse
ListAlarmsResponse'
            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
"alarmSummaries" 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 ListAlarms where
  hashWithSalt :: Int -> ListAlarms -> Int
hashWithSalt Int
_salt ListAlarms' {Maybe Natural
Maybe Text
Text
alarmModelName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:alarmModelName:ListAlarms' :: ListAlarms -> Text
$sel:nextToken:ListAlarms' :: ListAlarms -> Maybe Text
$sel:maxResults:ListAlarms' :: ListAlarms -> 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
alarmModelName

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

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

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

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

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

-- | A list that summarizes each alarm.
listAlarmsResponse_alarmSummaries :: Lens.Lens' ListAlarmsResponse (Prelude.Maybe [AlarmSummary])
listAlarmsResponse_alarmSummaries :: Lens' ListAlarmsResponse (Maybe [AlarmSummary])
listAlarmsResponse_alarmSummaries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlarmsResponse' {Maybe [AlarmSummary]
alarmSummaries :: Maybe [AlarmSummary]
$sel:alarmSummaries:ListAlarmsResponse' :: ListAlarmsResponse -> Maybe [AlarmSummary]
alarmSummaries} -> Maybe [AlarmSummary]
alarmSummaries) (\s :: ListAlarmsResponse
s@ListAlarmsResponse' {} Maybe [AlarmSummary]
a -> ListAlarmsResponse
s {$sel:alarmSummaries:ListAlarmsResponse' :: Maybe [AlarmSummary]
alarmSummaries = Maybe [AlarmSummary]
a} :: ListAlarmsResponse) 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.
listAlarmsResponse_nextToken :: Lens.Lens' ListAlarmsResponse (Prelude.Maybe Prelude.Text)
listAlarmsResponse_nextToken :: Lens' ListAlarmsResponse (Maybe Text)
listAlarmsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAlarmsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAlarmsResponse' :: ListAlarmsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAlarmsResponse
s@ListAlarmsResponse' {} Maybe Text
a -> ListAlarmsResponse
s {$sel:nextToken:ListAlarmsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAlarmsResponse)

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

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