{-# 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.Organizations.ListTargetsForPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists all the roots, organizational units (OUs), and accounts that the
-- specified policy is attached to.
--
-- Always check the @NextToken@ response parameter for a @null@ value when
-- calling a @List*@ operation. These operations can occasionally return an
-- empty set of results even when there are more results available. The
-- @NextToken@ response parameter value is @null@ /only/ when there are no
-- more results to display.
--
-- This operation can be called only from the organization\'s management
-- account or by a member account that is a delegated administrator for an
-- Amazon Web Services service.
--
-- This operation returns paginated results.
module Amazonka.Organizations.ListTargetsForPolicy
  ( -- * Creating a Request
    ListTargetsForPolicy (..),
    newListTargetsForPolicy,

    -- * Request Lenses
    listTargetsForPolicy_maxResults,
    listTargetsForPolicy_nextToken,
    listTargetsForPolicy_policyId,

    -- * Destructuring the Response
    ListTargetsForPolicyResponse (..),
    newListTargetsForPolicyResponse,

    -- * Response Lenses
    listTargetsForPolicyResponse_nextToken,
    listTargetsForPolicyResponse_targets,
    listTargetsForPolicyResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListTargetsForPolicy' smart constructor.
data ListTargetsForPolicy = ListTargetsForPolicy'
  { -- | The total number of results that you want included on each page of the
    -- response. If you do not include this parameter, it defaults to a value
    -- that is specific to the operation. If additional items exist beyond the
    -- maximum you specify, the @NextToken@ response element is present and has
    -- a value (is not null). Include that value as the @NextToken@ request
    -- parameter in the next call to the operation to get the next part of the
    -- results. Note that Organizations might return fewer results than the
    -- maximum even when there are more results available. You should check
    -- @NextToken@ after every operation to ensure that you receive all of the
    -- results.
    ListTargetsForPolicy -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The parameter for receiving additional results if you receive a
    -- @NextToken@ response in a previous request. A @NextToken@ response
    -- indicates that more output is available. Set this parameter to the value
    -- of the previous call\'s @NextToken@ response to indicate where the
    -- output should continue from.
    ListTargetsForPolicy -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier (ID) of the policy whose attachments you want to
    -- know.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> for a policy ID
    -- string requires \"p-\" followed by from 8 to 128 lowercase or uppercase
    -- letters, digits, or the underscore character (_).
    ListTargetsForPolicy -> Text
policyId :: Prelude.Text
  }
  deriving (ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
$c/= :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
== :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
$c== :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
Prelude.Eq, ReadPrec [ListTargetsForPolicy]
ReadPrec ListTargetsForPolicy
Int -> ReadS ListTargetsForPolicy
ReadS [ListTargetsForPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTargetsForPolicy]
$creadListPrec :: ReadPrec [ListTargetsForPolicy]
readPrec :: ReadPrec ListTargetsForPolicy
$creadPrec :: ReadPrec ListTargetsForPolicy
readList :: ReadS [ListTargetsForPolicy]
$creadList :: ReadS [ListTargetsForPolicy]
readsPrec :: Int -> ReadS ListTargetsForPolicy
$creadsPrec :: Int -> ReadS ListTargetsForPolicy
Prelude.Read, Int -> ListTargetsForPolicy -> ShowS
[ListTargetsForPolicy] -> ShowS
ListTargetsForPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTargetsForPolicy] -> ShowS
$cshowList :: [ListTargetsForPolicy] -> ShowS
show :: ListTargetsForPolicy -> String
$cshow :: ListTargetsForPolicy -> String
showsPrec :: Int -> ListTargetsForPolicy -> ShowS
$cshowsPrec :: Int -> ListTargetsForPolicy -> ShowS
Prelude.Show, forall x. Rep ListTargetsForPolicy x -> ListTargetsForPolicy
forall x. ListTargetsForPolicy -> Rep ListTargetsForPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTargetsForPolicy x -> ListTargetsForPolicy
$cfrom :: forall x. ListTargetsForPolicy -> Rep ListTargetsForPolicy x
Prelude.Generic)

-- |
-- Create a value of 'ListTargetsForPolicy' 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', 'listTargetsForPolicy_maxResults' - The total number of results that you want included on each page of the
-- response. If you do not include this parameter, it defaults to a value
-- that is specific to the operation. If additional items exist beyond the
-- maximum you specify, the @NextToken@ response element is present and has
-- a value (is not null). Include that value as the @NextToken@ request
-- parameter in the next call to the operation to get the next part of the
-- results. Note that Organizations might return fewer results than the
-- maximum even when there are more results available. You should check
-- @NextToken@ after every operation to ensure that you receive all of the
-- results.
--
-- 'nextToken', 'listTargetsForPolicy_nextToken' - The parameter for receiving additional results if you receive a
-- @NextToken@ response in a previous request. A @NextToken@ response
-- indicates that more output is available. Set this parameter to the value
-- of the previous call\'s @NextToken@ response to indicate where the
-- output should continue from.
--
-- 'policyId', 'listTargetsForPolicy_policyId' - The unique identifier (ID) of the policy whose attachments you want to
-- know.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a policy ID
-- string requires \"p-\" followed by from 8 to 128 lowercase or uppercase
-- letters, digits, or the underscore character (_).
newListTargetsForPolicy ::
  -- | 'policyId'
  Prelude.Text ->
  ListTargetsForPolicy
newListTargetsForPolicy :: Text -> ListTargetsForPolicy
newListTargetsForPolicy Text
pPolicyId_ =
  ListTargetsForPolicy'
    { $sel:maxResults:ListTargetsForPolicy' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListTargetsForPolicy' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:policyId:ListTargetsForPolicy' :: Text
policyId = Text
pPolicyId_
    }

-- | The total number of results that you want included on each page of the
-- response. If you do not include this parameter, it defaults to a value
-- that is specific to the operation. If additional items exist beyond the
-- maximum you specify, the @NextToken@ response element is present and has
-- a value (is not null). Include that value as the @NextToken@ request
-- parameter in the next call to the operation to get the next part of the
-- results. Note that Organizations might return fewer results than the
-- maximum even when there are more results available. You should check
-- @NextToken@ after every operation to ensure that you receive all of the
-- results.
listTargetsForPolicy_maxResults :: Lens.Lens' ListTargetsForPolicy (Prelude.Maybe Prelude.Natural)
listTargetsForPolicy_maxResults :: Lens' ListTargetsForPolicy (Maybe Natural)
listTargetsForPolicy_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicy' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListTargetsForPolicy
s@ListTargetsForPolicy' {} Maybe Natural
a -> ListTargetsForPolicy
s {$sel:maxResults:ListTargetsForPolicy' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListTargetsForPolicy)

-- | The parameter for receiving additional results if you receive a
-- @NextToken@ response in a previous request. A @NextToken@ response
-- indicates that more output is available. Set this parameter to the value
-- of the previous call\'s @NextToken@ response to indicate where the
-- output should continue from.
listTargetsForPolicy_nextToken :: Lens.Lens' ListTargetsForPolicy (Prelude.Maybe Prelude.Text)
listTargetsForPolicy_nextToken :: Lens' ListTargetsForPolicy (Maybe Text)
listTargetsForPolicy_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicy' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTargetsForPolicy
s@ListTargetsForPolicy' {} Maybe Text
a -> ListTargetsForPolicy
s {$sel:nextToken:ListTargetsForPolicy' :: Maybe Text
nextToken = Maybe Text
a} :: ListTargetsForPolicy)

-- | The unique identifier (ID) of the policy whose attachments you want to
-- know.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> for a policy ID
-- string requires \"p-\" followed by from 8 to 128 lowercase or uppercase
-- letters, digits, or the underscore character (_).
listTargetsForPolicy_policyId :: Lens.Lens' ListTargetsForPolicy Prelude.Text
listTargetsForPolicy_policyId :: Lens' ListTargetsForPolicy Text
listTargetsForPolicy_policyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicy' {Text
policyId :: Text
$sel:policyId:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
policyId} -> Text
policyId) (\s :: ListTargetsForPolicy
s@ListTargetsForPolicy' {} Text
a -> ListTargetsForPolicy
s {$sel:policyId:ListTargetsForPolicy' :: Text
policyId = Text
a} :: ListTargetsForPolicy)

instance Core.AWSPager ListTargetsForPolicy where
  page :: ListTargetsForPolicy
-> AWSResponse ListTargetsForPolicy -> Maybe ListTargetsForPolicy
page ListTargetsForPolicy
rq AWSResponse ListTargetsForPolicy
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListTargetsForPolicy
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTargetsForPolicyResponse (Maybe Text)
listTargetsForPolicyResponse_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 ListTargetsForPolicy
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTargetsForPolicyResponse (Maybe [PolicyTargetSummary])
listTargetsForPolicyResponse_targets
            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.$ ListTargetsForPolicy
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListTargetsForPolicy (Maybe Text)
listTargetsForPolicy_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListTargetsForPolicy
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTargetsForPolicyResponse (Maybe Text)
listTargetsForPolicyResponse_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 ListTargetsForPolicy where
  type
    AWSResponse ListTargetsForPolicy =
      ListTargetsForPolicyResponse
  request :: (Service -> Service)
-> ListTargetsForPolicy -> Request ListTargetsForPolicy
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 ListTargetsForPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTargetsForPolicy)))
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 [PolicyTargetSummary]
-> Int
-> ListTargetsForPolicyResponse
ListTargetsForPolicyResponse'
            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
"NextToken")
            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
"Targets" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListTargetsForPolicy where
  hashWithSalt :: Int -> ListTargetsForPolicy -> Int
hashWithSalt Int
_salt ListTargetsForPolicy' {Maybe Natural
Maybe Text
Text
policyId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:policyId:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
$sel:nextToken:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
$sel:maxResults:ListTargetsForPolicy' :: ListTargetsForPolicy -> 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
policyId

instance Prelude.NFData ListTargetsForPolicy where
  rnf :: ListTargetsForPolicy -> ()
rnf ListTargetsForPolicy' {Maybe Natural
Maybe Text
Text
policyId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:policyId:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
$sel:nextToken:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
$sel:maxResults:ListTargetsForPolicy' :: ListTargetsForPolicy -> 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
policyId

instance Data.ToHeaders ListTargetsForPolicy where
  toHeaders :: ListTargetsForPolicy -> 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
"AWSOrganizationsV20161128.ListTargetsForPolicy" ::
                          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 ListTargetsForPolicy where
  toJSON :: ListTargetsForPolicy -> Value
toJSON ListTargetsForPolicy' {Maybe Natural
Maybe Text
Text
policyId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:policyId:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
$sel:nextToken:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
$sel:maxResults:ListTargetsForPolicy' :: ListTargetsForPolicy -> 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
"PolicyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
policyId)
          ]
      )

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

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

-- | /See:/ 'newListTargetsForPolicyResponse' smart constructor.
data ListTargetsForPolicyResponse = ListTargetsForPolicyResponse'
  { -- | If present, indicates that more output is available than is included in
    -- the current response. Use this value in the @NextToken@ request
    -- parameter in a subsequent call to the operation to get the next part of
    -- the output. You should repeat this until the @NextToken@ response
    -- element comes back as @null@.
    ListTargetsForPolicyResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of structures, each of which contains details about one of the
    -- entities to which the specified policy is attached.
    ListTargetsForPolicyResponse -> Maybe [PolicyTargetSummary]
targets :: Prelude.Maybe [PolicyTargetSummary],
    -- | The response's http status code.
    ListTargetsForPolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
$c/= :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
== :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
$c== :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
Prelude.Eq, ReadPrec [ListTargetsForPolicyResponse]
ReadPrec ListTargetsForPolicyResponse
Int -> ReadS ListTargetsForPolicyResponse
ReadS [ListTargetsForPolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTargetsForPolicyResponse]
$creadListPrec :: ReadPrec [ListTargetsForPolicyResponse]
readPrec :: ReadPrec ListTargetsForPolicyResponse
$creadPrec :: ReadPrec ListTargetsForPolicyResponse
readList :: ReadS [ListTargetsForPolicyResponse]
$creadList :: ReadS [ListTargetsForPolicyResponse]
readsPrec :: Int -> ReadS ListTargetsForPolicyResponse
$creadsPrec :: Int -> ReadS ListTargetsForPolicyResponse
Prelude.Read, Int -> ListTargetsForPolicyResponse -> ShowS
[ListTargetsForPolicyResponse] -> ShowS
ListTargetsForPolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTargetsForPolicyResponse] -> ShowS
$cshowList :: [ListTargetsForPolicyResponse] -> ShowS
show :: ListTargetsForPolicyResponse -> String
$cshow :: ListTargetsForPolicyResponse -> String
showsPrec :: Int -> ListTargetsForPolicyResponse -> ShowS
$cshowsPrec :: Int -> ListTargetsForPolicyResponse -> ShowS
Prelude.Show, forall x.
Rep ListTargetsForPolicyResponse x -> ListTargetsForPolicyResponse
forall x.
ListTargetsForPolicyResponse -> Rep ListTargetsForPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListTargetsForPolicyResponse x -> ListTargetsForPolicyResponse
$cfrom :: forall x.
ListTargetsForPolicyResponse -> Rep ListTargetsForPolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTargetsForPolicyResponse' 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', 'listTargetsForPolicyResponse_nextToken' - If present, indicates that more output is available than is included in
-- the current response. Use this value in the @NextToken@ request
-- parameter in a subsequent call to the operation to get the next part of
-- the output. You should repeat this until the @NextToken@ response
-- element comes back as @null@.
--
-- 'targets', 'listTargetsForPolicyResponse_targets' - A list of structures, each of which contains details about one of the
-- entities to which the specified policy is attached.
--
-- 'httpStatus', 'listTargetsForPolicyResponse_httpStatus' - The response's http status code.
newListTargetsForPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTargetsForPolicyResponse
newListTargetsForPolicyResponse :: Int -> ListTargetsForPolicyResponse
newListTargetsForPolicyResponse Int
pHttpStatus_ =
  ListTargetsForPolicyResponse'
    { $sel:nextToken:ListTargetsForPolicyResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:targets:ListTargetsForPolicyResponse' :: Maybe [PolicyTargetSummary]
targets = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTargetsForPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If present, indicates that more output is available than is included in
-- the current response. Use this value in the @NextToken@ request
-- parameter in a subsequent call to the operation to get the next part of
-- the output. You should repeat this until the @NextToken@ response
-- element comes back as @null@.
listTargetsForPolicyResponse_nextToken :: Lens.Lens' ListTargetsForPolicyResponse (Prelude.Maybe Prelude.Text)
listTargetsForPolicyResponse_nextToken :: Lens' ListTargetsForPolicyResponse (Maybe Text)
listTargetsForPolicyResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicyResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTargetsForPolicyResponse
s@ListTargetsForPolicyResponse' {} Maybe Text
a -> ListTargetsForPolicyResponse
s {$sel:nextToken:ListTargetsForPolicyResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTargetsForPolicyResponse)

-- | A list of structures, each of which contains details about one of the
-- entities to which the specified policy is attached.
listTargetsForPolicyResponse_targets :: Lens.Lens' ListTargetsForPolicyResponse (Prelude.Maybe [PolicyTargetSummary])
listTargetsForPolicyResponse_targets :: Lens' ListTargetsForPolicyResponse (Maybe [PolicyTargetSummary])
listTargetsForPolicyResponse_targets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicyResponse' {Maybe [PolicyTargetSummary]
targets :: Maybe [PolicyTargetSummary]
$sel:targets:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Maybe [PolicyTargetSummary]
targets} -> Maybe [PolicyTargetSummary]
targets) (\s :: ListTargetsForPolicyResponse
s@ListTargetsForPolicyResponse' {} Maybe [PolicyTargetSummary]
a -> ListTargetsForPolicyResponse
s {$sel:targets:ListTargetsForPolicyResponse' :: Maybe [PolicyTargetSummary]
targets = Maybe [PolicyTargetSummary]
a} :: ListTargetsForPolicyResponse) 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

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

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