{-# 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.BatchResetAlarm
-- 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)
--
-- Resets one or more alarms. The alarms return to the @NORMAL@ state after
-- you reset them.
module Amazonka.IoTEventsData.BatchResetAlarm
  ( -- * Creating a Request
    BatchResetAlarm (..),
    newBatchResetAlarm,

    -- * Request Lenses
    batchResetAlarm_resetActionRequests,

    -- * Destructuring the Response
    BatchResetAlarmResponse (..),
    newBatchResetAlarmResponse,

    -- * Response Lenses
    batchResetAlarmResponse_errorEntries,
    batchResetAlarmResponse_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:/ 'newBatchResetAlarm' smart constructor.
data BatchResetAlarm = BatchResetAlarm'
  { -- | The list of reset action requests. You can specify up to 10 requests per
    -- operation.
    BatchResetAlarm -> NonEmpty ResetAlarmActionRequest
resetActionRequests :: Prelude.NonEmpty ResetAlarmActionRequest
  }
  deriving (BatchResetAlarm -> BatchResetAlarm -> Bool
(BatchResetAlarm -> BatchResetAlarm -> Bool)
-> (BatchResetAlarm -> BatchResetAlarm -> Bool)
-> Eq BatchResetAlarm
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchResetAlarm -> BatchResetAlarm -> Bool
$c/= :: BatchResetAlarm -> BatchResetAlarm -> Bool
== :: BatchResetAlarm -> BatchResetAlarm -> Bool
$c== :: BatchResetAlarm -> BatchResetAlarm -> Bool
Prelude.Eq, ReadPrec [BatchResetAlarm]
ReadPrec BatchResetAlarm
Int -> ReadS BatchResetAlarm
ReadS [BatchResetAlarm]
(Int -> ReadS BatchResetAlarm)
-> ReadS [BatchResetAlarm]
-> ReadPrec BatchResetAlarm
-> ReadPrec [BatchResetAlarm]
-> Read BatchResetAlarm
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchResetAlarm]
$creadListPrec :: ReadPrec [BatchResetAlarm]
readPrec :: ReadPrec BatchResetAlarm
$creadPrec :: ReadPrec BatchResetAlarm
readList :: ReadS [BatchResetAlarm]
$creadList :: ReadS [BatchResetAlarm]
readsPrec :: Int -> ReadS BatchResetAlarm
$creadsPrec :: Int -> ReadS BatchResetAlarm
Prelude.Read, Int -> BatchResetAlarm -> ShowS
[BatchResetAlarm] -> ShowS
BatchResetAlarm -> String
(Int -> BatchResetAlarm -> ShowS)
-> (BatchResetAlarm -> String)
-> ([BatchResetAlarm] -> ShowS)
-> Show BatchResetAlarm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchResetAlarm] -> ShowS
$cshowList :: [BatchResetAlarm] -> ShowS
show :: BatchResetAlarm -> String
$cshow :: BatchResetAlarm -> String
showsPrec :: Int -> BatchResetAlarm -> ShowS
$cshowsPrec :: Int -> BatchResetAlarm -> ShowS
Prelude.Show, (forall x. BatchResetAlarm -> Rep BatchResetAlarm x)
-> (forall x. Rep BatchResetAlarm x -> BatchResetAlarm)
-> Generic BatchResetAlarm
forall x. Rep BatchResetAlarm x -> BatchResetAlarm
forall x. BatchResetAlarm -> Rep BatchResetAlarm x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchResetAlarm x -> BatchResetAlarm
$cfrom :: forall x. BatchResetAlarm -> Rep BatchResetAlarm x
Prelude.Generic)

-- |
-- Create a value of 'BatchResetAlarm' 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:
--
-- 'resetActionRequests', 'batchResetAlarm_resetActionRequests' - The list of reset action requests. You can specify up to 10 requests per
-- operation.
newBatchResetAlarm ::
  -- | 'resetActionRequests'
  Prelude.NonEmpty ResetAlarmActionRequest ->
  BatchResetAlarm
newBatchResetAlarm :: NonEmpty ResetAlarmActionRequest -> BatchResetAlarm
newBatchResetAlarm NonEmpty ResetAlarmActionRequest
pResetActionRequests_ =
  BatchResetAlarm' :: NonEmpty ResetAlarmActionRequest -> BatchResetAlarm
BatchResetAlarm'
    { $sel:resetActionRequests:BatchResetAlarm' :: NonEmpty ResetAlarmActionRequest
resetActionRequests =
        Tagged
  (NonEmpty ResetAlarmActionRequest)
  (Identity (NonEmpty ResetAlarmActionRequest))
-> Tagged
     (NonEmpty ResetAlarmActionRequest)
     (Identity (NonEmpty ResetAlarmActionRequest))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty ResetAlarmActionRequest)
   (Identity (NonEmpty ResetAlarmActionRequest))
 -> Tagged
      (NonEmpty ResetAlarmActionRequest)
      (Identity (NonEmpty ResetAlarmActionRequest)))
-> NonEmpty ResetAlarmActionRequest
-> NonEmpty ResetAlarmActionRequest
forall t b. AReview t b -> b -> t
Lens.# NonEmpty ResetAlarmActionRequest
pResetActionRequests_
    }

-- | The list of reset action requests. You can specify up to 10 requests per
-- operation.
batchResetAlarm_resetActionRequests :: Lens.Lens' BatchResetAlarm (Prelude.NonEmpty ResetAlarmActionRequest)
batchResetAlarm_resetActionRequests :: (NonEmpty ResetAlarmActionRequest
 -> f (NonEmpty ResetAlarmActionRequest))
-> BatchResetAlarm -> f BatchResetAlarm
batchResetAlarm_resetActionRequests = (BatchResetAlarm -> NonEmpty ResetAlarmActionRequest)
-> (BatchResetAlarm
    -> NonEmpty ResetAlarmActionRequest -> BatchResetAlarm)
-> Lens
     BatchResetAlarm
     BatchResetAlarm
     (NonEmpty ResetAlarmActionRequest)
     (NonEmpty ResetAlarmActionRequest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchResetAlarm' {NonEmpty ResetAlarmActionRequest
resetActionRequests :: NonEmpty ResetAlarmActionRequest
$sel:resetActionRequests:BatchResetAlarm' :: BatchResetAlarm -> NonEmpty ResetAlarmActionRequest
resetActionRequests} -> NonEmpty ResetAlarmActionRequest
resetActionRequests) (\s :: BatchResetAlarm
s@BatchResetAlarm' {} NonEmpty ResetAlarmActionRequest
a -> BatchResetAlarm
s {$sel:resetActionRequests:BatchResetAlarm' :: NonEmpty ResetAlarmActionRequest
resetActionRequests = NonEmpty ResetAlarmActionRequest
a} :: BatchResetAlarm) ((NonEmpty ResetAlarmActionRequest
  -> f (NonEmpty ResetAlarmActionRequest))
 -> BatchResetAlarm -> f BatchResetAlarm)
-> ((NonEmpty ResetAlarmActionRequest
     -> f (NonEmpty ResetAlarmActionRequest))
    -> NonEmpty ResetAlarmActionRequest
    -> f (NonEmpty ResetAlarmActionRequest))
-> (NonEmpty ResetAlarmActionRequest
    -> f (NonEmpty ResetAlarmActionRequest))
-> BatchResetAlarm
-> f BatchResetAlarm
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty ResetAlarmActionRequest
 -> f (NonEmpty ResetAlarmActionRequest))
-> NonEmpty ResetAlarmActionRequest
-> f (NonEmpty ResetAlarmActionRequest)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchResetAlarm where
  type
    AWSResponse BatchResetAlarm =
      BatchResetAlarmResponse
  request :: BatchResetAlarm -> Request BatchResetAlarm
request = Service -> BatchResetAlarm -> Request BatchResetAlarm
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy BatchResetAlarm
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchResetAlarm)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse BatchResetAlarm))
-> Logger
-> Service
-> Proxy BatchResetAlarm
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse BatchResetAlarm)))
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 [BatchAlarmActionErrorEntry]
-> Int -> BatchResetAlarmResponse
BatchResetAlarmResponse'
            (Maybe [BatchAlarmActionErrorEntry]
 -> Int -> BatchResetAlarmResponse)
-> Either String (Maybe [BatchAlarmActionErrorEntry])
-> Either String (Int -> BatchResetAlarmResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Key
-> Either String (Maybe (Maybe [BatchAlarmActionErrorEntry]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"errorEntries" Either String (Maybe (Maybe [BatchAlarmActionErrorEntry]))
-> Maybe [BatchAlarmActionErrorEntry]
-> Either String (Maybe [BatchAlarmActionErrorEntry])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [BatchAlarmActionErrorEntry]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> BatchResetAlarmResponse)
-> Either String Int -> Either String BatchResetAlarmResponse
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 BatchResetAlarm

instance Prelude.NFData BatchResetAlarm

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

instance Core.ToJSON BatchResetAlarm where
  toJSON :: BatchResetAlarm -> Value
toJSON BatchResetAlarm' {NonEmpty ResetAlarmActionRequest
resetActionRequests :: NonEmpty ResetAlarmActionRequest
$sel:resetActionRequests:BatchResetAlarm' :: BatchResetAlarm -> NonEmpty ResetAlarmActionRequest
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Key
"resetActionRequests" Key -> NonEmpty ResetAlarmActionRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= NonEmpty ResetAlarmActionRequest
resetActionRequests)
          ]
      )

instance Core.ToPath BatchResetAlarm where
  toPath :: BatchResetAlarm -> ByteString
toPath = ByteString -> BatchResetAlarm -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/alarms/reset"

instance Core.ToQuery BatchResetAlarm where
  toQuery :: BatchResetAlarm -> QueryString
toQuery = QueryString -> BatchResetAlarm -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newBatchResetAlarmResponse' smart constructor.
data BatchResetAlarmResponse = BatchResetAlarmResponse'
  { -- | A list of errors associated with the request, or @null@ if there are no
    -- errors. Each error entry contains an entry ID that helps you identify
    -- the entry that failed.
    BatchResetAlarmResponse -> Maybe [BatchAlarmActionErrorEntry]
errorEntries :: Prelude.Maybe [BatchAlarmActionErrorEntry],
    -- | The response's http status code.
    BatchResetAlarmResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchResetAlarmResponse -> BatchResetAlarmResponse -> Bool
(BatchResetAlarmResponse -> BatchResetAlarmResponse -> Bool)
-> (BatchResetAlarmResponse -> BatchResetAlarmResponse -> Bool)
-> Eq BatchResetAlarmResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchResetAlarmResponse -> BatchResetAlarmResponse -> Bool
$c/= :: BatchResetAlarmResponse -> BatchResetAlarmResponse -> Bool
== :: BatchResetAlarmResponse -> BatchResetAlarmResponse -> Bool
$c== :: BatchResetAlarmResponse -> BatchResetAlarmResponse -> Bool
Prelude.Eq, ReadPrec [BatchResetAlarmResponse]
ReadPrec BatchResetAlarmResponse
Int -> ReadS BatchResetAlarmResponse
ReadS [BatchResetAlarmResponse]
(Int -> ReadS BatchResetAlarmResponse)
-> ReadS [BatchResetAlarmResponse]
-> ReadPrec BatchResetAlarmResponse
-> ReadPrec [BatchResetAlarmResponse]
-> Read BatchResetAlarmResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchResetAlarmResponse]
$creadListPrec :: ReadPrec [BatchResetAlarmResponse]
readPrec :: ReadPrec BatchResetAlarmResponse
$creadPrec :: ReadPrec BatchResetAlarmResponse
readList :: ReadS [BatchResetAlarmResponse]
$creadList :: ReadS [BatchResetAlarmResponse]
readsPrec :: Int -> ReadS BatchResetAlarmResponse
$creadsPrec :: Int -> ReadS BatchResetAlarmResponse
Prelude.Read, Int -> BatchResetAlarmResponse -> ShowS
[BatchResetAlarmResponse] -> ShowS
BatchResetAlarmResponse -> String
(Int -> BatchResetAlarmResponse -> ShowS)
-> (BatchResetAlarmResponse -> String)
-> ([BatchResetAlarmResponse] -> ShowS)
-> Show BatchResetAlarmResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchResetAlarmResponse] -> ShowS
$cshowList :: [BatchResetAlarmResponse] -> ShowS
show :: BatchResetAlarmResponse -> String
$cshow :: BatchResetAlarmResponse -> String
showsPrec :: Int -> BatchResetAlarmResponse -> ShowS
$cshowsPrec :: Int -> BatchResetAlarmResponse -> ShowS
Prelude.Show, (forall x.
 BatchResetAlarmResponse -> Rep BatchResetAlarmResponse x)
-> (forall x.
    Rep BatchResetAlarmResponse x -> BatchResetAlarmResponse)
-> Generic BatchResetAlarmResponse
forall x. Rep BatchResetAlarmResponse x -> BatchResetAlarmResponse
forall x. BatchResetAlarmResponse -> Rep BatchResetAlarmResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchResetAlarmResponse x -> BatchResetAlarmResponse
$cfrom :: forall x. BatchResetAlarmResponse -> Rep BatchResetAlarmResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchResetAlarmResponse' 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:
--
-- 'errorEntries', 'batchResetAlarmResponse_errorEntries' - A list of errors associated with the request, or @null@ if there are no
-- errors. Each error entry contains an entry ID that helps you identify
-- the entry that failed.
--
-- 'httpStatus', 'batchResetAlarmResponse_httpStatus' - The response's http status code.
newBatchResetAlarmResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchResetAlarmResponse
newBatchResetAlarmResponse :: Int -> BatchResetAlarmResponse
newBatchResetAlarmResponse Int
pHttpStatus_ =
  BatchResetAlarmResponse' :: Maybe [BatchAlarmActionErrorEntry]
-> Int -> BatchResetAlarmResponse
BatchResetAlarmResponse'
    { $sel:errorEntries:BatchResetAlarmResponse' :: Maybe [BatchAlarmActionErrorEntry]
errorEntries =
        Maybe [BatchAlarmActionErrorEntry]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchResetAlarmResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of errors associated with the request, or @null@ if there are no
-- errors. Each error entry contains an entry ID that helps you identify
-- the entry that failed.
batchResetAlarmResponse_errorEntries :: Lens.Lens' BatchResetAlarmResponse (Prelude.Maybe [BatchAlarmActionErrorEntry])
batchResetAlarmResponse_errorEntries :: (Maybe [BatchAlarmActionErrorEntry]
 -> f (Maybe [BatchAlarmActionErrorEntry]))
-> BatchResetAlarmResponse -> f BatchResetAlarmResponse
batchResetAlarmResponse_errorEntries = (BatchResetAlarmResponse -> Maybe [BatchAlarmActionErrorEntry])
-> (BatchResetAlarmResponse
    -> Maybe [BatchAlarmActionErrorEntry] -> BatchResetAlarmResponse)
-> Lens
     BatchResetAlarmResponse
     BatchResetAlarmResponse
     (Maybe [BatchAlarmActionErrorEntry])
     (Maybe [BatchAlarmActionErrorEntry])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchResetAlarmResponse' {Maybe [BatchAlarmActionErrorEntry]
errorEntries :: Maybe [BatchAlarmActionErrorEntry]
$sel:errorEntries:BatchResetAlarmResponse' :: BatchResetAlarmResponse -> Maybe [BatchAlarmActionErrorEntry]
errorEntries} -> Maybe [BatchAlarmActionErrorEntry]
errorEntries) (\s :: BatchResetAlarmResponse
s@BatchResetAlarmResponse' {} Maybe [BatchAlarmActionErrorEntry]
a -> BatchResetAlarmResponse
s {$sel:errorEntries:BatchResetAlarmResponse' :: Maybe [BatchAlarmActionErrorEntry]
errorEntries = Maybe [BatchAlarmActionErrorEntry]
a} :: BatchResetAlarmResponse) ((Maybe [BatchAlarmActionErrorEntry]
  -> f (Maybe [BatchAlarmActionErrorEntry]))
 -> BatchResetAlarmResponse -> f BatchResetAlarmResponse)
-> ((Maybe [BatchAlarmActionErrorEntry]
     -> f (Maybe [BatchAlarmActionErrorEntry]))
    -> Maybe [BatchAlarmActionErrorEntry]
    -> f (Maybe [BatchAlarmActionErrorEntry]))
-> (Maybe [BatchAlarmActionErrorEntry]
    -> f (Maybe [BatchAlarmActionErrorEntry]))
-> BatchResetAlarmResponse
-> f BatchResetAlarmResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [BatchAlarmActionErrorEntry]
  [BatchAlarmActionErrorEntry]
  [BatchAlarmActionErrorEntry]
  [BatchAlarmActionErrorEntry]
-> Iso
     (Maybe [BatchAlarmActionErrorEntry])
     (Maybe [BatchAlarmActionErrorEntry])
     (Maybe [BatchAlarmActionErrorEntry])
     (Maybe [BatchAlarmActionErrorEntry])
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
  [BatchAlarmActionErrorEntry]
  [BatchAlarmActionErrorEntry]
  [BatchAlarmActionErrorEntry]
  [BatchAlarmActionErrorEntry]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData BatchResetAlarmResponse