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

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

-- | The details about an event generated by an SaaS partner.
--
-- /See:/ 'newPutPartnerEventsRequestEntry' smart constructor.
data PutPartnerEventsRequestEntry = PutPartnerEventsRequestEntry'
  { -- | The date and time of the event.
    PutPartnerEventsRequestEntry -> Maybe POSIX
time :: Prelude.Maybe Core.POSIX,
    -- | A free-form string used to decide what fields to expect in the event
    -- detail.
    PutPartnerEventsRequestEntry -> Maybe Text
detailType :: Prelude.Maybe Prelude.Text,
    -- | Amazon Web Services resources, identified by Amazon Resource Name (ARN),
    -- which the event primarily concerns. Any number, including zero, may be
    -- present.
    PutPartnerEventsRequestEntry -> Maybe [Text]
resources :: Prelude.Maybe [Prelude.Text],
    -- | The event source that is generating the entry.
    PutPartnerEventsRequestEntry -> Maybe Text
source :: Prelude.Maybe Prelude.Text,
    -- | A valid JSON string. There is no other schema imposed. The JSON string
    -- may contain fields and nested subobjects.
    PutPartnerEventsRequestEntry -> Maybe Text
detail :: Prelude.Maybe Prelude.Text
  }
  deriving (PutPartnerEventsRequestEntry
-> PutPartnerEventsRequestEntry -> Bool
(PutPartnerEventsRequestEntry
 -> PutPartnerEventsRequestEntry -> Bool)
-> (PutPartnerEventsRequestEntry
    -> PutPartnerEventsRequestEntry -> Bool)
-> Eq PutPartnerEventsRequestEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutPartnerEventsRequestEntry
-> PutPartnerEventsRequestEntry -> Bool
$c/= :: PutPartnerEventsRequestEntry
-> PutPartnerEventsRequestEntry -> Bool
== :: PutPartnerEventsRequestEntry
-> PutPartnerEventsRequestEntry -> Bool
$c== :: PutPartnerEventsRequestEntry
-> PutPartnerEventsRequestEntry -> Bool
Prelude.Eq, ReadPrec [PutPartnerEventsRequestEntry]
ReadPrec PutPartnerEventsRequestEntry
Int -> ReadS PutPartnerEventsRequestEntry
ReadS [PutPartnerEventsRequestEntry]
(Int -> ReadS PutPartnerEventsRequestEntry)
-> ReadS [PutPartnerEventsRequestEntry]
-> ReadPrec PutPartnerEventsRequestEntry
-> ReadPrec [PutPartnerEventsRequestEntry]
-> Read PutPartnerEventsRequestEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutPartnerEventsRequestEntry]
$creadListPrec :: ReadPrec [PutPartnerEventsRequestEntry]
readPrec :: ReadPrec PutPartnerEventsRequestEntry
$creadPrec :: ReadPrec PutPartnerEventsRequestEntry
readList :: ReadS [PutPartnerEventsRequestEntry]
$creadList :: ReadS [PutPartnerEventsRequestEntry]
readsPrec :: Int -> ReadS PutPartnerEventsRequestEntry
$creadsPrec :: Int -> ReadS PutPartnerEventsRequestEntry
Prelude.Read, Int -> PutPartnerEventsRequestEntry -> ShowS
[PutPartnerEventsRequestEntry] -> ShowS
PutPartnerEventsRequestEntry -> String
(Int -> PutPartnerEventsRequestEntry -> ShowS)
-> (PutPartnerEventsRequestEntry -> String)
-> ([PutPartnerEventsRequestEntry] -> ShowS)
-> Show PutPartnerEventsRequestEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutPartnerEventsRequestEntry] -> ShowS
$cshowList :: [PutPartnerEventsRequestEntry] -> ShowS
show :: PutPartnerEventsRequestEntry -> String
$cshow :: PutPartnerEventsRequestEntry -> String
showsPrec :: Int -> PutPartnerEventsRequestEntry -> ShowS
$cshowsPrec :: Int -> PutPartnerEventsRequestEntry -> ShowS
Prelude.Show, (forall x.
 PutPartnerEventsRequestEntry -> Rep PutPartnerEventsRequestEntry x)
-> (forall x.
    Rep PutPartnerEventsRequestEntry x -> PutPartnerEventsRequestEntry)
-> Generic PutPartnerEventsRequestEntry
forall x.
Rep PutPartnerEventsRequestEntry x -> PutPartnerEventsRequestEntry
forall x.
PutPartnerEventsRequestEntry -> Rep PutPartnerEventsRequestEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutPartnerEventsRequestEntry x -> PutPartnerEventsRequestEntry
$cfrom :: forall x.
PutPartnerEventsRequestEntry -> Rep PutPartnerEventsRequestEntry x
Prelude.Generic)

-- |
-- Create a value of 'PutPartnerEventsRequestEntry' 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:
--
-- 'time', 'putPartnerEventsRequestEntry_time' - The date and time of the event.
--
-- 'detailType', 'putPartnerEventsRequestEntry_detailType' - A free-form string used to decide what fields to expect in the event
-- detail.
--
-- 'resources', 'putPartnerEventsRequestEntry_resources' - Amazon Web Services resources, identified by Amazon Resource Name (ARN),
-- which the event primarily concerns. Any number, including zero, may be
-- present.
--
-- 'source', 'putPartnerEventsRequestEntry_source' - The event source that is generating the entry.
--
-- 'detail', 'putPartnerEventsRequestEntry_detail' - A valid JSON string. There is no other schema imposed. The JSON string
-- may contain fields and nested subobjects.
newPutPartnerEventsRequestEntry ::
  PutPartnerEventsRequestEntry
newPutPartnerEventsRequestEntry :: PutPartnerEventsRequestEntry
newPutPartnerEventsRequestEntry =
  PutPartnerEventsRequestEntry' :: Maybe POSIX
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> PutPartnerEventsRequestEntry
PutPartnerEventsRequestEntry'
    { $sel:time:PutPartnerEventsRequestEntry' :: Maybe POSIX
time =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:detailType:PutPartnerEventsRequestEntry' :: Maybe Text
detailType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resources:PutPartnerEventsRequestEntry' :: Maybe [Text]
resources = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:source:PutPartnerEventsRequestEntry' :: Maybe Text
source = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:detail:PutPartnerEventsRequestEntry' :: Maybe Text
detail = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time of the event.
putPartnerEventsRequestEntry_time :: Lens.Lens' PutPartnerEventsRequestEntry (Prelude.Maybe Prelude.UTCTime)
putPartnerEventsRequestEntry_time :: (Maybe UTCTime -> f (Maybe UTCTime))
-> PutPartnerEventsRequestEntry -> f PutPartnerEventsRequestEntry
putPartnerEventsRequestEntry_time = (PutPartnerEventsRequestEntry -> Maybe POSIX)
-> (PutPartnerEventsRequestEntry
    -> Maybe POSIX -> PutPartnerEventsRequestEntry)
-> Lens
     PutPartnerEventsRequestEntry
     PutPartnerEventsRequestEntry
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPartnerEventsRequestEntry' {Maybe POSIX
time :: Maybe POSIX
$sel:time:PutPartnerEventsRequestEntry' :: PutPartnerEventsRequestEntry -> Maybe POSIX
time} -> Maybe POSIX
time) (\s :: PutPartnerEventsRequestEntry
s@PutPartnerEventsRequestEntry' {} Maybe POSIX
a -> PutPartnerEventsRequestEntry
s {$sel:time:PutPartnerEventsRequestEntry' :: Maybe POSIX
time = Maybe POSIX
a} :: PutPartnerEventsRequestEntry) ((Maybe POSIX -> f (Maybe POSIX))
 -> PutPartnerEventsRequestEntry -> f PutPartnerEventsRequestEntry)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> PutPartnerEventsRequestEntry
-> f PutPartnerEventsRequestEntry
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

-- | A free-form string used to decide what fields to expect in the event
-- detail.
putPartnerEventsRequestEntry_detailType :: Lens.Lens' PutPartnerEventsRequestEntry (Prelude.Maybe Prelude.Text)
putPartnerEventsRequestEntry_detailType :: (Maybe Text -> f (Maybe Text))
-> PutPartnerEventsRequestEntry -> f PutPartnerEventsRequestEntry
putPartnerEventsRequestEntry_detailType = (PutPartnerEventsRequestEntry -> Maybe Text)
-> (PutPartnerEventsRequestEntry
    -> Maybe Text -> PutPartnerEventsRequestEntry)
-> Lens
     PutPartnerEventsRequestEntry
     PutPartnerEventsRequestEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPartnerEventsRequestEntry' {Maybe Text
detailType :: Maybe Text
$sel:detailType:PutPartnerEventsRequestEntry' :: PutPartnerEventsRequestEntry -> Maybe Text
detailType} -> Maybe Text
detailType) (\s :: PutPartnerEventsRequestEntry
s@PutPartnerEventsRequestEntry' {} Maybe Text
a -> PutPartnerEventsRequestEntry
s {$sel:detailType:PutPartnerEventsRequestEntry' :: Maybe Text
detailType = Maybe Text
a} :: PutPartnerEventsRequestEntry)

-- | Amazon Web Services resources, identified by Amazon Resource Name (ARN),
-- which the event primarily concerns. Any number, including zero, may be
-- present.
putPartnerEventsRequestEntry_resources :: Lens.Lens' PutPartnerEventsRequestEntry (Prelude.Maybe [Prelude.Text])
putPartnerEventsRequestEntry_resources :: (Maybe [Text] -> f (Maybe [Text]))
-> PutPartnerEventsRequestEntry -> f PutPartnerEventsRequestEntry
putPartnerEventsRequestEntry_resources = (PutPartnerEventsRequestEntry -> Maybe [Text])
-> (PutPartnerEventsRequestEntry
    -> Maybe [Text] -> PutPartnerEventsRequestEntry)
-> Lens
     PutPartnerEventsRequestEntry
     PutPartnerEventsRequestEntry
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPartnerEventsRequestEntry' {Maybe [Text]
resources :: Maybe [Text]
$sel:resources:PutPartnerEventsRequestEntry' :: PutPartnerEventsRequestEntry -> Maybe [Text]
resources} -> Maybe [Text]
resources) (\s :: PutPartnerEventsRequestEntry
s@PutPartnerEventsRequestEntry' {} Maybe [Text]
a -> PutPartnerEventsRequestEntry
s {$sel:resources:PutPartnerEventsRequestEntry' :: Maybe [Text]
resources = Maybe [Text]
a} :: PutPartnerEventsRequestEntry) ((Maybe [Text] -> f (Maybe [Text]))
 -> PutPartnerEventsRequestEntry -> f PutPartnerEventsRequestEntry)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutPartnerEventsRequestEntry
-> f PutPartnerEventsRequestEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The event source that is generating the entry.
putPartnerEventsRequestEntry_source :: Lens.Lens' PutPartnerEventsRequestEntry (Prelude.Maybe Prelude.Text)
putPartnerEventsRequestEntry_source :: (Maybe Text -> f (Maybe Text))
-> PutPartnerEventsRequestEntry -> f PutPartnerEventsRequestEntry
putPartnerEventsRequestEntry_source = (PutPartnerEventsRequestEntry -> Maybe Text)
-> (PutPartnerEventsRequestEntry
    -> Maybe Text -> PutPartnerEventsRequestEntry)
-> Lens
     PutPartnerEventsRequestEntry
     PutPartnerEventsRequestEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPartnerEventsRequestEntry' {Maybe Text
source :: Maybe Text
$sel:source:PutPartnerEventsRequestEntry' :: PutPartnerEventsRequestEntry -> Maybe Text
source} -> Maybe Text
source) (\s :: PutPartnerEventsRequestEntry
s@PutPartnerEventsRequestEntry' {} Maybe Text
a -> PutPartnerEventsRequestEntry
s {$sel:source:PutPartnerEventsRequestEntry' :: Maybe Text
source = Maybe Text
a} :: PutPartnerEventsRequestEntry)

-- | A valid JSON string. There is no other schema imposed. The JSON string
-- may contain fields and nested subobjects.
putPartnerEventsRequestEntry_detail :: Lens.Lens' PutPartnerEventsRequestEntry (Prelude.Maybe Prelude.Text)
putPartnerEventsRequestEntry_detail :: (Maybe Text -> f (Maybe Text))
-> PutPartnerEventsRequestEntry -> f PutPartnerEventsRequestEntry
putPartnerEventsRequestEntry_detail = (PutPartnerEventsRequestEntry -> Maybe Text)
-> (PutPartnerEventsRequestEntry
    -> Maybe Text -> PutPartnerEventsRequestEntry)
-> Lens
     PutPartnerEventsRequestEntry
     PutPartnerEventsRequestEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPartnerEventsRequestEntry' {Maybe Text
detail :: Maybe Text
$sel:detail:PutPartnerEventsRequestEntry' :: PutPartnerEventsRequestEntry -> Maybe Text
detail} -> Maybe Text
detail) (\s :: PutPartnerEventsRequestEntry
s@PutPartnerEventsRequestEntry' {} Maybe Text
a -> PutPartnerEventsRequestEntry
s {$sel:detail:PutPartnerEventsRequestEntry' :: Maybe Text
detail = Maybe Text
a} :: PutPartnerEventsRequestEntry)

instance
  Prelude.Hashable
    PutPartnerEventsRequestEntry

instance Prelude.NFData PutPartnerEventsRequestEntry

instance Core.ToJSON PutPartnerEventsRequestEntry where
  toJSON :: PutPartnerEventsRequestEntry -> Value
toJSON PutPartnerEventsRequestEntry' {Maybe [Text]
Maybe Text
Maybe POSIX
detail :: Maybe Text
source :: Maybe Text
resources :: Maybe [Text]
detailType :: Maybe Text
time :: Maybe POSIX
$sel:detail:PutPartnerEventsRequestEntry' :: PutPartnerEventsRequestEntry -> Maybe Text
$sel:source:PutPartnerEventsRequestEntry' :: PutPartnerEventsRequestEntry -> Maybe Text
$sel:resources:PutPartnerEventsRequestEntry' :: PutPartnerEventsRequestEntry -> Maybe [Text]
$sel:detailType:PutPartnerEventsRequestEntry' :: PutPartnerEventsRequestEntry -> Maybe Text
$sel:time:PutPartnerEventsRequestEntry' :: PutPartnerEventsRequestEntry -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Time" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
time,
            (Text
"DetailType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
detailType,
            (Text
"Resources" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
resources,
            (Text
"Source" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
source,
            (Text
"Detail" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
detail
          ]
      )