{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of accounts in the organization from Organizations that
-- are affected by the provided event. For more information about the
-- different types of 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 Health to work
-- with 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_maxResults,
    describeAffectedAccountsForOrganization_nextToken,
    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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | The maximum number of items to return in one batch, between 10 and 100,
    -- inclusive.
    DescribeAffectedAccountsForOrganization -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | 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 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
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]
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
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.
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:
--
-- 'maxResults', 'describeAffectedAccountsForOrganization_maxResults' - The maximum number of items to return in one batch, between 10 and 100,
-- inclusive.
--
-- '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.
--
-- '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'
    { $sel:maxResults:DescribeAffectedAccountsForOrganization' :: Maybe Natural
maxResults =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeAffectedAccountsForOrganization' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:eventArn:DescribeAffectedAccountsForOrganization' :: Text
eventArn = Text
pEventArn_
    }

-- | 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 :: Lens' DescribeAffectedAccountsForOrganization (Maybe Natural)
describeAffectedAccountsForOrganization_maxResults = 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)

-- | 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 :: Lens' DescribeAffectedAccountsForOrganization (Maybe Text)
describeAffectedAccountsForOrganization_nextToken = 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 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 :: Lens' DescribeAffectedAccountsForOrganization Text
describeAffectedAccountsForOrganization_eventArn = 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
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeAffectedAccountsForOrganization
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeAffectedAccountsForOrganizationResponse (Maybe Text)
describeAffectedAccountsForOrganizationResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeAffectedAccountsForOrganization
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens'
  DescribeAffectedAccountsForOrganizationResponse (Maybe [Text])
describeAffectedAccountsForOrganizationResponse_affectedAccounts
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ DescribeAffectedAccountsForOrganization
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' DescribeAffectedAccountsForOrganization (Maybe Text)
describeAffectedAccountsForOrganization_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeAffectedAccountsForOrganization
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeAffectedAccountsForOrganizationResponse (Maybe Text)
describeAffectedAccountsForOrganizationResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance
  Core.AWSRequest
    DescribeAffectedAccountsForOrganization
  where
  type
    AWSResponse
      DescribeAffectedAccountsForOrganization =
      DescribeAffectedAccountsForOrganizationResponse
  request :: (Service -> Service)
-> DescribeAffectedAccountsForOrganization
-> Request DescribeAffectedAccountsForOrganization
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeAffectedAccountsForOrganization
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse DescribeAffectedAccountsForOrganization)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"affectedAccounts"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"eventScopeCode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    DescribeAffectedAccountsForOrganization
  where
  hashWithSalt :: Int -> DescribeAffectedAccountsForOrganization -> Int
hashWithSalt
    Int
_salt
    DescribeAffectedAccountsForOrganization' {Maybe Natural
Maybe Text
Text
eventArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:eventArn:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Text
$sel:nextToken:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Maybe Text
$sel:maxResults:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Maybe Natural
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
eventArn

instance
  Prelude.NFData
    DescribeAffectedAccountsForOrganization
  where
  rnf :: DescribeAffectedAccountsForOrganization -> ()
rnf DescribeAffectedAccountsForOrganization' {Maybe Natural
Maybe Text
Text
eventArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:eventArn:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Text
$sel:nextToken:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Maybe Text
$sel:maxResults:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
eventArn

instance
  Data.ToHeaders
    DescribeAffectedAccountsForOrganization
  where
  toHeaders :: DescribeAffectedAccountsForOrganization -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSHealth_20160804.DescribeAffectedAccountsForOrganization" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance
  Data.ToJSON
    DescribeAffectedAccountsForOrganization
  where
  toJSON :: DescribeAffectedAccountsForOrganization -> Value
toJSON DescribeAffectedAccountsForOrganization' {Maybe Natural
Maybe Text
Text
eventArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:eventArn:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Text
$sel:nextToken:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Maybe Text
$sel:maxResults:DescribeAffectedAccountsForOrganization' :: DescribeAffectedAccountsForOrganization -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"nextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"eventArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
eventArn)
          ]
      )

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

instance
  Data.ToQuery
    DescribeAffectedAccountsForOrganization
  where
  toQuery :: DescribeAffectedAccountsForOrganization -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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 Health event is a public Amazon Web
    -- Services 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 Amazon Web Services
    --     accounts in your organization. For example, if an event affects a
    --     service such as Amazon Elastic Compute Cloud and you have Amazon Web
    --     Services 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
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]
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
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.
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 Health event is a public Amazon Web
-- Services 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 Amazon Web Services
--     accounts in your organization. For example, if an event affects a
--     service such as Amazon Elastic Compute Cloud and you have Amazon Web
--     Services 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'
      { $sel:affectedAccounts:DescribeAffectedAccountsForOrganizationResponse' :: Maybe [Text]
affectedAccounts =
          forall a. Maybe a
Prelude.Nothing,
        $sel:eventScopeCode:DescribeAffectedAccountsForOrganizationResponse' :: Maybe EventScopeCode
eventScopeCode =
          forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:DescribeAffectedAccountsForOrganizationResponse' :: Maybe Text
nextToken =
          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 :: Lens'
  DescribeAffectedAccountsForOrganizationResponse (Maybe [Text])
describeAffectedAccountsForOrganizationResponse_affectedAccounts = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | This parameter specifies if the Health event is a public Amazon Web
-- Services 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 Amazon Web Services
--     accounts in your organization. For example, if an event affects a
--     service such as Amazon Elastic Compute Cloud and you have Amazon Web
--     Services 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 :: Lens'
  DescribeAffectedAccountsForOrganizationResponse
  (Maybe EventScopeCode)
describeAffectedAccountsForOrganizationResponse_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 :: Lens' DescribeAffectedAccountsForOrganizationResponse (Maybe Text)
describeAffectedAccountsForOrganizationResponse_nextToken = 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 :: Lens' DescribeAffectedAccountsForOrganizationResponse Int
describeAffectedAccountsForOrganizationResponse_httpStatus = 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
  where
  rnf :: DescribeAffectedAccountsForOrganizationResponse -> ()
rnf
    DescribeAffectedAccountsForOrganizationResponse' {Int
Maybe [Text]
Maybe Text
Maybe EventScopeCode
httpStatus :: Int
nextToken :: Maybe Text
eventScopeCode :: Maybe EventScopeCode
affectedAccounts :: Maybe [Text]
$sel:httpStatus:DescribeAffectedAccountsForOrganizationResponse' :: DescribeAffectedAccountsForOrganizationResponse -> Int
$sel:nextToken:DescribeAffectedAccountsForOrganizationResponse' :: DescribeAffectedAccountsForOrganizationResponse -> Maybe Text
$sel:eventScopeCode:DescribeAffectedAccountsForOrganizationResponse' :: DescribeAffectedAccountsForOrganizationResponse
-> Maybe EventScopeCode
$sel:affectedAccounts:DescribeAffectedAccountsForOrganizationResponse' :: DescribeAffectedAccountsForOrganizationResponse -> Maybe [Text]
..} =
      forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
affectedAccounts
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EventScopeCode
eventScopeCode
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus