{-# 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.DescribeEventsForOrganization
-- 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 information about events across your organization in AWS
-- Organizations. You can use the@filters@ parameter to specify the events
-- that you want to return. Events are returned in a summary form and
-- don\'t include the affected accounts, detailed description, any
-- additional metadata that depends on the event type, or any affected
-- resources. To retrieve that information, use the following operations:
--
-- -   <https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeAffectedAccountsForOrganization.html DescribeAffectedAccountsForOrganization>
--
-- -   <https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeEventDetailsForOrganization.html DescribeEventDetailsForOrganization>
--
-- -   <https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeAffectedEntitiesForOrganization.html DescribeAffectedEntitiesForOrganization>
--
-- If you don\'t specify a @filter@, the @DescribeEventsForOrganizations@
-- returns all events across your organization. Results are sorted by
-- @lastModifiedTime@, starting with the most recent event.
--
-- For more information about the different types of AWS Health events, see
-- <https://docs.aws.amazon.com/health/latest/APIReference/API_Event.html Event>.
--
-- Before you can call this operation, you must first enable AWS Health to
-- work with AWS Organizations. To do this, call the
-- <https://docs.aws.amazon.com/health/latest/APIReference/API_EnableHealthServiceAccessForOrganization.html EnableHealthServiceAccessForOrganization>
-- operation from your organization\'s management account.
--
-- 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.DescribeEventsForOrganization
  ( -- * Creating a Request
    DescribeEventsForOrganization (..),
    newDescribeEventsForOrganization,

    -- * Request Lenses
    describeEventsForOrganization_locale,
    describeEventsForOrganization_nextToken,
    describeEventsForOrganization_filter,
    describeEventsForOrganization_maxResults,

    -- * Destructuring the Response
    DescribeEventsForOrganizationResponse (..),
    newDescribeEventsForOrganizationResponse,

    -- * Response Lenses
    describeEventsForOrganizationResponse_nextToken,
    describeEventsForOrganizationResponse_events,
    describeEventsForOrganizationResponse_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:/ 'newDescribeEventsForOrganization' smart constructor.
data DescribeEventsForOrganization = DescribeEventsForOrganization'
  { -- | The locale (language) to return information in. English (en) is the
    -- default and the only supported value at this time.
    DescribeEventsForOrganization -> Maybe Text
locale :: Prelude.Maybe Prelude.Text,
    -- | 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.
    DescribeEventsForOrganization -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Values to narrow the results returned.
    DescribeEventsForOrganization -> Maybe OrganizationEventFilter
filter' :: Prelude.Maybe OrganizationEventFilter,
    -- | The maximum number of items to return in one batch, between 10 and 100,
    -- inclusive.
    DescribeEventsForOrganization -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (DescribeEventsForOrganization
-> DescribeEventsForOrganization -> Bool
(DescribeEventsForOrganization
 -> DescribeEventsForOrganization -> Bool)
-> (DescribeEventsForOrganization
    -> DescribeEventsForOrganization -> Bool)
-> Eq DescribeEventsForOrganization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeEventsForOrganization
-> DescribeEventsForOrganization -> Bool
$c/= :: DescribeEventsForOrganization
-> DescribeEventsForOrganization -> Bool
== :: DescribeEventsForOrganization
-> DescribeEventsForOrganization -> Bool
$c== :: DescribeEventsForOrganization
-> DescribeEventsForOrganization -> Bool
Prelude.Eq, ReadPrec [DescribeEventsForOrganization]
ReadPrec DescribeEventsForOrganization
Int -> ReadS DescribeEventsForOrganization
ReadS [DescribeEventsForOrganization]
(Int -> ReadS DescribeEventsForOrganization)
-> ReadS [DescribeEventsForOrganization]
-> ReadPrec DescribeEventsForOrganization
-> ReadPrec [DescribeEventsForOrganization]
-> Read DescribeEventsForOrganization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeEventsForOrganization]
$creadListPrec :: ReadPrec [DescribeEventsForOrganization]
readPrec :: ReadPrec DescribeEventsForOrganization
$creadPrec :: ReadPrec DescribeEventsForOrganization
readList :: ReadS [DescribeEventsForOrganization]
$creadList :: ReadS [DescribeEventsForOrganization]
readsPrec :: Int -> ReadS DescribeEventsForOrganization
$creadsPrec :: Int -> ReadS DescribeEventsForOrganization
Prelude.Read, Int -> DescribeEventsForOrganization -> ShowS
[DescribeEventsForOrganization] -> ShowS
DescribeEventsForOrganization -> String
(Int -> DescribeEventsForOrganization -> ShowS)
-> (DescribeEventsForOrganization -> String)
-> ([DescribeEventsForOrganization] -> ShowS)
-> Show DescribeEventsForOrganization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeEventsForOrganization] -> ShowS
$cshowList :: [DescribeEventsForOrganization] -> ShowS
show :: DescribeEventsForOrganization -> String
$cshow :: DescribeEventsForOrganization -> String
showsPrec :: Int -> DescribeEventsForOrganization -> ShowS
$cshowsPrec :: Int -> DescribeEventsForOrganization -> ShowS
Prelude.Show, (forall x.
 DescribeEventsForOrganization
 -> Rep DescribeEventsForOrganization x)
-> (forall x.
    Rep DescribeEventsForOrganization x
    -> DescribeEventsForOrganization)
-> Generic DescribeEventsForOrganization
forall x.
Rep DescribeEventsForOrganization x
-> DescribeEventsForOrganization
forall x.
DescribeEventsForOrganization
-> Rep DescribeEventsForOrganization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeEventsForOrganization x
-> DescribeEventsForOrganization
$cfrom :: forall x.
DescribeEventsForOrganization
-> Rep DescribeEventsForOrganization x
Prelude.Generic)

-- |
-- Create a value of 'DescribeEventsForOrganization' 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:
--
-- 'locale', 'describeEventsForOrganization_locale' - The locale (language) to return information in. English (en) is the
-- default and the only supported value at this time.
--
-- 'nextToken', 'describeEventsForOrganization_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'', 'describeEventsForOrganization_filter' - Values to narrow the results returned.
--
-- 'maxResults', 'describeEventsForOrganization_maxResults' - The maximum number of items to return in one batch, between 10 and 100,
-- inclusive.
newDescribeEventsForOrganization ::
  DescribeEventsForOrganization
newDescribeEventsForOrganization :: DescribeEventsForOrganization
newDescribeEventsForOrganization =
  DescribeEventsForOrganization' :: Maybe Text
-> Maybe Text
-> Maybe OrganizationEventFilter
-> Maybe Natural
-> DescribeEventsForOrganization
DescribeEventsForOrganization'
    { $sel:locale:DescribeEventsForOrganization' :: Maybe Text
locale =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeEventsForOrganization' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filter':DescribeEventsForOrganization' :: Maybe OrganizationEventFilter
filter' = Maybe OrganizationEventFilter
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeEventsForOrganization' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The locale (language) to return information in. English (en) is the
-- default and the only supported value at this time.
describeEventsForOrganization_locale :: Lens.Lens' DescribeEventsForOrganization (Prelude.Maybe Prelude.Text)
describeEventsForOrganization_locale :: (Maybe Text -> f (Maybe Text))
-> DescribeEventsForOrganization -> f DescribeEventsForOrganization
describeEventsForOrganization_locale = (DescribeEventsForOrganization -> Maybe Text)
-> (DescribeEventsForOrganization
    -> Maybe Text -> DescribeEventsForOrganization)
-> Lens
     DescribeEventsForOrganization
     DescribeEventsForOrganization
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventsForOrganization' {Maybe Text
locale :: Maybe Text
$sel:locale:DescribeEventsForOrganization' :: DescribeEventsForOrganization -> Maybe Text
locale} -> Maybe Text
locale) (\s :: DescribeEventsForOrganization
s@DescribeEventsForOrganization' {} Maybe Text
a -> DescribeEventsForOrganization
s {$sel:locale:DescribeEventsForOrganization' :: Maybe Text
locale = Maybe Text
a} :: DescribeEventsForOrganization)

-- | 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.
describeEventsForOrganization_nextToken :: Lens.Lens' DescribeEventsForOrganization (Prelude.Maybe Prelude.Text)
describeEventsForOrganization_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeEventsForOrganization -> f DescribeEventsForOrganization
describeEventsForOrganization_nextToken = (DescribeEventsForOrganization -> Maybe Text)
-> (DescribeEventsForOrganization
    -> Maybe Text -> DescribeEventsForOrganization)
-> Lens
     DescribeEventsForOrganization
     DescribeEventsForOrganization
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventsForOrganization' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeEventsForOrganization' :: DescribeEventsForOrganization -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeEventsForOrganization
s@DescribeEventsForOrganization' {} Maybe Text
a -> DescribeEventsForOrganization
s {$sel:nextToken:DescribeEventsForOrganization' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeEventsForOrganization)

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

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

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

instance Prelude.NFData DescribeEventsForOrganization

instance Core.ToHeaders DescribeEventsForOrganization where
  toHeaders :: DescribeEventsForOrganization -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeEventsForOrganization -> 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.DescribeEventsForOrganization" ::
                          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 DescribeEventsForOrganization where
  toJSON :: DescribeEventsForOrganization -> Value
toJSON DescribeEventsForOrganization' {Maybe Natural
Maybe Text
Maybe OrganizationEventFilter
maxResults :: Maybe Natural
filter' :: Maybe OrganizationEventFilter
nextToken :: Maybe Text
locale :: Maybe Text
$sel:maxResults:DescribeEventsForOrganization' :: DescribeEventsForOrganization -> Maybe Natural
$sel:filter':DescribeEventsForOrganization' :: DescribeEventsForOrganization -> Maybe OrganizationEventFilter
$sel:nextToken:DescribeEventsForOrganization' :: DescribeEventsForOrganization -> Maybe Text
$sel:locale:DescribeEventsForOrganization' :: DescribeEventsForOrganization -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"locale" 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
locale,
            (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 -> OrganizationEventFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (OrganizationEventFilter -> Pair)
-> Maybe OrganizationEventFilter -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OrganizationEventFilter
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
          ]
      )

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

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

-- | /See:/ 'newDescribeEventsForOrganizationResponse' smart constructor.
data DescribeEventsForOrganizationResponse = DescribeEventsForOrganizationResponse'
  { -- | 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.
    DescribeEventsForOrganizationResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The events that match the specified filter criteria.
    DescribeEventsForOrganizationResponse -> Maybe [OrganizationEvent]
events :: Prelude.Maybe [OrganizationEvent],
    -- | The response's http status code.
    DescribeEventsForOrganizationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeEventsForOrganizationResponse
-> DescribeEventsForOrganizationResponse -> Bool
(DescribeEventsForOrganizationResponse
 -> DescribeEventsForOrganizationResponse -> Bool)
-> (DescribeEventsForOrganizationResponse
    -> DescribeEventsForOrganizationResponse -> Bool)
-> Eq DescribeEventsForOrganizationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeEventsForOrganizationResponse
-> DescribeEventsForOrganizationResponse -> Bool
$c/= :: DescribeEventsForOrganizationResponse
-> DescribeEventsForOrganizationResponse -> Bool
== :: DescribeEventsForOrganizationResponse
-> DescribeEventsForOrganizationResponse -> Bool
$c== :: DescribeEventsForOrganizationResponse
-> DescribeEventsForOrganizationResponse -> Bool
Prelude.Eq, ReadPrec [DescribeEventsForOrganizationResponse]
ReadPrec DescribeEventsForOrganizationResponse
Int -> ReadS DescribeEventsForOrganizationResponse
ReadS [DescribeEventsForOrganizationResponse]
(Int -> ReadS DescribeEventsForOrganizationResponse)
-> ReadS [DescribeEventsForOrganizationResponse]
-> ReadPrec DescribeEventsForOrganizationResponse
-> ReadPrec [DescribeEventsForOrganizationResponse]
-> Read DescribeEventsForOrganizationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeEventsForOrganizationResponse]
$creadListPrec :: ReadPrec [DescribeEventsForOrganizationResponse]
readPrec :: ReadPrec DescribeEventsForOrganizationResponse
$creadPrec :: ReadPrec DescribeEventsForOrganizationResponse
readList :: ReadS [DescribeEventsForOrganizationResponse]
$creadList :: ReadS [DescribeEventsForOrganizationResponse]
readsPrec :: Int -> ReadS DescribeEventsForOrganizationResponse
$creadsPrec :: Int -> ReadS DescribeEventsForOrganizationResponse
Prelude.Read, Int -> DescribeEventsForOrganizationResponse -> ShowS
[DescribeEventsForOrganizationResponse] -> ShowS
DescribeEventsForOrganizationResponse -> String
(Int -> DescribeEventsForOrganizationResponse -> ShowS)
-> (DescribeEventsForOrganizationResponse -> String)
-> ([DescribeEventsForOrganizationResponse] -> ShowS)
-> Show DescribeEventsForOrganizationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeEventsForOrganizationResponse] -> ShowS
$cshowList :: [DescribeEventsForOrganizationResponse] -> ShowS
show :: DescribeEventsForOrganizationResponse -> String
$cshow :: DescribeEventsForOrganizationResponse -> String
showsPrec :: Int -> DescribeEventsForOrganizationResponse -> ShowS
$cshowsPrec :: Int -> DescribeEventsForOrganizationResponse -> ShowS
Prelude.Show, (forall x.
 DescribeEventsForOrganizationResponse
 -> Rep DescribeEventsForOrganizationResponse x)
-> (forall x.
    Rep DescribeEventsForOrganizationResponse x
    -> DescribeEventsForOrganizationResponse)
-> Generic DescribeEventsForOrganizationResponse
forall x.
Rep DescribeEventsForOrganizationResponse x
-> DescribeEventsForOrganizationResponse
forall x.
DescribeEventsForOrganizationResponse
-> Rep DescribeEventsForOrganizationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeEventsForOrganizationResponse x
-> DescribeEventsForOrganizationResponse
$cfrom :: forall x.
DescribeEventsForOrganizationResponse
-> Rep DescribeEventsForOrganizationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeEventsForOrganizationResponse' 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', 'describeEventsForOrganizationResponse_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.
--
-- 'events', 'describeEventsForOrganizationResponse_events' - The events that match the specified filter criteria.
--
-- 'httpStatus', 'describeEventsForOrganizationResponse_httpStatus' - The response's http status code.
newDescribeEventsForOrganizationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeEventsForOrganizationResponse
newDescribeEventsForOrganizationResponse :: Int -> DescribeEventsForOrganizationResponse
newDescribeEventsForOrganizationResponse Int
pHttpStatus_ =
  DescribeEventsForOrganizationResponse' :: Maybe Text
-> Maybe [OrganizationEvent]
-> Int
-> DescribeEventsForOrganizationResponse
DescribeEventsForOrganizationResponse'
    { $sel:nextToken:DescribeEventsForOrganizationResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:events:DescribeEventsForOrganizationResponse' :: Maybe [OrganizationEvent]
events = Maybe [OrganizationEvent]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeEventsForOrganizationResponse' :: 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.
describeEventsForOrganizationResponse_nextToken :: Lens.Lens' DescribeEventsForOrganizationResponse (Prelude.Maybe Prelude.Text)
describeEventsForOrganizationResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeEventsForOrganizationResponse
-> f DescribeEventsForOrganizationResponse
describeEventsForOrganizationResponse_nextToken = (DescribeEventsForOrganizationResponse -> Maybe Text)
-> (DescribeEventsForOrganizationResponse
    -> Maybe Text -> DescribeEventsForOrganizationResponse)
-> Lens' DescribeEventsForOrganizationResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventsForOrganizationResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeEventsForOrganizationResponse' :: DescribeEventsForOrganizationResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeEventsForOrganizationResponse
s@DescribeEventsForOrganizationResponse' {} Maybe Text
a -> DescribeEventsForOrganizationResponse
s {$sel:nextToken:DescribeEventsForOrganizationResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeEventsForOrganizationResponse)

-- | The events that match the specified filter criteria.
describeEventsForOrganizationResponse_events :: Lens.Lens' DescribeEventsForOrganizationResponse (Prelude.Maybe [OrganizationEvent])
describeEventsForOrganizationResponse_events :: (Maybe [OrganizationEvent] -> f (Maybe [OrganizationEvent]))
-> DescribeEventsForOrganizationResponse
-> f DescribeEventsForOrganizationResponse
describeEventsForOrganizationResponse_events = (DescribeEventsForOrganizationResponse
 -> Maybe [OrganizationEvent])
-> (DescribeEventsForOrganizationResponse
    -> Maybe [OrganizationEvent]
    -> DescribeEventsForOrganizationResponse)
-> Lens'
     DescribeEventsForOrganizationResponse (Maybe [OrganizationEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEventsForOrganizationResponse' {Maybe [OrganizationEvent]
events :: Maybe [OrganizationEvent]
$sel:events:DescribeEventsForOrganizationResponse' :: DescribeEventsForOrganizationResponse -> Maybe [OrganizationEvent]
events} -> Maybe [OrganizationEvent]
events) (\s :: DescribeEventsForOrganizationResponse
s@DescribeEventsForOrganizationResponse' {} Maybe [OrganizationEvent]
a -> DescribeEventsForOrganizationResponse
s {$sel:events:DescribeEventsForOrganizationResponse' :: Maybe [OrganizationEvent]
events = Maybe [OrganizationEvent]
a} :: DescribeEventsForOrganizationResponse) ((Maybe [OrganizationEvent] -> f (Maybe [OrganizationEvent]))
 -> DescribeEventsForOrganizationResponse
 -> f DescribeEventsForOrganizationResponse)
-> ((Maybe [OrganizationEvent] -> f (Maybe [OrganizationEvent]))
    -> Maybe [OrganizationEvent] -> f (Maybe [OrganizationEvent]))
-> (Maybe [OrganizationEvent] -> f (Maybe [OrganizationEvent]))
-> DescribeEventsForOrganizationResponse
-> f DescribeEventsForOrganizationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [OrganizationEvent]
  [OrganizationEvent]
  [OrganizationEvent]
  [OrganizationEvent]
-> Iso
     (Maybe [OrganizationEvent])
     (Maybe [OrganizationEvent])
     (Maybe [OrganizationEvent])
     (Maybe [OrganizationEvent])
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
  [OrganizationEvent]
  [OrganizationEvent]
  [OrganizationEvent]
  [OrganizationEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribeEventsForOrganizationResponse