{-# 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.DMS.Types.EventCategoryGroup
-- 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.DMS.Types.EventCategoryGroup where

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

-- | Lists categories of events subscribed to, and generated by, the
-- applicable DMS resource type. This data type appears in response to the
-- <https://docs.aws.amazon.com/dms/latest/APIReference/API_EventCategoryGroup.html DescribeEventCategories>
-- action.
--
-- /See:/ 'newEventCategoryGroup' smart constructor.
data EventCategoryGroup = EventCategoryGroup'
  { -- | The type of DMS resource that generates events.
    --
    -- Valid values: replication-instance | replication-server | security-group
    -- | replication-task
    EventCategoryGroup -> Maybe Text
sourceType :: Prelude.Maybe Prelude.Text,
    -- | A list of event categories from a source type that you\'ve chosen.
    EventCategoryGroup -> Maybe [Text]
eventCategories :: Prelude.Maybe [Prelude.Text]
  }
  deriving (EventCategoryGroup -> EventCategoryGroup -> Bool
(EventCategoryGroup -> EventCategoryGroup -> Bool)
-> (EventCategoryGroup -> EventCategoryGroup -> Bool)
-> Eq EventCategoryGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventCategoryGroup -> EventCategoryGroup -> Bool
$c/= :: EventCategoryGroup -> EventCategoryGroup -> Bool
== :: EventCategoryGroup -> EventCategoryGroup -> Bool
$c== :: EventCategoryGroup -> EventCategoryGroup -> Bool
Prelude.Eq, ReadPrec [EventCategoryGroup]
ReadPrec EventCategoryGroup
Int -> ReadS EventCategoryGroup
ReadS [EventCategoryGroup]
(Int -> ReadS EventCategoryGroup)
-> ReadS [EventCategoryGroup]
-> ReadPrec EventCategoryGroup
-> ReadPrec [EventCategoryGroup]
-> Read EventCategoryGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventCategoryGroup]
$creadListPrec :: ReadPrec [EventCategoryGroup]
readPrec :: ReadPrec EventCategoryGroup
$creadPrec :: ReadPrec EventCategoryGroup
readList :: ReadS [EventCategoryGroup]
$creadList :: ReadS [EventCategoryGroup]
readsPrec :: Int -> ReadS EventCategoryGroup
$creadsPrec :: Int -> ReadS EventCategoryGroup
Prelude.Read, Int -> EventCategoryGroup -> ShowS
[EventCategoryGroup] -> ShowS
EventCategoryGroup -> String
(Int -> EventCategoryGroup -> ShowS)
-> (EventCategoryGroup -> String)
-> ([EventCategoryGroup] -> ShowS)
-> Show EventCategoryGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventCategoryGroup] -> ShowS
$cshowList :: [EventCategoryGroup] -> ShowS
show :: EventCategoryGroup -> String
$cshow :: EventCategoryGroup -> String
showsPrec :: Int -> EventCategoryGroup -> ShowS
$cshowsPrec :: Int -> EventCategoryGroup -> ShowS
Prelude.Show, (forall x. EventCategoryGroup -> Rep EventCategoryGroup x)
-> (forall x. Rep EventCategoryGroup x -> EventCategoryGroup)
-> Generic EventCategoryGroup
forall x. Rep EventCategoryGroup x -> EventCategoryGroup
forall x. EventCategoryGroup -> Rep EventCategoryGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventCategoryGroup x -> EventCategoryGroup
$cfrom :: forall x. EventCategoryGroup -> Rep EventCategoryGroup x
Prelude.Generic)

-- |
-- Create a value of 'EventCategoryGroup' 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', 'eventCategoryGroup_sourceType' - The type of DMS resource that generates events.
--
-- Valid values: replication-instance | replication-server | security-group
-- | replication-task
--
-- 'eventCategories', 'eventCategoryGroup_eventCategories' - A list of event categories from a source type that you\'ve chosen.
newEventCategoryGroup ::
  EventCategoryGroup
newEventCategoryGroup :: EventCategoryGroup
newEventCategoryGroup =
  EventCategoryGroup' :: Maybe Text -> Maybe [Text] -> EventCategoryGroup
EventCategoryGroup'
    { $sel:sourceType:EventCategoryGroup' :: Maybe Text
sourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventCategories:EventCategoryGroup' :: Maybe [Text]
eventCategories = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of DMS resource that generates events.
--
-- Valid values: replication-instance | replication-server | security-group
-- | replication-task
eventCategoryGroup_sourceType :: Lens.Lens' EventCategoryGroup (Prelude.Maybe Prelude.Text)
eventCategoryGroup_sourceType :: (Maybe Text -> f (Maybe Text))
-> EventCategoryGroup -> f EventCategoryGroup
eventCategoryGroup_sourceType = (EventCategoryGroup -> Maybe Text)
-> (EventCategoryGroup -> Maybe Text -> EventCategoryGroup)
-> Lens
     EventCategoryGroup EventCategoryGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventCategoryGroup' {Maybe Text
sourceType :: Maybe Text
$sel:sourceType:EventCategoryGroup' :: EventCategoryGroup -> Maybe Text
sourceType} -> Maybe Text
sourceType) (\s :: EventCategoryGroup
s@EventCategoryGroup' {} Maybe Text
a -> EventCategoryGroup
s {$sel:sourceType:EventCategoryGroup' :: Maybe Text
sourceType = Maybe Text
a} :: EventCategoryGroup)

-- | A list of event categories from a source type that you\'ve chosen.
eventCategoryGroup_eventCategories :: Lens.Lens' EventCategoryGroup (Prelude.Maybe [Prelude.Text])
eventCategoryGroup_eventCategories :: (Maybe [Text] -> f (Maybe [Text]))
-> EventCategoryGroup -> f EventCategoryGroup
eventCategoryGroup_eventCategories = (EventCategoryGroup -> Maybe [Text])
-> (EventCategoryGroup -> Maybe [Text] -> EventCategoryGroup)
-> Lens
     EventCategoryGroup EventCategoryGroup (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventCategoryGroup' {Maybe [Text]
eventCategories :: Maybe [Text]
$sel:eventCategories:EventCategoryGroup' :: EventCategoryGroup -> Maybe [Text]
eventCategories} -> Maybe [Text]
eventCategories) (\s :: EventCategoryGroup
s@EventCategoryGroup' {} Maybe [Text]
a -> EventCategoryGroup
s {$sel:eventCategories:EventCategoryGroup' :: Maybe [Text]
eventCategories = Maybe [Text]
a} :: EventCategoryGroup) ((Maybe [Text] -> f (Maybe [Text]))
 -> EventCategoryGroup -> f EventCategoryGroup)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> EventCategoryGroup
-> f EventCategoryGroup
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.FromJSON EventCategoryGroup where
  parseJSON :: Value -> Parser EventCategoryGroup
parseJSON =
    String
-> (Object -> Parser EventCategoryGroup)
-> Value
-> Parser EventCategoryGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventCategoryGroup"
      ( \Object
x ->
          Maybe Text -> Maybe [Text] -> EventCategoryGroup
EventCategoryGroup'
            (Maybe Text -> Maybe [Text] -> EventCategoryGroup)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> EventCategoryGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SourceType")
            Parser (Maybe [Text] -> EventCategoryGroup)
-> Parser (Maybe [Text]) -> Parser EventCategoryGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EventCategories"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable EventCategoryGroup

instance Prelude.NFData EventCategoryGroup