{-# 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.CloudWatchEvents.Types.EventBus
-- 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.CloudWatchEvents.Types.EventBus where

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

-- | An event bus receives events from a source and routes them to rules
-- associated with that event bus. Your account\'s default event bus
-- receives events from Amazon Web Services services. A custom event bus
-- can receive events from your custom applications and services. A partner
-- event bus receives events from an event source created by an SaaS
-- partner. These events come from the partners services or applications.
--
-- /See:/ 'newEventBus' smart constructor.
data EventBus = EventBus'
  { -- | The ARN of the event bus.
    EventBus -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name of the event bus.
    EventBus -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The permissions policy of the event bus, describing which other Amazon
    -- Web Services accounts can write events to this event bus.
    EventBus -> Maybe Text
policy :: Prelude.Maybe Prelude.Text
  }
  deriving (EventBus -> EventBus -> Bool
(EventBus -> EventBus -> Bool)
-> (EventBus -> EventBus -> Bool) -> Eq EventBus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventBus -> EventBus -> Bool
$c/= :: EventBus -> EventBus -> Bool
== :: EventBus -> EventBus -> Bool
$c== :: EventBus -> EventBus -> Bool
Prelude.Eq, ReadPrec [EventBus]
ReadPrec EventBus
Int -> ReadS EventBus
ReadS [EventBus]
(Int -> ReadS EventBus)
-> ReadS [EventBus]
-> ReadPrec EventBus
-> ReadPrec [EventBus]
-> Read EventBus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventBus]
$creadListPrec :: ReadPrec [EventBus]
readPrec :: ReadPrec EventBus
$creadPrec :: ReadPrec EventBus
readList :: ReadS [EventBus]
$creadList :: ReadS [EventBus]
readsPrec :: Int -> ReadS EventBus
$creadsPrec :: Int -> ReadS EventBus
Prelude.Read, Int -> EventBus -> ShowS
[EventBus] -> ShowS
EventBus -> String
(Int -> EventBus -> ShowS)
-> (EventBus -> String) -> ([EventBus] -> ShowS) -> Show EventBus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventBus] -> ShowS
$cshowList :: [EventBus] -> ShowS
show :: EventBus -> String
$cshow :: EventBus -> String
showsPrec :: Int -> EventBus -> ShowS
$cshowsPrec :: Int -> EventBus -> ShowS
Prelude.Show, (forall x. EventBus -> Rep EventBus x)
-> (forall x. Rep EventBus x -> EventBus) -> Generic EventBus
forall x. Rep EventBus x -> EventBus
forall x. EventBus -> Rep EventBus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventBus x -> EventBus
$cfrom :: forall x. EventBus -> Rep EventBus x
Prelude.Generic)

-- |
-- Create a value of 'EventBus' 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:
--
-- 'arn', 'eventBus_arn' - The ARN of the event bus.
--
-- 'name', 'eventBus_name' - The name of the event bus.
--
-- 'policy', 'eventBus_policy' - The permissions policy of the event bus, describing which other Amazon
-- Web Services accounts can write events to this event bus.
newEventBus ::
  EventBus
newEventBus :: EventBus
newEventBus =
  EventBus' :: Maybe Text -> Maybe Text -> Maybe Text -> EventBus
EventBus'
    { $sel:arn:EventBus' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:EventBus' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policy:EventBus' :: Maybe Text
policy = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the event bus.
eventBus_arn :: Lens.Lens' EventBus (Prelude.Maybe Prelude.Text)
eventBus_arn :: (Maybe Text -> f (Maybe Text)) -> EventBus -> f EventBus
eventBus_arn = (EventBus -> Maybe Text)
-> (EventBus -> Maybe Text -> EventBus)
-> Lens EventBus EventBus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventBus' {Maybe Text
arn :: Maybe Text
$sel:arn:EventBus' :: EventBus -> Maybe Text
arn} -> Maybe Text
arn) (\s :: EventBus
s@EventBus' {} Maybe Text
a -> EventBus
s {$sel:arn:EventBus' :: Maybe Text
arn = Maybe Text
a} :: EventBus)

-- | The name of the event bus.
eventBus_name :: Lens.Lens' EventBus (Prelude.Maybe Prelude.Text)
eventBus_name :: (Maybe Text -> f (Maybe Text)) -> EventBus -> f EventBus
eventBus_name = (EventBus -> Maybe Text)
-> (EventBus -> Maybe Text -> EventBus)
-> Lens EventBus EventBus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventBus' {Maybe Text
name :: Maybe Text
$sel:name:EventBus' :: EventBus -> Maybe Text
name} -> Maybe Text
name) (\s :: EventBus
s@EventBus' {} Maybe Text
a -> EventBus
s {$sel:name:EventBus' :: Maybe Text
name = Maybe Text
a} :: EventBus)

-- | The permissions policy of the event bus, describing which other Amazon
-- Web Services accounts can write events to this event bus.
eventBus_policy :: Lens.Lens' EventBus (Prelude.Maybe Prelude.Text)
eventBus_policy :: (Maybe Text -> f (Maybe Text)) -> EventBus -> f EventBus
eventBus_policy = (EventBus -> Maybe Text)
-> (EventBus -> Maybe Text -> EventBus)
-> Lens EventBus EventBus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventBus' {Maybe Text
policy :: Maybe Text
$sel:policy:EventBus' :: EventBus -> Maybe Text
policy} -> Maybe Text
policy) (\s :: EventBus
s@EventBus' {} Maybe Text
a -> EventBus
s {$sel:policy:EventBus' :: Maybe Text
policy = Maybe Text
a} :: EventBus)

instance Core.FromJSON EventBus where
  parseJSON :: Value -> Parser EventBus
parseJSON =
    String -> (Object -> Parser EventBus) -> Value -> Parser EventBus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventBus"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> EventBus
EventBus'
            (Maybe Text -> Maybe Text -> Maybe Text -> EventBus)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> EventBus)
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
"Arn")
            Parser (Maybe Text -> Maybe Text -> EventBus)
-> Parser (Maybe Text) -> Parser (Maybe Text -> EventBus)
forall (f :: * -> *) a b. Applicative f => 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
"Name")
            Parser (Maybe Text -> EventBus)
-> Parser (Maybe Text) -> Parser EventBus
forall (f :: * -> *) a b. Applicative f => 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
"Policy")
      )

instance Prelude.Hashable EventBus

instance Prelude.NFData EventBus