{-# 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.OpsWorksCM.DescribeEvents
-- 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)
--
-- Describes events for a specified server. Results are ordered by time,
-- with newest events first.
--
-- This operation is synchronous.
--
-- A @ResourceNotFoundException@ is thrown when the server does not exist.
-- A @ValidationException@ is raised when parameters of the request are not
-- valid.
--
-- This operation returns paginated results.
module Amazonka.OpsWorksCM.DescribeEvents
  ( -- * Creating a Request
    DescribeEvents (..),
    newDescribeEvents,

    -- * Request Lenses
    describeEvents_nextToken,
    describeEvents_maxResults,
    describeEvents_serverName,

    -- * Destructuring the Response
    DescribeEventsResponse (..),
    newDescribeEventsResponse,

    -- * Response Lenses
    describeEventsResponse_serverEvents,
    describeEventsResponse_nextToken,
    describeEventsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeEvents' smart constructor.
data DescribeEvents = DescribeEvents'
  { -- | NextToken is a string that is returned in some command responses. It
    -- indicates that not all entries have been returned, and that you must run
    -- at least one more request to get remaining items. To get remaining
    -- results, call @DescribeEvents@ again, and assign the token from the
    -- previous results as the value of the @nextToken@ parameter. If there are
    -- no more results, the response object\'s @nextToken@ parameter value is
    -- @null@. Setting a @nextToken@ value that was not returned in your
    -- previous results causes an @InvalidNextTokenException@ to occur.
    DescribeEvents -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | To receive a paginated response, use this parameter to specify the
    -- maximum number of results to be returned with a single call. If the
    -- number of available results exceeds this maximum, the response includes
    -- a @NextToken@ value that you can assign to the @NextToken@ request
    -- parameter to get the next set of results.
    DescribeEvents -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The name of the server for which you want to view events.
    DescribeEvents -> Text
serverName :: Prelude.Text
  }
  deriving (DescribeEvents -> DescribeEvents -> Bool
(DescribeEvents -> DescribeEvents -> Bool)
-> (DescribeEvents -> DescribeEvents -> Bool) -> Eq DescribeEvents
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeEvents -> DescribeEvents -> Bool
$c/= :: DescribeEvents -> DescribeEvents -> Bool
== :: DescribeEvents -> DescribeEvents -> Bool
$c== :: DescribeEvents -> DescribeEvents -> Bool
Prelude.Eq, ReadPrec [DescribeEvents]
ReadPrec DescribeEvents
Int -> ReadS DescribeEvents
ReadS [DescribeEvents]
(Int -> ReadS DescribeEvents)
-> ReadS [DescribeEvents]
-> ReadPrec DescribeEvents
-> ReadPrec [DescribeEvents]
-> Read DescribeEvents
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeEvents]
$creadListPrec :: ReadPrec [DescribeEvents]
readPrec :: ReadPrec DescribeEvents
$creadPrec :: ReadPrec DescribeEvents
readList :: ReadS [DescribeEvents]
$creadList :: ReadS [DescribeEvents]
readsPrec :: Int -> ReadS DescribeEvents
$creadsPrec :: Int -> ReadS DescribeEvents
Prelude.Read, Int -> DescribeEvents -> ShowS
[DescribeEvents] -> ShowS
DescribeEvents -> String
(Int -> DescribeEvents -> ShowS)
-> (DescribeEvents -> String)
-> ([DescribeEvents] -> ShowS)
-> Show DescribeEvents
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeEvents] -> ShowS
$cshowList :: [DescribeEvents] -> ShowS
show :: DescribeEvents -> String
$cshow :: DescribeEvents -> String
showsPrec :: Int -> DescribeEvents -> ShowS
$cshowsPrec :: Int -> DescribeEvents -> ShowS
Prelude.Show, (forall x. DescribeEvents -> Rep DescribeEvents x)
-> (forall x. Rep DescribeEvents x -> DescribeEvents)
-> Generic DescribeEvents
forall x. Rep DescribeEvents x -> DescribeEvents
forall x. DescribeEvents -> Rep DescribeEvents x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeEvents x -> DescribeEvents
$cfrom :: forall x. DescribeEvents -> Rep DescribeEvents x
Prelude.Generic)

-- |
-- Create a value of 'DescribeEvents' 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:
--
-- 'nextToken', 'describeEvents_nextToken' - NextToken is a string that is returned in some command responses. It
-- indicates that not all entries have been returned, and that you must run
-- at least one more request to get remaining items. To get remaining
-- results, call @DescribeEvents@ again, and assign the token from the
-- previous results as the value of the @nextToken@ parameter. If there are
-- no more results, the response object\'s @nextToken@ parameter value is
-- @null@. Setting a @nextToken@ value that was not returned in your
-- previous results causes an @InvalidNextTokenException@ to occur.
--
-- 'maxResults', 'describeEvents_maxResults' - To receive a paginated response, use this parameter to specify the
-- maximum number of results to be returned with a single call. If the
-- number of available results exceeds this maximum, the response includes
-- a @NextToken@ value that you can assign to the @NextToken@ request
-- parameter to get the next set of results.
--
-- 'serverName', 'describeEvents_serverName' - The name of the server for which you want to view events.
newDescribeEvents ::
  -- | 'serverName'
  Prelude.Text ->
  DescribeEvents
newDescribeEvents :: Text -> DescribeEvents
newDescribeEvents Text
pServerName_ =
  DescribeEvents' :: Maybe Text -> Maybe Natural -> Text -> DescribeEvents
DescribeEvents'
    { $sel:nextToken:DescribeEvents' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeEvents' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:serverName:DescribeEvents' :: Text
serverName = Text
pServerName_
    }

-- | NextToken is a string that is returned in some command responses. It
-- indicates that not all entries have been returned, and that you must run
-- at least one more request to get remaining items. To get remaining
-- results, call @DescribeEvents@ again, and assign the token from the
-- previous results as the value of the @nextToken@ parameter. If there are
-- no more results, the response object\'s @nextToken@ parameter value is
-- @null@. Setting a @nextToken@ value that was not returned in your
-- previous results causes an @InvalidNextTokenException@ to occur.
describeEvents_nextToken :: Lens.Lens' DescribeEvents (Prelude.Maybe Prelude.Text)
describeEvents_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeEvents -> f DescribeEvents
describeEvents_nextToken = (DescribeEvents -> Maybe Text)
-> (DescribeEvents -> Maybe Text -> DescribeEvents)
-> Lens DescribeEvents DescribeEvents (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEvents' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeEvents' :: DescribeEvents -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeEvents
s@DescribeEvents' {} Maybe Text
a -> DescribeEvents
s {$sel:nextToken:DescribeEvents' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeEvents)

-- | To receive a paginated response, use this parameter to specify the
-- maximum number of results to be returned with a single call. If the
-- number of available results exceeds this maximum, the response includes
-- a @NextToken@ value that you can assign to the @NextToken@ request
-- parameter to get the next set of results.
describeEvents_maxResults :: Lens.Lens' DescribeEvents (Prelude.Maybe Prelude.Natural)
describeEvents_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DescribeEvents -> f DescribeEvents
describeEvents_maxResults = (DescribeEvents -> Maybe Natural)
-> (DescribeEvents -> Maybe Natural -> DescribeEvents)
-> Lens
     DescribeEvents DescribeEvents (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEvents' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeEvents' :: DescribeEvents -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeEvents
s@DescribeEvents' {} Maybe Natural
a -> DescribeEvents
s {$sel:maxResults:DescribeEvents' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeEvents)

-- | The name of the server for which you want to view events.
describeEvents_serverName :: Lens.Lens' DescribeEvents Prelude.Text
describeEvents_serverName :: (Text -> f Text) -> DescribeEvents -> f DescribeEvents
describeEvents_serverName = (DescribeEvents -> Text)
-> (DescribeEvents -> Text -> DescribeEvents)
-> Lens DescribeEvents DescribeEvents Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEvents' {Text
serverName :: Text
$sel:serverName:DescribeEvents' :: DescribeEvents -> Text
serverName} -> Text
serverName) (\s :: DescribeEvents
s@DescribeEvents' {} Text
a -> DescribeEvents
s {$sel:serverName:DescribeEvents' :: Text
serverName = Text
a} :: DescribeEvents)

instance Core.AWSPager DescribeEvents where
  page :: DescribeEvents
-> AWSResponse DescribeEvents -> Maybe DescribeEvents
page DescribeEvents
rq AWSResponse DescribeEvents
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeEvents
DescribeEventsResponse
rs
            DescribeEventsResponse
-> Getting (First Text) DescribeEventsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeEventsResponse
-> Const (First Text) DescribeEventsResponse
Lens' DescribeEventsResponse (Maybe Text)
describeEventsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeEventsResponse
 -> Const (First Text) DescribeEventsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeEventsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeEvents
forall a. Maybe a
Prelude.Nothing
    | Maybe [ServerEvent] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeEvents
DescribeEventsResponse
rs
            DescribeEventsResponse
-> Getting
     (First [ServerEvent]) DescribeEventsResponse [ServerEvent]
-> Maybe [ServerEvent]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [ServerEvent]
 -> Const (First [ServerEvent]) (Maybe [ServerEvent]))
-> DescribeEventsResponse
-> Const (First [ServerEvent]) DescribeEventsResponse
Lens' DescribeEventsResponse (Maybe [ServerEvent])
describeEventsResponse_serverEvents
              ((Maybe [ServerEvent]
  -> Const (First [ServerEvent]) (Maybe [ServerEvent]))
 -> DescribeEventsResponse
 -> Const (First [ServerEvent]) DescribeEventsResponse)
-> (([ServerEvent] -> Const (First [ServerEvent]) [ServerEvent])
    -> Maybe [ServerEvent]
    -> Const (First [ServerEvent]) (Maybe [ServerEvent]))
-> Getting
     (First [ServerEvent]) DescribeEventsResponse [ServerEvent]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ServerEvent] -> Const (First [ServerEvent]) [ServerEvent])
-> Maybe [ServerEvent]
-> Const (First [ServerEvent]) (Maybe [ServerEvent])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeEvents
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeEvents -> Maybe DescribeEvents
forall a. a -> Maybe a
Prelude.Just (DescribeEvents -> Maybe DescribeEvents)
-> DescribeEvents -> Maybe DescribeEvents
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeEvents
rq
          DescribeEvents
-> (DescribeEvents -> DescribeEvents) -> DescribeEvents
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeEvents -> Identity DescribeEvents
Lens DescribeEvents DescribeEvents (Maybe Text) (Maybe Text)
describeEvents_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeEvents -> Identity DescribeEvents)
-> Maybe Text -> DescribeEvents -> DescribeEvents
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeEvents
DescribeEventsResponse
rs
          DescribeEventsResponse
-> Getting (First Text) DescribeEventsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeEventsResponse
-> Const (First Text) DescribeEventsResponse
Lens' DescribeEventsResponse (Maybe Text)
describeEventsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeEventsResponse
 -> Const (First Text) DescribeEventsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeEventsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeEvents where
  type
    AWSResponse DescribeEvents =
      DescribeEventsResponse
  request :: DescribeEvents -> Request DescribeEvents
request = Service -> DescribeEvents -> Request DescribeEvents
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeEvents
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeEvents)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeEvents))
-> Logger
-> Service
-> Proxy DescribeEvents
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeEvents)))
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 ->
          Maybe [ServerEvent] -> Maybe Text -> Int -> DescribeEventsResponse
DescribeEventsResponse'
            (Maybe [ServerEvent]
 -> Maybe Text -> Int -> DescribeEventsResponse)
-> Either String (Maybe [ServerEvent])
-> Either String (Maybe Text -> Int -> DescribeEventsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [ServerEvent]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ServerEvents" Either String (Maybe (Maybe [ServerEvent]))
-> Maybe [ServerEvent] -> Either String (Maybe [ServerEvent])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ServerEvent]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> DescribeEventsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeEventsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> DescribeEventsResponse)
-> Either String Int -> Either String DescribeEventsResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable DescribeEvents

instance Prelude.NFData DescribeEvents

instance Core.ToHeaders DescribeEvents where
  toHeaders :: DescribeEvents -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeEvents -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"OpsWorksCM_V2016_11_01.DescribeEvents" ::
                          Prelude.ByteString
                      ),
            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.ToJSON DescribeEvents where
  toJSON :: DescribeEvents -> Value
toJSON DescribeEvents' {Maybe Natural
Maybe Text
Text
serverName :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:serverName:DescribeEvents' :: DescribeEvents -> Text
$sel:maxResults:DescribeEvents' :: DescribeEvents -> Maybe Natural
$sel:nextToken:DescribeEvents' :: DescribeEvents -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" 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
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ServerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serverName)
          ]
      )

instance Core.ToPath DescribeEvents where
  toPath :: DescribeEvents -> ByteString
toPath = ByteString -> DescribeEvents -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeEventsResponse' smart constructor.
data DescribeEventsResponse = DescribeEventsResponse'
  { -- | Contains the response to a @DescribeEvents@ request.
    DescribeEventsResponse -> Maybe [ServerEvent]
serverEvents :: Prelude.Maybe [ServerEvent],
    -- | NextToken is a string that is returned in some command responses. It
    -- indicates that not all entries have been returned, and that you must run
    -- at least one more request to get remaining items. To get remaining
    -- results, call @DescribeEvents@ again, and assign the token from the
    -- previous results as the value of the @nextToken@ parameter. If there are
    -- no more results, the response object\'s @nextToken@ parameter value is
    -- @null@. Setting a @nextToken@ value that was not returned in your
    -- previous results causes an @InvalidNextTokenException@ to occur.
    DescribeEventsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeEventsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeEventsResponse -> DescribeEventsResponse -> Bool
(DescribeEventsResponse -> DescribeEventsResponse -> Bool)
-> (DescribeEventsResponse -> DescribeEventsResponse -> Bool)
-> Eq DescribeEventsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeEventsResponse -> DescribeEventsResponse -> Bool
$c/= :: DescribeEventsResponse -> DescribeEventsResponse -> Bool
== :: DescribeEventsResponse -> DescribeEventsResponse -> Bool
$c== :: DescribeEventsResponse -> DescribeEventsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeEventsResponse]
ReadPrec DescribeEventsResponse
Int -> ReadS DescribeEventsResponse
ReadS [DescribeEventsResponse]
(Int -> ReadS DescribeEventsResponse)
-> ReadS [DescribeEventsResponse]
-> ReadPrec DescribeEventsResponse
-> ReadPrec [DescribeEventsResponse]
-> Read DescribeEventsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeEventsResponse]
$creadListPrec :: ReadPrec [DescribeEventsResponse]
readPrec :: ReadPrec DescribeEventsResponse
$creadPrec :: ReadPrec DescribeEventsResponse
readList :: ReadS [DescribeEventsResponse]
$creadList :: ReadS [DescribeEventsResponse]
readsPrec :: Int -> ReadS DescribeEventsResponse
$creadsPrec :: Int -> ReadS DescribeEventsResponse
Prelude.Read, Int -> DescribeEventsResponse -> ShowS
[DescribeEventsResponse] -> ShowS
DescribeEventsResponse -> String
(Int -> DescribeEventsResponse -> ShowS)
-> (DescribeEventsResponse -> String)
-> ([DescribeEventsResponse] -> ShowS)
-> Show DescribeEventsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeEventsResponse] -> ShowS
$cshowList :: [DescribeEventsResponse] -> ShowS
show :: DescribeEventsResponse -> String
$cshow :: DescribeEventsResponse -> String
showsPrec :: Int -> DescribeEventsResponse -> ShowS
$cshowsPrec :: Int -> DescribeEventsResponse -> ShowS
Prelude.Show, (forall x. DescribeEventsResponse -> Rep DescribeEventsResponse x)
-> (forall x.
    Rep DescribeEventsResponse x -> DescribeEventsResponse)
-> Generic DescribeEventsResponse
forall x. Rep DescribeEventsResponse x -> DescribeEventsResponse
forall x. DescribeEventsResponse -> Rep DescribeEventsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeEventsResponse x -> DescribeEventsResponse
$cfrom :: forall x. DescribeEventsResponse -> Rep DescribeEventsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeEventsResponse' 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:
--
-- 'serverEvents', 'describeEventsResponse_serverEvents' - Contains the response to a @DescribeEvents@ request.
--
-- 'nextToken', 'describeEventsResponse_nextToken' - NextToken is a string that is returned in some command responses. It
-- indicates that not all entries have been returned, and that you must run
-- at least one more request to get remaining items. To get remaining
-- results, call @DescribeEvents@ again, and assign the token from the
-- previous results as the value of the @nextToken@ parameter. If there are
-- no more results, the response object\'s @nextToken@ parameter value is
-- @null@. Setting a @nextToken@ value that was not returned in your
-- previous results causes an @InvalidNextTokenException@ to occur.
--
-- 'httpStatus', 'describeEventsResponse_httpStatus' - The response's http status code.
newDescribeEventsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeEventsResponse
newDescribeEventsResponse :: Int -> DescribeEventsResponse
newDescribeEventsResponse Int
pHttpStatus_ =
  DescribeEventsResponse' :: Maybe [ServerEvent] -> Maybe Text -> Int -> DescribeEventsResponse
DescribeEventsResponse'
    { $sel:serverEvents:DescribeEventsResponse' :: Maybe [ServerEvent]
serverEvents =
        Maybe [ServerEvent]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeEventsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeEventsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Contains the response to a @DescribeEvents@ request.
describeEventsResponse_serverEvents :: Lens.Lens' DescribeEventsResponse (Prelude.Maybe [ServerEvent])
describeEventsResponse_serverEvents :: (Maybe [ServerEvent] -> f (Maybe [ServerEvent]))
-> DescribeEventsResponse -> f DescribeEventsResponse
describeEventsResponse_serverEvents = (DescribeEventsResponse -> Maybe [ServerEvent])
-> (DescribeEventsResponse
    -> Maybe [ServerEvent] -> DescribeEventsResponse)
-> Lens' DescribeEventsResponse (Maybe [ServerEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventsResponse' {Maybe [ServerEvent]
serverEvents :: Maybe [ServerEvent]
$sel:serverEvents:DescribeEventsResponse' :: DescribeEventsResponse -> Maybe [ServerEvent]
serverEvents} -> Maybe [ServerEvent]
serverEvents) (\s :: DescribeEventsResponse
s@DescribeEventsResponse' {} Maybe [ServerEvent]
a -> DescribeEventsResponse
s {$sel:serverEvents:DescribeEventsResponse' :: Maybe [ServerEvent]
serverEvents = Maybe [ServerEvent]
a} :: DescribeEventsResponse) ((Maybe [ServerEvent] -> f (Maybe [ServerEvent]))
 -> DescribeEventsResponse -> f DescribeEventsResponse)
-> ((Maybe [ServerEvent] -> f (Maybe [ServerEvent]))
    -> Maybe [ServerEvent] -> f (Maybe [ServerEvent]))
-> (Maybe [ServerEvent] -> f (Maybe [ServerEvent]))
-> DescribeEventsResponse
-> f DescribeEventsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ServerEvent] [ServerEvent] [ServerEvent] [ServerEvent]
-> Iso
     (Maybe [ServerEvent])
     (Maybe [ServerEvent])
     (Maybe [ServerEvent])
     (Maybe [ServerEvent])
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 [ServerEvent] [ServerEvent] [ServerEvent] [ServerEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | NextToken is a string that is returned in some command responses. It
-- indicates that not all entries have been returned, and that you must run
-- at least one more request to get remaining items. To get remaining
-- results, call @DescribeEvents@ again, and assign the token from the
-- previous results as the value of the @nextToken@ parameter. If there are
-- no more results, the response object\'s @nextToken@ parameter value is
-- @null@. Setting a @nextToken@ value that was not returned in your
-- previous results causes an @InvalidNextTokenException@ to occur.
describeEventsResponse_nextToken :: Lens.Lens' DescribeEventsResponse (Prelude.Maybe Prelude.Text)
describeEventsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeEventsResponse -> f DescribeEventsResponse
describeEventsResponse_nextToken = (DescribeEventsResponse -> Maybe Text)
-> (DescribeEventsResponse -> Maybe Text -> DescribeEventsResponse)
-> Lens' DescribeEventsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeEventsResponse' :: DescribeEventsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeEventsResponse
s@DescribeEventsResponse' {} Maybe Text
a -> DescribeEventsResponse
s {$sel:nextToken:DescribeEventsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeEventsResponse)

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

instance Prelude.NFData DescribeEventsResponse