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

-- | The event buses the endpoint is associated with.
--
-- /See:/ 'newEndpointEventBus' smart constructor.
data EndpointEventBus = EndpointEventBus'
  { -- | The ARN of the event bus the endpoint is associated with.
    EndpointEventBus -> Text
eventBusArn :: Prelude.Text
  }
  deriving (EndpointEventBus -> EndpointEventBus -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndpointEventBus -> EndpointEventBus -> Bool
$c/= :: EndpointEventBus -> EndpointEventBus -> Bool
== :: EndpointEventBus -> EndpointEventBus -> Bool
$c== :: EndpointEventBus -> EndpointEventBus -> Bool
Prelude.Eq, ReadPrec [EndpointEventBus]
ReadPrec EndpointEventBus
Int -> ReadS EndpointEventBus
ReadS [EndpointEventBus]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EndpointEventBus]
$creadListPrec :: ReadPrec [EndpointEventBus]
readPrec :: ReadPrec EndpointEventBus
$creadPrec :: ReadPrec EndpointEventBus
readList :: ReadS [EndpointEventBus]
$creadList :: ReadS [EndpointEventBus]
readsPrec :: Int -> ReadS EndpointEventBus
$creadsPrec :: Int -> ReadS EndpointEventBus
Prelude.Read, Int -> EndpointEventBus -> ShowS
[EndpointEventBus] -> ShowS
EndpointEventBus -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndpointEventBus] -> ShowS
$cshowList :: [EndpointEventBus] -> ShowS
show :: EndpointEventBus -> String
$cshow :: EndpointEventBus -> String
showsPrec :: Int -> EndpointEventBus -> ShowS
$cshowsPrec :: Int -> EndpointEventBus -> ShowS
Prelude.Show, forall x. Rep EndpointEventBus x -> EndpointEventBus
forall x. EndpointEventBus -> Rep EndpointEventBus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EndpointEventBus x -> EndpointEventBus
$cfrom :: forall x. EndpointEventBus -> Rep EndpointEventBus x
Prelude.Generic)

-- |
-- Create a value of 'EndpointEventBus' 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:
--
-- 'eventBusArn', 'endpointEventBus_eventBusArn' - The ARN of the event bus the endpoint is associated with.
newEndpointEventBus ::
  -- | 'eventBusArn'
  Prelude.Text ->
  EndpointEventBus
newEndpointEventBus :: Text -> EndpointEventBus
newEndpointEventBus Text
pEventBusArn_ =
  EndpointEventBus' {$sel:eventBusArn:EndpointEventBus' :: Text
eventBusArn = Text
pEventBusArn_}

-- | The ARN of the event bus the endpoint is associated with.
endpointEventBus_eventBusArn :: Lens.Lens' EndpointEventBus Prelude.Text
endpointEventBus_eventBusArn :: Lens' EndpointEventBus Text
endpointEventBus_eventBusArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointEventBus' {Text
eventBusArn :: Text
$sel:eventBusArn:EndpointEventBus' :: EndpointEventBus -> Text
eventBusArn} -> Text
eventBusArn) (\s :: EndpointEventBus
s@EndpointEventBus' {} Text
a -> EndpointEventBus
s {$sel:eventBusArn:EndpointEventBus' :: Text
eventBusArn = Text
a} :: EndpointEventBus)

instance Data.FromJSON EndpointEventBus where
  parseJSON :: Value -> Parser EndpointEventBus
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EndpointEventBus"
      ( \Object
x ->
          Text -> EndpointEventBus
EndpointEventBus'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"EventBusArn")
      )

instance Prelude.Hashable EndpointEventBus where
  hashWithSalt :: Int -> EndpointEventBus -> Int
hashWithSalt Int
_salt EndpointEventBus' {Text
eventBusArn :: Text
$sel:eventBusArn:EndpointEventBus' :: EndpointEventBus -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
eventBusArn

instance Prelude.NFData EndpointEventBus where
  rnf :: EndpointEventBus -> ()
rnf EndpointEventBus' {Text
eventBusArn :: Text
$sel:eventBusArn:EndpointEventBus' :: EndpointEventBus -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
eventBusArn

instance Data.ToJSON EndpointEventBus where
  toJSON :: EndpointEventBus -> Value
toJSON EndpointEventBus' {Text
eventBusArn :: Text
$sel:eventBusArn:EndpointEventBus' :: EndpointEventBus -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"EventBusArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
eventBusArn)]
      )