{-# 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.Redshift.Types.EventCategoriesMap
-- 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)
module Amazonka.Redshift.Types.EventCategoriesMap where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Internal
import Amazonka.Redshift.Types.EventInfoMap

-- | Describes event categories.
--
-- /See:/ 'newEventCategoriesMap' smart constructor.
data EventCategoriesMap = EventCategoriesMap'
  { -- | The source type, such as cluster or cluster-snapshot, that the returned
    -- categories belong to.
    EventCategoriesMap -> Maybe Text
sourceType :: Prelude.Maybe Prelude.Text,
    -- | The events in the event category.
    EventCategoriesMap -> Maybe [EventInfoMap]
events :: Prelude.Maybe [EventInfoMap]
  }
  deriving (EventCategoriesMap -> EventCategoriesMap -> Bool
(EventCategoriesMap -> EventCategoriesMap -> Bool)
-> (EventCategoriesMap -> EventCategoriesMap -> Bool)
-> Eq EventCategoriesMap
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventCategoriesMap -> EventCategoriesMap -> Bool
$c/= :: EventCategoriesMap -> EventCategoriesMap -> Bool
== :: EventCategoriesMap -> EventCategoriesMap -> Bool
$c== :: EventCategoriesMap -> EventCategoriesMap -> Bool
Prelude.Eq, ReadPrec [EventCategoriesMap]
ReadPrec EventCategoriesMap
Int -> ReadS EventCategoriesMap
ReadS [EventCategoriesMap]
(Int -> ReadS EventCategoriesMap)
-> ReadS [EventCategoriesMap]
-> ReadPrec EventCategoriesMap
-> ReadPrec [EventCategoriesMap]
-> Read EventCategoriesMap
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventCategoriesMap]
$creadListPrec :: ReadPrec [EventCategoriesMap]
readPrec :: ReadPrec EventCategoriesMap
$creadPrec :: ReadPrec EventCategoriesMap
readList :: ReadS [EventCategoriesMap]
$creadList :: ReadS [EventCategoriesMap]
readsPrec :: Int -> ReadS EventCategoriesMap
$creadsPrec :: Int -> ReadS EventCategoriesMap
Prelude.Read, Int -> EventCategoriesMap -> ShowS
[EventCategoriesMap] -> ShowS
EventCategoriesMap -> String
(Int -> EventCategoriesMap -> ShowS)
-> (EventCategoriesMap -> String)
-> ([EventCategoriesMap] -> ShowS)
-> Show EventCategoriesMap
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventCategoriesMap] -> ShowS
$cshowList :: [EventCategoriesMap] -> ShowS
show :: EventCategoriesMap -> String
$cshow :: EventCategoriesMap -> String
showsPrec :: Int -> EventCategoriesMap -> ShowS
$cshowsPrec :: Int -> EventCategoriesMap -> ShowS
Prelude.Show, (forall x. EventCategoriesMap -> Rep EventCategoriesMap x)
-> (forall x. Rep EventCategoriesMap x -> EventCategoriesMap)
-> Generic EventCategoriesMap
forall x. Rep EventCategoriesMap x -> EventCategoriesMap
forall x. EventCategoriesMap -> Rep EventCategoriesMap x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventCategoriesMap x -> EventCategoriesMap
$cfrom :: forall x. EventCategoriesMap -> Rep EventCategoriesMap x
Prelude.Generic)

-- |
-- Create a value of 'EventCategoriesMap' 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:
--
-- 'sourceType', 'eventCategoriesMap_sourceType' - The source type, such as cluster or cluster-snapshot, that the returned
-- categories belong to.
--
-- 'events', 'eventCategoriesMap_events' - The events in the event category.
newEventCategoriesMap ::
  EventCategoriesMap
newEventCategoriesMap :: EventCategoriesMap
newEventCategoriesMap =
  EventCategoriesMap' :: Maybe Text -> Maybe [EventInfoMap] -> EventCategoriesMap
EventCategoriesMap'
    { $sel:sourceType:EventCategoriesMap' :: Maybe Text
sourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:events:EventCategoriesMap' :: Maybe [EventInfoMap]
events = Maybe [EventInfoMap]
forall a. Maybe a
Prelude.Nothing
    }

-- | The source type, such as cluster or cluster-snapshot, that the returned
-- categories belong to.
eventCategoriesMap_sourceType :: Lens.Lens' EventCategoriesMap (Prelude.Maybe Prelude.Text)
eventCategoriesMap_sourceType :: (Maybe Text -> f (Maybe Text))
-> EventCategoriesMap -> f EventCategoriesMap
eventCategoriesMap_sourceType = (EventCategoriesMap -> Maybe Text)
-> (EventCategoriesMap -> Maybe Text -> EventCategoriesMap)
-> Lens
     EventCategoriesMap EventCategoriesMap (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventCategoriesMap' {Maybe Text
sourceType :: Maybe Text
$sel:sourceType:EventCategoriesMap' :: EventCategoriesMap -> Maybe Text
sourceType} -> Maybe Text
sourceType) (\s :: EventCategoriesMap
s@EventCategoriesMap' {} Maybe Text
a -> EventCategoriesMap
s {$sel:sourceType:EventCategoriesMap' :: Maybe Text
sourceType = Maybe Text
a} :: EventCategoriesMap)

-- | The events in the event category.
eventCategoriesMap_events :: Lens.Lens' EventCategoriesMap (Prelude.Maybe [EventInfoMap])
eventCategoriesMap_events :: (Maybe [EventInfoMap] -> f (Maybe [EventInfoMap]))
-> EventCategoriesMap -> f EventCategoriesMap
eventCategoriesMap_events = (EventCategoriesMap -> Maybe [EventInfoMap])
-> (EventCategoriesMap
    -> Maybe [EventInfoMap] -> EventCategoriesMap)
-> Lens
     EventCategoriesMap
     EventCategoriesMap
     (Maybe [EventInfoMap])
     (Maybe [EventInfoMap])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventCategoriesMap' {Maybe [EventInfoMap]
events :: Maybe [EventInfoMap]
$sel:events:EventCategoriesMap' :: EventCategoriesMap -> Maybe [EventInfoMap]
events} -> Maybe [EventInfoMap]
events) (\s :: EventCategoriesMap
s@EventCategoriesMap' {} Maybe [EventInfoMap]
a -> EventCategoriesMap
s {$sel:events:EventCategoriesMap' :: Maybe [EventInfoMap]
events = Maybe [EventInfoMap]
a} :: EventCategoriesMap) ((Maybe [EventInfoMap] -> f (Maybe [EventInfoMap]))
 -> EventCategoriesMap -> f EventCategoriesMap)
-> ((Maybe [EventInfoMap] -> f (Maybe [EventInfoMap]))
    -> Maybe [EventInfoMap] -> f (Maybe [EventInfoMap]))
-> (Maybe [EventInfoMap] -> f (Maybe [EventInfoMap]))
-> EventCategoriesMap
-> f EventCategoriesMap
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [EventInfoMap] [EventInfoMap] [EventInfoMap] [EventInfoMap]
-> Iso
     (Maybe [EventInfoMap])
     (Maybe [EventInfoMap])
     (Maybe [EventInfoMap])
     (Maybe [EventInfoMap])
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 [EventInfoMap] [EventInfoMap] [EventInfoMap] [EventInfoMap]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML EventCategoriesMap where
  parseXML :: [Node] -> Either String EventCategoriesMap
parseXML [Node]
x =
    Maybe Text -> Maybe [EventInfoMap] -> EventCategoriesMap
EventCategoriesMap'
      (Maybe Text -> Maybe [EventInfoMap] -> EventCategoriesMap)
-> Either String (Maybe Text)
-> Either String (Maybe [EventInfoMap] -> EventCategoriesMap)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SourceType")
      Either String (Maybe [EventInfoMap] -> EventCategoriesMap)
-> Either String (Maybe [EventInfoMap])
-> Either String EventCategoriesMap
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Events" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [EventInfoMap]))
-> Either String (Maybe [EventInfoMap])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [EventInfoMap])
-> [Node] -> Either String (Maybe [EventInfoMap])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [EventInfoMap]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"EventInfoMap")
                  )

instance Prelude.Hashable EventCategoriesMap

instance Prelude.NFData EventCategoriesMap