{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.GetEventStream
-- 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)
--
-- Retrieves information about the event stream settings for an
-- application.
module Amazonka.Pinpoint.GetEventStream
  ( -- * Creating a Request
    GetEventStream (..),
    newGetEventStream,

    -- * Request Lenses
    getEventStream_applicationId,

    -- * Destructuring the Response
    GetEventStreamResponse (..),
    newGetEventStreamResponse,

    -- * Response Lenses
    getEventStreamResponse_httpStatus,
    getEventStreamResponse_eventStream,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetEventStream' smart constructor.
data GetEventStream = GetEventStream'
  { -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    GetEventStream -> Text
applicationId :: Prelude.Text
  }
  deriving (GetEventStream -> GetEventStream -> Bool
(GetEventStream -> GetEventStream -> Bool)
-> (GetEventStream -> GetEventStream -> Bool) -> Eq GetEventStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEventStream -> GetEventStream -> Bool
$c/= :: GetEventStream -> GetEventStream -> Bool
== :: GetEventStream -> GetEventStream -> Bool
$c== :: GetEventStream -> GetEventStream -> Bool
Prelude.Eq, ReadPrec [GetEventStream]
ReadPrec GetEventStream
Int -> ReadS GetEventStream
ReadS [GetEventStream]
(Int -> ReadS GetEventStream)
-> ReadS [GetEventStream]
-> ReadPrec GetEventStream
-> ReadPrec [GetEventStream]
-> Read GetEventStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEventStream]
$creadListPrec :: ReadPrec [GetEventStream]
readPrec :: ReadPrec GetEventStream
$creadPrec :: ReadPrec GetEventStream
readList :: ReadS [GetEventStream]
$creadList :: ReadS [GetEventStream]
readsPrec :: Int -> ReadS GetEventStream
$creadsPrec :: Int -> ReadS GetEventStream
Prelude.Read, Int -> GetEventStream -> ShowS
[GetEventStream] -> ShowS
GetEventStream -> String
(Int -> GetEventStream -> ShowS)
-> (GetEventStream -> String)
-> ([GetEventStream] -> ShowS)
-> Show GetEventStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEventStream] -> ShowS
$cshowList :: [GetEventStream] -> ShowS
show :: GetEventStream -> String
$cshow :: GetEventStream -> String
showsPrec :: Int -> GetEventStream -> ShowS
$cshowsPrec :: Int -> GetEventStream -> ShowS
Prelude.Show, (forall x. GetEventStream -> Rep GetEventStream x)
-> (forall x. Rep GetEventStream x -> GetEventStream)
-> Generic GetEventStream
forall x. Rep GetEventStream x -> GetEventStream
forall x. GetEventStream -> Rep GetEventStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEventStream x -> GetEventStream
$cfrom :: forall x. GetEventStream -> Rep GetEventStream x
Prelude.Generic)

-- |
-- Create a value of 'GetEventStream' 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:
--
-- 'applicationId', 'getEventStream_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
newGetEventStream ::
  -- | 'applicationId'
  Prelude.Text ->
  GetEventStream
newGetEventStream :: Text -> GetEventStream
newGetEventStream Text
pApplicationId_ =
  GetEventStream' :: Text -> GetEventStream
GetEventStream' {$sel:applicationId:GetEventStream' :: Text
applicationId = Text
pApplicationId_}

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
getEventStream_applicationId :: Lens.Lens' GetEventStream Prelude.Text
getEventStream_applicationId :: (Text -> f Text) -> GetEventStream -> f GetEventStream
getEventStream_applicationId = (GetEventStream -> Text)
-> (GetEventStream -> Text -> GetEventStream)
-> Lens GetEventStream GetEventStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventStream' {Text
applicationId :: Text
$sel:applicationId:GetEventStream' :: GetEventStream -> Text
applicationId} -> Text
applicationId) (\s :: GetEventStream
s@GetEventStream' {} Text
a -> GetEventStream
s {$sel:applicationId:GetEventStream' :: Text
applicationId = Text
a} :: GetEventStream)

instance Core.AWSRequest GetEventStream where
  type
    AWSResponse GetEventStream =
      GetEventStreamResponse
  request :: GetEventStream -> Request GetEventStream
request = Service -> GetEventStream -> Request GetEventStream
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetEventStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetEventStream)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetEventStream))
-> Logger
-> Service
-> Proxy GetEventStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetEventStream)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> EventStream -> GetEventStreamResponse
GetEventStreamResponse'
            (Int -> EventStream -> GetEventStreamResponse)
-> Either String Int
-> Either String (EventStream -> GetEventStreamResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String (EventStream -> GetEventStreamResponse)
-> Either String EventStream
-> Either String GetEventStreamResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String EventStream
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable GetEventStream

instance Prelude.NFData GetEventStream

instance Core.ToHeaders GetEventStream where
  toHeaders :: GetEventStream -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetEventStream -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath GetEventStream where
  toPath :: GetEventStream -> ByteString
toPath GetEventStream' {Text
applicationId :: Text
$sel:applicationId:GetEventStream' :: GetEventStream -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apps/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
        ByteString
"/eventstream"
      ]

instance Core.ToQuery GetEventStream where
  toQuery :: GetEventStream -> QueryString
toQuery = QueryString -> GetEventStream -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetEventStreamResponse' smart constructor.
data GetEventStreamResponse = GetEventStreamResponse'
  { -- | The response's http status code.
    GetEventStreamResponse -> Int
httpStatus :: Prelude.Int,
    GetEventStreamResponse -> EventStream
eventStream :: EventStream
  }
  deriving (GetEventStreamResponse -> GetEventStreamResponse -> Bool
(GetEventStreamResponse -> GetEventStreamResponse -> Bool)
-> (GetEventStreamResponse -> GetEventStreamResponse -> Bool)
-> Eq GetEventStreamResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEventStreamResponse -> GetEventStreamResponse -> Bool
$c/= :: GetEventStreamResponse -> GetEventStreamResponse -> Bool
== :: GetEventStreamResponse -> GetEventStreamResponse -> Bool
$c== :: GetEventStreamResponse -> GetEventStreamResponse -> Bool
Prelude.Eq, ReadPrec [GetEventStreamResponse]
ReadPrec GetEventStreamResponse
Int -> ReadS GetEventStreamResponse
ReadS [GetEventStreamResponse]
(Int -> ReadS GetEventStreamResponse)
-> ReadS [GetEventStreamResponse]
-> ReadPrec GetEventStreamResponse
-> ReadPrec [GetEventStreamResponse]
-> Read GetEventStreamResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEventStreamResponse]
$creadListPrec :: ReadPrec [GetEventStreamResponse]
readPrec :: ReadPrec GetEventStreamResponse
$creadPrec :: ReadPrec GetEventStreamResponse
readList :: ReadS [GetEventStreamResponse]
$creadList :: ReadS [GetEventStreamResponse]
readsPrec :: Int -> ReadS GetEventStreamResponse
$creadsPrec :: Int -> ReadS GetEventStreamResponse
Prelude.Read, Int -> GetEventStreamResponse -> ShowS
[GetEventStreamResponse] -> ShowS
GetEventStreamResponse -> String
(Int -> GetEventStreamResponse -> ShowS)
-> (GetEventStreamResponse -> String)
-> ([GetEventStreamResponse] -> ShowS)
-> Show GetEventStreamResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEventStreamResponse] -> ShowS
$cshowList :: [GetEventStreamResponse] -> ShowS
show :: GetEventStreamResponse -> String
$cshow :: GetEventStreamResponse -> String
showsPrec :: Int -> GetEventStreamResponse -> ShowS
$cshowsPrec :: Int -> GetEventStreamResponse -> ShowS
Prelude.Show, (forall x. GetEventStreamResponse -> Rep GetEventStreamResponse x)
-> (forall x.
    Rep GetEventStreamResponse x -> GetEventStreamResponse)
-> Generic GetEventStreamResponse
forall x. Rep GetEventStreamResponse x -> GetEventStreamResponse
forall x. GetEventStreamResponse -> Rep GetEventStreamResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEventStreamResponse x -> GetEventStreamResponse
$cfrom :: forall x. GetEventStreamResponse -> Rep GetEventStreamResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetEventStreamResponse' 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:
--
-- 'httpStatus', 'getEventStreamResponse_httpStatus' - The response's http status code.
--
-- 'eventStream', 'getEventStreamResponse_eventStream' - Undocumented member.
newGetEventStreamResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'eventStream'
  EventStream ->
  GetEventStreamResponse
newGetEventStreamResponse :: Int -> EventStream -> GetEventStreamResponse
newGetEventStreamResponse Int
pHttpStatus_ EventStream
pEventStream_ =
  GetEventStreamResponse' :: Int -> EventStream -> GetEventStreamResponse
GetEventStreamResponse'
    { $sel:httpStatus:GetEventStreamResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:eventStream:GetEventStreamResponse' :: EventStream
eventStream = EventStream
pEventStream_
    }

-- | The response's http status code.
getEventStreamResponse_httpStatus :: Lens.Lens' GetEventStreamResponse Prelude.Int
getEventStreamResponse_httpStatus :: (Int -> f Int)
-> GetEventStreamResponse -> f GetEventStreamResponse
getEventStreamResponse_httpStatus = (GetEventStreamResponse -> Int)
-> (GetEventStreamResponse -> Int -> GetEventStreamResponse)
-> Lens GetEventStreamResponse GetEventStreamResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventStreamResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetEventStreamResponse' :: GetEventStreamResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetEventStreamResponse
s@GetEventStreamResponse' {} Int
a -> GetEventStreamResponse
s {$sel:httpStatus:GetEventStreamResponse' :: Int
httpStatus = Int
a} :: GetEventStreamResponse)

-- | Undocumented member.
getEventStreamResponse_eventStream :: Lens.Lens' GetEventStreamResponse EventStream
getEventStreamResponse_eventStream :: (EventStream -> f EventStream)
-> GetEventStreamResponse -> f GetEventStreamResponse
getEventStreamResponse_eventStream = (GetEventStreamResponse -> EventStream)
-> (GetEventStreamResponse
    -> EventStream -> GetEventStreamResponse)
-> Lens
     GetEventStreamResponse
     GetEventStreamResponse
     EventStream
     EventStream
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEventStreamResponse' {EventStream
eventStream :: EventStream
$sel:eventStream:GetEventStreamResponse' :: GetEventStreamResponse -> EventStream
eventStream} -> EventStream
eventStream) (\s :: GetEventStreamResponse
s@GetEventStreamResponse' {} EventStream
a -> GetEventStreamResponse
s {$sel:eventStream:GetEventStreamResponse' :: EventStream
eventStream = EventStream
a} :: GetEventStreamResponse)

instance Prelude.NFData GetEventStreamResponse