{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Rum.Types.CustomEvents
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Rum.Types.CustomEvents where

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 Amazonka.Rum.Types.CustomEventsStatus

-- | A structure that contains information about custom events for this app
-- monitor.
--
-- /See:/ 'newCustomEvents' smart constructor.
data CustomEvents = CustomEvents'
  { -- | Specifies whether this app monitor allows the web client to define and
    -- send custom events. The default is for custom events to be @DISABLED@.
    CustomEvents -> Maybe CustomEventsStatus
status :: Prelude.Maybe CustomEventsStatus
  }
  deriving (CustomEvents -> CustomEvents -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomEvents -> CustomEvents -> Bool
$c/= :: CustomEvents -> CustomEvents -> Bool
== :: CustomEvents -> CustomEvents -> Bool
$c== :: CustomEvents -> CustomEvents -> Bool
Prelude.Eq, ReadPrec [CustomEvents]
ReadPrec CustomEvents
Int -> ReadS CustomEvents
ReadS [CustomEvents]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomEvents]
$creadListPrec :: ReadPrec [CustomEvents]
readPrec :: ReadPrec CustomEvents
$creadPrec :: ReadPrec CustomEvents
readList :: ReadS [CustomEvents]
$creadList :: ReadS [CustomEvents]
readsPrec :: Int -> ReadS CustomEvents
$creadsPrec :: Int -> ReadS CustomEvents
Prelude.Read, Int -> CustomEvents -> ShowS
[CustomEvents] -> ShowS
CustomEvents -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomEvents] -> ShowS
$cshowList :: [CustomEvents] -> ShowS
show :: CustomEvents -> String
$cshow :: CustomEvents -> String
showsPrec :: Int -> CustomEvents -> ShowS
$cshowsPrec :: Int -> CustomEvents -> ShowS
Prelude.Show, forall x. Rep CustomEvents x -> CustomEvents
forall x. CustomEvents -> Rep CustomEvents x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomEvents x -> CustomEvents
$cfrom :: forall x. CustomEvents -> Rep CustomEvents x
Prelude.Generic)

-- |
-- Create a value of 'CustomEvents' 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:
--
-- 'status', 'customEvents_status' - Specifies whether this app monitor allows the web client to define and
-- send custom events. The default is for custom events to be @DISABLED@.
newCustomEvents ::
  CustomEvents
newCustomEvents :: CustomEvents
newCustomEvents =
  CustomEvents' {$sel:status:CustomEvents' :: Maybe CustomEventsStatus
status = forall a. Maybe a
Prelude.Nothing}

-- | Specifies whether this app monitor allows the web client to define and
-- send custom events. The default is for custom events to be @DISABLED@.
customEvents_status :: Lens.Lens' CustomEvents (Prelude.Maybe CustomEventsStatus)
customEvents_status :: Lens' CustomEvents (Maybe CustomEventsStatus)
customEvents_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomEvents' {Maybe CustomEventsStatus
status :: Maybe CustomEventsStatus
$sel:status:CustomEvents' :: CustomEvents -> Maybe CustomEventsStatus
status} -> Maybe CustomEventsStatus
status) (\s :: CustomEvents
s@CustomEvents' {} Maybe CustomEventsStatus
a -> CustomEvents
s {$sel:status:CustomEvents' :: Maybe CustomEventsStatus
status = Maybe CustomEventsStatus
a} :: CustomEvents)

instance Data.FromJSON CustomEvents where
  parseJSON :: Value -> Parser CustomEvents
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomEvents"
      ( \Object
x ->
          Maybe CustomEventsStatus -> CustomEvents
CustomEvents' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Status")
      )

instance Prelude.Hashable CustomEvents where
  hashWithSalt :: Int -> CustomEvents -> Int
hashWithSalt Int
_salt CustomEvents' {Maybe CustomEventsStatus
status :: Maybe CustomEventsStatus
$sel:status:CustomEvents' :: CustomEvents -> Maybe CustomEventsStatus
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CustomEventsStatus
status

instance Prelude.NFData CustomEvents where
  rnf :: CustomEvents -> ()
rnf CustomEvents' {Maybe CustomEventsStatus
status :: Maybe CustomEventsStatus
$sel:status:CustomEvents' :: CustomEvents -> Maybe CustomEventsStatus
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe CustomEventsStatus
status

instance Data.ToJSON CustomEvents where
  toJSON :: CustomEvents -> Value
toJSON CustomEvents' {Maybe CustomEventsStatus
status :: Maybe CustomEventsStatus
$sel:status:CustomEvents' :: CustomEvents -> Maybe CustomEventsStatus
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Status" 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 CustomEventsStatus
status]
      )