{-# 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.Pinpoint.Types.WriteEventStream
-- 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.Pinpoint.Types.WriteEventStream where

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

-- | Specifies the Amazon Resource Name (ARN) of an event stream to publish
-- events to and the AWS Identity and Access Management (IAM) role to use
-- when publishing those events.
--
-- /See:/ 'newWriteEventStream' smart constructor.
data WriteEventStream = WriteEventStream'
  { -- | The AWS Identity and Access Management (IAM) role that authorizes Amazon
    -- Pinpoint to publish event data to the stream in your AWS account.
    WriteEventStream -> Text
roleArn :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Amazon Kinesis data stream or
    -- Amazon Kinesis Data Firehose delivery stream that you want to publish
    -- event data to.
    --
    -- For a Kinesis data stream, the ARN format is:
    -- arn:aws:kinesis:region:account-id:stream\/stream_name
    --
    -- For a Kinesis Data Firehose delivery stream, the ARN format is:
    -- arn:aws:firehose:region:account-id:deliverystream\/stream_name
    WriteEventStream -> Text
destinationStreamArn :: Prelude.Text
  }
  deriving (WriteEventStream -> WriteEventStream -> Bool
(WriteEventStream -> WriteEventStream -> Bool)
-> (WriteEventStream -> WriteEventStream -> Bool)
-> Eq WriteEventStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WriteEventStream -> WriteEventStream -> Bool
$c/= :: WriteEventStream -> WriteEventStream -> Bool
== :: WriteEventStream -> WriteEventStream -> Bool
$c== :: WriteEventStream -> WriteEventStream -> Bool
Prelude.Eq, ReadPrec [WriteEventStream]
ReadPrec WriteEventStream
Int -> ReadS WriteEventStream
ReadS [WriteEventStream]
(Int -> ReadS WriteEventStream)
-> ReadS [WriteEventStream]
-> ReadPrec WriteEventStream
-> ReadPrec [WriteEventStream]
-> Read WriteEventStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WriteEventStream]
$creadListPrec :: ReadPrec [WriteEventStream]
readPrec :: ReadPrec WriteEventStream
$creadPrec :: ReadPrec WriteEventStream
readList :: ReadS [WriteEventStream]
$creadList :: ReadS [WriteEventStream]
readsPrec :: Int -> ReadS WriteEventStream
$creadsPrec :: Int -> ReadS WriteEventStream
Prelude.Read, Int -> WriteEventStream -> ShowS
[WriteEventStream] -> ShowS
WriteEventStream -> String
(Int -> WriteEventStream -> ShowS)
-> (WriteEventStream -> String)
-> ([WriteEventStream] -> ShowS)
-> Show WriteEventStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WriteEventStream] -> ShowS
$cshowList :: [WriteEventStream] -> ShowS
show :: WriteEventStream -> String
$cshow :: WriteEventStream -> String
showsPrec :: Int -> WriteEventStream -> ShowS
$cshowsPrec :: Int -> WriteEventStream -> ShowS
Prelude.Show, (forall x. WriteEventStream -> Rep WriteEventStream x)
-> (forall x. Rep WriteEventStream x -> WriteEventStream)
-> Generic WriteEventStream
forall x. Rep WriteEventStream x -> WriteEventStream
forall x. WriteEventStream -> Rep WriteEventStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WriteEventStream x -> WriteEventStream
$cfrom :: forall x. WriteEventStream -> Rep WriteEventStream x
Prelude.Generic)

-- |
-- Create a value of 'WriteEventStream' 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:
--
-- 'roleArn', 'writeEventStream_roleArn' - The AWS Identity and Access Management (IAM) role that authorizes Amazon
-- Pinpoint to publish event data to the stream in your AWS account.
--
-- 'destinationStreamArn', 'writeEventStream_destinationStreamArn' - The Amazon Resource Name (ARN) of the Amazon Kinesis data stream or
-- Amazon Kinesis Data Firehose delivery stream that you want to publish
-- event data to.
--
-- For a Kinesis data stream, the ARN format is:
-- arn:aws:kinesis:region:account-id:stream\/stream_name
--
-- For a Kinesis Data Firehose delivery stream, the ARN format is:
-- arn:aws:firehose:region:account-id:deliverystream\/stream_name
newWriteEventStream ::
  -- | 'roleArn'
  Prelude.Text ->
  -- | 'destinationStreamArn'
  Prelude.Text ->
  WriteEventStream
newWriteEventStream :: Text -> Text -> WriteEventStream
newWriteEventStream Text
pRoleArn_ Text
pDestinationStreamArn_ =
  WriteEventStream' :: Text -> Text -> WriteEventStream
WriteEventStream'
    { $sel:roleArn:WriteEventStream' :: Text
roleArn = Text
pRoleArn_,
      $sel:destinationStreamArn:WriteEventStream' :: Text
destinationStreamArn = Text
pDestinationStreamArn_
    }

-- | The AWS Identity and Access Management (IAM) role that authorizes Amazon
-- Pinpoint to publish event data to the stream in your AWS account.
writeEventStream_roleArn :: Lens.Lens' WriteEventStream Prelude.Text
writeEventStream_roleArn :: (Text -> f Text) -> WriteEventStream -> f WriteEventStream
writeEventStream_roleArn = (WriteEventStream -> Text)
-> (WriteEventStream -> Text -> WriteEventStream)
-> Lens WriteEventStream WriteEventStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteEventStream' {Text
roleArn :: Text
$sel:roleArn:WriteEventStream' :: WriteEventStream -> Text
roleArn} -> Text
roleArn) (\s :: WriteEventStream
s@WriteEventStream' {} Text
a -> WriteEventStream
s {$sel:roleArn:WriteEventStream' :: Text
roleArn = Text
a} :: WriteEventStream)

-- | The Amazon Resource Name (ARN) of the Amazon Kinesis data stream or
-- Amazon Kinesis Data Firehose delivery stream that you want to publish
-- event data to.
--
-- For a Kinesis data stream, the ARN format is:
-- arn:aws:kinesis:region:account-id:stream\/stream_name
--
-- For a Kinesis Data Firehose delivery stream, the ARN format is:
-- arn:aws:firehose:region:account-id:deliverystream\/stream_name
writeEventStream_destinationStreamArn :: Lens.Lens' WriteEventStream Prelude.Text
writeEventStream_destinationStreamArn :: (Text -> f Text) -> WriteEventStream -> f WriteEventStream
writeEventStream_destinationStreamArn = (WriteEventStream -> Text)
-> (WriteEventStream -> Text -> WriteEventStream)
-> Lens WriteEventStream WriteEventStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteEventStream' {Text
destinationStreamArn :: Text
$sel:destinationStreamArn:WriteEventStream' :: WriteEventStream -> Text
destinationStreamArn} -> Text
destinationStreamArn) (\s :: WriteEventStream
s@WriteEventStream' {} Text
a -> WriteEventStream
s {$sel:destinationStreamArn:WriteEventStream' :: Text
destinationStreamArn = Text
a} :: WriteEventStream)

instance Prelude.Hashable WriteEventStream

instance Prelude.NFData WriteEventStream

instance Core.ToJSON WriteEventStream where
  toJSON :: WriteEventStream -> Value
toJSON WriteEventStream' {Text
destinationStreamArn :: Text
roleArn :: Text
$sel:destinationStreamArn:WriteEventStream' :: WriteEventStream -> Text
$sel:roleArn:WriteEventStream' :: WriteEventStream -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"DestinationStreamArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
destinationStreamArn
              )
          ]
      )