{-# 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.DescribeAffectedAccountsForOrganization
-- 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 a list of accounts in the organization from AWS Organizations
-- that are affected by the provided 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.DescribeAffectedAccountsForOrganization
  ( -- * Creating a Request
    DescribeAffectedAccountsForOrganization (..),
    newDescribeAffectedAccountsForOrganization,

    -- * Request Lenses
    describeAffectedAccountsForOrganization_nextToken,
    describeAffectedAccountsForOrganization_maxResults,
    describeAffectedAccountsForOrganization_eventArn,

    -- * Destructuring the Response
    DescribeAffectedAccountsForOrganizationResponse (..),
    newDescribeAffectedAccountsForOrganizationResponse,

    -- * Response Lenses
    describeAffectedAccountsForOrganizationResponse_affectedAccounts,
    describeAffectedAccountsForOrganizationResponse_eventScopeCode,
    describeAffectedAccountsForOrganizationResponse_nextToken,
    describeAffectedAccountsForOrganizationResponse_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:/ 'newDescribeAffectedAccountsForOrganization' smart constructor.
data DescribeAffectedAccountsForOrganization = DescribeAffectedAccountsForOrganization'
  { -- | 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.
    DescribeAffectedAccountsForOrganization -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return in one batch, between 10 and 100,
    -- inclusive.
    DescribeAffectedAccountsForOrganization -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The unique identifier for the event. The event ARN has the
    -- @arn:aws:health:event-region::event\/SERVICE\/EVENT_TYPE_CODE\/EVENT_TYPE_PLUS_ID @
    -- format.
    --
    -- For example, an event ARN might look like the following:
    --
    -- @arn:aws:health:us-east-1::event\/EC2\/EC2_INSTANCE_RETIREMENT_SCHEDULED\/EC2_INSTANCE_RETIREMENT_SCHEDULED_ABC123-DEF456@
    DescribeAffectedAccountsForOrganization -> Text
eventArn :: Prelude.Text
  }
  deriving (DescribeAffectedAccountsForOrganization
-> DescribeAffectedAccountsForOrganization -> Bool
(DescribeAffectedAccountsForOrganization
 -> DescribeAffectedAccountsForOrganization -> Bool)
-> (DescribeAffectedAccountsForOrganization
    -> DescribeAffectedAccountsForOrganization -> Bool)
-> Eq DescribeAffectedAccountsForOrganization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAffectedAccountsForOrganization
-> DescribeAffectedAccountsForOrganization -> Bool
$c/= :: DescribeAffectedAccountsForOrganization
-> DescribeAffectedAccountsForOrganization -> Bool
== :: DescribeAffectedAccountsForOrganization
-> DescribeAffectedAccountsForOrganization -> Bool
$c== :: DescribeAffectedAccountsForOrganization
-> DescribeAffectedAccountsForOrganization -> Bool
Prelude.Eq, ReadPrec [DescribeAffectedAccountsForOrganization]
ReadPrec DescribeAffectedAccountsForOrganization
Int -> ReadS DescribeAffectedAccountsForOrganization
ReadS [DescribeAffectedAccountsForOrganization]
(Int -> ReadS DescribeAffectedAccountsForOrganization)
-> ReadS [DescribeAffectedAccountsForOrganization]
-> ReadPrec DescribeAffectedAccountsForOrganization
-> ReadPrec [DescribeAffectedAccountsForOrganization]
-> Read DescribeAffectedAccountsForOrganization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAffectedAccountsForOrganization]
$creadListPrec :: ReadPrec [DescribeAffectedAccountsForOrganization]
readPrec :: ReadPrec DescribeAffectedAccountsForOrganization
$creadPrec :: ReadPrec DescribeAffectedAccountsForOrganization
readList :: ReadS [DescribeAffectedAccountsForOrganization]
$creadList :: ReadS [DescribeAffectedAccountsForOrganization]
readsPrec :: Int -> ReadS DescribeAffectedAccountsForOrganization
$creadsPrec :: Int -> ReadS DescribeAffectedAccountsForOrganization
Prelude.Read, Int -> DescribeAffectedAccountsForOrganization -> ShowS
[DescribeAffectedAccountsForOrganization] -> ShowS
DescribeAffectedAccountsForOrganization -> String
(Int -> DescribeAffectedAccountsForOrganization -> ShowS)
-> (DescribeAffectedAccountsForOrganization -> String)
-> ([DescribeAffectedAccountsForOrganization] -> ShowS)
-> Show DescribeAffectedAccountsForOrganization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAffectedAccountsForOrganization] -> ShowS
$cshowList :: [DescribeAffectedAccountsForOrganization] -> ShowS
show :: DescribeAffectedAccountsForOrganization -> String
$cshow :: DescribeAffectedAccountsForOrganization -> String
showsPrec :: Int -> DescribeAffectedAccountsForOrganization -> ShowS
$cshowsPrec :: Int -> DescribeAffectedAccountsForOrganization -> ShowS
Prelude.Show, (forall x.
 DescribeAffectedAccountsForOrganization
 -> Rep DescribeAffectedAccountsForOrganization x)
-> (forall x.
    Rep DescribeAffectedAccountsForOrganization x
    -> DescribeAffectedAccountsForOrganization)
-> Generic DescribeAffectedAccountsForOrganization
forall x.
Rep DescribeAffectedAccountsForOrganization x
-> DescribeAffectedAccountsForOrganization
forall x.
DescribeAffectedAccountsForOrganization
-> Rep DescribeAffectedAccountsForOrganization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAffectedAccountsForOrganization x
-> DescribeAffectedAccountsForOrganization
$cfrom :: forall x.
DescribeAffectedAccountsForOrganization
-> Rep DescribeAffectedAccountsForOrganization x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAffectedAccountsForOrganization' 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', 'describeAffectedAccountsForOrganization_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.
--
-- 'maxResults', 'describeAffectedAccountsForOrganization_maxResults' - The maximum number of items to return in one batch, between 10 and 100,
-- inclusive.
--
-- 'eventArn', 'describeAffectedAccountsForOrganization_eventArn' - The unique identifier for the event. The event ARN has the
-- @arn:aws:health:event-region::event\/SERVICE\/EVENT_TYPE_CODE\/EVENT_TYPE_PLUS_ID @
-- format.
--
-- For example, an event ARN might look like the following:
--
-- @arn:aws:health:us-east-1::event\/EC2\/EC2_INSTANCE_RETIREMENT_SCHEDULED\/EC2_INSTANCE_RETIREMENT_SCHEDULED_ABC123-DEF456@
newDescribeAffectedAccountsForOrganization ::
  -- | 'eventArn'
  Prelude.Text ->
  DescribeAffectedAccountsForOrganization
newDescribeAffectedAccountsForOrganization :: Text -> DescribeAffectedAccountsForOrganization
newDescribeAffectedAccountsForOrganization Text
pEventArn_ =
  DescribeAffectedAccountsForOrganization' :: Maybe Text
-> Maybe Natural -> Text -> DescribeAffectedAccountsForOrganization
DescribeAffectedAccountsForOrganization'
    { $sel:nextToken:DescribeAffectedAccountsForOrganization' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeAffectedAccountsForOrganization' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:eventArn:DescribeAffectedAccountsForOrganization' :: Text
eventArn = Text
pEventArn_
    }

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

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

-- | The unique identifier for the event. The event ARN has the
-- @arn:aws:health:event-region::event\/SERVICE\/EVENT_TYPE_CODE\/EVENT_TYPE_PLUS_ID @
-- format.
--
-- For example, an event ARN might look like the following:
--
-- @arn:aws:health:us-east-1::event\/EC2\/EC2_INSTANCE_RETIREMENT_SCHEDULED\/EC2_INSTANCE_RETIREMENT_SCHEDULED_ABC123-DEF456@
describeAffectedAccountsForOrganization_eventArn :: Lens.Lens' DescribeAffectedAccountsForOrganization Prelude.Text
describeAffectedAccountsForOrganization_eventArn :: (Text -> f Text)
-> DescribeAffectedAccountsForOrganization
-> f DescribeAffectedAccountsForOrganization
describeAffectedAccountsForOrganization_eventArn = (DescribeAffectedAccountsForOrganization -> Text)
-> (DescribeAffectedAccountsForOrganization
    -> Text -> DescribeAffectedAccountsForOrganization)
-> Lens
     DescribeAffectedAccountsForOrganization
     DescribeAffectedAccountsForOrganization
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAffectedAccountsForOrganization' {Text
eventArn :: Text
$sel:eventArn:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Text
eventArn} -> Text
eventArn) (\s :: DescribeAffectedAccountsForOrganization
s@DescribeAffectedAccountsForOrganization' {} Text
a -> DescribeAffectedAccountsForOrganization
s {$sel:eventArn:DescribeAffectedAccountsForOrganization' :: Text
eventArn = Text
a} :: DescribeAffectedAccountsForOrganization)

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

instance
  Prelude.NFData
    DescribeAffectedAccountsForOrganization

instance
  Core.ToHeaders
    DescribeAffectedAccountsForOrganization
  where
  toHeaders :: DescribeAffectedAccountsForOrganization -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DescribeAffectedAccountsForOrganization -> 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.DescribeAffectedAccountsForOrganization" ::
                          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
    DescribeAffectedAccountsForOrganization
  where
  toJSON :: DescribeAffectedAccountsForOrganization -> Value
toJSON DescribeAffectedAccountsForOrganization' {Maybe Natural
Maybe Text
Text
eventArn :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:eventArn:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Text
$sel:maxResults:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Maybe Natural
$sel:nextToken:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> 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
"eventArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
eventArn)
          ]
      )

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

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

-- | /See:/ 'newDescribeAffectedAccountsForOrganizationResponse' smart constructor.
data DescribeAffectedAccountsForOrganizationResponse = DescribeAffectedAccountsForOrganizationResponse'
  { -- | A JSON set of elements of the affected accounts.
    DescribeAffectedAccountsForOrganizationResponse -> Maybe [Text]
affectedAccounts :: Prelude.Maybe [Prelude.Text],
    -- | This parameter specifies if the AWS Health event is a public AWS service
    -- event or an account-specific event.
    --
    -- -   If the @eventScopeCode@ value is @PUBLIC@, then the
    --     @affectedAccounts@ value is always empty.
    --
    -- -   If the @eventScopeCode@ value is @ACCOUNT_SPECIFIC@, then the
    --     @affectedAccounts@ value lists the affected AWS accounts in your
    --     organization. For example, if an event affects a service such as
    --     Amazon Elastic Compute Cloud and you have AWS accounts that use that
    --     service, those account IDs appear in the response.
    --
    -- -   If the @eventScopeCode@ value is @NONE@, then the @eventArn@ that
    --     you specified in the request is invalid or doesn\'t exist.
    DescribeAffectedAccountsForOrganizationResponse
-> Maybe EventScopeCode
eventScopeCode :: Prelude.Maybe EventScopeCode,
    -- | 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.
    DescribeAffectedAccountsForOrganizationResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeAffectedAccountsForOrganizationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAffectedAccountsForOrganizationResponse
-> DescribeAffectedAccountsForOrganizationResponse -> Bool
(DescribeAffectedAccountsForOrganizationResponse
 -> DescribeAffectedAccountsForOrganizationResponse -> Bool)
-> (DescribeAffectedAccountsForOrganizationResponse
    -> DescribeAffectedAccountsForOrganizationResponse -> Bool)
-> Eq DescribeAffectedAccountsForOrganizationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAffectedAccountsForOrganizationResponse
-> DescribeAffectedAccountsForOrganizationResponse -> Bool
$c/= :: DescribeAffectedAccountsForOrganizationResponse
-> DescribeAffectedAccountsForOrganizationResponse -> Bool
== :: DescribeAffectedAccountsForOrganizationResponse
-> DescribeAffectedAccountsForOrganizationResponse -> Bool
$c== :: DescribeAffectedAccountsForOrganizationResponse
-> DescribeAffectedAccountsForOrganizationResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAffectedAccountsForOrganizationResponse]
ReadPrec DescribeAffectedAccountsForOrganizationResponse
Int -> ReadS DescribeAffectedAccountsForOrganizationResponse
ReadS [DescribeAffectedAccountsForOrganizationResponse]
(Int -> ReadS DescribeAffectedAccountsForOrganizationResponse)
-> ReadS [DescribeAffectedAccountsForOrganizationResponse]
-> ReadPrec DescribeAffectedAccountsForOrganizationResponse
-> ReadPrec [DescribeAffectedAccountsForOrganizationResponse]
-> Read DescribeAffectedAccountsForOrganizationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAffectedAccountsForOrganizationResponse]
$creadListPrec :: ReadPrec [DescribeAffectedAccountsForOrganizationResponse]
readPrec :: ReadPrec DescribeAffectedAccountsForOrganizationResponse
$creadPrec :: ReadPrec DescribeAffectedAccountsForOrganizationResponse
readList :: ReadS [DescribeAffectedAccountsForOrganizationResponse]
$creadList :: ReadS [DescribeAffectedAccountsForOrganizationResponse]
readsPrec :: Int -> ReadS DescribeAffectedAccountsForOrganizationResponse
$creadsPrec :: Int -> ReadS DescribeAffectedAccountsForOrganizationResponse
Prelude.Read, Int -> DescribeAffectedAccountsForOrganizationResponse -> ShowS
[DescribeAffectedAccountsForOrganizationResponse] -> ShowS
DescribeAffectedAccountsForOrganizationResponse -> String
(Int -> DescribeAffectedAccountsForOrganizationResponse -> ShowS)
-> (DescribeAffectedAccountsForOrganizationResponse -> String)
-> ([DescribeAffectedAccountsForOrganizationResponse] -> ShowS)
-> Show DescribeAffectedAccountsForOrganizationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAffectedAccountsForOrganizationResponse] -> ShowS
$cshowList :: [DescribeAffectedAccountsForOrganizationResponse] -> ShowS
show :: DescribeAffectedAccountsForOrganizationResponse -> String
$cshow :: DescribeAffectedAccountsForOrganizationResponse -> String
showsPrec :: Int -> DescribeAffectedAccountsForOrganizationResponse -> ShowS
$cshowsPrec :: Int -> DescribeAffectedAccountsForOrganizationResponse -> ShowS
Prelude.Show, (forall x.
 DescribeAffectedAccountsForOrganizationResponse
 -> Rep DescribeAffectedAccountsForOrganizationResponse x)
-> (forall x.
    Rep DescribeAffectedAccountsForOrganizationResponse x
    -> DescribeAffectedAccountsForOrganizationResponse)
-> Generic DescribeAffectedAccountsForOrganizationResponse
forall x.
Rep DescribeAffectedAccountsForOrganizationResponse x
-> DescribeAffectedAccountsForOrganizationResponse
forall x.
DescribeAffectedAccountsForOrganizationResponse
-> Rep DescribeAffectedAccountsForOrganizationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAffectedAccountsForOrganizationResponse x
-> DescribeAffectedAccountsForOrganizationResponse
$cfrom :: forall x.
DescribeAffectedAccountsForOrganizationResponse
-> Rep DescribeAffectedAccountsForOrganizationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAffectedAccountsForOrganizationResponse' 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:
--
-- 'affectedAccounts', 'describeAffectedAccountsForOrganizationResponse_affectedAccounts' - A JSON set of elements of the affected accounts.
--
-- 'eventScopeCode', 'describeAffectedAccountsForOrganizationResponse_eventScopeCode' - This parameter specifies if the AWS Health event is a public AWS service
-- event or an account-specific event.
--
-- -   If the @eventScopeCode@ value is @PUBLIC@, then the
--     @affectedAccounts@ value is always empty.
--
-- -   If the @eventScopeCode@ value is @ACCOUNT_SPECIFIC@, then the
--     @affectedAccounts@ value lists the affected AWS accounts in your
--     organization. For example, if an event affects a service such as
--     Amazon Elastic Compute Cloud and you have AWS accounts that use that
--     service, those account IDs appear in the response.
--
-- -   If the @eventScopeCode@ value is @NONE@, then the @eventArn@ that
--     you specified in the request is invalid or doesn\'t exist.
--
-- 'nextToken', 'describeAffectedAccountsForOrganizationResponse_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.
--
-- 'httpStatus', 'describeAffectedAccountsForOrganizationResponse_httpStatus' - The response's http status code.
newDescribeAffectedAccountsForOrganizationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAffectedAccountsForOrganizationResponse
newDescribeAffectedAccountsForOrganizationResponse :: Int -> DescribeAffectedAccountsForOrganizationResponse
newDescribeAffectedAccountsForOrganizationResponse
  Int
pHttpStatus_ =
    DescribeAffectedAccountsForOrganizationResponse' :: Maybe [Text]
-> Maybe EventScopeCode
-> Maybe Text
-> Int
-> DescribeAffectedAccountsForOrganizationResponse
DescribeAffectedAccountsForOrganizationResponse'
      { $sel:affectedAccounts:DescribeAffectedAccountsForOrganizationResponse' :: Maybe [Text]
affectedAccounts =
          Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:eventScopeCode:DescribeAffectedAccountsForOrganizationResponse' :: Maybe EventScopeCode
eventScopeCode =
          Maybe EventScopeCode
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:DescribeAffectedAccountsForOrganizationResponse' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeAffectedAccountsForOrganizationResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | A JSON set of elements of the affected accounts.
describeAffectedAccountsForOrganizationResponse_affectedAccounts :: Lens.Lens' DescribeAffectedAccountsForOrganizationResponse (Prelude.Maybe [Prelude.Text])
describeAffectedAccountsForOrganizationResponse_affectedAccounts :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeAffectedAccountsForOrganizationResponse
-> f DescribeAffectedAccountsForOrganizationResponse
describeAffectedAccountsForOrganizationResponse_affectedAccounts = (DescribeAffectedAccountsForOrganizationResponse -> Maybe [Text])
-> (DescribeAffectedAccountsForOrganizationResponse
    -> Maybe [Text] -> DescribeAffectedAccountsForOrganizationResponse)
-> Lens'
     DescribeAffectedAccountsForOrganizationResponse (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAffectedAccountsForOrganizationResponse' {Maybe [Text]
affectedAccounts :: Maybe [Text]
$sel:affectedAccounts:DescribeAffectedAccountsForOrganizationResponse' :: DescribeAffectedAccountsForOrganizationResponse -> Maybe [Text]
affectedAccounts} -> Maybe [Text]
affectedAccounts) (\s :: DescribeAffectedAccountsForOrganizationResponse
s@DescribeAffectedAccountsForOrganizationResponse' {} Maybe [Text]
a -> DescribeAffectedAccountsForOrganizationResponse
s {$sel:affectedAccounts:DescribeAffectedAccountsForOrganizationResponse' :: Maybe [Text]
affectedAccounts = Maybe [Text]
a} :: DescribeAffectedAccountsForOrganizationResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeAffectedAccountsForOrganizationResponse
 -> f DescribeAffectedAccountsForOrganizationResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeAffectedAccountsForOrganizationResponse
-> f DescribeAffectedAccountsForOrganizationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | This parameter specifies if the AWS Health event is a public AWS service
-- event or an account-specific event.
--
-- -   If the @eventScopeCode@ value is @PUBLIC@, then the
--     @affectedAccounts@ value is always empty.
--
-- -   If the @eventScopeCode@ value is @ACCOUNT_SPECIFIC@, then the
--     @affectedAccounts@ value lists the affected AWS accounts in your
--     organization. For example, if an event affects a service such as
--     Amazon Elastic Compute Cloud and you have AWS accounts that use that
--     service, those account IDs appear in the response.
--
-- -   If the @eventScopeCode@ value is @NONE@, then the @eventArn@ that
--     you specified in the request is invalid or doesn\'t exist.
describeAffectedAccountsForOrganizationResponse_eventScopeCode :: Lens.Lens' DescribeAffectedAccountsForOrganizationResponse (Prelude.Maybe EventScopeCode)
describeAffectedAccountsForOrganizationResponse_eventScopeCode :: (Maybe EventScopeCode -> f (Maybe EventScopeCode))
-> DescribeAffectedAccountsForOrganizationResponse
-> f DescribeAffectedAccountsForOrganizationResponse
describeAffectedAccountsForOrganizationResponse_eventScopeCode = (DescribeAffectedAccountsForOrganizationResponse
 -> Maybe EventScopeCode)
-> (DescribeAffectedAccountsForOrganizationResponse
    -> Maybe EventScopeCode
    -> DescribeAffectedAccountsForOrganizationResponse)
-> Lens
     DescribeAffectedAccountsForOrganizationResponse
     DescribeAffectedAccountsForOrganizationResponse
     (Maybe EventScopeCode)
     (Maybe EventScopeCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAffectedAccountsForOrganizationResponse' {Maybe EventScopeCode
eventScopeCode :: Maybe EventScopeCode
$sel:eventScopeCode:DescribeAffectedAccountsForOrganizationResponse' :: DescribeAffectedAccountsForOrganizationResponse
-> Maybe EventScopeCode
eventScopeCode} -> Maybe EventScopeCode
eventScopeCode) (\s :: DescribeAffectedAccountsForOrganizationResponse
s@DescribeAffectedAccountsForOrganizationResponse' {} Maybe EventScopeCode
a -> DescribeAffectedAccountsForOrganizationResponse
s {$sel:eventScopeCode:DescribeAffectedAccountsForOrganizationResponse' :: Maybe EventScopeCode
eventScopeCode = Maybe EventScopeCode
a} :: DescribeAffectedAccountsForOrganizationResponse)

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

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

instance
  Prelude.NFData
    DescribeAffectedAccountsForOrganizationResponse