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

import Amazonka.CloudWatchEvents.Types.EventSourceState
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The Amazon Web Services account that a partner event source has been
-- offered to.
--
-- /See:/ 'newPartnerEventSourceAccount' smart constructor.
data PartnerEventSourceAccount = PartnerEventSourceAccount'
  { -- | The date and time the event source was created.
    PartnerEventSourceAccount -> 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.
    PartnerEventSourceAccount -> Maybe EventSourceState
state :: Prelude.Maybe EventSourceState,
    -- | The Amazon Web Services account ID that the partner event source was
    -- offered to.
    PartnerEventSourceAccount -> Maybe Text
account :: 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.
    PartnerEventSourceAccount -> Maybe POSIX
expirationTime :: Prelude.Maybe Core.POSIX
  }
  deriving (PartnerEventSourceAccount -> PartnerEventSourceAccount -> Bool
(PartnerEventSourceAccount -> PartnerEventSourceAccount -> Bool)
-> (PartnerEventSourceAccount -> PartnerEventSourceAccount -> Bool)
-> Eq PartnerEventSourceAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartnerEventSourceAccount -> PartnerEventSourceAccount -> Bool
$c/= :: PartnerEventSourceAccount -> PartnerEventSourceAccount -> Bool
== :: PartnerEventSourceAccount -> PartnerEventSourceAccount -> Bool
$c== :: PartnerEventSourceAccount -> PartnerEventSourceAccount -> Bool
Prelude.Eq, ReadPrec [PartnerEventSourceAccount]
ReadPrec PartnerEventSourceAccount
Int -> ReadS PartnerEventSourceAccount
ReadS [PartnerEventSourceAccount]
(Int -> ReadS PartnerEventSourceAccount)
-> ReadS [PartnerEventSourceAccount]
-> ReadPrec PartnerEventSourceAccount
-> ReadPrec [PartnerEventSourceAccount]
-> Read PartnerEventSourceAccount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PartnerEventSourceAccount]
$creadListPrec :: ReadPrec [PartnerEventSourceAccount]
readPrec :: ReadPrec PartnerEventSourceAccount
$creadPrec :: ReadPrec PartnerEventSourceAccount
readList :: ReadS [PartnerEventSourceAccount]
$creadList :: ReadS [PartnerEventSourceAccount]
readsPrec :: Int -> ReadS PartnerEventSourceAccount
$creadsPrec :: Int -> ReadS PartnerEventSourceAccount
Prelude.Read, Int -> PartnerEventSourceAccount -> ShowS
[PartnerEventSourceAccount] -> ShowS
PartnerEventSourceAccount -> String
(Int -> PartnerEventSourceAccount -> ShowS)
-> (PartnerEventSourceAccount -> String)
-> ([PartnerEventSourceAccount] -> ShowS)
-> Show PartnerEventSourceAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartnerEventSourceAccount] -> ShowS
$cshowList :: [PartnerEventSourceAccount] -> ShowS
show :: PartnerEventSourceAccount -> String
$cshow :: PartnerEventSourceAccount -> String
showsPrec :: Int -> PartnerEventSourceAccount -> ShowS
$cshowsPrec :: Int -> PartnerEventSourceAccount -> ShowS
Prelude.Show, (forall x.
 PartnerEventSourceAccount -> Rep PartnerEventSourceAccount x)
-> (forall x.
    Rep PartnerEventSourceAccount x -> PartnerEventSourceAccount)
-> Generic PartnerEventSourceAccount
forall x.
Rep PartnerEventSourceAccount x -> PartnerEventSourceAccount
forall x.
PartnerEventSourceAccount -> Rep PartnerEventSourceAccount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PartnerEventSourceAccount x -> PartnerEventSourceAccount
$cfrom :: forall x.
PartnerEventSourceAccount -> Rep PartnerEventSourceAccount x
Prelude.Generic)

-- |
-- Create a value of 'PartnerEventSourceAccount' 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', 'partnerEventSourceAccount_creationTime' - The date and time the event source was created.
--
-- 'state', 'partnerEventSourceAccount_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.
--
-- 'account', 'partnerEventSourceAccount_account' - The Amazon Web Services account ID that the partner event source was
-- offered to.
--
-- 'expirationTime', 'partnerEventSourceAccount_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.
newPartnerEventSourceAccount ::
  PartnerEventSourceAccount
newPartnerEventSourceAccount :: PartnerEventSourceAccount
newPartnerEventSourceAccount =
  PartnerEventSourceAccount' :: Maybe POSIX
-> Maybe EventSourceState
-> Maybe Text
-> Maybe POSIX
-> PartnerEventSourceAccount
PartnerEventSourceAccount'
    { $sel:creationTime:PartnerEventSourceAccount' :: Maybe POSIX
creationTime =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:state:PartnerEventSourceAccount' :: Maybe EventSourceState
state = Maybe EventSourceState
forall a. Maybe a
Prelude.Nothing,
      $sel:account:PartnerEventSourceAccount' :: Maybe Text
account = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:expirationTime:PartnerEventSourceAccount' :: Maybe POSIX
expirationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time the event source was created.
partnerEventSourceAccount_creationTime :: Lens.Lens' PartnerEventSourceAccount (Prelude.Maybe Prelude.UTCTime)
partnerEventSourceAccount_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> PartnerEventSourceAccount -> f PartnerEventSourceAccount
partnerEventSourceAccount_creationTime = (PartnerEventSourceAccount -> Maybe POSIX)
-> (PartnerEventSourceAccount
    -> Maybe POSIX -> PartnerEventSourceAccount)
-> Lens
     PartnerEventSourceAccount
     PartnerEventSourceAccount
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartnerEventSourceAccount' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:PartnerEventSourceAccount' :: PartnerEventSourceAccount -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: PartnerEventSourceAccount
s@PartnerEventSourceAccount' {} Maybe POSIX
a -> PartnerEventSourceAccount
s {$sel:creationTime:PartnerEventSourceAccount' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: PartnerEventSourceAccount) ((Maybe POSIX -> f (Maybe POSIX))
 -> PartnerEventSourceAccount -> f PartnerEventSourceAccount)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> PartnerEventSourceAccount
-> f PartnerEventSourceAccount
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.
partnerEventSourceAccount_state :: Lens.Lens' PartnerEventSourceAccount (Prelude.Maybe EventSourceState)
partnerEventSourceAccount_state :: (Maybe EventSourceState -> f (Maybe EventSourceState))
-> PartnerEventSourceAccount -> f PartnerEventSourceAccount
partnerEventSourceAccount_state = (PartnerEventSourceAccount -> Maybe EventSourceState)
-> (PartnerEventSourceAccount
    -> Maybe EventSourceState -> PartnerEventSourceAccount)
-> Lens
     PartnerEventSourceAccount
     PartnerEventSourceAccount
     (Maybe EventSourceState)
     (Maybe EventSourceState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartnerEventSourceAccount' {Maybe EventSourceState
state :: Maybe EventSourceState
$sel:state:PartnerEventSourceAccount' :: PartnerEventSourceAccount -> Maybe EventSourceState
state} -> Maybe EventSourceState
state) (\s :: PartnerEventSourceAccount
s@PartnerEventSourceAccount' {} Maybe EventSourceState
a -> PartnerEventSourceAccount
s {$sel:state:PartnerEventSourceAccount' :: Maybe EventSourceState
state = Maybe EventSourceState
a} :: PartnerEventSourceAccount)

-- | The Amazon Web Services account ID that the partner event source was
-- offered to.
partnerEventSourceAccount_account :: Lens.Lens' PartnerEventSourceAccount (Prelude.Maybe Prelude.Text)
partnerEventSourceAccount_account :: (Maybe Text -> f (Maybe Text))
-> PartnerEventSourceAccount -> f PartnerEventSourceAccount
partnerEventSourceAccount_account = (PartnerEventSourceAccount -> Maybe Text)
-> (PartnerEventSourceAccount
    -> Maybe Text -> PartnerEventSourceAccount)
-> Lens
     PartnerEventSourceAccount
     PartnerEventSourceAccount
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartnerEventSourceAccount' {Maybe Text
account :: Maybe Text
$sel:account:PartnerEventSourceAccount' :: PartnerEventSourceAccount -> Maybe Text
account} -> Maybe Text
account) (\s :: PartnerEventSourceAccount
s@PartnerEventSourceAccount' {} Maybe Text
a -> PartnerEventSourceAccount
s {$sel:account:PartnerEventSourceAccount' :: Maybe Text
account = Maybe Text
a} :: PartnerEventSourceAccount)

-- | 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.
partnerEventSourceAccount_expirationTime :: Lens.Lens' PartnerEventSourceAccount (Prelude.Maybe Prelude.UTCTime)
partnerEventSourceAccount_expirationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> PartnerEventSourceAccount -> f PartnerEventSourceAccount
partnerEventSourceAccount_expirationTime = (PartnerEventSourceAccount -> Maybe POSIX)
-> (PartnerEventSourceAccount
    -> Maybe POSIX -> PartnerEventSourceAccount)
-> Lens
     PartnerEventSourceAccount
     PartnerEventSourceAccount
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartnerEventSourceAccount' {Maybe POSIX
expirationTime :: Maybe POSIX
$sel:expirationTime:PartnerEventSourceAccount' :: PartnerEventSourceAccount -> Maybe POSIX
expirationTime} -> Maybe POSIX
expirationTime) (\s :: PartnerEventSourceAccount
s@PartnerEventSourceAccount' {} Maybe POSIX
a -> PartnerEventSourceAccount
s {$sel:expirationTime:PartnerEventSourceAccount' :: Maybe POSIX
expirationTime = Maybe POSIX
a} :: PartnerEventSourceAccount) ((Maybe POSIX -> f (Maybe POSIX))
 -> PartnerEventSourceAccount -> f PartnerEventSourceAccount)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> PartnerEventSourceAccount
-> f PartnerEventSourceAccount
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 PartnerEventSourceAccount where
  parseJSON :: Value -> Parser PartnerEventSourceAccount
parseJSON =
    String
-> (Object -> Parser PartnerEventSourceAccount)
-> Value
-> Parser PartnerEventSourceAccount
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PartnerEventSourceAccount"
      ( \Object
x ->
          Maybe POSIX
-> Maybe EventSourceState
-> Maybe Text
-> Maybe POSIX
-> PartnerEventSourceAccount
PartnerEventSourceAccount'
            (Maybe POSIX
 -> Maybe EventSourceState
 -> Maybe Text
 -> Maybe POSIX
 -> PartnerEventSourceAccount)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe EventSourceState
      -> Maybe Text -> Maybe POSIX -> PartnerEventSourceAccount)
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 POSIX -> PartnerEventSourceAccount)
-> Parser (Maybe EventSourceState)
-> Parser (Maybe Text -> Maybe POSIX -> PartnerEventSourceAccount)
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 POSIX -> PartnerEventSourceAccount)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> PartnerEventSourceAccount)
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
"Account")
            Parser (Maybe POSIX -> PartnerEventSourceAccount)
-> Parser (Maybe POSIX) -> Parser PartnerEventSourceAccount
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 PartnerEventSourceAccount

instance Prelude.NFData PartnerEventSourceAccount