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

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

-- | Represents an event to be submitted.
--
-- /See:/ 'newPutEventsRequestEntry' smart constructor.
data PutEventsRequestEntry = PutEventsRequestEntry'
  { -- | A valid JSON object. There is no other schema imposed. The JSON object
    -- may contain fields and nested subobjects.
    PutEventsRequestEntry -> Maybe Text
detail :: Prelude.Maybe Prelude.Text,
    -- | Free-form string used to decide what fields to expect in the event
    -- detail.
    PutEventsRequestEntry -> Maybe Text
detailType :: Prelude.Maybe Prelude.Text,
    -- | The name or ARN of the event bus to receive the event. Only the rules
    -- that are associated with this event bus are used to match the event. If
    -- you omit this, the default event bus is used.
    --
    -- If you\'re using a global endpoint with a custom bus, you must enter the
    -- name, not the ARN, of the event bus in either the primary or secondary
    -- Region here and the corresponding event bus in the other Region will be
    -- determined based on the endpoint referenced by the @EndpointId@.
    PutEventsRequestEntry -> Maybe Text
eventBusName :: 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.
    PutEventsRequestEntry -> Maybe [Text]
resources :: Prelude.Maybe [Prelude.Text],
    -- | The source of the event.
    PutEventsRequestEntry -> Maybe Text
source :: Prelude.Maybe Prelude.Text,
    -- | The time stamp of the event, per
    -- <https://www.rfc-editor.org/rfc/rfc3339.txt RFC3339>. If no time stamp
    -- is provided, the time stamp of the
    -- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutEvents.html PutEvents>
    -- call is used.
    PutEventsRequestEntry -> Maybe POSIX
time :: Prelude.Maybe Data.POSIX,
    -- | An X-Ray trace header, which is an http header (X-Amzn-Trace-Id) that
    -- contains the trace-id associated with the event.
    --
    -- To learn more about X-Ray trace headers, see
    -- <https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader Tracing header>
    -- in the X-Ray Developer Guide.
    PutEventsRequestEntry -> Maybe Text
traceHeader :: Prelude.Maybe Prelude.Text
  }
  deriving (PutEventsRequestEntry -> PutEventsRequestEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEventsRequestEntry -> PutEventsRequestEntry -> Bool
$c/= :: PutEventsRequestEntry -> PutEventsRequestEntry -> Bool
== :: PutEventsRequestEntry -> PutEventsRequestEntry -> Bool
$c== :: PutEventsRequestEntry -> PutEventsRequestEntry -> Bool
Prelude.Eq, ReadPrec [PutEventsRequestEntry]
ReadPrec PutEventsRequestEntry
Int -> ReadS PutEventsRequestEntry
ReadS [PutEventsRequestEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEventsRequestEntry]
$creadListPrec :: ReadPrec [PutEventsRequestEntry]
readPrec :: ReadPrec PutEventsRequestEntry
$creadPrec :: ReadPrec PutEventsRequestEntry
readList :: ReadS [PutEventsRequestEntry]
$creadList :: ReadS [PutEventsRequestEntry]
readsPrec :: Int -> ReadS PutEventsRequestEntry
$creadsPrec :: Int -> ReadS PutEventsRequestEntry
Prelude.Read, Int -> PutEventsRequestEntry -> ShowS
[PutEventsRequestEntry] -> ShowS
PutEventsRequestEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEventsRequestEntry] -> ShowS
$cshowList :: [PutEventsRequestEntry] -> ShowS
show :: PutEventsRequestEntry -> String
$cshow :: PutEventsRequestEntry -> String
showsPrec :: Int -> PutEventsRequestEntry -> ShowS
$cshowsPrec :: Int -> PutEventsRequestEntry -> ShowS
Prelude.Show, forall x. Rep PutEventsRequestEntry x -> PutEventsRequestEntry
forall x. PutEventsRequestEntry -> Rep PutEventsRequestEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutEventsRequestEntry x -> PutEventsRequestEntry
$cfrom :: forall x. PutEventsRequestEntry -> Rep PutEventsRequestEntry x
Prelude.Generic)

-- |
-- Create a value of 'PutEventsRequestEntry' 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:
--
-- 'detail', 'putEventsRequestEntry_detail' - A valid JSON object. There is no other schema imposed. The JSON object
-- may contain fields and nested subobjects.
--
-- 'detailType', 'putEventsRequestEntry_detailType' - Free-form string used to decide what fields to expect in the event
-- detail.
--
-- 'eventBusName', 'putEventsRequestEntry_eventBusName' - The name or ARN of the event bus to receive the event. Only the rules
-- that are associated with this event bus are used to match the event. If
-- you omit this, the default event bus is used.
--
-- If you\'re using a global endpoint with a custom bus, you must enter the
-- name, not the ARN, of the event bus in either the primary or secondary
-- Region here and the corresponding event bus in the other Region will be
-- determined based on the endpoint referenced by the @EndpointId@.
--
-- 'resources', 'putEventsRequestEntry_resources' - Amazon Web Services resources, identified by Amazon Resource Name (ARN),
-- which the event primarily concerns. Any number, including zero, may be
-- present.
--
-- 'source', 'putEventsRequestEntry_source' - The source of the event.
--
-- 'time', 'putEventsRequestEntry_time' - The time stamp of the event, per
-- <https://www.rfc-editor.org/rfc/rfc3339.txt RFC3339>. If no time stamp
-- is provided, the time stamp of the
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutEvents.html PutEvents>
-- call is used.
--
-- 'traceHeader', 'putEventsRequestEntry_traceHeader' - An X-Ray trace header, which is an http header (X-Amzn-Trace-Id) that
-- contains the trace-id associated with the event.
--
-- To learn more about X-Ray trace headers, see
-- <https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader Tracing header>
-- in the X-Ray Developer Guide.
newPutEventsRequestEntry ::
  PutEventsRequestEntry
newPutEventsRequestEntry :: PutEventsRequestEntry
newPutEventsRequestEntry =
  PutEventsRequestEntry'
    { $sel:detail:PutEventsRequestEntry' :: Maybe Text
detail = forall a. Maybe a
Prelude.Nothing,
      $sel:detailType:PutEventsRequestEntry' :: Maybe Text
detailType = forall a. Maybe a
Prelude.Nothing,
      $sel:eventBusName:PutEventsRequestEntry' :: Maybe Text
eventBusName = forall a. Maybe a
Prelude.Nothing,
      $sel:resources:PutEventsRequestEntry' :: Maybe [Text]
resources = forall a. Maybe a
Prelude.Nothing,
      $sel:source:PutEventsRequestEntry' :: Maybe Text
source = forall a. Maybe a
Prelude.Nothing,
      $sel:time:PutEventsRequestEntry' :: Maybe POSIX
time = forall a. Maybe a
Prelude.Nothing,
      $sel:traceHeader:PutEventsRequestEntry' :: Maybe Text
traceHeader = forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | The name or ARN of the event bus to receive the event. Only the rules
-- that are associated with this event bus are used to match the event. If
-- you omit this, the default event bus is used.
--
-- If you\'re using a global endpoint with a custom bus, you must enter the
-- name, not the ARN, of the event bus in either the primary or secondary
-- Region here and the corresponding event bus in the other Region will be
-- determined based on the endpoint referenced by the @EndpointId@.
putEventsRequestEntry_eventBusName :: Lens.Lens' PutEventsRequestEntry (Prelude.Maybe Prelude.Text)
putEventsRequestEntry_eventBusName :: Lens' PutEventsRequestEntry (Maybe Text)
putEventsRequestEntry_eventBusName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventsRequestEntry' {Maybe Text
eventBusName :: Maybe Text
$sel:eventBusName:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
eventBusName} -> Maybe Text
eventBusName) (\s :: PutEventsRequestEntry
s@PutEventsRequestEntry' {} Maybe Text
a -> PutEventsRequestEntry
s {$sel:eventBusName:PutEventsRequestEntry' :: Maybe Text
eventBusName = Maybe Text
a} :: PutEventsRequestEntry)

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

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

-- | The time stamp of the event, per
-- <https://www.rfc-editor.org/rfc/rfc3339.txt RFC3339>. If no time stamp
-- is provided, the time stamp of the
-- <https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutEvents.html PutEvents>
-- call is used.
putEventsRequestEntry_time :: Lens.Lens' PutEventsRequestEntry (Prelude.Maybe Prelude.UTCTime)
putEventsRequestEntry_time :: Lens' PutEventsRequestEntry (Maybe UTCTime)
putEventsRequestEntry_time = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventsRequestEntry' {Maybe POSIX
time :: Maybe POSIX
$sel:time:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe POSIX
time} -> Maybe POSIX
time) (\s :: PutEventsRequestEntry
s@PutEventsRequestEntry' {} Maybe POSIX
a -> PutEventsRequestEntry
s {$sel:time:PutEventsRequestEntry' :: Maybe POSIX
time = Maybe POSIX
a} :: PutEventsRequestEntry) 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

-- | An X-Ray trace header, which is an http header (X-Amzn-Trace-Id) that
-- contains the trace-id associated with the event.
--
-- To learn more about X-Ray trace headers, see
-- <https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader Tracing header>
-- in the X-Ray Developer Guide.
putEventsRequestEntry_traceHeader :: Lens.Lens' PutEventsRequestEntry (Prelude.Maybe Prelude.Text)
putEventsRequestEntry_traceHeader :: Lens' PutEventsRequestEntry (Maybe Text)
putEventsRequestEntry_traceHeader = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEventsRequestEntry' {Maybe Text
traceHeader :: Maybe Text
$sel:traceHeader:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
traceHeader} -> Maybe Text
traceHeader) (\s :: PutEventsRequestEntry
s@PutEventsRequestEntry' {} Maybe Text
a -> PutEventsRequestEntry
s {$sel:traceHeader:PutEventsRequestEntry' :: Maybe Text
traceHeader = Maybe Text
a} :: PutEventsRequestEntry)

instance Prelude.Hashable PutEventsRequestEntry where
  hashWithSalt :: Int -> PutEventsRequestEntry -> Int
hashWithSalt Int
_salt PutEventsRequestEntry' {Maybe [Text]
Maybe Text
Maybe POSIX
traceHeader :: Maybe Text
time :: Maybe POSIX
source :: Maybe Text
resources :: Maybe [Text]
eventBusName :: Maybe Text
detailType :: Maybe Text
detail :: Maybe Text
$sel:traceHeader:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
$sel:time:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe POSIX
$sel:source:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
$sel:resources:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe [Text]
$sel:eventBusName:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
$sel:detailType:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
$sel:detail:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
detail
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
detailType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
eventBusName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
resources
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
source
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
time
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
traceHeader

instance Prelude.NFData PutEventsRequestEntry where
  rnf :: PutEventsRequestEntry -> ()
rnf PutEventsRequestEntry' {Maybe [Text]
Maybe Text
Maybe POSIX
traceHeader :: Maybe Text
time :: Maybe POSIX
source :: Maybe Text
resources :: Maybe [Text]
eventBusName :: Maybe Text
detailType :: Maybe Text
detail :: Maybe Text
$sel:traceHeader:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
$sel:time:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe POSIX
$sel:source:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
$sel:resources:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe [Text]
$sel:eventBusName:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
$sel:detailType:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
$sel:detail:PutEventsRequestEntry' :: PutEventsRequestEntry -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
detail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
detailType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eventBusName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
resources
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
source
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
time
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
traceHeader

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