{-# 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.CloudFront.Types.EndPoint
-- 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.CloudFront.Types.EndPoint where

import Amazonka.CloudFront.Types.KinesisStreamConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the Amazon Kinesis data stream where you are
-- sending real-time log data in a real-time log configuration.
--
-- /See:/ 'newEndPoint' smart constructor.
data EndPoint = EndPoint'
  { -- | Contains information about the Amazon Kinesis data stream where you are
    -- sending real-time log data.
    EndPoint -> Maybe KinesisStreamConfig
kinesisStreamConfig :: Prelude.Maybe KinesisStreamConfig,
    -- | The type of data stream where you are sending real-time log data. The
    -- only valid value is @Kinesis@.
    EndPoint -> Text
streamType :: Prelude.Text
  }
  deriving (EndPoint -> EndPoint -> Bool
(EndPoint -> EndPoint -> Bool)
-> (EndPoint -> EndPoint -> Bool) -> Eq EndPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndPoint -> EndPoint -> Bool
$c/= :: EndPoint -> EndPoint -> Bool
== :: EndPoint -> EndPoint -> Bool
$c== :: EndPoint -> EndPoint -> Bool
Prelude.Eq, ReadPrec [EndPoint]
ReadPrec EndPoint
Int -> ReadS EndPoint
ReadS [EndPoint]
(Int -> ReadS EndPoint)
-> ReadS [EndPoint]
-> ReadPrec EndPoint
-> ReadPrec [EndPoint]
-> Read EndPoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EndPoint]
$creadListPrec :: ReadPrec [EndPoint]
readPrec :: ReadPrec EndPoint
$creadPrec :: ReadPrec EndPoint
readList :: ReadS [EndPoint]
$creadList :: ReadS [EndPoint]
readsPrec :: Int -> ReadS EndPoint
$creadsPrec :: Int -> ReadS EndPoint
Prelude.Read, Int -> EndPoint -> ShowS
[EndPoint] -> ShowS
EndPoint -> String
(Int -> EndPoint -> ShowS)
-> (EndPoint -> String) -> ([EndPoint] -> ShowS) -> Show EndPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndPoint] -> ShowS
$cshowList :: [EndPoint] -> ShowS
show :: EndPoint -> String
$cshow :: EndPoint -> String
showsPrec :: Int -> EndPoint -> ShowS
$cshowsPrec :: Int -> EndPoint -> ShowS
Prelude.Show, (forall x. EndPoint -> Rep EndPoint x)
-> (forall x. Rep EndPoint x -> EndPoint) -> Generic EndPoint
forall x. Rep EndPoint x -> EndPoint
forall x. EndPoint -> Rep EndPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EndPoint x -> EndPoint
$cfrom :: forall x. EndPoint -> Rep EndPoint x
Prelude.Generic)

-- |
-- Create a value of 'EndPoint' 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:
--
-- 'kinesisStreamConfig', 'endPoint_kinesisStreamConfig' - Contains information about the Amazon Kinesis data stream where you are
-- sending real-time log data.
--
-- 'streamType', 'endPoint_streamType' - The type of data stream where you are sending real-time log data. The
-- only valid value is @Kinesis@.
newEndPoint ::
  -- | 'streamType'
  Prelude.Text ->
  EndPoint
newEndPoint :: Text -> EndPoint
newEndPoint Text
pStreamType_ =
  EndPoint' :: Maybe KinesisStreamConfig -> Text -> EndPoint
EndPoint'
    { $sel:kinesisStreamConfig:EndPoint' :: Maybe KinesisStreamConfig
kinesisStreamConfig = Maybe KinesisStreamConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:streamType:EndPoint' :: Text
streamType = Text
pStreamType_
    }

-- | Contains information about the Amazon Kinesis data stream where you are
-- sending real-time log data.
endPoint_kinesisStreamConfig :: Lens.Lens' EndPoint (Prelude.Maybe KinesisStreamConfig)
endPoint_kinesisStreamConfig :: (Maybe KinesisStreamConfig -> f (Maybe KinesisStreamConfig))
-> EndPoint -> f EndPoint
endPoint_kinesisStreamConfig = (EndPoint -> Maybe KinesisStreamConfig)
-> (EndPoint -> Maybe KinesisStreamConfig -> EndPoint)
-> Lens
     EndPoint
     EndPoint
     (Maybe KinesisStreamConfig)
     (Maybe KinesisStreamConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndPoint' {Maybe KinesisStreamConfig
kinesisStreamConfig :: Maybe KinesisStreamConfig
$sel:kinesisStreamConfig:EndPoint' :: EndPoint -> Maybe KinesisStreamConfig
kinesisStreamConfig} -> Maybe KinesisStreamConfig
kinesisStreamConfig) (\s :: EndPoint
s@EndPoint' {} Maybe KinesisStreamConfig
a -> EndPoint
s {$sel:kinesisStreamConfig:EndPoint' :: Maybe KinesisStreamConfig
kinesisStreamConfig = Maybe KinesisStreamConfig
a} :: EndPoint)

-- | The type of data stream where you are sending real-time log data. The
-- only valid value is @Kinesis@.
endPoint_streamType :: Lens.Lens' EndPoint Prelude.Text
endPoint_streamType :: (Text -> f Text) -> EndPoint -> f EndPoint
endPoint_streamType = (EndPoint -> Text)
-> (EndPoint -> Text -> EndPoint)
-> Lens EndPoint EndPoint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndPoint' {Text
streamType :: Text
$sel:streamType:EndPoint' :: EndPoint -> Text
streamType} -> Text
streamType) (\s :: EndPoint
s@EndPoint' {} Text
a -> EndPoint
s {$sel:streamType:EndPoint' :: Text
streamType = Text
a} :: EndPoint)

instance Core.FromXML EndPoint where
  parseXML :: [Node] -> Either String EndPoint
parseXML [Node]
x =
    Maybe KinesisStreamConfig -> Text -> EndPoint
EndPoint'
      (Maybe KinesisStreamConfig -> Text -> EndPoint)
-> Either String (Maybe KinesisStreamConfig)
-> Either String (Text -> EndPoint)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe KinesisStreamConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"KinesisStreamConfig")
      Either String (Text -> EndPoint)
-> Either String Text -> Either String EndPoint
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"StreamType")

instance Prelude.Hashable EndPoint

instance Prelude.NFData EndPoint

instance Core.ToXML EndPoint where
  toXML :: EndPoint -> XML
toXML EndPoint' {Maybe KinesisStreamConfig
Text
streamType :: Text
kinesisStreamConfig :: Maybe KinesisStreamConfig
$sel:streamType:EndPoint' :: EndPoint -> Text
$sel:kinesisStreamConfig:EndPoint' :: EndPoint -> Maybe KinesisStreamConfig
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"KinesisStreamConfig" Name -> Maybe KinesisStreamConfig -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe KinesisStreamConfig
kinesisStreamConfig,
        Name
"StreamType" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
streamType
      ]