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

import Amazonka.CloudWatchEvents.Types.EventSourceState
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

-- | 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:/ 'newEventSource' smart constructor.
data EventSource = EventSource'
  { -- | The ARN of the event source.
    EventSource -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name of the partner that created the event source.
    EventSource -> Maybe Text
createdBy :: Prelude.Maybe Prelude.Text,
    -- | The date and time the event source was created.
    EventSource -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX,
    -- | The date and time that the event source will expire, if the Amazon Web
    -- Services account doesn\'t create a matching event bus for it.
    EventSource -> Maybe POSIX
expirationTime :: Prelude.Maybe Data.POSIX,
    -- | The name of the event source.
    EventSource -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The state of the event source. If it is ACTIVE, you have already created
    -- a matching event bus for this event source, and that event bus is
    -- active. If it is PENDING, either you haven\'t yet created a matching
    -- event bus, or that event bus is deactivated. If it is DELETED, you have
    -- created a matching event bus, but the event source has since been
    -- deleted.
    EventSource -> Maybe EventSourceState
state :: Prelude.Maybe EventSourceState
  }
  deriving (EventSource -> EventSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventSource -> EventSource -> Bool
$c/= :: EventSource -> EventSource -> Bool
== :: EventSource -> EventSource -> Bool
$c== :: EventSource -> EventSource -> Bool
Prelude.Eq, ReadPrec [EventSource]
ReadPrec EventSource
Int -> ReadS EventSource
ReadS [EventSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventSource]
$creadListPrec :: ReadPrec [EventSource]
readPrec :: ReadPrec EventSource
$creadPrec :: ReadPrec EventSource
readList :: ReadS [EventSource]
$creadList :: ReadS [EventSource]
readsPrec :: Int -> ReadS EventSource
$creadsPrec :: Int -> ReadS EventSource
Prelude.Read, Int -> EventSource -> ShowS
[EventSource] -> ShowS
EventSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventSource] -> ShowS
$cshowList :: [EventSource] -> ShowS
show :: EventSource -> String
$cshow :: EventSource -> String
showsPrec :: Int -> EventSource -> ShowS
$cshowsPrec :: Int -> EventSource -> ShowS
Prelude.Show, forall x. Rep EventSource x -> EventSource
forall x. EventSource -> Rep EventSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventSource x -> EventSource
$cfrom :: forall x. EventSource -> Rep EventSource x
Prelude.Generic)

-- |
-- Create a value of 'EventSource' 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', 'eventSource_arn' - The ARN of the event source.
--
-- 'createdBy', 'eventSource_createdBy' - The name of the partner that created the event source.
--
-- 'creationTime', 'eventSource_creationTime' - The date and time the event source was created.
--
-- 'expirationTime', 'eventSource_expirationTime' - The date and time that the event source will expire, if the Amazon Web
-- Services account doesn\'t create a matching event bus for it.
--
-- 'name', 'eventSource_name' - The name of the event source.
--
-- 'state', 'eventSource_state' - The state of the event source. If it is ACTIVE, you have already created
-- a matching event bus for this event source, and that event bus is
-- active. If it is PENDING, either you haven\'t yet created a matching
-- event bus, or that event bus is deactivated. If it is DELETED, you have
-- created a matching event bus, but the event source has since been
-- deleted.
newEventSource ::
  EventSource
newEventSource :: EventSource
newEventSource =
  EventSource'
    { $sel:arn:EventSource' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:createdBy:EventSource' :: Maybe Text
createdBy = forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:EventSource' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:expirationTime:EventSource' :: Maybe POSIX
expirationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:name:EventSource' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:state:EventSource' :: Maybe EventSourceState
state = forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | The date and time the event source was created.
eventSource_creationTime :: Lens.Lens' EventSource (Prelude.Maybe Prelude.UTCTime)
eventSource_creationTime :: Lens' EventSource (Maybe UTCTime)
eventSource_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSource' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:EventSource' :: EventSource -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: EventSource
s@EventSource' {} Maybe POSIX
a -> EventSource
s {$sel:creationTime:EventSource' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: EventSource) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The date and time that the event source will expire, if the Amazon Web
-- Services account doesn\'t create a matching event bus for it.
eventSource_expirationTime :: Lens.Lens' EventSource (Prelude.Maybe Prelude.UTCTime)
eventSource_expirationTime :: Lens' EventSource (Maybe UTCTime)
eventSource_expirationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSource' {Maybe POSIX
expirationTime :: Maybe POSIX
$sel:expirationTime:EventSource' :: EventSource -> Maybe POSIX
expirationTime} -> Maybe POSIX
expirationTime) (\s :: EventSource
s@EventSource' {} Maybe POSIX
a -> EventSource
s {$sel:expirationTime:EventSource' :: Maybe POSIX
expirationTime = Maybe POSIX
a} :: EventSource) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

-- | The state of the event source. If it is ACTIVE, you have already created
-- a matching event bus for this event source, and that event bus is
-- active. If it is PENDING, either you haven\'t yet created a matching
-- event bus, or that event bus is deactivated. If it is DELETED, you have
-- created a matching event bus, but the event source has since been
-- deleted.
eventSource_state :: Lens.Lens' EventSource (Prelude.Maybe EventSourceState)
eventSource_state :: Lens' EventSource (Maybe EventSourceState)
eventSource_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSource' {Maybe EventSourceState
state :: Maybe EventSourceState
$sel:state:EventSource' :: EventSource -> Maybe EventSourceState
state} -> Maybe EventSourceState
state) (\s :: EventSource
s@EventSource' {} Maybe EventSourceState
a -> EventSource
s {$sel:state:EventSource' :: Maybe EventSourceState
state = Maybe EventSourceState
a} :: EventSource)

instance Data.FromJSON EventSource where
  parseJSON :: Value -> Parser EventSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EventSource"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe EventSourceState
-> EventSource
EventSource'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreatedBy")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ExpirationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"State")
      )

instance Prelude.Hashable EventSource where
  hashWithSalt :: Int -> EventSource -> Int
hashWithSalt Int
_salt EventSource' {Maybe Text
Maybe POSIX
Maybe EventSourceState
state :: Maybe EventSourceState
name :: Maybe Text
expirationTime :: Maybe POSIX
creationTime :: Maybe POSIX
createdBy :: Maybe Text
arn :: Maybe Text
$sel:state:EventSource' :: EventSource -> Maybe EventSourceState
$sel:name:EventSource' :: EventSource -> Maybe Text
$sel:expirationTime:EventSource' :: EventSource -> Maybe POSIX
$sel:creationTime:EventSource' :: EventSource -> Maybe POSIX
$sel:createdBy:EventSource' :: EventSource -> Maybe Text
$sel:arn:EventSource' :: EventSource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
createdBy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
expirationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EventSourceState
state

instance Prelude.NFData EventSource where
  rnf :: EventSource -> ()
rnf EventSource' {Maybe Text
Maybe POSIX
Maybe EventSourceState
state :: Maybe EventSourceState
name :: Maybe Text
expirationTime :: Maybe POSIX
creationTime :: Maybe POSIX
createdBy :: Maybe Text
arn :: Maybe Text
$sel:state:EventSource' :: EventSource -> Maybe EventSourceState
$sel:name:EventSource' :: EventSource -> Maybe Text
$sel:expirationTime:EventSource' :: EventSource -> Maybe POSIX
$sel:creationTime:EventSource' :: EventSource -> Maybe POSIX
$sel:createdBy:EventSource' :: EventSource -> Maybe Text
$sel:arn:EventSource' :: EventSource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
createdBy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
expirationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EventSourceState
state