{-# 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.PartnerEventSource
-- 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.PartnerEventSource where

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

-- | A partner event source is created by an SaaS partner. If a customer
-- creates a partner event bus that matches this event source, that Amazon
-- Web Services account can receive events from the partner\'s applications
-- or services.
--
-- /See:/ 'newPartnerEventSource' smart constructor.
data PartnerEventSource = PartnerEventSource'
  { -- | The ARN of the partner event source.
    PartnerEventSource -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name of the partner event source.
    PartnerEventSource -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (PartnerEventSource -> PartnerEventSource -> Bool
(PartnerEventSource -> PartnerEventSource -> Bool)
-> (PartnerEventSource -> PartnerEventSource -> Bool)
-> Eq PartnerEventSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartnerEventSource -> PartnerEventSource -> Bool
$c/= :: PartnerEventSource -> PartnerEventSource -> Bool
== :: PartnerEventSource -> PartnerEventSource -> Bool
$c== :: PartnerEventSource -> PartnerEventSource -> Bool
Prelude.Eq, ReadPrec [PartnerEventSource]
ReadPrec PartnerEventSource
Int -> ReadS PartnerEventSource
ReadS [PartnerEventSource]
(Int -> ReadS PartnerEventSource)
-> ReadS [PartnerEventSource]
-> ReadPrec PartnerEventSource
-> ReadPrec [PartnerEventSource]
-> Read PartnerEventSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PartnerEventSource]
$creadListPrec :: ReadPrec [PartnerEventSource]
readPrec :: ReadPrec PartnerEventSource
$creadPrec :: ReadPrec PartnerEventSource
readList :: ReadS [PartnerEventSource]
$creadList :: ReadS [PartnerEventSource]
readsPrec :: Int -> ReadS PartnerEventSource
$creadsPrec :: Int -> ReadS PartnerEventSource
Prelude.Read, Int -> PartnerEventSource -> ShowS
[PartnerEventSource] -> ShowS
PartnerEventSource -> String
(Int -> PartnerEventSource -> ShowS)
-> (PartnerEventSource -> String)
-> ([PartnerEventSource] -> ShowS)
-> Show PartnerEventSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartnerEventSource] -> ShowS
$cshowList :: [PartnerEventSource] -> ShowS
show :: PartnerEventSource -> String
$cshow :: PartnerEventSource -> String
showsPrec :: Int -> PartnerEventSource -> ShowS
$cshowsPrec :: Int -> PartnerEventSource -> ShowS
Prelude.Show, (forall x. PartnerEventSource -> Rep PartnerEventSource x)
-> (forall x. Rep PartnerEventSource x -> PartnerEventSource)
-> Generic PartnerEventSource
forall x. Rep PartnerEventSource x -> PartnerEventSource
forall x. PartnerEventSource -> Rep PartnerEventSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PartnerEventSource x -> PartnerEventSource
$cfrom :: forall x. PartnerEventSource -> Rep PartnerEventSource x
Prelude.Generic)

-- |
-- Create a value of 'PartnerEventSource' 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', 'partnerEventSource_arn' - The ARN of the partner event source.
--
-- 'name', 'partnerEventSource_name' - The name of the partner event source.
newPartnerEventSource ::
  PartnerEventSource
newPartnerEventSource :: PartnerEventSource
newPartnerEventSource =
  PartnerEventSource' :: Maybe Text -> Maybe Text -> PartnerEventSource
PartnerEventSource'
    { $sel:arn:PartnerEventSource' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:PartnerEventSource' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

instance Core.FromJSON PartnerEventSource where
  parseJSON :: Value -> Parser PartnerEventSource
parseJSON =
    String
-> (Object -> Parser PartnerEventSource)
-> Value
-> Parser PartnerEventSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PartnerEventSource"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> PartnerEventSource
PartnerEventSource'
            (Maybe Text -> Maybe Text -> PartnerEventSource)
-> Parser (Maybe Text) -> Parser (Maybe Text -> PartnerEventSource)
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 -> PartnerEventSource)
-> Parser (Maybe Text) -> Parser PartnerEventSource
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")
      )

instance Prelude.Hashable PartnerEventSource

instance Prelude.NFData PartnerEventSource