{-# 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-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 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_nextToken,
    listAlarms_maxResults,
    listAlarms_alarmModelName,

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

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

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

-- | The token that you can use to return the next set of results.
listAlarms_nextToken :: Lens.Lens' ListAlarms (Prelude.Maybe Prelude.Text)
listAlarms_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListAlarms -> f ListAlarms
listAlarms_nextToken = (ListAlarms -> Maybe Text)
-> (ListAlarms -> Maybe Text -> ListAlarms)
-> Lens ListAlarms ListAlarms (Maybe Text) (Maybe Text)
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 maximum number of results to be returned per request.
listAlarms_maxResults :: Lens.Lens' ListAlarms (Prelude.Maybe Prelude.Natural)
listAlarms_maxResults :: (Maybe Natural -> f (Maybe Natural)) -> ListAlarms -> f ListAlarms
listAlarms_maxResults = (ListAlarms -> Maybe Natural)
-> (ListAlarms -> Maybe Natural -> ListAlarms)
-> Lens ListAlarms ListAlarms (Maybe Natural) (Maybe Natural)
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 name of the alarm model.
listAlarms_alarmModelName :: Lens.Lens' ListAlarms Prelude.Text
listAlarms_alarmModelName :: (Text -> f Text) -> ListAlarms -> f ListAlarms
listAlarms_alarmModelName = (ListAlarms -> Text)
-> (ListAlarms -> Text -> ListAlarms)
-> Lens ListAlarms ListAlarms Text Text
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 :: ListAlarms -> Request ListAlarms
request = Service -> ListAlarms -> Request ListAlarms
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAlarms
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAlarms)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListAlarms))
-> Logger
-> Service
-> Proxy ListAlarms
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAlarms)))
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 [AlarmSummary] -> Int -> ListAlarmsResponse
ListAlarmsResponse'
            (Maybe Text -> Maybe [AlarmSummary] -> Int -> ListAlarmsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [AlarmSummary] -> Int -> ListAlarmsResponse)
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 [AlarmSummary] -> Int -> ListAlarmsResponse)
-> Either String (Maybe [AlarmSummary])
-> Either String (Int -> ListAlarmsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [AlarmSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"alarmSummaries" Either String (Maybe (Maybe [AlarmSummary]))
-> Maybe [AlarmSummary] -> Either String (Maybe [AlarmSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [AlarmSummary]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListAlarmsResponse)
-> Either String Int -> Either String ListAlarmsResponse
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 ListAlarms

instance Prelude.NFData ListAlarms

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

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

instance Core.ToQuery ListAlarms where
  toQuery :: ListAlarms -> QueryString
toQuery ListAlarms' {Maybe Natural
Maybe Text
Text
alarmModelName :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:alarmModelName:ListAlarms' :: ListAlarms -> Text
$sel:maxResults:ListAlarms' :: ListAlarms -> Maybe Natural
$sel:nextToken:ListAlarms' :: ListAlarms -> 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:/ 'newListAlarmsResponse' smart constructor.
data ListAlarmsResponse = ListAlarmsResponse'
  { -- | 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,
    -- | A list that summarizes each alarm.
    ListAlarmsResponse -> Maybe [AlarmSummary]
alarmSummaries :: Prelude.Maybe [AlarmSummary],
    -- | The response's http status code.
    ListAlarmsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAlarmsResponse -> ListAlarmsResponse -> Bool
(ListAlarmsResponse -> ListAlarmsResponse -> Bool)
-> (ListAlarmsResponse -> ListAlarmsResponse -> Bool)
-> Eq ListAlarmsResponse
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]
(Int -> ReadS ListAlarmsResponse)
-> ReadS [ListAlarmsResponse]
-> ReadPrec ListAlarmsResponse
-> ReadPrec [ListAlarmsResponse]
-> Read 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
(Int -> ListAlarmsResponse -> ShowS)
-> (ListAlarmsResponse -> String)
-> ([ListAlarmsResponse] -> ShowS)
-> Show ListAlarmsResponse
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. ListAlarmsResponse -> Rep ListAlarmsResponse x)
-> (forall x. Rep ListAlarmsResponse x -> ListAlarmsResponse)
-> Generic ListAlarmsResponse
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:
--
-- 'nextToken', 'listAlarmsResponse_nextToken' - The token that you can use to return the next set of results, or @null@
-- if there are no more results.
--
-- 'alarmSummaries', 'listAlarmsResponse_alarmSummaries' - A list that summarizes each alarm.
--
-- 'httpStatus', 'listAlarmsResponse_httpStatus' - The response's http status code.
newListAlarmsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAlarmsResponse
newListAlarmsResponse :: Int -> ListAlarmsResponse
newListAlarmsResponse Int
pHttpStatus_ =
  ListAlarmsResponse' :: Maybe Text -> Maybe [AlarmSummary] -> Int -> ListAlarmsResponse
ListAlarmsResponse'
    { $sel:nextToken:ListAlarmsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmSummaries:ListAlarmsResponse' :: Maybe [AlarmSummary]
alarmSummaries = Maybe [AlarmSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAlarmsResponse' :: 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.
listAlarmsResponse_nextToken :: Lens.Lens' ListAlarmsResponse (Prelude.Maybe Prelude.Text)
listAlarmsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAlarmsResponse -> f ListAlarmsResponse
listAlarmsResponse_nextToken = (ListAlarmsResponse -> Maybe Text)
-> (ListAlarmsResponse -> Maybe Text -> ListAlarmsResponse)
-> Lens
     ListAlarmsResponse ListAlarmsResponse (Maybe Text) (Maybe Text)
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)

-- | A list that summarizes each alarm.
listAlarmsResponse_alarmSummaries :: Lens.Lens' ListAlarmsResponse (Prelude.Maybe [AlarmSummary])
listAlarmsResponse_alarmSummaries :: (Maybe [AlarmSummary] -> f (Maybe [AlarmSummary]))
-> ListAlarmsResponse -> f ListAlarmsResponse
listAlarmsResponse_alarmSummaries = (ListAlarmsResponse -> Maybe [AlarmSummary])
-> (ListAlarmsResponse
    -> Maybe [AlarmSummary] -> ListAlarmsResponse)
-> Lens
     ListAlarmsResponse
     ListAlarmsResponse
     (Maybe [AlarmSummary])
     (Maybe [AlarmSummary])
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) ((Maybe [AlarmSummary] -> f (Maybe [AlarmSummary]))
 -> ListAlarmsResponse -> f ListAlarmsResponse)
-> ((Maybe [AlarmSummary] -> f (Maybe [AlarmSummary]))
    -> Maybe [AlarmSummary] -> f (Maybe [AlarmSummary]))
-> (Maybe [AlarmSummary] -> f (Maybe [AlarmSummary]))
-> ListAlarmsResponse
-> f ListAlarmsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [AlarmSummary] [AlarmSummary] [AlarmSummary] [AlarmSummary]
-> Iso
     (Maybe [AlarmSummary])
     (Maybe [AlarmSummary])
     (Maybe [AlarmSummary])
     (Maybe [AlarmSummary])
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 [AlarmSummary] [AlarmSummary] [AlarmSummary] [AlarmSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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