{-# 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.CloudWatch.DescribeAlarmHistory
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the history for the specified alarm. You can filter the
-- results by date range or item type. If an alarm name is not specified,
-- the histories for either all metric alarms or all composite alarms are
-- returned.
--
-- CloudWatch retains the history of an alarm even if you delete the alarm.
--
-- To use this operation and return information about a composite alarm,
-- you must be signed on with the @cloudwatch:DescribeAlarmHistory@
-- permission that is scoped to @*@. You can\'t return information about
-- composite alarms if your @cloudwatch:DescribeAlarmHistory@ permission
-- has a narrower scope.
--
-- This operation returns paginated results.
module Amazonka.CloudWatch.DescribeAlarmHistory
  ( -- * Creating a Request
    DescribeAlarmHistory (..),
    newDescribeAlarmHistory,

    -- * Request Lenses
    describeAlarmHistory_alarmName,
    describeAlarmHistory_alarmTypes,
    describeAlarmHistory_endDate,
    describeAlarmHistory_historyItemType,
    describeAlarmHistory_maxRecords,
    describeAlarmHistory_nextToken,
    describeAlarmHistory_scanBy,
    describeAlarmHistory_startDate,

    -- * Destructuring the Response
    DescribeAlarmHistoryResponse (..),
    newDescribeAlarmHistoryResponse,

    -- * Response Lenses
    describeAlarmHistoryResponse_alarmHistoryItems,
    describeAlarmHistoryResponse_nextToken,
    describeAlarmHistoryResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeAlarmHistory' smart constructor.
data DescribeAlarmHistory = DescribeAlarmHistory'
  { -- | The name of the alarm.
    DescribeAlarmHistory -> Maybe Text
alarmName :: Prelude.Maybe Prelude.Text,
    -- | Use this parameter to specify whether you want the operation to return
    -- metric alarms or composite alarms. If you omit this parameter, only
    -- metric alarms are returned.
    DescribeAlarmHistory -> Maybe [AlarmType]
alarmTypes :: Prelude.Maybe [AlarmType],
    -- | The ending date to retrieve alarm history.
    DescribeAlarmHistory -> Maybe ISO8601
endDate :: Prelude.Maybe Data.ISO8601,
    -- | The type of alarm histories to retrieve.
    DescribeAlarmHistory -> Maybe HistoryItemType
historyItemType :: Prelude.Maybe HistoryItemType,
    -- | The maximum number of alarm history records to retrieve.
    DescribeAlarmHistory -> Maybe Natural
maxRecords :: Prelude.Maybe Prelude.Natural,
    -- | The token returned by a previous call to indicate that there is more
    -- data available.
    DescribeAlarmHistory -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Specified whether to return the newest or oldest alarm history first.
    -- Specify @TimestampDescending@ to have the newest event history returned
    -- first, and specify @TimestampAscending@ to have the oldest history
    -- returned first.
    DescribeAlarmHistory -> Maybe ScanBy
scanBy :: Prelude.Maybe ScanBy,
    -- | The starting date to retrieve alarm history.
    DescribeAlarmHistory -> Maybe ISO8601
startDate :: Prelude.Maybe Data.ISO8601
  }
  deriving (DescribeAlarmHistory -> DescribeAlarmHistory -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAlarmHistory -> DescribeAlarmHistory -> Bool
$c/= :: DescribeAlarmHistory -> DescribeAlarmHistory -> Bool
== :: DescribeAlarmHistory -> DescribeAlarmHistory -> Bool
$c== :: DescribeAlarmHistory -> DescribeAlarmHistory -> Bool
Prelude.Eq, ReadPrec [DescribeAlarmHistory]
ReadPrec DescribeAlarmHistory
Int -> ReadS DescribeAlarmHistory
ReadS [DescribeAlarmHistory]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAlarmHistory]
$creadListPrec :: ReadPrec [DescribeAlarmHistory]
readPrec :: ReadPrec DescribeAlarmHistory
$creadPrec :: ReadPrec DescribeAlarmHistory
readList :: ReadS [DescribeAlarmHistory]
$creadList :: ReadS [DescribeAlarmHistory]
readsPrec :: Int -> ReadS DescribeAlarmHistory
$creadsPrec :: Int -> ReadS DescribeAlarmHistory
Prelude.Read, Int -> DescribeAlarmHistory -> ShowS
[DescribeAlarmHistory] -> ShowS
DescribeAlarmHistory -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAlarmHistory] -> ShowS
$cshowList :: [DescribeAlarmHistory] -> ShowS
show :: DescribeAlarmHistory -> String
$cshow :: DescribeAlarmHistory -> String
showsPrec :: Int -> DescribeAlarmHistory -> ShowS
$cshowsPrec :: Int -> DescribeAlarmHistory -> ShowS
Prelude.Show, forall x. Rep DescribeAlarmHistory x -> DescribeAlarmHistory
forall x. DescribeAlarmHistory -> Rep DescribeAlarmHistory x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAlarmHistory x -> DescribeAlarmHistory
$cfrom :: forall x. DescribeAlarmHistory -> Rep DescribeAlarmHistory x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAlarmHistory' 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:
--
-- 'alarmName', 'describeAlarmHistory_alarmName' - The name of the alarm.
--
-- 'alarmTypes', 'describeAlarmHistory_alarmTypes' - Use this parameter to specify whether you want the operation to return
-- metric alarms or composite alarms. If you omit this parameter, only
-- metric alarms are returned.
--
-- 'endDate', 'describeAlarmHistory_endDate' - The ending date to retrieve alarm history.
--
-- 'historyItemType', 'describeAlarmHistory_historyItemType' - The type of alarm histories to retrieve.
--
-- 'maxRecords', 'describeAlarmHistory_maxRecords' - The maximum number of alarm history records to retrieve.
--
-- 'nextToken', 'describeAlarmHistory_nextToken' - The token returned by a previous call to indicate that there is more
-- data available.
--
-- 'scanBy', 'describeAlarmHistory_scanBy' - Specified whether to return the newest or oldest alarm history first.
-- Specify @TimestampDescending@ to have the newest event history returned
-- first, and specify @TimestampAscending@ to have the oldest history
-- returned first.
--
-- 'startDate', 'describeAlarmHistory_startDate' - The starting date to retrieve alarm history.
newDescribeAlarmHistory ::
  DescribeAlarmHistory
newDescribeAlarmHistory :: DescribeAlarmHistory
newDescribeAlarmHistory =
  DescribeAlarmHistory'
    { $sel:alarmName:DescribeAlarmHistory' :: Maybe Text
alarmName = forall a. Maybe a
Prelude.Nothing,
      $sel:alarmTypes:DescribeAlarmHistory' :: Maybe [AlarmType]
alarmTypes = forall a. Maybe a
Prelude.Nothing,
      $sel:endDate:DescribeAlarmHistory' :: Maybe ISO8601
endDate = forall a. Maybe a
Prelude.Nothing,
      $sel:historyItemType:DescribeAlarmHistory' :: Maybe HistoryItemType
historyItemType = forall a. Maybe a
Prelude.Nothing,
      $sel:maxRecords:DescribeAlarmHistory' :: Maybe Natural
maxRecords = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeAlarmHistory' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:scanBy:DescribeAlarmHistory' :: Maybe ScanBy
scanBy = forall a. Maybe a
Prelude.Nothing,
      $sel:startDate:DescribeAlarmHistory' :: Maybe ISO8601
startDate = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the alarm.
describeAlarmHistory_alarmName :: Lens.Lens' DescribeAlarmHistory (Prelude.Maybe Prelude.Text)
describeAlarmHistory_alarmName :: Lens' DescribeAlarmHistory (Maybe Text)
describeAlarmHistory_alarmName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmHistory' {Maybe Text
alarmName :: Maybe Text
$sel:alarmName:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Text
alarmName} -> Maybe Text
alarmName) (\s :: DescribeAlarmHistory
s@DescribeAlarmHistory' {} Maybe Text
a -> DescribeAlarmHistory
s {$sel:alarmName:DescribeAlarmHistory' :: Maybe Text
alarmName = Maybe Text
a} :: DescribeAlarmHistory)

-- | Use this parameter to specify whether you want the operation to return
-- metric alarms or composite alarms. If you omit this parameter, only
-- metric alarms are returned.
describeAlarmHistory_alarmTypes :: Lens.Lens' DescribeAlarmHistory (Prelude.Maybe [AlarmType])
describeAlarmHistory_alarmTypes :: Lens' DescribeAlarmHistory (Maybe [AlarmType])
describeAlarmHistory_alarmTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmHistory' {Maybe [AlarmType]
alarmTypes :: Maybe [AlarmType]
$sel:alarmTypes:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe [AlarmType]
alarmTypes} -> Maybe [AlarmType]
alarmTypes) (\s :: DescribeAlarmHistory
s@DescribeAlarmHistory' {} Maybe [AlarmType]
a -> DescribeAlarmHistory
s {$sel:alarmTypes:DescribeAlarmHistory' :: Maybe [AlarmType]
alarmTypes = Maybe [AlarmType]
a} :: DescribeAlarmHistory) 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 ending date to retrieve alarm history.
describeAlarmHistory_endDate :: Lens.Lens' DescribeAlarmHistory (Prelude.Maybe Prelude.UTCTime)
describeAlarmHistory_endDate :: Lens' DescribeAlarmHistory (Maybe UTCTime)
describeAlarmHistory_endDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmHistory' {Maybe ISO8601
endDate :: Maybe ISO8601
$sel:endDate:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ISO8601
endDate} -> Maybe ISO8601
endDate) (\s :: DescribeAlarmHistory
s@DescribeAlarmHistory' {} Maybe ISO8601
a -> DescribeAlarmHistory
s {$sel:endDate:DescribeAlarmHistory' :: Maybe ISO8601
endDate = Maybe ISO8601
a} :: DescribeAlarmHistory) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The type of alarm histories to retrieve.
describeAlarmHistory_historyItemType :: Lens.Lens' DescribeAlarmHistory (Prelude.Maybe HistoryItemType)
describeAlarmHistory_historyItemType :: Lens' DescribeAlarmHistory (Maybe HistoryItemType)
describeAlarmHistory_historyItemType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmHistory' {Maybe HistoryItemType
historyItemType :: Maybe HistoryItemType
$sel:historyItemType:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe HistoryItemType
historyItemType} -> Maybe HistoryItemType
historyItemType) (\s :: DescribeAlarmHistory
s@DescribeAlarmHistory' {} Maybe HistoryItemType
a -> DescribeAlarmHistory
s {$sel:historyItemType:DescribeAlarmHistory' :: Maybe HistoryItemType
historyItemType = Maybe HistoryItemType
a} :: DescribeAlarmHistory)

-- | The maximum number of alarm history records to retrieve.
describeAlarmHistory_maxRecords :: Lens.Lens' DescribeAlarmHistory (Prelude.Maybe Prelude.Natural)
describeAlarmHistory_maxRecords :: Lens' DescribeAlarmHistory (Maybe Natural)
describeAlarmHistory_maxRecords = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmHistory' {Maybe Natural
maxRecords :: Maybe Natural
$sel:maxRecords:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Natural
maxRecords} -> Maybe Natural
maxRecords) (\s :: DescribeAlarmHistory
s@DescribeAlarmHistory' {} Maybe Natural
a -> DescribeAlarmHistory
s {$sel:maxRecords:DescribeAlarmHistory' :: Maybe Natural
maxRecords = Maybe Natural
a} :: DescribeAlarmHistory)

-- | The token returned by a previous call to indicate that there is more
-- data available.
describeAlarmHistory_nextToken :: Lens.Lens' DescribeAlarmHistory (Prelude.Maybe Prelude.Text)
describeAlarmHistory_nextToken :: Lens' DescribeAlarmHistory (Maybe Text)
describeAlarmHistory_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmHistory' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeAlarmHistory
s@DescribeAlarmHistory' {} Maybe Text
a -> DescribeAlarmHistory
s {$sel:nextToken:DescribeAlarmHistory' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeAlarmHistory)

-- | Specified whether to return the newest or oldest alarm history first.
-- Specify @TimestampDescending@ to have the newest event history returned
-- first, and specify @TimestampAscending@ to have the oldest history
-- returned first.
describeAlarmHistory_scanBy :: Lens.Lens' DescribeAlarmHistory (Prelude.Maybe ScanBy)
describeAlarmHistory_scanBy :: Lens' DescribeAlarmHistory (Maybe ScanBy)
describeAlarmHistory_scanBy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmHistory' {Maybe ScanBy
scanBy :: Maybe ScanBy
$sel:scanBy:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ScanBy
scanBy} -> Maybe ScanBy
scanBy) (\s :: DescribeAlarmHistory
s@DescribeAlarmHistory' {} Maybe ScanBy
a -> DescribeAlarmHistory
s {$sel:scanBy:DescribeAlarmHistory' :: Maybe ScanBy
scanBy = Maybe ScanBy
a} :: DescribeAlarmHistory)

-- | The starting date to retrieve alarm history.
describeAlarmHistory_startDate :: Lens.Lens' DescribeAlarmHistory (Prelude.Maybe Prelude.UTCTime)
describeAlarmHistory_startDate :: Lens' DescribeAlarmHistory (Maybe UTCTime)
describeAlarmHistory_startDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmHistory' {Maybe ISO8601
startDate :: Maybe ISO8601
$sel:startDate:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ISO8601
startDate} -> Maybe ISO8601
startDate) (\s :: DescribeAlarmHistory
s@DescribeAlarmHistory' {} Maybe ISO8601
a -> DescribeAlarmHistory
s {$sel:startDate:DescribeAlarmHistory' :: Maybe ISO8601
startDate = Maybe ISO8601
a} :: DescribeAlarmHistory) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Core.AWSPager DescribeAlarmHistory where
  page :: DescribeAlarmHistory
-> AWSResponse DescribeAlarmHistory -> Maybe DescribeAlarmHistory
page DescribeAlarmHistory
rq AWSResponse DescribeAlarmHistory
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeAlarmHistory
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeAlarmHistoryResponse (Maybe Text)
describeAlarmHistoryResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeAlarmHistory
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeAlarmHistoryResponse (Maybe [AlarmHistoryItem])
describeAlarmHistoryResponse_alarmHistoryItems
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ DescribeAlarmHistory
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' DescribeAlarmHistory (Maybe Text)
describeAlarmHistory_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeAlarmHistory
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeAlarmHistoryResponse (Maybe Text)
describeAlarmHistoryResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeAlarmHistory where
  type
    AWSResponse DescribeAlarmHistory =
      DescribeAlarmHistoryResponse
  request :: (Service -> Service)
-> DescribeAlarmHistory -> Request DescribeAlarmHistory
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeAlarmHistory
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeAlarmHistory)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DescribeAlarmHistoryResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [AlarmHistoryItem]
-> Maybe Text -> Int -> DescribeAlarmHistoryResponse
DescribeAlarmHistoryResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"AlarmHistoryItems"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"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 DescribeAlarmHistory where
  hashWithSalt :: Int -> DescribeAlarmHistory -> Int
hashWithSalt Int
_salt DescribeAlarmHistory' {Maybe Natural
Maybe [AlarmType]
Maybe Text
Maybe ISO8601
Maybe HistoryItemType
Maybe ScanBy
startDate :: Maybe ISO8601
scanBy :: Maybe ScanBy
nextToken :: Maybe Text
maxRecords :: Maybe Natural
historyItemType :: Maybe HistoryItemType
endDate :: Maybe ISO8601
alarmTypes :: Maybe [AlarmType]
alarmName :: Maybe Text
$sel:startDate:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ISO8601
$sel:scanBy:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ScanBy
$sel:nextToken:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Text
$sel:maxRecords:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Natural
$sel:historyItemType:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe HistoryItemType
$sel:endDate:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ISO8601
$sel:alarmTypes:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe [AlarmType]
$sel:alarmName:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
alarmName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AlarmType]
alarmTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
endDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HistoryItemType
historyItemType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxRecords
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ScanBy
scanBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
startDate

instance Prelude.NFData DescribeAlarmHistory where
  rnf :: DescribeAlarmHistory -> ()
rnf DescribeAlarmHistory' {Maybe Natural
Maybe [AlarmType]
Maybe Text
Maybe ISO8601
Maybe HistoryItemType
Maybe ScanBy
startDate :: Maybe ISO8601
scanBy :: Maybe ScanBy
nextToken :: Maybe Text
maxRecords :: Maybe Natural
historyItemType :: Maybe HistoryItemType
endDate :: Maybe ISO8601
alarmTypes :: Maybe [AlarmType]
alarmName :: Maybe Text
$sel:startDate:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ISO8601
$sel:scanBy:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ScanBy
$sel:nextToken:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Text
$sel:maxRecords:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Natural
$sel:historyItemType:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe HistoryItemType
$sel:endDate:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ISO8601
$sel:alarmTypes:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe [AlarmType]
$sel:alarmName:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
alarmName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [AlarmType]
alarmTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
endDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe HistoryItemType
historyItemType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxRecords
      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 Maybe ScanBy
scanBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
startDate

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

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

instance Data.ToQuery DescribeAlarmHistory where
  toQuery :: DescribeAlarmHistory -> QueryString
toQuery DescribeAlarmHistory' {Maybe Natural
Maybe [AlarmType]
Maybe Text
Maybe ISO8601
Maybe HistoryItemType
Maybe ScanBy
startDate :: Maybe ISO8601
scanBy :: Maybe ScanBy
nextToken :: Maybe Text
maxRecords :: Maybe Natural
historyItemType :: Maybe HistoryItemType
endDate :: Maybe ISO8601
alarmTypes :: Maybe [AlarmType]
alarmName :: Maybe Text
$sel:startDate:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ISO8601
$sel:scanBy:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ScanBy
$sel:nextToken:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Text
$sel:maxRecords:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Natural
$sel:historyItemType:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe HistoryItemType
$sel:endDate:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe ISO8601
$sel:alarmTypes:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe [AlarmType]
$sel:alarmName:DescribeAlarmHistory' :: DescribeAlarmHistory -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DescribeAlarmHistory" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"AlarmName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
alarmName,
        ByteString
"AlarmTypes"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AlarmType]
alarmTypes),
        ByteString
"EndDate" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe ISO8601
endDate,
        ByteString
"HistoryItemType" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe HistoryItemType
historyItemType,
        ByteString
"MaxRecords" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxRecords,
        ByteString
"NextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken,
        ByteString
"ScanBy" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe ScanBy
scanBy,
        ByteString
"StartDate" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe ISO8601
startDate
      ]

-- | /See:/ 'newDescribeAlarmHistoryResponse' smart constructor.
data DescribeAlarmHistoryResponse = DescribeAlarmHistoryResponse'
  { -- | The alarm histories, in JSON format.
    DescribeAlarmHistoryResponse -> Maybe [AlarmHistoryItem]
alarmHistoryItems :: Prelude.Maybe [AlarmHistoryItem],
    -- | The token that marks the start of the next batch of returned results.
    DescribeAlarmHistoryResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeAlarmHistoryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAlarmHistoryResponse
-> DescribeAlarmHistoryResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAlarmHistoryResponse
-> DescribeAlarmHistoryResponse -> Bool
$c/= :: DescribeAlarmHistoryResponse
-> DescribeAlarmHistoryResponse -> Bool
== :: DescribeAlarmHistoryResponse
-> DescribeAlarmHistoryResponse -> Bool
$c== :: DescribeAlarmHistoryResponse
-> DescribeAlarmHistoryResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAlarmHistoryResponse]
ReadPrec DescribeAlarmHistoryResponse
Int -> ReadS DescribeAlarmHistoryResponse
ReadS [DescribeAlarmHistoryResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAlarmHistoryResponse]
$creadListPrec :: ReadPrec [DescribeAlarmHistoryResponse]
readPrec :: ReadPrec DescribeAlarmHistoryResponse
$creadPrec :: ReadPrec DescribeAlarmHistoryResponse
readList :: ReadS [DescribeAlarmHistoryResponse]
$creadList :: ReadS [DescribeAlarmHistoryResponse]
readsPrec :: Int -> ReadS DescribeAlarmHistoryResponse
$creadsPrec :: Int -> ReadS DescribeAlarmHistoryResponse
Prelude.Read, Int -> DescribeAlarmHistoryResponse -> ShowS
[DescribeAlarmHistoryResponse] -> ShowS
DescribeAlarmHistoryResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAlarmHistoryResponse] -> ShowS
$cshowList :: [DescribeAlarmHistoryResponse] -> ShowS
show :: DescribeAlarmHistoryResponse -> String
$cshow :: DescribeAlarmHistoryResponse -> String
showsPrec :: Int -> DescribeAlarmHistoryResponse -> ShowS
$cshowsPrec :: Int -> DescribeAlarmHistoryResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeAlarmHistoryResponse x -> DescribeAlarmHistoryResponse
forall x.
DescribeAlarmHistoryResponse -> Rep DescribeAlarmHistoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAlarmHistoryResponse x -> DescribeAlarmHistoryResponse
$cfrom :: forall x.
DescribeAlarmHistoryResponse -> Rep DescribeAlarmHistoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAlarmHistoryResponse' 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:
--
-- 'alarmHistoryItems', 'describeAlarmHistoryResponse_alarmHistoryItems' - The alarm histories, in JSON format.
--
-- 'nextToken', 'describeAlarmHistoryResponse_nextToken' - The token that marks the start of the next batch of returned results.
--
-- 'httpStatus', 'describeAlarmHistoryResponse_httpStatus' - The response's http status code.
newDescribeAlarmHistoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAlarmHistoryResponse
newDescribeAlarmHistoryResponse :: Int -> DescribeAlarmHistoryResponse
newDescribeAlarmHistoryResponse Int
pHttpStatus_ =
  DescribeAlarmHistoryResponse'
    { $sel:alarmHistoryItems:DescribeAlarmHistoryResponse' :: Maybe [AlarmHistoryItem]
alarmHistoryItems =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeAlarmHistoryResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAlarmHistoryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The alarm histories, in JSON format.
describeAlarmHistoryResponse_alarmHistoryItems :: Lens.Lens' DescribeAlarmHistoryResponse (Prelude.Maybe [AlarmHistoryItem])
describeAlarmHistoryResponse_alarmHistoryItems :: Lens' DescribeAlarmHistoryResponse (Maybe [AlarmHistoryItem])
describeAlarmHistoryResponse_alarmHistoryItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmHistoryResponse' {Maybe [AlarmHistoryItem]
alarmHistoryItems :: Maybe [AlarmHistoryItem]
$sel:alarmHistoryItems:DescribeAlarmHistoryResponse' :: DescribeAlarmHistoryResponse -> Maybe [AlarmHistoryItem]
alarmHistoryItems} -> Maybe [AlarmHistoryItem]
alarmHistoryItems) (\s :: DescribeAlarmHistoryResponse
s@DescribeAlarmHistoryResponse' {} Maybe [AlarmHistoryItem]
a -> DescribeAlarmHistoryResponse
s {$sel:alarmHistoryItems:DescribeAlarmHistoryResponse' :: Maybe [AlarmHistoryItem]
alarmHistoryItems = Maybe [AlarmHistoryItem]
a} :: DescribeAlarmHistoryResponse) 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 marks the start of the next batch of returned results.
describeAlarmHistoryResponse_nextToken :: Lens.Lens' DescribeAlarmHistoryResponse (Prelude.Maybe Prelude.Text)
describeAlarmHistoryResponse_nextToken :: Lens' DescribeAlarmHistoryResponse (Maybe Text)
describeAlarmHistoryResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmHistoryResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeAlarmHistoryResponse' :: DescribeAlarmHistoryResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeAlarmHistoryResponse
s@DescribeAlarmHistoryResponse' {} Maybe Text
a -> DescribeAlarmHistoryResponse
s {$sel:nextToken:DescribeAlarmHistoryResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeAlarmHistoryResponse)

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

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