{-# 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.AWSHealth.DescribeEventAggregates
-- 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)
--
-- Returns the number of events of each event type (issue, scheduled
-- change, and account notification). If no filter is specified, the counts
-- of all events in each category are returned.
--
-- This API operation uses pagination. Specify the @nextToken@ parameter in
-- the next request to return more results.
--
-- This operation returns paginated results.
module Amazonka.AWSHealth.DescribeEventAggregates
  ( -- * Creating a Request
    DescribeEventAggregates (..),
    newDescribeEventAggregates,

    -- * Request Lenses
    describeEventAggregates_nextToken,
    describeEventAggregates_filter,
    describeEventAggregates_maxResults,
    describeEventAggregates_aggregateField,

    -- * Destructuring the Response
    DescribeEventAggregatesResponse (..),
    newDescribeEventAggregatesResponse,

    -- * Response Lenses
    describeEventAggregatesResponse_nextToken,
    describeEventAggregatesResponse_eventAggregates,
    describeEventAggregatesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeEventAggregates' smart constructor.
data DescribeEventAggregates = DescribeEventAggregates'
  { -- | If the results of a search are large, only a portion of the results are
    -- returned, and a @nextToken@ pagination token is returned in the
    -- response. To retrieve the next batch of results, reissue the search
    -- request and include the returned token. When all results have been
    -- returned, the response does not contain a pagination token value.
    DescribeEventAggregates -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Values to narrow the results returned.
    DescribeEventAggregates -> Maybe EventFilter
filter' :: Prelude.Maybe EventFilter,
    -- | The maximum number of items to return in one batch, between 10 and 100,
    -- inclusive.
    DescribeEventAggregates -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The only currently supported value is @eventTypeCategory@.
    DescribeEventAggregates -> EventAggregateField
aggregateField :: EventAggregateField
  }
  deriving (DescribeEventAggregates -> DescribeEventAggregates -> Bool
(DescribeEventAggregates -> DescribeEventAggregates -> Bool)
-> (DescribeEventAggregates -> DescribeEventAggregates -> Bool)
-> Eq DescribeEventAggregates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeEventAggregates -> DescribeEventAggregates -> Bool
$c/= :: DescribeEventAggregates -> DescribeEventAggregates -> Bool
== :: DescribeEventAggregates -> DescribeEventAggregates -> Bool
$c== :: DescribeEventAggregates -> DescribeEventAggregates -> Bool
Prelude.Eq, ReadPrec [DescribeEventAggregates]
ReadPrec DescribeEventAggregates
Int -> ReadS DescribeEventAggregates
ReadS [DescribeEventAggregates]
(Int -> ReadS DescribeEventAggregates)
-> ReadS [DescribeEventAggregates]
-> ReadPrec DescribeEventAggregates
-> ReadPrec [DescribeEventAggregates]
-> Read DescribeEventAggregates
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeEventAggregates]
$creadListPrec :: ReadPrec [DescribeEventAggregates]
readPrec :: ReadPrec DescribeEventAggregates
$creadPrec :: ReadPrec DescribeEventAggregates
readList :: ReadS [DescribeEventAggregates]
$creadList :: ReadS [DescribeEventAggregates]
readsPrec :: Int -> ReadS DescribeEventAggregates
$creadsPrec :: Int -> ReadS DescribeEventAggregates
Prelude.Read, Int -> DescribeEventAggregates -> ShowS
[DescribeEventAggregates] -> ShowS
DescribeEventAggregates -> String
(Int -> DescribeEventAggregates -> ShowS)
-> (DescribeEventAggregates -> String)
-> ([DescribeEventAggregates] -> ShowS)
-> Show DescribeEventAggregates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeEventAggregates] -> ShowS
$cshowList :: [DescribeEventAggregates] -> ShowS
show :: DescribeEventAggregates -> String
$cshow :: DescribeEventAggregates -> String
showsPrec :: Int -> DescribeEventAggregates -> ShowS
$cshowsPrec :: Int -> DescribeEventAggregates -> ShowS
Prelude.Show, (forall x.
 DescribeEventAggregates -> Rep DescribeEventAggregates x)
-> (forall x.
    Rep DescribeEventAggregates x -> DescribeEventAggregates)
-> Generic DescribeEventAggregates
forall x. Rep DescribeEventAggregates x -> DescribeEventAggregates
forall x. DescribeEventAggregates -> Rep DescribeEventAggregates x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeEventAggregates x -> DescribeEventAggregates
$cfrom :: forall x. DescribeEventAggregates -> Rep DescribeEventAggregates x
Prelude.Generic)

-- |
-- Create a value of 'DescribeEventAggregates' 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', 'describeEventAggregates_nextToken' - If the results of a search are large, only a portion of the results are
-- returned, and a @nextToken@ pagination token is returned in the
-- response. To retrieve the next batch of results, reissue the search
-- request and include the returned token. When all results have been
-- returned, the response does not contain a pagination token value.
--
-- 'filter'', 'describeEventAggregates_filter' - Values to narrow the results returned.
--
-- 'maxResults', 'describeEventAggregates_maxResults' - The maximum number of items to return in one batch, between 10 and 100,
-- inclusive.
--
-- 'aggregateField', 'describeEventAggregates_aggregateField' - The only currently supported value is @eventTypeCategory@.
newDescribeEventAggregates ::
  -- | 'aggregateField'
  EventAggregateField ->
  DescribeEventAggregates
newDescribeEventAggregates :: EventAggregateField -> DescribeEventAggregates
newDescribeEventAggregates EventAggregateField
pAggregateField_ =
  DescribeEventAggregates' :: Maybe Text
-> Maybe EventFilter
-> Maybe Natural
-> EventAggregateField
-> DescribeEventAggregates
DescribeEventAggregates'
    { $sel:nextToken:DescribeEventAggregates' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filter':DescribeEventAggregates' :: Maybe EventFilter
filter' = Maybe EventFilter
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeEventAggregates' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:aggregateField:DescribeEventAggregates' :: EventAggregateField
aggregateField = EventAggregateField
pAggregateField_
    }

-- | If the results of a search are large, only a portion of the results are
-- returned, and a @nextToken@ pagination token is returned in the
-- response. To retrieve the next batch of results, reissue the search
-- request and include the returned token. When all results have been
-- returned, the response does not contain a pagination token value.
describeEventAggregates_nextToken :: Lens.Lens' DescribeEventAggregates (Prelude.Maybe Prelude.Text)
describeEventAggregates_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeEventAggregates -> f DescribeEventAggregates
describeEventAggregates_nextToken = (DescribeEventAggregates -> Maybe Text)
-> (DescribeEventAggregates
    -> Maybe Text -> DescribeEventAggregates)
-> Lens
     DescribeEventAggregates
     DescribeEventAggregates
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventAggregates' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeEventAggregates' :: DescribeEventAggregates -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeEventAggregates
s@DescribeEventAggregates' {} Maybe Text
a -> DescribeEventAggregates
s {$sel:nextToken:DescribeEventAggregates' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeEventAggregates)

-- | Values to narrow the results returned.
describeEventAggregates_filter :: Lens.Lens' DescribeEventAggregates (Prelude.Maybe EventFilter)
describeEventAggregates_filter :: (Maybe EventFilter -> f (Maybe EventFilter))
-> DescribeEventAggregates -> f DescribeEventAggregates
describeEventAggregates_filter = (DescribeEventAggregates -> Maybe EventFilter)
-> (DescribeEventAggregates
    -> Maybe EventFilter -> DescribeEventAggregates)
-> Lens
     DescribeEventAggregates
     DescribeEventAggregates
     (Maybe EventFilter)
     (Maybe EventFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventAggregates' {Maybe EventFilter
filter' :: Maybe EventFilter
$sel:filter':DescribeEventAggregates' :: DescribeEventAggregates -> Maybe EventFilter
filter'} -> Maybe EventFilter
filter') (\s :: DescribeEventAggregates
s@DescribeEventAggregates' {} Maybe EventFilter
a -> DescribeEventAggregates
s {$sel:filter':DescribeEventAggregates' :: Maybe EventFilter
filter' = Maybe EventFilter
a} :: DescribeEventAggregates)

-- | The maximum number of items to return in one batch, between 10 and 100,
-- inclusive.
describeEventAggregates_maxResults :: Lens.Lens' DescribeEventAggregates (Prelude.Maybe Prelude.Natural)
describeEventAggregates_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DescribeEventAggregates -> f DescribeEventAggregates
describeEventAggregates_maxResults = (DescribeEventAggregates -> Maybe Natural)
-> (DescribeEventAggregates
    -> Maybe Natural -> DescribeEventAggregates)
-> Lens
     DescribeEventAggregates
     DescribeEventAggregates
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventAggregates' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeEventAggregates' :: DescribeEventAggregates -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeEventAggregates
s@DescribeEventAggregates' {} Maybe Natural
a -> DescribeEventAggregates
s {$sel:maxResults:DescribeEventAggregates' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeEventAggregates)

-- | The only currently supported value is @eventTypeCategory@.
describeEventAggregates_aggregateField :: Lens.Lens' DescribeEventAggregates EventAggregateField
describeEventAggregates_aggregateField :: (EventAggregateField -> f EventAggregateField)
-> DescribeEventAggregates -> f DescribeEventAggregates
describeEventAggregates_aggregateField = (DescribeEventAggregates -> EventAggregateField)
-> (DescribeEventAggregates
    -> EventAggregateField -> DescribeEventAggregates)
-> Lens
     DescribeEventAggregates
     DescribeEventAggregates
     EventAggregateField
     EventAggregateField
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventAggregates' {EventAggregateField
aggregateField :: EventAggregateField
$sel:aggregateField:DescribeEventAggregates' :: DescribeEventAggregates -> EventAggregateField
aggregateField} -> EventAggregateField
aggregateField) (\s :: DescribeEventAggregates
s@DescribeEventAggregates' {} EventAggregateField
a -> DescribeEventAggregates
s {$sel:aggregateField:DescribeEventAggregates' :: EventAggregateField
aggregateField = EventAggregateField
a} :: DescribeEventAggregates)

instance Core.AWSPager DescribeEventAggregates where
  page :: DescribeEventAggregates
-> AWSResponse DescribeEventAggregates
-> Maybe DescribeEventAggregates
page DescribeEventAggregates
rq AWSResponse DescribeEventAggregates
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeEventAggregates
DescribeEventAggregatesResponse
rs
            DescribeEventAggregatesResponse
-> Getting (First Text) DescribeEventAggregatesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeEventAggregatesResponse
-> Const (First Text) DescribeEventAggregatesResponse
Lens' DescribeEventAggregatesResponse (Maybe Text)
describeEventAggregatesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeEventAggregatesResponse
 -> Const (First Text) DescribeEventAggregatesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeEventAggregatesResponse 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 DescribeEventAggregates
forall a. Maybe a
Prelude.Nothing
    | Maybe [EventAggregate] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeEventAggregates
DescribeEventAggregatesResponse
rs
            DescribeEventAggregatesResponse
-> Getting
     (First [EventAggregate])
     DescribeEventAggregatesResponse
     [EventAggregate]
-> Maybe [EventAggregate]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [EventAggregate]
 -> Const (First [EventAggregate]) (Maybe [EventAggregate]))
-> DescribeEventAggregatesResponse
-> Const (First [EventAggregate]) DescribeEventAggregatesResponse
Lens' DescribeEventAggregatesResponse (Maybe [EventAggregate])
describeEventAggregatesResponse_eventAggregates
              ((Maybe [EventAggregate]
  -> Const (First [EventAggregate]) (Maybe [EventAggregate]))
 -> DescribeEventAggregatesResponse
 -> Const (First [EventAggregate]) DescribeEventAggregatesResponse)
-> (([EventAggregate]
     -> Const (First [EventAggregate]) [EventAggregate])
    -> Maybe [EventAggregate]
    -> Const (First [EventAggregate]) (Maybe [EventAggregate]))
-> Getting
     (First [EventAggregate])
     DescribeEventAggregatesResponse
     [EventAggregate]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([EventAggregate]
 -> Const (First [EventAggregate]) [EventAggregate])
-> Maybe [EventAggregate]
-> Const (First [EventAggregate]) (Maybe [EventAggregate])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeEventAggregates
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeEventAggregates -> Maybe DescribeEventAggregates
forall a. a -> Maybe a
Prelude.Just (DescribeEventAggregates -> Maybe DescribeEventAggregates)
-> DescribeEventAggregates -> Maybe DescribeEventAggregates
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeEventAggregates
rq
          DescribeEventAggregates
-> (DescribeEventAggregates -> DescribeEventAggregates)
-> DescribeEventAggregates
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeEventAggregates -> Identity DescribeEventAggregates
Lens
  DescribeEventAggregates
  DescribeEventAggregates
  (Maybe Text)
  (Maybe Text)
describeEventAggregates_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeEventAggregates -> Identity DescribeEventAggregates)
-> Maybe Text -> DescribeEventAggregates -> DescribeEventAggregates
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeEventAggregates
DescribeEventAggregatesResponse
rs
          DescribeEventAggregatesResponse
-> Getting (First Text) DescribeEventAggregatesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeEventAggregatesResponse
-> Const (First Text) DescribeEventAggregatesResponse
Lens' DescribeEventAggregatesResponse (Maybe Text)
describeEventAggregatesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeEventAggregatesResponse
 -> Const (First Text) DescribeEventAggregatesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeEventAggregatesResponse 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 DescribeEventAggregates where
  type
    AWSResponse DescribeEventAggregates =
      DescribeEventAggregatesResponse
  request :: DescribeEventAggregates -> Request DescribeEventAggregates
request = Service
-> DescribeEventAggregates -> Request DescribeEventAggregates
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeEventAggregates
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeEventAggregates)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeEventAggregates))
-> Logger
-> Service
-> Proxy DescribeEventAggregates
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeEventAggregates)))
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 Text
-> Maybe [EventAggregate] -> Int -> DescribeEventAggregatesResponse
DescribeEventAggregatesResponse'
            (Maybe Text
 -> Maybe [EventAggregate]
 -> Int
 -> DescribeEventAggregatesResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [EventAggregate] -> Int -> DescribeEventAggregatesResponse)
forall (f :: * -> *) a b. Functor 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
  (Maybe [EventAggregate] -> Int -> DescribeEventAggregatesResponse)
-> Either String (Maybe [EventAggregate])
-> Either String (Int -> DescribeEventAggregatesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (Maybe [EventAggregate]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"eventAggregates"
                            Either String (Maybe (Maybe [EventAggregate]))
-> Maybe [EventAggregate] -> Either String (Maybe [EventAggregate])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [EventAggregate]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> DescribeEventAggregatesResponse)
-> Either String Int
-> Either String DescribeEventAggregatesResponse
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 DescribeEventAggregates

instance Prelude.NFData DescribeEventAggregates

instance Core.ToHeaders DescribeEventAggregates where
  toHeaders :: DescribeEventAggregates -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeEventAggregates -> 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
"AWSHealth_20160804.DescribeEventAggregates" ::
                          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 DescribeEventAggregates where
  toJSON :: DescribeEventAggregates -> Value
toJSON DescribeEventAggregates' {Maybe Natural
Maybe Text
Maybe EventFilter
EventAggregateField
aggregateField :: EventAggregateField
maxResults :: Maybe Natural
filter' :: Maybe EventFilter
nextToken :: Maybe Text
$sel:aggregateField:DescribeEventAggregates' :: DescribeEventAggregates -> EventAggregateField
$sel:maxResults:DescribeEventAggregates' :: DescribeEventAggregates -> Maybe Natural
$sel:filter':DescribeEventAggregates' :: DescribeEventAggregates -> Maybe EventFilter
$sel:nextToken:DescribeEventAggregates' :: DescribeEventAggregates -> 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
"filter" Text -> EventFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (EventFilter -> Pair) -> Maybe EventFilter -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EventFilter
filter',
            (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
"aggregateField" Text -> EventAggregateField -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EventAggregateField
aggregateField)
          ]
      )

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

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

-- | /See:/ 'newDescribeEventAggregatesResponse' smart constructor.
data DescribeEventAggregatesResponse = DescribeEventAggregatesResponse'
  { -- | If the results of a search are large, only a portion of the results are
    -- returned, and a @nextToken@ pagination token is returned in the
    -- response. To retrieve the next batch of results, reissue the search
    -- request and include the returned token. When all results have been
    -- returned, the response does not contain a pagination token value.
    DescribeEventAggregatesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The number of events in each category that meet the optional filter
    -- criteria.
    DescribeEventAggregatesResponse -> Maybe [EventAggregate]
eventAggregates :: Prelude.Maybe [EventAggregate],
    -- | The response's http status code.
    DescribeEventAggregatesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeEventAggregatesResponse
-> DescribeEventAggregatesResponse -> Bool
(DescribeEventAggregatesResponse
 -> DescribeEventAggregatesResponse -> Bool)
-> (DescribeEventAggregatesResponse
    -> DescribeEventAggregatesResponse -> Bool)
-> Eq DescribeEventAggregatesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeEventAggregatesResponse
-> DescribeEventAggregatesResponse -> Bool
$c/= :: DescribeEventAggregatesResponse
-> DescribeEventAggregatesResponse -> Bool
== :: DescribeEventAggregatesResponse
-> DescribeEventAggregatesResponse -> Bool
$c== :: DescribeEventAggregatesResponse
-> DescribeEventAggregatesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeEventAggregatesResponse]
ReadPrec DescribeEventAggregatesResponse
Int -> ReadS DescribeEventAggregatesResponse
ReadS [DescribeEventAggregatesResponse]
(Int -> ReadS DescribeEventAggregatesResponse)
-> ReadS [DescribeEventAggregatesResponse]
-> ReadPrec DescribeEventAggregatesResponse
-> ReadPrec [DescribeEventAggregatesResponse]
-> Read DescribeEventAggregatesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeEventAggregatesResponse]
$creadListPrec :: ReadPrec [DescribeEventAggregatesResponse]
readPrec :: ReadPrec DescribeEventAggregatesResponse
$creadPrec :: ReadPrec DescribeEventAggregatesResponse
readList :: ReadS [DescribeEventAggregatesResponse]
$creadList :: ReadS [DescribeEventAggregatesResponse]
readsPrec :: Int -> ReadS DescribeEventAggregatesResponse
$creadsPrec :: Int -> ReadS DescribeEventAggregatesResponse
Prelude.Read, Int -> DescribeEventAggregatesResponse -> ShowS
[DescribeEventAggregatesResponse] -> ShowS
DescribeEventAggregatesResponse -> String
(Int -> DescribeEventAggregatesResponse -> ShowS)
-> (DescribeEventAggregatesResponse -> String)
-> ([DescribeEventAggregatesResponse] -> ShowS)
-> Show DescribeEventAggregatesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeEventAggregatesResponse] -> ShowS
$cshowList :: [DescribeEventAggregatesResponse] -> ShowS
show :: DescribeEventAggregatesResponse -> String
$cshow :: DescribeEventAggregatesResponse -> String
showsPrec :: Int -> DescribeEventAggregatesResponse -> ShowS
$cshowsPrec :: Int -> DescribeEventAggregatesResponse -> ShowS
Prelude.Show, (forall x.
 DescribeEventAggregatesResponse
 -> Rep DescribeEventAggregatesResponse x)
-> (forall x.
    Rep DescribeEventAggregatesResponse x
    -> DescribeEventAggregatesResponse)
-> Generic DescribeEventAggregatesResponse
forall x.
Rep DescribeEventAggregatesResponse x
-> DescribeEventAggregatesResponse
forall x.
DescribeEventAggregatesResponse
-> Rep DescribeEventAggregatesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeEventAggregatesResponse x
-> DescribeEventAggregatesResponse
$cfrom :: forall x.
DescribeEventAggregatesResponse
-> Rep DescribeEventAggregatesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeEventAggregatesResponse' 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', 'describeEventAggregatesResponse_nextToken' - If the results of a search are large, only a portion of the results are
-- returned, and a @nextToken@ pagination token is returned in the
-- response. To retrieve the next batch of results, reissue the search
-- request and include the returned token. When all results have been
-- returned, the response does not contain a pagination token value.
--
-- 'eventAggregates', 'describeEventAggregatesResponse_eventAggregates' - The number of events in each category that meet the optional filter
-- criteria.
--
-- 'httpStatus', 'describeEventAggregatesResponse_httpStatus' - The response's http status code.
newDescribeEventAggregatesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeEventAggregatesResponse
newDescribeEventAggregatesResponse :: Int -> DescribeEventAggregatesResponse
newDescribeEventAggregatesResponse Int
pHttpStatus_ =
  DescribeEventAggregatesResponse' :: Maybe Text
-> Maybe [EventAggregate] -> Int -> DescribeEventAggregatesResponse
DescribeEventAggregatesResponse'
    { $sel:nextToken:DescribeEventAggregatesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:eventAggregates:DescribeEventAggregatesResponse' :: Maybe [EventAggregate]
eventAggregates = Maybe [EventAggregate]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeEventAggregatesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If the results of a search are large, only a portion of the results are
-- returned, and a @nextToken@ pagination token is returned in the
-- response. To retrieve the next batch of results, reissue the search
-- request and include the returned token. When all results have been
-- returned, the response does not contain a pagination token value.
describeEventAggregatesResponse_nextToken :: Lens.Lens' DescribeEventAggregatesResponse (Prelude.Maybe Prelude.Text)
describeEventAggregatesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeEventAggregatesResponse
-> f DescribeEventAggregatesResponse
describeEventAggregatesResponse_nextToken = (DescribeEventAggregatesResponse -> Maybe Text)
-> (DescribeEventAggregatesResponse
    -> Maybe Text -> DescribeEventAggregatesResponse)
-> Lens' DescribeEventAggregatesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventAggregatesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeEventAggregatesResponse' :: DescribeEventAggregatesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeEventAggregatesResponse
s@DescribeEventAggregatesResponse' {} Maybe Text
a -> DescribeEventAggregatesResponse
s {$sel:nextToken:DescribeEventAggregatesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeEventAggregatesResponse)

-- | The number of events in each category that meet the optional filter
-- criteria.
describeEventAggregatesResponse_eventAggregates :: Lens.Lens' DescribeEventAggregatesResponse (Prelude.Maybe [EventAggregate])
describeEventAggregatesResponse_eventAggregates :: (Maybe [EventAggregate] -> f (Maybe [EventAggregate]))
-> DescribeEventAggregatesResponse
-> f DescribeEventAggregatesResponse
describeEventAggregatesResponse_eventAggregates = (DescribeEventAggregatesResponse -> Maybe [EventAggregate])
-> (DescribeEventAggregatesResponse
    -> Maybe [EventAggregate] -> DescribeEventAggregatesResponse)
-> Lens' DescribeEventAggregatesResponse (Maybe [EventAggregate])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventAggregatesResponse' {Maybe [EventAggregate]
eventAggregates :: Maybe [EventAggregate]
$sel:eventAggregates:DescribeEventAggregatesResponse' :: DescribeEventAggregatesResponse -> Maybe [EventAggregate]
eventAggregates} -> Maybe [EventAggregate]
eventAggregates) (\s :: DescribeEventAggregatesResponse
s@DescribeEventAggregatesResponse' {} Maybe [EventAggregate]
a -> DescribeEventAggregatesResponse
s {$sel:eventAggregates:DescribeEventAggregatesResponse' :: Maybe [EventAggregate]
eventAggregates = Maybe [EventAggregate]
a} :: DescribeEventAggregatesResponse) ((Maybe [EventAggregate] -> f (Maybe [EventAggregate]))
 -> DescribeEventAggregatesResponse
 -> f DescribeEventAggregatesResponse)
-> ((Maybe [EventAggregate] -> f (Maybe [EventAggregate]))
    -> Maybe [EventAggregate] -> f (Maybe [EventAggregate]))
-> (Maybe [EventAggregate] -> f (Maybe [EventAggregate]))
-> DescribeEventAggregatesResponse
-> f DescribeEventAggregatesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EventAggregate] [EventAggregate] [EventAggregate] [EventAggregate]
-> Iso
     (Maybe [EventAggregate])
     (Maybe [EventAggregate])
     (Maybe [EventAggregate])
     (Maybe [EventAggregate])
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
  [EventAggregate] [EventAggregate] [EventAggregate] [EventAggregate]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribeEventAggregatesResponse