{-# 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.CloudDirectory.ListPolicyAttachments
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns all of the @ObjectIdentifiers@ to which a given policy is
-- attached.
--
-- This operation returns paginated results.
module Amazonka.CloudDirectory.ListPolicyAttachments
  ( -- * Creating a Request
    ListPolicyAttachments (..),
    newListPolicyAttachments,

    -- * Request Lenses
    listPolicyAttachments_consistencyLevel,
    listPolicyAttachments_nextToken,
    listPolicyAttachments_maxResults,
    listPolicyAttachments_directoryArn,
    listPolicyAttachments_policyReference,

    -- * Destructuring the Response
    ListPolicyAttachmentsResponse (..),
    newListPolicyAttachmentsResponse,

    -- * Response Lenses
    listPolicyAttachmentsResponse_objectIdentifiers,
    listPolicyAttachmentsResponse_nextToken,
    listPolicyAttachmentsResponse_httpStatus,
  )
where

import Amazonka.CloudDirectory.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListPolicyAttachments' smart constructor.
data ListPolicyAttachments = ListPolicyAttachments'
  { -- | Represents the manner and timing in which the successful write or update
    -- of an object is reflected in a subsequent read operation of that same
    -- object.
    ListPolicyAttachments -> Maybe ConsistencyLevel
consistencyLevel :: Prelude.Maybe ConsistencyLevel,
    -- | The pagination token.
    ListPolicyAttachments -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to be retrieved in a single call. This is an
    -- approximate number.
    ListPolicyAttachments -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Name (ARN) that is associated with the Directory
    -- where objects reside. For more information, see arns.
    ListPolicyAttachments -> Text
directoryArn :: Prelude.Text,
    -- | The reference that identifies the policy object.
    ListPolicyAttachments -> ObjectReference
policyReference :: ObjectReference
  }
  deriving (ListPolicyAttachments -> ListPolicyAttachments -> Bool
(ListPolicyAttachments -> ListPolicyAttachments -> Bool)
-> (ListPolicyAttachments -> ListPolicyAttachments -> Bool)
-> Eq ListPolicyAttachments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPolicyAttachments -> ListPolicyAttachments -> Bool
$c/= :: ListPolicyAttachments -> ListPolicyAttachments -> Bool
== :: ListPolicyAttachments -> ListPolicyAttachments -> Bool
$c== :: ListPolicyAttachments -> ListPolicyAttachments -> Bool
Prelude.Eq, ReadPrec [ListPolicyAttachments]
ReadPrec ListPolicyAttachments
Int -> ReadS ListPolicyAttachments
ReadS [ListPolicyAttachments]
(Int -> ReadS ListPolicyAttachments)
-> ReadS [ListPolicyAttachments]
-> ReadPrec ListPolicyAttachments
-> ReadPrec [ListPolicyAttachments]
-> Read ListPolicyAttachments
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPolicyAttachments]
$creadListPrec :: ReadPrec [ListPolicyAttachments]
readPrec :: ReadPrec ListPolicyAttachments
$creadPrec :: ReadPrec ListPolicyAttachments
readList :: ReadS [ListPolicyAttachments]
$creadList :: ReadS [ListPolicyAttachments]
readsPrec :: Int -> ReadS ListPolicyAttachments
$creadsPrec :: Int -> ReadS ListPolicyAttachments
Prelude.Read, Int -> ListPolicyAttachments -> ShowS
[ListPolicyAttachments] -> ShowS
ListPolicyAttachments -> String
(Int -> ListPolicyAttachments -> ShowS)
-> (ListPolicyAttachments -> String)
-> ([ListPolicyAttachments] -> ShowS)
-> Show ListPolicyAttachments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPolicyAttachments] -> ShowS
$cshowList :: [ListPolicyAttachments] -> ShowS
show :: ListPolicyAttachments -> String
$cshow :: ListPolicyAttachments -> String
showsPrec :: Int -> ListPolicyAttachments -> ShowS
$cshowsPrec :: Int -> ListPolicyAttachments -> ShowS
Prelude.Show, (forall x. ListPolicyAttachments -> Rep ListPolicyAttachments x)
-> (forall x. Rep ListPolicyAttachments x -> ListPolicyAttachments)
-> Generic ListPolicyAttachments
forall x. Rep ListPolicyAttachments x -> ListPolicyAttachments
forall x. ListPolicyAttachments -> Rep ListPolicyAttachments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPolicyAttachments x -> ListPolicyAttachments
$cfrom :: forall x. ListPolicyAttachments -> Rep ListPolicyAttachments x
Prelude.Generic)

-- |
-- Create a value of 'ListPolicyAttachments' 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:
--
-- 'consistencyLevel', 'listPolicyAttachments_consistencyLevel' - Represents the manner and timing in which the successful write or update
-- of an object is reflected in a subsequent read operation of that same
-- object.
--
-- 'nextToken', 'listPolicyAttachments_nextToken' - The pagination token.
--
-- 'maxResults', 'listPolicyAttachments_maxResults' - The maximum number of items to be retrieved in a single call. This is an
-- approximate number.
--
-- 'directoryArn', 'listPolicyAttachments_directoryArn' - The Amazon Resource Name (ARN) that is associated with the Directory
-- where objects reside. For more information, see arns.
--
-- 'policyReference', 'listPolicyAttachments_policyReference' - The reference that identifies the policy object.
newListPolicyAttachments ::
  -- | 'directoryArn'
  Prelude.Text ->
  -- | 'policyReference'
  ObjectReference ->
  ListPolicyAttachments
newListPolicyAttachments :: Text -> ObjectReference -> ListPolicyAttachments
newListPolicyAttachments
  Text
pDirectoryArn_
  ObjectReference
pPolicyReference_ =
    ListPolicyAttachments' :: Maybe ConsistencyLevel
-> Maybe Text
-> Maybe Natural
-> Text
-> ObjectReference
-> ListPolicyAttachments
ListPolicyAttachments'
      { $sel:consistencyLevel:ListPolicyAttachments' :: Maybe ConsistencyLevel
consistencyLevel =
          Maybe ConsistencyLevel
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:ListPolicyAttachments' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:ListPolicyAttachments' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:directoryArn:ListPolicyAttachments' :: Text
directoryArn = Text
pDirectoryArn_,
        $sel:policyReference:ListPolicyAttachments' :: ObjectReference
policyReference = ObjectReference
pPolicyReference_
      }

-- | Represents the manner and timing in which the successful write or update
-- of an object is reflected in a subsequent read operation of that same
-- object.
listPolicyAttachments_consistencyLevel :: Lens.Lens' ListPolicyAttachments (Prelude.Maybe ConsistencyLevel)
listPolicyAttachments_consistencyLevel :: (Maybe ConsistencyLevel -> f (Maybe ConsistencyLevel))
-> ListPolicyAttachments -> f ListPolicyAttachments
listPolicyAttachments_consistencyLevel = (ListPolicyAttachments -> Maybe ConsistencyLevel)
-> (ListPolicyAttachments
    -> Maybe ConsistencyLevel -> ListPolicyAttachments)
-> Lens
     ListPolicyAttachments
     ListPolicyAttachments
     (Maybe ConsistencyLevel)
     (Maybe ConsistencyLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicyAttachments' {Maybe ConsistencyLevel
consistencyLevel :: Maybe ConsistencyLevel
$sel:consistencyLevel:ListPolicyAttachments' :: ListPolicyAttachments -> Maybe ConsistencyLevel
consistencyLevel} -> Maybe ConsistencyLevel
consistencyLevel) (\s :: ListPolicyAttachments
s@ListPolicyAttachments' {} Maybe ConsistencyLevel
a -> ListPolicyAttachments
s {$sel:consistencyLevel:ListPolicyAttachments' :: Maybe ConsistencyLevel
consistencyLevel = Maybe ConsistencyLevel
a} :: ListPolicyAttachments)

-- | The pagination token.
listPolicyAttachments_nextToken :: Lens.Lens' ListPolicyAttachments (Prelude.Maybe Prelude.Text)
listPolicyAttachments_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListPolicyAttachments -> f ListPolicyAttachments
listPolicyAttachments_nextToken = (ListPolicyAttachments -> Maybe Text)
-> (ListPolicyAttachments -> Maybe Text -> ListPolicyAttachments)
-> Lens
     ListPolicyAttachments
     ListPolicyAttachments
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicyAttachments' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPolicyAttachments' :: ListPolicyAttachments -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPolicyAttachments
s@ListPolicyAttachments' {} Maybe Text
a -> ListPolicyAttachments
s {$sel:nextToken:ListPolicyAttachments' :: Maybe Text
nextToken = Maybe Text
a} :: ListPolicyAttachments)

-- | The maximum number of items to be retrieved in a single call. This is an
-- approximate number.
listPolicyAttachments_maxResults :: Lens.Lens' ListPolicyAttachments (Prelude.Maybe Prelude.Natural)
listPolicyAttachments_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListPolicyAttachments -> f ListPolicyAttachments
listPolicyAttachments_maxResults = (ListPolicyAttachments -> Maybe Natural)
-> (ListPolicyAttachments
    -> Maybe Natural -> ListPolicyAttachments)
-> Lens
     ListPolicyAttachments
     ListPolicyAttachments
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicyAttachments' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListPolicyAttachments' :: ListPolicyAttachments -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListPolicyAttachments
s@ListPolicyAttachments' {} Maybe Natural
a -> ListPolicyAttachments
s {$sel:maxResults:ListPolicyAttachments' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListPolicyAttachments)

-- | The Amazon Resource Name (ARN) that is associated with the Directory
-- where objects reside. For more information, see arns.
listPolicyAttachments_directoryArn :: Lens.Lens' ListPolicyAttachments Prelude.Text
listPolicyAttachments_directoryArn :: (Text -> f Text)
-> ListPolicyAttachments -> f ListPolicyAttachments
listPolicyAttachments_directoryArn = (ListPolicyAttachments -> Text)
-> (ListPolicyAttachments -> Text -> ListPolicyAttachments)
-> Lens ListPolicyAttachments ListPolicyAttachments Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicyAttachments' {Text
directoryArn :: Text
$sel:directoryArn:ListPolicyAttachments' :: ListPolicyAttachments -> Text
directoryArn} -> Text
directoryArn) (\s :: ListPolicyAttachments
s@ListPolicyAttachments' {} Text
a -> ListPolicyAttachments
s {$sel:directoryArn:ListPolicyAttachments' :: Text
directoryArn = Text
a} :: ListPolicyAttachments)

-- | The reference that identifies the policy object.
listPolicyAttachments_policyReference :: Lens.Lens' ListPolicyAttachments ObjectReference
listPolicyAttachments_policyReference :: (ObjectReference -> f ObjectReference)
-> ListPolicyAttachments -> f ListPolicyAttachments
listPolicyAttachments_policyReference = (ListPolicyAttachments -> ObjectReference)
-> (ListPolicyAttachments
    -> ObjectReference -> ListPolicyAttachments)
-> Lens
     ListPolicyAttachments
     ListPolicyAttachments
     ObjectReference
     ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicyAttachments' {ObjectReference
policyReference :: ObjectReference
$sel:policyReference:ListPolicyAttachments' :: ListPolicyAttachments -> ObjectReference
policyReference} -> ObjectReference
policyReference) (\s :: ListPolicyAttachments
s@ListPolicyAttachments' {} ObjectReference
a -> ListPolicyAttachments
s {$sel:policyReference:ListPolicyAttachments' :: ObjectReference
policyReference = ObjectReference
a} :: ListPolicyAttachments)

instance Core.AWSPager ListPolicyAttachments where
  page :: ListPolicyAttachments
-> AWSResponse ListPolicyAttachments -> Maybe ListPolicyAttachments
page ListPolicyAttachments
rq AWSResponse ListPolicyAttachments
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPolicyAttachments
ListPolicyAttachmentsResponse
rs
            ListPolicyAttachmentsResponse
-> Getting (First Text) ListPolicyAttachmentsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPolicyAttachmentsResponse
-> Const (First Text) ListPolicyAttachmentsResponse
Lens' ListPolicyAttachmentsResponse (Maybe Text)
listPolicyAttachmentsResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPolicyAttachmentsResponse
 -> Const (First Text) ListPolicyAttachmentsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPolicyAttachmentsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListPolicyAttachments
forall a. Maybe a
Prelude.Nothing
    | Maybe [Text] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPolicyAttachments
ListPolicyAttachmentsResponse
rs
            ListPolicyAttachmentsResponse
-> Getting (First [Text]) ListPolicyAttachmentsResponse [Text]
-> Maybe [Text]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> ListPolicyAttachmentsResponse
-> Const (First [Text]) ListPolicyAttachmentsResponse
Lens' ListPolicyAttachmentsResponse (Maybe [Text])
listPolicyAttachmentsResponse_objectIdentifiers
              ((Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
 -> ListPolicyAttachmentsResponse
 -> Const (First [Text]) ListPolicyAttachmentsResponse)
-> (([Text] -> Const (First [Text]) [Text])
    -> Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> Getting (First [Text]) ListPolicyAttachmentsResponse [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> Const (First [Text]) [Text])
-> Maybe [Text] -> Const (First [Text]) (Maybe [Text])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListPolicyAttachments
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListPolicyAttachments -> Maybe ListPolicyAttachments
forall a. a -> Maybe a
Prelude.Just (ListPolicyAttachments -> Maybe ListPolicyAttachments)
-> ListPolicyAttachments -> Maybe ListPolicyAttachments
forall a b. (a -> b) -> a -> b
Prelude.$
        ListPolicyAttachments
rq
          ListPolicyAttachments
-> (ListPolicyAttachments -> ListPolicyAttachments)
-> ListPolicyAttachments
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListPolicyAttachments -> Identity ListPolicyAttachments
Lens
  ListPolicyAttachments
  ListPolicyAttachments
  (Maybe Text)
  (Maybe Text)
listPolicyAttachments_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListPolicyAttachments -> Identity ListPolicyAttachments)
-> Maybe Text -> ListPolicyAttachments -> ListPolicyAttachments
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListPolicyAttachments
ListPolicyAttachmentsResponse
rs
          ListPolicyAttachmentsResponse
-> Getting (First Text) ListPolicyAttachmentsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPolicyAttachmentsResponse
-> Const (First Text) ListPolicyAttachmentsResponse
Lens' ListPolicyAttachmentsResponse (Maybe Text)
listPolicyAttachmentsResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPolicyAttachmentsResponse
 -> Const (First Text) ListPolicyAttachmentsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPolicyAttachmentsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListPolicyAttachments where
  type
    AWSResponse ListPolicyAttachments =
      ListPolicyAttachmentsResponse
  request :: ListPolicyAttachments -> Request ListPolicyAttachments
request = Service -> ListPolicyAttachments -> Request ListPolicyAttachments
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListPolicyAttachments
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListPolicyAttachments)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListPolicyAttachments))
-> Logger
-> Service
-> Proxy ListPolicyAttachments
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListPolicyAttachments)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Text] -> Maybe Text -> Int -> ListPolicyAttachmentsResponse
ListPolicyAttachmentsResponse'
            (Maybe [Text]
 -> Maybe Text -> Int -> ListPolicyAttachmentsResponse)
-> Either String (Maybe [Text])
-> Either
     String (Maybe Text -> Int -> ListPolicyAttachmentsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ObjectIdentifiers"
                            Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Maybe Text -> Int -> ListPolicyAttachmentsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListPolicyAttachmentsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> ListPolicyAttachmentsResponse)
-> Either String Int -> Either String ListPolicyAttachmentsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListPolicyAttachments

instance Prelude.NFData ListPolicyAttachments

instance Core.ToHeaders ListPolicyAttachments where
  toHeaders :: ListPolicyAttachments -> ResponseHeaders
toHeaders ListPolicyAttachments' {Maybe Natural
Maybe Text
Maybe ConsistencyLevel
Text
ObjectReference
policyReference :: ObjectReference
directoryArn :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
consistencyLevel :: Maybe ConsistencyLevel
$sel:policyReference:ListPolicyAttachments' :: ListPolicyAttachments -> ObjectReference
$sel:directoryArn:ListPolicyAttachments' :: ListPolicyAttachments -> Text
$sel:maxResults:ListPolicyAttachments' :: ListPolicyAttachments -> Maybe Natural
$sel:nextToken:ListPolicyAttachments' :: ListPolicyAttachments -> Maybe Text
$sel:consistencyLevel:ListPolicyAttachments' :: ListPolicyAttachments -> Maybe ConsistencyLevel
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-consistency-level" HeaderName -> Maybe ConsistencyLevel -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe ConsistencyLevel
consistencyLevel,
        HeaderName
"x-amz-data-partition" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
directoryArn
      ]

instance Core.ToJSON ListPolicyAttachments where
  toJSON :: ListPolicyAttachments -> Value
toJSON ListPolicyAttachments' {Maybe Natural
Maybe Text
Maybe ConsistencyLevel
Text
ObjectReference
policyReference :: ObjectReference
directoryArn :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
consistencyLevel :: Maybe ConsistencyLevel
$sel:policyReference:ListPolicyAttachments' :: ListPolicyAttachments -> ObjectReference
$sel:directoryArn:ListPolicyAttachments' :: ListPolicyAttachments -> Text
$sel:maxResults:ListPolicyAttachments' :: ListPolicyAttachments -> Maybe Natural
$sel:nextToken:ListPolicyAttachments' :: ListPolicyAttachments -> Maybe Text
$sel:consistencyLevel:ListPolicyAttachments' :: ListPolicyAttachments -> Maybe ConsistencyLevel
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"PolicyReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
policyReference)
          ]
      )

instance Core.ToPath ListPolicyAttachments where
  toPath :: ListPolicyAttachments -> ByteString
toPath =
    ByteString -> ListPolicyAttachments -> ByteString
forall a b. a -> b -> a
Prelude.const
      ByteString
"/amazonclouddirectory/2017-01-11/policy/attachment"

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

-- | /See:/ 'newListPolicyAttachmentsResponse' smart constructor.
data ListPolicyAttachmentsResponse = ListPolicyAttachmentsResponse'
  { -- | A list of @ObjectIdentifiers@ to which the policy is attached.
    ListPolicyAttachmentsResponse -> Maybe [Text]
objectIdentifiers :: Prelude.Maybe [Prelude.Text],
    -- | The pagination token.
    ListPolicyAttachmentsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListPolicyAttachmentsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPolicyAttachmentsResponse
-> ListPolicyAttachmentsResponse -> Bool
(ListPolicyAttachmentsResponse
 -> ListPolicyAttachmentsResponse -> Bool)
-> (ListPolicyAttachmentsResponse
    -> ListPolicyAttachmentsResponse -> Bool)
-> Eq ListPolicyAttachmentsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPolicyAttachmentsResponse
-> ListPolicyAttachmentsResponse -> Bool
$c/= :: ListPolicyAttachmentsResponse
-> ListPolicyAttachmentsResponse -> Bool
== :: ListPolicyAttachmentsResponse
-> ListPolicyAttachmentsResponse -> Bool
$c== :: ListPolicyAttachmentsResponse
-> ListPolicyAttachmentsResponse -> Bool
Prelude.Eq, ReadPrec [ListPolicyAttachmentsResponse]
ReadPrec ListPolicyAttachmentsResponse
Int -> ReadS ListPolicyAttachmentsResponse
ReadS [ListPolicyAttachmentsResponse]
(Int -> ReadS ListPolicyAttachmentsResponse)
-> ReadS [ListPolicyAttachmentsResponse]
-> ReadPrec ListPolicyAttachmentsResponse
-> ReadPrec [ListPolicyAttachmentsResponse]
-> Read ListPolicyAttachmentsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPolicyAttachmentsResponse]
$creadListPrec :: ReadPrec [ListPolicyAttachmentsResponse]
readPrec :: ReadPrec ListPolicyAttachmentsResponse
$creadPrec :: ReadPrec ListPolicyAttachmentsResponse
readList :: ReadS [ListPolicyAttachmentsResponse]
$creadList :: ReadS [ListPolicyAttachmentsResponse]
readsPrec :: Int -> ReadS ListPolicyAttachmentsResponse
$creadsPrec :: Int -> ReadS ListPolicyAttachmentsResponse
Prelude.Read, Int -> ListPolicyAttachmentsResponse -> ShowS
[ListPolicyAttachmentsResponse] -> ShowS
ListPolicyAttachmentsResponse -> String
(Int -> ListPolicyAttachmentsResponse -> ShowS)
-> (ListPolicyAttachmentsResponse -> String)
-> ([ListPolicyAttachmentsResponse] -> ShowS)
-> Show ListPolicyAttachmentsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPolicyAttachmentsResponse] -> ShowS
$cshowList :: [ListPolicyAttachmentsResponse] -> ShowS
show :: ListPolicyAttachmentsResponse -> String
$cshow :: ListPolicyAttachmentsResponse -> String
showsPrec :: Int -> ListPolicyAttachmentsResponse -> ShowS
$cshowsPrec :: Int -> ListPolicyAttachmentsResponse -> ShowS
Prelude.Show, (forall x.
 ListPolicyAttachmentsResponse
 -> Rep ListPolicyAttachmentsResponse x)
-> (forall x.
    Rep ListPolicyAttachmentsResponse x
    -> ListPolicyAttachmentsResponse)
-> Generic ListPolicyAttachmentsResponse
forall x.
Rep ListPolicyAttachmentsResponse x
-> ListPolicyAttachmentsResponse
forall x.
ListPolicyAttachmentsResponse
-> Rep ListPolicyAttachmentsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListPolicyAttachmentsResponse x
-> ListPolicyAttachmentsResponse
$cfrom :: forall x.
ListPolicyAttachmentsResponse
-> Rep ListPolicyAttachmentsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPolicyAttachmentsResponse' 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:
--
-- 'objectIdentifiers', 'listPolicyAttachmentsResponse_objectIdentifiers' - A list of @ObjectIdentifiers@ to which the policy is attached.
--
-- 'nextToken', 'listPolicyAttachmentsResponse_nextToken' - The pagination token.
--
-- 'httpStatus', 'listPolicyAttachmentsResponse_httpStatus' - The response's http status code.
newListPolicyAttachmentsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPolicyAttachmentsResponse
newListPolicyAttachmentsResponse :: Int -> ListPolicyAttachmentsResponse
newListPolicyAttachmentsResponse Int
pHttpStatus_ =
  ListPolicyAttachmentsResponse' :: Maybe [Text] -> Maybe Text -> Int -> ListPolicyAttachmentsResponse
ListPolicyAttachmentsResponse'
    { $sel:objectIdentifiers:ListPolicyAttachmentsResponse' :: Maybe [Text]
objectIdentifiers =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPolicyAttachmentsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPolicyAttachmentsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of @ObjectIdentifiers@ to which the policy is attached.
listPolicyAttachmentsResponse_objectIdentifiers :: Lens.Lens' ListPolicyAttachmentsResponse (Prelude.Maybe [Prelude.Text])
listPolicyAttachmentsResponse_objectIdentifiers :: (Maybe [Text] -> f (Maybe [Text]))
-> ListPolicyAttachmentsResponse -> f ListPolicyAttachmentsResponse
listPolicyAttachmentsResponse_objectIdentifiers = (ListPolicyAttachmentsResponse -> Maybe [Text])
-> (ListPolicyAttachmentsResponse
    -> Maybe [Text] -> ListPolicyAttachmentsResponse)
-> Lens' ListPolicyAttachmentsResponse (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicyAttachmentsResponse' {Maybe [Text]
objectIdentifiers :: Maybe [Text]
$sel:objectIdentifiers:ListPolicyAttachmentsResponse' :: ListPolicyAttachmentsResponse -> Maybe [Text]
objectIdentifiers} -> Maybe [Text]
objectIdentifiers) (\s :: ListPolicyAttachmentsResponse
s@ListPolicyAttachmentsResponse' {} Maybe [Text]
a -> ListPolicyAttachmentsResponse
s {$sel:objectIdentifiers:ListPolicyAttachmentsResponse' :: Maybe [Text]
objectIdentifiers = Maybe [Text]
a} :: ListPolicyAttachmentsResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListPolicyAttachmentsResponse
 -> f ListPolicyAttachmentsResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListPolicyAttachmentsResponse
-> f ListPolicyAttachmentsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The pagination token.
listPolicyAttachmentsResponse_nextToken :: Lens.Lens' ListPolicyAttachmentsResponse (Prelude.Maybe Prelude.Text)
listPolicyAttachmentsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListPolicyAttachmentsResponse -> f ListPolicyAttachmentsResponse
listPolicyAttachmentsResponse_nextToken = (ListPolicyAttachmentsResponse -> Maybe Text)
-> (ListPolicyAttachmentsResponse
    -> Maybe Text -> ListPolicyAttachmentsResponse)
-> Lens' ListPolicyAttachmentsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPolicyAttachmentsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPolicyAttachmentsResponse' :: ListPolicyAttachmentsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPolicyAttachmentsResponse
s@ListPolicyAttachmentsResponse' {} Maybe Text
a -> ListPolicyAttachmentsResponse
s {$sel:nextToken:ListPolicyAttachmentsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListPolicyAttachmentsResponse)

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

instance Prelude.NFData ListPolicyAttachmentsResponse