{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types
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
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]
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
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.
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'
    { $sel:eventConfigurations:UpdateEventConfigurations' :: Maybe (HashMap EventType Configuration)
eventConfigurations =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The new event configuration values.
updateEventConfigurations_eventConfigurations :: Lens.Lens' UpdateEventConfigurations (Prelude.Maybe (Prelude.HashMap EventType Configuration))
updateEventConfigurations_eventConfigurations :: Lens'
  UpdateEventConfigurations (Maybe (HashMap EventType Configuration))
updateEventConfigurations_eventConfigurations = 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) 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

instance Core.AWSRequest UpdateEventConfigurations where
  type
    AWSResponse UpdateEventConfigurations =
      UpdateEventConfigurationsResponse
  request :: (Service -> Service)
-> UpdateEventConfigurations -> Request UpdateEventConfigurations
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateEventConfigurations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateEventConfigurations)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateEventConfigurationsResponse
UpdateEventConfigurationsResponse'
            forall (f :: * -> *) a b. Functor 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 UpdateEventConfigurations where
  hashWithSalt :: Int -> UpdateEventConfigurations -> Int
hashWithSalt Int
_salt UpdateEventConfigurations' {Maybe (HashMap EventType Configuration)
eventConfigurations :: Maybe (HashMap EventType Configuration)
$sel:eventConfigurations:UpdateEventConfigurations' :: UpdateEventConfigurations
-> Maybe (HashMap EventType Configuration)
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap EventType Configuration)
eventConfigurations

instance Prelude.NFData UpdateEventConfigurations where
  rnf :: UpdateEventConfigurations -> ()
rnf UpdateEventConfigurations' {Maybe (HashMap EventType Configuration)
eventConfigurations :: Maybe (HashMap EventType Configuration)
$sel:eventConfigurations:UpdateEventConfigurations' :: UpdateEventConfigurations
-> Maybe (HashMap EventType Configuration)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap EventType Configuration)
eventConfigurations

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

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"eventConfigurations" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap EventType Configuration)
eventConfigurations
          ]
      )

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

instance Data.ToQuery UpdateEventConfigurations where
  toQuery :: UpdateEventConfigurations -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:UpdateEventConfigurationsResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateEventConfigurationsResponse_httpStatus :: Lens.Lens' UpdateEventConfigurationsResponse Prelude.Int
updateEventConfigurationsResponse_httpStatus :: Lens' UpdateEventConfigurationsResponse Int
updateEventConfigurationsResponse_httpStatus = 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
  where
  rnf :: UpdateEventConfigurationsResponse -> ()
rnf UpdateEventConfigurationsResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateEventConfigurationsResponse' :: UpdateEventConfigurationsResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus