{-# 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.IoT.UpdateEventConfigurations
-- 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)
--
-- Updates the event configurations.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions UpdateEventConfigurations>
-- action.
module Amazonka.IoT.UpdateEventConfigurations
  ( -- * Creating a Request
    UpdateEventConfigurations (..),
    newUpdateEventConfigurations,

    -- * Request Lenses
    updateEventConfigurations_eventConfigurations,

    -- * Destructuring the Response
    UpdateEventConfigurationsResponse (..),
    newUpdateEventConfigurationsResponse,

    -- * Response Lenses
    updateEventConfigurationsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.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:/ 'newUpdateEventConfigurations' smart constructor.
data UpdateEventConfigurations = UpdateEventConfigurations'
  { -- | The new event configuration values.
    UpdateEventConfigurations
-> Maybe (HashMap EventType Configuration)
eventConfigurations :: Prelude.Maybe (Prelude.HashMap EventType Configuration)
  }
  deriving (UpdateEventConfigurations -> UpdateEventConfigurations -> Bool
(UpdateEventConfigurations -> UpdateEventConfigurations -> Bool)
-> (UpdateEventConfigurations -> UpdateEventConfigurations -> Bool)
-> Eq UpdateEventConfigurations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateEventConfigurations -> UpdateEventConfigurations -> Bool
$c/= :: UpdateEventConfigurations -> UpdateEventConfigurations -> Bool
== :: UpdateEventConfigurations -> UpdateEventConfigurations -> Bool
$c== :: UpdateEventConfigurations -> UpdateEventConfigurations -> Bool
Prelude.Eq, ReadPrec [UpdateEventConfigurations]
ReadPrec UpdateEventConfigurations
Int -> ReadS UpdateEventConfigurations
ReadS [UpdateEventConfigurations]
(Int -> ReadS UpdateEventConfigurations)
-> ReadS [UpdateEventConfigurations]
-> ReadPrec UpdateEventConfigurations
-> ReadPrec [UpdateEventConfigurations]
-> Read UpdateEventConfigurations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateEventConfigurations]
$creadListPrec :: ReadPrec [UpdateEventConfigurations]
readPrec :: ReadPrec UpdateEventConfigurations
$creadPrec :: ReadPrec UpdateEventConfigurations
readList :: ReadS [UpdateEventConfigurations]
$creadList :: ReadS [UpdateEventConfigurations]
readsPrec :: Int -> ReadS UpdateEventConfigurations
$creadsPrec :: Int -> ReadS UpdateEventConfigurations
Prelude.Read, Int -> UpdateEventConfigurations -> ShowS
[UpdateEventConfigurations] -> ShowS
UpdateEventConfigurations -> String
(Int -> UpdateEventConfigurations -> ShowS)
-> (UpdateEventConfigurations -> String)
-> ([UpdateEventConfigurations] -> ShowS)
-> Show UpdateEventConfigurations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateEventConfigurations] -> ShowS
$cshowList :: [UpdateEventConfigurations] -> ShowS
show :: UpdateEventConfigurations -> String
$cshow :: UpdateEventConfigurations -> String
showsPrec :: Int -> UpdateEventConfigurations -> ShowS
$cshowsPrec :: Int -> UpdateEventConfigurations -> ShowS
Prelude.Show, (forall x.
 UpdateEventConfigurations -> Rep UpdateEventConfigurations x)
-> (forall x.
    Rep UpdateEventConfigurations x -> UpdateEventConfigurations)
-> Generic UpdateEventConfigurations
forall x.
Rep UpdateEventConfigurations x -> UpdateEventConfigurations
forall x.
UpdateEventConfigurations -> Rep UpdateEventConfigurations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateEventConfigurations x -> UpdateEventConfigurations
$cfrom :: forall x.
UpdateEventConfigurations -> Rep UpdateEventConfigurations x
Prelude.Generic)

-- |
-- Create a value of 'UpdateEventConfigurations' 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:
--
-- 'eventConfigurations', 'updateEventConfigurations_eventConfigurations' - The new event configuration values.
newUpdateEventConfigurations ::
  UpdateEventConfigurations
newUpdateEventConfigurations :: UpdateEventConfigurations
newUpdateEventConfigurations =
  UpdateEventConfigurations' :: Maybe (HashMap EventType Configuration)
-> UpdateEventConfigurations
UpdateEventConfigurations'
    { $sel:eventConfigurations:UpdateEventConfigurations' :: Maybe (HashMap EventType Configuration)
eventConfigurations =
        Maybe (HashMap EventType Configuration)
forall a. Maybe a
Prelude.Nothing
    }

-- | The new event configuration values.
updateEventConfigurations_eventConfigurations :: Lens.Lens' UpdateEventConfigurations (Prelude.Maybe (Prelude.HashMap EventType Configuration))
updateEventConfigurations_eventConfigurations :: (Maybe (HashMap EventType Configuration)
 -> f (Maybe (HashMap EventType Configuration)))
-> UpdateEventConfigurations -> f UpdateEventConfigurations
updateEventConfigurations_eventConfigurations = (UpdateEventConfigurations
 -> Maybe (HashMap EventType Configuration))
-> (UpdateEventConfigurations
    -> Maybe (HashMap EventType Configuration)
    -> UpdateEventConfigurations)
-> Lens
     UpdateEventConfigurations
     UpdateEventConfigurations
     (Maybe (HashMap EventType Configuration))
     (Maybe (HashMap EventType Configuration))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEventConfigurations' {Maybe (HashMap EventType Configuration)
eventConfigurations :: Maybe (HashMap EventType Configuration)
$sel:eventConfigurations:UpdateEventConfigurations' :: UpdateEventConfigurations
-> Maybe (HashMap EventType Configuration)
eventConfigurations} -> Maybe (HashMap EventType Configuration)
eventConfigurations) (\s :: UpdateEventConfigurations
s@UpdateEventConfigurations' {} Maybe (HashMap EventType Configuration)
a -> UpdateEventConfigurations
s {$sel:eventConfigurations:UpdateEventConfigurations' :: Maybe (HashMap EventType Configuration)
eventConfigurations = Maybe (HashMap EventType Configuration)
a} :: UpdateEventConfigurations) ((Maybe (HashMap EventType Configuration)
  -> f (Maybe (HashMap EventType Configuration)))
 -> UpdateEventConfigurations -> f UpdateEventConfigurations)
-> ((Maybe (HashMap EventType Configuration)
     -> f (Maybe (HashMap EventType Configuration)))
    -> Maybe (HashMap EventType Configuration)
    -> f (Maybe (HashMap EventType Configuration)))
-> (Maybe (HashMap EventType Configuration)
    -> f (Maybe (HashMap EventType Configuration)))
-> UpdateEventConfigurations
-> f UpdateEventConfigurations
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap EventType Configuration)
  (HashMap EventType Configuration)
  (HashMap EventType Configuration)
  (HashMap EventType Configuration)
-> Iso
     (Maybe (HashMap EventType Configuration))
     (Maybe (HashMap EventType Configuration))
     (Maybe (HashMap EventType Configuration))
     (Maybe (HashMap EventType Configuration))
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
  (HashMap EventType Configuration)
  (HashMap EventType Configuration)
  (HashMap EventType Configuration)
  (HashMap EventType Configuration)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UpdateEventConfigurations where
  type
    AWSResponse UpdateEventConfigurations =
      UpdateEventConfigurationsResponse
  request :: UpdateEventConfigurations -> Request UpdateEventConfigurations
request = Service
-> UpdateEventConfigurations -> Request UpdateEventConfigurations
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateEventConfigurations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateEventConfigurations)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateEventConfigurations))
-> Logger
-> Service
-> Proxy UpdateEventConfigurations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateEventConfigurations)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateEventConfigurationsResponse
UpdateEventConfigurationsResponse'
            (Int -> UpdateEventConfigurationsResponse)
-> Either String Int
-> Either String UpdateEventConfigurationsResponse
forall (f :: * -> *) a b. Functor 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 UpdateEventConfigurations

instance Prelude.NFData UpdateEventConfigurations

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

instance Core.ToJSON UpdateEventConfigurations where
  toJSON :: UpdateEventConfigurations -> Value
toJSON UpdateEventConfigurations' {Maybe (HashMap EventType Configuration)
eventConfigurations :: Maybe (HashMap EventType Configuration)
$sel:eventConfigurations:UpdateEventConfigurations' :: UpdateEventConfigurations
-> Maybe (HashMap EventType Configuration)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"eventConfigurations" Text -> HashMap EventType Configuration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap EventType Configuration -> Pair)
-> Maybe (HashMap EventType Configuration) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap EventType Configuration)
eventConfigurations
          ]
      )

instance Core.ToPath UpdateEventConfigurations where
  toPath :: UpdateEventConfigurations -> ByteString
toPath = ByteString -> UpdateEventConfigurations -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/event-configurations"

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

-- | /See:/ 'newUpdateEventConfigurationsResponse' smart constructor.
data UpdateEventConfigurationsResponse = UpdateEventConfigurationsResponse'
  { -- | The response's http status code.
    UpdateEventConfigurationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateEventConfigurationsResponse
-> UpdateEventConfigurationsResponse -> Bool
(UpdateEventConfigurationsResponse
 -> UpdateEventConfigurationsResponse -> Bool)
-> (UpdateEventConfigurationsResponse
    -> UpdateEventConfigurationsResponse -> Bool)
-> Eq UpdateEventConfigurationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateEventConfigurationsResponse
-> UpdateEventConfigurationsResponse -> Bool
$c/= :: UpdateEventConfigurationsResponse
-> UpdateEventConfigurationsResponse -> Bool
== :: UpdateEventConfigurationsResponse
-> UpdateEventConfigurationsResponse -> Bool
$c== :: UpdateEventConfigurationsResponse
-> UpdateEventConfigurationsResponse -> Bool
Prelude.Eq, ReadPrec [UpdateEventConfigurationsResponse]
ReadPrec UpdateEventConfigurationsResponse
Int -> ReadS UpdateEventConfigurationsResponse
ReadS [UpdateEventConfigurationsResponse]
(Int -> ReadS UpdateEventConfigurationsResponse)
-> ReadS [UpdateEventConfigurationsResponse]
-> ReadPrec UpdateEventConfigurationsResponse
-> ReadPrec [UpdateEventConfigurationsResponse]
-> Read UpdateEventConfigurationsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateEventConfigurationsResponse]
$creadListPrec :: ReadPrec [UpdateEventConfigurationsResponse]
readPrec :: ReadPrec UpdateEventConfigurationsResponse
$creadPrec :: ReadPrec UpdateEventConfigurationsResponse
readList :: ReadS [UpdateEventConfigurationsResponse]
$creadList :: ReadS [UpdateEventConfigurationsResponse]
readsPrec :: Int -> ReadS UpdateEventConfigurationsResponse
$creadsPrec :: Int -> ReadS UpdateEventConfigurationsResponse
Prelude.Read, Int -> UpdateEventConfigurationsResponse -> ShowS
[UpdateEventConfigurationsResponse] -> ShowS
UpdateEventConfigurationsResponse -> String
(Int -> UpdateEventConfigurationsResponse -> ShowS)
-> (UpdateEventConfigurationsResponse -> String)
-> ([UpdateEventConfigurationsResponse] -> ShowS)
-> Show UpdateEventConfigurationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateEventConfigurationsResponse] -> ShowS
$cshowList :: [UpdateEventConfigurationsResponse] -> ShowS
show :: UpdateEventConfigurationsResponse -> String
$cshow :: UpdateEventConfigurationsResponse -> String
showsPrec :: Int -> UpdateEventConfigurationsResponse -> ShowS
$cshowsPrec :: Int -> UpdateEventConfigurationsResponse -> ShowS
Prelude.Show, (forall x.
 UpdateEventConfigurationsResponse
 -> Rep UpdateEventConfigurationsResponse x)
-> (forall x.
    Rep UpdateEventConfigurationsResponse x
    -> UpdateEventConfigurationsResponse)
-> Generic UpdateEventConfigurationsResponse
forall x.
Rep UpdateEventConfigurationsResponse x
-> UpdateEventConfigurationsResponse
forall x.
UpdateEventConfigurationsResponse
-> Rep UpdateEventConfigurationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateEventConfigurationsResponse x
-> UpdateEventConfigurationsResponse
$cfrom :: forall x.
UpdateEventConfigurationsResponse
-> Rep UpdateEventConfigurationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateEventConfigurationsResponse' 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:
--
-- 'httpStatus', 'updateEventConfigurationsResponse_httpStatus' - The response's http status code.
newUpdateEventConfigurationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateEventConfigurationsResponse
newUpdateEventConfigurationsResponse :: Int -> UpdateEventConfigurationsResponse
newUpdateEventConfigurationsResponse Int
pHttpStatus_ =
  UpdateEventConfigurationsResponse' :: Int -> UpdateEventConfigurationsResponse
UpdateEventConfigurationsResponse'
    { $sel:httpStatus:UpdateEventConfigurationsResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    UpdateEventConfigurationsResponse