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

import Amazonka.CloudWatchEvents.Types.EventSourceState
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:/ 'newEventSource' smart constructor.
data EventSource = EventSource'
  { -- | The date and time the event source was created.
    EventSource -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | 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,
    -- | 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 name of the event source.
    EventSource -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | 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 Core.POSIX
  }
  deriving (EventSource -> EventSource -> Bool
(EventSource -> EventSource -> Bool)
-> (EventSource -> EventSource -> Bool) -> Eq EventSource
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]
(Int -> ReadS EventSource)
-> ReadS [EventSource]
-> ReadPrec EventSource
-> ReadPrec [EventSource]
-> Read 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
(Int -> EventSource -> ShowS)
-> (EventSource -> String)
-> ([EventSource] -> ShowS)
-> Show EventSource
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. EventSource -> Rep EventSource x)
-> (forall x. Rep EventSource x -> EventSource)
-> Generic EventSource
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:
--
-- 'creationTime', 'eventSource_creationTime' - The date and time the event source was created.
--
-- '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.
--
-- 'arn', 'eventSource_arn' - The ARN of the event source.
--
-- 'createdBy', 'eventSource_createdBy' - The name of the partner that created the event source.
--
-- 'name', 'eventSource_name' - The name of the event source.
--
-- '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.
newEventSource ::
  EventSource
newEventSource :: EventSource
newEventSource =
  EventSource' :: Maybe POSIX
-> Maybe EventSourceState
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> EventSource
EventSource'
    { $sel:creationTime:EventSource' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:state:EventSource' :: Maybe EventSourceState
state = Maybe EventSourceState
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:EventSource' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdBy:EventSource' :: Maybe Text
createdBy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:EventSource' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expirationTime:EventSource' :: Maybe POSIX
expirationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time the event source was created.
eventSource_creationTime :: Lens.Lens' EventSource (Prelude.Maybe Prelude.UTCTime)
eventSource_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> EventSource -> f EventSource
eventSource_creationTime = (EventSource -> Maybe POSIX)
-> (EventSource -> Maybe POSIX -> EventSource)
-> Lens EventSource EventSource (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> EventSource -> f EventSource)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EventSource
-> f EventSource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | 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 :: (Maybe EventSourceState -> f (Maybe EventSourceState))
-> EventSource -> f EventSource
eventSource_state = (EventSource -> Maybe EventSourceState)
-> (EventSource -> Maybe EventSourceState -> EventSource)
-> Lens
     EventSource
     EventSource
     (Maybe EventSourceState)
     (Maybe EventSourceState)
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)

-- | The ARN of the event source.
eventSource_arn :: Lens.Lens' EventSource (Prelude.Maybe Prelude.Text)
eventSource_arn :: (Maybe Text -> f (Maybe Text)) -> EventSource -> f EventSource
eventSource_arn = (EventSource -> Maybe Text)
-> (EventSource -> Maybe Text -> EventSource)
-> Lens EventSource EventSource (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> EventSource -> f EventSource
eventSource_createdBy = (EventSource -> Maybe Text)
-> (EventSource -> Maybe Text -> EventSource)
-> Lens EventSource EventSource (Maybe Text) (Maybe Text)
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 name of the event source.
eventSource_name :: Lens.Lens' EventSource (Prelude.Maybe Prelude.Text)
eventSource_name :: (Maybe Text -> f (Maybe Text)) -> EventSource -> f EventSource
eventSource_name = (EventSource -> Maybe Text)
-> (EventSource -> Maybe Text -> EventSource)
-> Lens EventSource EventSource (Maybe Text) (Maybe Text)
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 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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> EventSource -> f EventSource
eventSource_expirationTime = (EventSource -> Maybe POSIX)
-> (EventSource -> Maybe POSIX -> EventSource)
-> Lens EventSource EventSource (Maybe POSIX) (Maybe POSIX)
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) ((Maybe POSIX -> f (Maybe POSIX)) -> EventSource -> f EventSource)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EventSource
-> f EventSource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.Hashable EventSource

instance Prelude.NFData EventSource