{-# 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.DocumentDB.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.DocumentDB.Types.EventCategoriesMap where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An event source type, accompanied by one or more event category names.
--
-- /See:/ 'newEventCategoriesMap' smart constructor.
data EventCategoriesMap = EventCategoriesMap'
  { -- | The source type that the returned categories belong to.
    EventCategoriesMap -> Maybe Text
sourceType :: Prelude.Maybe Prelude.Text,
    -- | The event categories for the specified source type.
    EventCategoriesMap -> Maybe [Text]
eventCategories :: Prelude.Maybe [Prelude.Text]
  }
  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 that the returned categories belong to.
--
-- 'eventCategories', 'eventCategoriesMap_eventCategories' - The event categories for the specified source type.
newEventCategoriesMap ::
  EventCategoriesMap
newEventCategoriesMap :: EventCategoriesMap
newEventCategoriesMap =
  EventCategoriesMap' :: Maybe Text -> Maybe [Text] -> EventCategoriesMap
EventCategoriesMap'
    { $sel:sourceType:EventCategoriesMap' :: Maybe Text
sourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventCategories:EventCategoriesMap' :: Maybe [Text]
eventCategories = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The source type 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 event categories for the specified source type.
eventCategoriesMap_eventCategories :: Lens.Lens' EventCategoriesMap (Prelude.Maybe [Prelude.Text])
eventCategoriesMap_eventCategories :: (Maybe [Text] -> f (Maybe [Text]))
-> EventCategoriesMap -> f EventCategoriesMap
eventCategoriesMap_eventCategories = (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]
eventCategories :: Maybe [Text]
$sel:eventCategories:EventCategoriesMap' :: EventCategoriesMap -> Maybe [Text]
eventCategories} -> Maybe [Text]
eventCategories) (\s :: EventCategoriesMap
s@EventCategoriesMap' {} Maybe [Text]
a -> EventCategoriesMap
s {$sel:eventCategories:EventCategoriesMap' :: Maybe [Text]
eventCategories = Maybe [Text]
a} :: EventCategoriesMap) ((Maybe [Text] -> f (Maybe [Text]))
 -> EventCategoriesMap -> f EventCategoriesMap)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> EventCategoriesMap
-> f EventCategoriesMap
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
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 [Text] -> EventCategoriesMap
EventCategoriesMap'
      (Maybe Text -> Maybe [Text] -> EventCategoriesMap)
-> Either String (Maybe Text)
-> Either String (Maybe [Text] -> 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 [Text] -> EventCategoriesMap)
-> Either String (Maybe [Text]) -> 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
"EventCategories" 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 [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"EventCategory")
                  )

instance Prelude.Hashable EventCategoriesMap

instance Prelude.NFData EventCategoriesMap