{-# 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.DescribeAffectedEntitiesForOrganization
-- 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 entities that have been affected by one or more events
-- for one or more accounts in your organization in Organizations, based on
-- the filter criteria. Entities can refer to individual customer
-- resources, groups of customer resources, or any other construct,
-- depending on the Amazon Web Services service.
--
-- At least one event Amazon Resource Name (ARN) and account ID are
-- required.
--
-- 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 doesn\'t support resource-level permissions. You
--     can\'t use this operation to allow or deny access to specific Health
--     events. For more information, see
--     <https://docs.aws.amazon.com/health/latest/ug/security_iam_id-based-policy-examples.html#resource-action-based-conditions Resource- and action-based conditions>
--     in the /Health User Guide/.
--
-- This operation returns paginated results.
module Amazonka.AWSHealth.DescribeAffectedEntitiesForOrganization
  ( -- * Creating a Request
    DescribeAffectedEntitiesForOrganization (..),
    newDescribeAffectedEntitiesForOrganization,

    -- * Request Lenses
    describeAffectedEntitiesForOrganization_locale,
    describeAffectedEntitiesForOrganization_maxResults,
    describeAffectedEntitiesForOrganization_nextToken,
    describeAffectedEntitiesForOrganization_organizationEntityFilters,

    -- * Destructuring the Response
    DescribeAffectedEntitiesForOrganizationResponse (..),
    newDescribeAffectedEntitiesForOrganizationResponse,

    -- * Response Lenses
    describeAffectedEntitiesForOrganizationResponse_entities,
    describeAffectedEntitiesForOrganizationResponse_failedSet,
    describeAffectedEntitiesForOrganizationResponse_nextToken,
    describeAffectedEntitiesForOrganizationResponse_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:/ 'newDescribeAffectedEntitiesForOrganization' smart constructor.
data DescribeAffectedEntitiesForOrganization = DescribeAffectedEntitiesForOrganization'
  { -- | The locale (language) to return information in. English (en) is the
    -- default and the only supported value at this time.
    DescribeAffectedEntitiesForOrganization -> Maybe Text
locale :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to return in one batch, between 10 and 100,
    -- inclusive.
    DescribeAffectedEntitiesForOrganization -> 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.
    DescribeAffectedEntitiesForOrganization -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A JSON set of elements including the @awsAccountId@ and the @eventArn@.
    DescribeAffectedEntitiesForOrganization
-> NonEmpty EventAccountFilter
organizationEntityFilters :: Prelude.NonEmpty EventAccountFilter
  }
  deriving (DescribeAffectedEntitiesForOrganization
-> DescribeAffectedEntitiesForOrganization -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAffectedEntitiesForOrganization
-> DescribeAffectedEntitiesForOrganization -> Bool
$c/= :: DescribeAffectedEntitiesForOrganization
-> DescribeAffectedEntitiesForOrganization -> Bool
== :: DescribeAffectedEntitiesForOrganization
-> DescribeAffectedEntitiesForOrganization -> Bool
$c== :: DescribeAffectedEntitiesForOrganization
-> DescribeAffectedEntitiesForOrganization -> Bool
Prelude.Eq, ReadPrec [DescribeAffectedEntitiesForOrganization]
ReadPrec DescribeAffectedEntitiesForOrganization
Int -> ReadS DescribeAffectedEntitiesForOrganization
ReadS [DescribeAffectedEntitiesForOrganization]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAffectedEntitiesForOrganization]
$creadListPrec :: ReadPrec [DescribeAffectedEntitiesForOrganization]
readPrec :: ReadPrec DescribeAffectedEntitiesForOrganization
$creadPrec :: ReadPrec DescribeAffectedEntitiesForOrganization
readList :: ReadS [DescribeAffectedEntitiesForOrganization]
$creadList :: ReadS [DescribeAffectedEntitiesForOrganization]
readsPrec :: Int -> ReadS DescribeAffectedEntitiesForOrganization
$creadsPrec :: Int -> ReadS DescribeAffectedEntitiesForOrganization
Prelude.Read, Int -> DescribeAffectedEntitiesForOrganization -> ShowS
[DescribeAffectedEntitiesForOrganization] -> ShowS
DescribeAffectedEntitiesForOrganization -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAffectedEntitiesForOrganization] -> ShowS
$cshowList :: [DescribeAffectedEntitiesForOrganization] -> ShowS
show :: DescribeAffectedEntitiesForOrganization -> String
$cshow :: DescribeAffectedEntitiesForOrganization -> String
showsPrec :: Int -> DescribeAffectedEntitiesForOrganization -> ShowS
$cshowsPrec :: Int -> DescribeAffectedEntitiesForOrganization -> ShowS
Prelude.Show, forall x.
Rep DescribeAffectedEntitiesForOrganization x
-> DescribeAffectedEntitiesForOrganization
forall x.
DescribeAffectedEntitiesForOrganization
-> Rep DescribeAffectedEntitiesForOrganization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAffectedEntitiesForOrganization x
-> DescribeAffectedEntitiesForOrganization
$cfrom :: forall x.
DescribeAffectedEntitiesForOrganization
-> Rep DescribeAffectedEntitiesForOrganization x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAffectedEntitiesForOrganization' 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', 'describeAffectedEntitiesForOrganization_locale' - The locale (language) to return information in. English (en) is the
-- default and the only supported value at this time.
--
-- 'maxResults', 'describeAffectedEntitiesForOrganization_maxResults' - The maximum number of items to return in one batch, between 10 and 100,
-- inclusive.
--
-- 'nextToken', 'describeAffectedEntitiesForOrganization_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.
--
-- 'organizationEntityFilters', 'describeAffectedEntitiesForOrganization_organizationEntityFilters' - A JSON set of elements including the @awsAccountId@ and the @eventArn@.
newDescribeAffectedEntitiesForOrganization ::
  -- | 'organizationEntityFilters'
  Prelude.NonEmpty EventAccountFilter ->
  DescribeAffectedEntitiesForOrganization
newDescribeAffectedEntitiesForOrganization :: NonEmpty EventAccountFilter
-> DescribeAffectedEntitiesForOrganization
newDescribeAffectedEntitiesForOrganization
  NonEmpty EventAccountFilter
pOrganizationEntityFilters_ =
    DescribeAffectedEntitiesForOrganization'
      { $sel:locale:DescribeAffectedEntitiesForOrganization' :: Maybe Text
locale =
          forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:DescribeAffectedEntitiesForOrganization' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:DescribeAffectedEntitiesForOrganization' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
        $sel:organizationEntityFilters:DescribeAffectedEntitiesForOrganization' :: NonEmpty EventAccountFilter
organizationEntityFilters =
          forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
            forall t b. AReview t b -> b -> t
Lens.# NonEmpty EventAccountFilter
pOrganizationEntityFilters_
      }

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

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

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

-- | A JSON set of elements including the @awsAccountId@ and the @eventArn@.
describeAffectedEntitiesForOrganization_organizationEntityFilters :: Lens.Lens' DescribeAffectedEntitiesForOrganization (Prelude.NonEmpty EventAccountFilter)
describeAffectedEntitiesForOrganization_organizationEntityFilters :: Lens'
  DescribeAffectedEntitiesForOrganization
  (NonEmpty EventAccountFilter)
describeAffectedEntitiesForOrganization_organizationEntityFilters = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAffectedEntitiesForOrganization' {NonEmpty EventAccountFilter
organizationEntityFilters :: NonEmpty EventAccountFilter
$sel:organizationEntityFilters:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization
-> NonEmpty EventAccountFilter
organizationEntityFilters} -> NonEmpty EventAccountFilter
organizationEntityFilters) (\s :: DescribeAffectedEntitiesForOrganization
s@DescribeAffectedEntitiesForOrganization' {} NonEmpty EventAccountFilter
a -> DescribeAffectedEntitiesForOrganization
s {$sel:organizationEntityFilters:DescribeAffectedEntitiesForOrganization' :: NonEmpty EventAccountFilter
organizationEntityFilters = NonEmpty EventAccountFilter
a} :: DescribeAffectedEntitiesForOrganization) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.AWSPager
    DescribeAffectedEntitiesForOrganization
  where
  page :: DescribeAffectedEntitiesForOrganization
-> AWSResponse DescribeAffectedEntitiesForOrganization
-> Maybe DescribeAffectedEntitiesForOrganization
page DescribeAffectedEntitiesForOrganization
rq AWSResponse DescribeAffectedEntitiesForOrganization
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeAffectedEntitiesForOrganization
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeAffectedEntitiesForOrganizationResponse (Maybe Text)
describeAffectedEntitiesForOrganizationResponse_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 DescribeAffectedEntitiesForOrganization
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens'
  DescribeAffectedEntitiesForOrganizationResponse
  (Maybe [AffectedEntity])
describeAffectedEntitiesForOrganizationResponse_entities
            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.$ DescribeAffectedEntitiesForOrganization
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' DescribeAffectedEntitiesForOrganization (Maybe Text)
describeAffectedEntitiesForOrganization_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeAffectedEntitiesForOrganization
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' DescribeAffectedEntitiesForOrganizationResponse (Maybe Text)
describeAffectedEntitiesForOrganizationResponse_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
    DescribeAffectedEntitiesForOrganization
  where
  type
    AWSResponse
      DescribeAffectedEntitiesForOrganization =
      DescribeAffectedEntitiesForOrganizationResponse
  request :: (Service -> Service)
-> DescribeAffectedEntitiesForOrganization
-> Request DescribeAffectedEntitiesForOrganization
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 DescribeAffectedEntitiesForOrganization
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse DescribeAffectedEntitiesForOrganization)))
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 [AffectedEntity]
-> Maybe [OrganizationAffectedEntitiesErrorItem]
-> Maybe Text
-> Int
-> DescribeAffectedEntitiesForOrganizationResponse
DescribeAffectedEntitiesForOrganizationResponse'
            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
"entities" 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
"failedSet" 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
"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
    DescribeAffectedEntitiesForOrganization
  where
  hashWithSalt :: Int -> DescribeAffectedEntitiesForOrganization -> Int
hashWithSalt
    Int
_salt
    DescribeAffectedEntitiesForOrganization' {Maybe Natural
Maybe Text
NonEmpty EventAccountFilter
organizationEntityFilters :: NonEmpty EventAccountFilter
nextToken :: Maybe Text
maxResults :: Maybe Natural
locale :: Maybe Text
$sel:organizationEntityFilters:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization
-> NonEmpty EventAccountFilter
$sel:nextToken:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization -> Maybe Text
$sel:maxResults:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization -> Maybe Natural
$sel:locale:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
locale
        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` NonEmpty EventAccountFilter
organizationEntityFilters

instance
  Prelude.NFData
    DescribeAffectedEntitiesForOrganization
  where
  rnf :: DescribeAffectedEntitiesForOrganization -> ()
rnf DescribeAffectedEntitiesForOrganization' {Maybe Natural
Maybe Text
NonEmpty EventAccountFilter
organizationEntityFilters :: NonEmpty EventAccountFilter
nextToken :: Maybe Text
maxResults :: Maybe Natural
locale :: Maybe Text
$sel:organizationEntityFilters:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization
-> NonEmpty EventAccountFilter
$sel:nextToken:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization -> Maybe Text
$sel:maxResults:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization -> Maybe Natural
$sel:locale:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
locale
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 NonEmpty EventAccountFilter
organizationEntityFilters

instance
  Data.ToHeaders
    DescribeAffectedEntitiesForOrganization
  where
  toHeaders :: DescribeAffectedEntitiesForOrganization -> 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.DescribeAffectedEntitiesForOrganization" ::
                          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
    DescribeAffectedEntitiesForOrganization
  where
  toJSON :: DescribeAffectedEntitiesForOrganization -> Value
toJSON DescribeAffectedEntitiesForOrganization' {Maybe Natural
Maybe Text
NonEmpty EventAccountFilter
organizationEntityFilters :: NonEmpty EventAccountFilter
nextToken :: Maybe Text
maxResults :: Maybe Natural
locale :: Maybe Text
$sel:organizationEntityFilters:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization
-> NonEmpty EventAccountFilter
$sel:nextToken:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization -> Maybe Text
$sel:maxResults:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization -> Maybe Natural
$sel:locale:DescribeAffectedEntitiesForOrganization' :: DescribeAffectedEntitiesForOrganization -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"locale" 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
locale,
            (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
"organizationEntityFilters"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty EventAccountFilter
organizationEntityFilters
              )
          ]
      )

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

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

-- | /See:/ 'newDescribeAffectedEntitiesForOrganizationResponse' smart constructor.
data DescribeAffectedEntitiesForOrganizationResponse = DescribeAffectedEntitiesForOrganizationResponse'
  { -- | A JSON set of elements including the @awsAccountId@ and its @entityArn@,
    -- @entityValue@ and its @entityArn@, @lastUpdatedTime@, and @statusCode@.
    DescribeAffectedEntitiesForOrganizationResponse
-> Maybe [AffectedEntity]
entities :: Prelude.Maybe [AffectedEntity],
    -- | A JSON set of elements of the failed response, including the
    -- @awsAccountId@, @errorMessage@, @errorName@, and @eventArn@.
    DescribeAffectedEntitiesForOrganizationResponse
-> Maybe [OrganizationAffectedEntitiesErrorItem]
failedSet :: Prelude.Maybe [OrganizationAffectedEntitiesErrorItem],
    -- | 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.
    DescribeAffectedEntitiesForOrganizationResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeAffectedEntitiesForOrganizationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAffectedEntitiesForOrganizationResponse
-> DescribeAffectedEntitiesForOrganizationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAffectedEntitiesForOrganizationResponse
-> DescribeAffectedEntitiesForOrganizationResponse -> Bool
$c/= :: DescribeAffectedEntitiesForOrganizationResponse
-> DescribeAffectedEntitiesForOrganizationResponse -> Bool
== :: DescribeAffectedEntitiesForOrganizationResponse
-> DescribeAffectedEntitiesForOrganizationResponse -> Bool
$c== :: DescribeAffectedEntitiesForOrganizationResponse
-> DescribeAffectedEntitiesForOrganizationResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAffectedEntitiesForOrganizationResponse]
ReadPrec DescribeAffectedEntitiesForOrganizationResponse
Int -> ReadS DescribeAffectedEntitiesForOrganizationResponse
ReadS [DescribeAffectedEntitiesForOrganizationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAffectedEntitiesForOrganizationResponse]
$creadListPrec :: ReadPrec [DescribeAffectedEntitiesForOrganizationResponse]
readPrec :: ReadPrec DescribeAffectedEntitiesForOrganizationResponse
$creadPrec :: ReadPrec DescribeAffectedEntitiesForOrganizationResponse
readList :: ReadS [DescribeAffectedEntitiesForOrganizationResponse]
$creadList :: ReadS [DescribeAffectedEntitiesForOrganizationResponse]
readsPrec :: Int -> ReadS DescribeAffectedEntitiesForOrganizationResponse
$creadsPrec :: Int -> ReadS DescribeAffectedEntitiesForOrganizationResponse
Prelude.Read, Int -> DescribeAffectedEntitiesForOrganizationResponse -> ShowS
[DescribeAffectedEntitiesForOrganizationResponse] -> ShowS
DescribeAffectedEntitiesForOrganizationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAffectedEntitiesForOrganizationResponse] -> ShowS
$cshowList :: [DescribeAffectedEntitiesForOrganizationResponse] -> ShowS
show :: DescribeAffectedEntitiesForOrganizationResponse -> String
$cshow :: DescribeAffectedEntitiesForOrganizationResponse -> String
showsPrec :: Int -> DescribeAffectedEntitiesForOrganizationResponse -> ShowS
$cshowsPrec :: Int -> DescribeAffectedEntitiesForOrganizationResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeAffectedEntitiesForOrganizationResponse x
-> DescribeAffectedEntitiesForOrganizationResponse
forall x.
DescribeAffectedEntitiesForOrganizationResponse
-> Rep DescribeAffectedEntitiesForOrganizationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAffectedEntitiesForOrganizationResponse x
-> DescribeAffectedEntitiesForOrganizationResponse
$cfrom :: forall x.
DescribeAffectedEntitiesForOrganizationResponse
-> Rep DescribeAffectedEntitiesForOrganizationResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAffectedEntitiesForOrganizationResponse' 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:
--
-- 'entities', 'describeAffectedEntitiesForOrganizationResponse_entities' - A JSON set of elements including the @awsAccountId@ and its @entityArn@,
-- @entityValue@ and its @entityArn@, @lastUpdatedTime@, and @statusCode@.
--
-- 'failedSet', 'describeAffectedEntitiesForOrganizationResponse_failedSet' - A JSON set of elements of the failed response, including the
-- @awsAccountId@, @errorMessage@, @errorName@, and @eventArn@.
--
-- 'nextToken', 'describeAffectedEntitiesForOrganizationResponse_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', 'describeAffectedEntitiesForOrganizationResponse_httpStatus' - The response's http status code.
newDescribeAffectedEntitiesForOrganizationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAffectedEntitiesForOrganizationResponse
newDescribeAffectedEntitiesForOrganizationResponse :: Int -> DescribeAffectedEntitiesForOrganizationResponse
newDescribeAffectedEntitiesForOrganizationResponse
  Int
pHttpStatus_ =
    DescribeAffectedEntitiesForOrganizationResponse'
      { $sel:entities:DescribeAffectedEntitiesForOrganizationResponse' :: Maybe [AffectedEntity]
entities =
          forall a. Maybe a
Prelude.Nothing,
        $sel:failedSet:DescribeAffectedEntitiesForOrganizationResponse' :: Maybe [OrganizationAffectedEntitiesErrorItem]
failedSet =
          forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:DescribeAffectedEntitiesForOrganizationResponse' :: Maybe Text
nextToken =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeAffectedEntitiesForOrganizationResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | A JSON set of elements including the @awsAccountId@ and its @entityArn@,
-- @entityValue@ and its @entityArn@, @lastUpdatedTime@, and @statusCode@.
describeAffectedEntitiesForOrganizationResponse_entities :: Lens.Lens' DescribeAffectedEntitiesForOrganizationResponse (Prelude.Maybe [AffectedEntity])
describeAffectedEntitiesForOrganizationResponse_entities :: Lens'
  DescribeAffectedEntitiesForOrganizationResponse
  (Maybe [AffectedEntity])
describeAffectedEntitiesForOrganizationResponse_entities = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAffectedEntitiesForOrganizationResponse' {Maybe [AffectedEntity]
entities :: Maybe [AffectedEntity]
$sel:entities:DescribeAffectedEntitiesForOrganizationResponse' :: DescribeAffectedEntitiesForOrganizationResponse
-> Maybe [AffectedEntity]
entities} -> Maybe [AffectedEntity]
entities) (\s :: DescribeAffectedEntitiesForOrganizationResponse
s@DescribeAffectedEntitiesForOrganizationResponse' {} Maybe [AffectedEntity]
a -> DescribeAffectedEntitiesForOrganizationResponse
s {$sel:entities:DescribeAffectedEntitiesForOrganizationResponse' :: Maybe [AffectedEntity]
entities = Maybe [AffectedEntity]
a} :: DescribeAffectedEntitiesForOrganizationResponse) 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

-- | A JSON set of elements of the failed response, including the
-- @awsAccountId@, @errorMessage@, @errorName@, and @eventArn@.
describeAffectedEntitiesForOrganizationResponse_failedSet :: Lens.Lens' DescribeAffectedEntitiesForOrganizationResponse (Prelude.Maybe [OrganizationAffectedEntitiesErrorItem])
describeAffectedEntitiesForOrganizationResponse_failedSet :: Lens'
  DescribeAffectedEntitiesForOrganizationResponse
  (Maybe [OrganizationAffectedEntitiesErrorItem])
describeAffectedEntitiesForOrganizationResponse_failedSet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAffectedEntitiesForOrganizationResponse' {Maybe [OrganizationAffectedEntitiesErrorItem]
failedSet :: Maybe [OrganizationAffectedEntitiesErrorItem]
$sel:failedSet:DescribeAffectedEntitiesForOrganizationResponse' :: DescribeAffectedEntitiesForOrganizationResponse
-> Maybe [OrganizationAffectedEntitiesErrorItem]
failedSet} -> Maybe [OrganizationAffectedEntitiesErrorItem]
failedSet) (\s :: DescribeAffectedEntitiesForOrganizationResponse
s@DescribeAffectedEntitiesForOrganizationResponse' {} Maybe [OrganizationAffectedEntitiesErrorItem]
a -> DescribeAffectedEntitiesForOrganizationResponse
s {$sel:failedSet:DescribeAffectedEntitiesForOrganizationResponse' :: Maybe [OrganizationAffectedEntitiesErrorItem]
failedSet = Maybe [OrganizationAffectedEntitiesErrorItem]
a} :: DescribeAffectedEntitiesForOrganizationResponse) 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

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

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

instance
  Prelude.NFData
    DescribeAffectedEntitiesForOrganizationResponse
  where
  rnf :: DescribeAffectedEntitiesForOrganizationResponse -> ()
rnf
    DescribeAffectedEntitiesForOrganizationResponse' {Int
Maybe [AffectedEntity]
Maybe [OrganizationAffectedEntitiesErrorItem]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
failedSet :: Maybe [OrganizationAffectedEntitiesErrorItem]
entities :: Maybe [AffectedEntity]
$sel:httpStatus:DescribeAffectedEntitiesForOrganizationResponse' :: DescribeAffectedEntitiesForOrganizationResponse -> Int
$sel:nextToken:DescribeAffectedEntitiesForOrganizationResponse' :: DescribeAffectedEntitiesForOrganizationResponse -> Maybe Text
$sel:failedSet:DescribeAffectedEntitiesForOrganizationResponse' :: DescribeAffectedEntitiesForOrganizationResponse
-> Maybe [OrganizationAffectedEntitiesErrorItem]
$sel:entities:DescribeAffectedEntitiesForOrganizationResponse' :: DescribeAffectedEntitiesForOrganizationResponse
-> Maybe [AffectedEntity]
..} =
      forall a. NFData a => a -> ()
Prelude.rnf Maybe [AffectedEntity]
entities
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [OrganizationAffectedEntitiesErrorItem]
failedSet
        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