{-# 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.ListObjectPolicies
-- 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 policies attached to an object in pagination fashion.
--
-- This operation returns paginated results.
module Amazonka.CloudDirectory.ListObjectPolicies
  ( -- * Creating a Request
    ListObjectPolicies (..),
    newListObjectPolicies,

    -- * Request Lenses
    listObjectPolicies_consistencyLevel,
    listObjectPolicies_nextToken,
    listObjectPolicies_maxResults,
    listObjectPolicies_directoryArn,
    listObjectPolicies_objectReference,

    -- * Destructuring the Response
    ListObjectPoliciesResponse (..),
    newListObjectPoliciesResponse,

    -- * Response Lenses
    listObjectPoliciesResponse_nextToken,
    listObjectPoliciesResponse_attachedPolicyIds,
    listObjectPoliciesResponse_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:/ 'newListObjectPolicies' smart constructor.
data ListObjectPolicies = ListObjectPolicies'
  { -- | 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.
    ListObjectPolicies -> Maybe ConsistencyLevel
consistencyLevel :: Prelude.Maybe ConsistencyLevel,
    -- | The pagination token.
    ListObjectPolicies -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of items to be retrieved in a single call. This is an
    -- approximate number.
    ListObjectPolicies -> 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.
    ListObjectPolicies -> Text
directoryArn :: Prelude.Text,
    -- | Reference that identifies the object for which policies will be listed.
    ListObjectPolicies -> ObjectReference
objectReference :: ObjectReference
  }
  deriving (ListObjectPolicies -> ListObjectPolicies -> Bool
(ListObjectPolicies -> ListObjectPolicies -> Bool)
-> (ListObjectPolicies -> ListObjectPolicies -> Bool)
-> Eq ListObjectPolicies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListObjectPolicies -> ListObjectPolicies -> Bool
$c/= :: ListObjectPolicies -> ListObjectPolicies -> Bool
== :: ListObjectPolicies -> ListObjectPolicies -> Bool
$c== :: ListObjectPolicies -> ListObjectPolicies -> Bool
Prelude.Eq, ReadPrec [ListObjectPolicies]
ReadPrec ListObjectPolicies
Int -> ReadS ListObjectPolicies
ReadS [ListObjectPolicies]
(Int -> ReadS ListObjectPolicies)
-> ReadS [ListObjectPolicies]
-> ReadPrec ListObjectPolicies
-> ReadPrec [ListObjectPolicies]
-> Read ListObjectPolicies
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListObjectPolicies]
$creadListPrec :: ReadPrec [ListObjectPolicies]
readPrec :: ReadPrec ListObjectPolicies
$creadPrec :: ReadPrec ListObjectPolicies
readList :: ReadS [ListObjectPolicies]
$creadList :: ReadS [ListObjectPolicies]
readsPrec :: Int -> ReadS ListObjectPolicies
$creadsPrec :: Int -> ReadS ListObjectPolicies
Prelude.Read, Int -> ListObjectPolicies -> ShowS
[ListObjectPolicies] -> ShowS
ListObjectPolicies -> String
(Int -> ListObjectPolicies -> ShowS)
-> (ListObjectPolicies -> String)
-> ([ListObjectPolicies] -> ShowS)
-> Show ListObjectPolicies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListObjectPolicies] -> ShowS
$cshowList :: [ListObjectPolicies] -> ShowS
show :: ListObjectPolicies -> String
$cshow :: ListObjectPolicies -> String
showsPrec :: Int -> ListObjectPolicies -> ShowS
$cshowsPrec :: Int -> ListObjectPolicies -> ShowS
Prelude.Show, (forall x. ListObjectPolicies -> Rep ListObjectPolicies x)
-> (forall x. Rep ListObjectPolicies x -> ListObjectPolicies)
-> Generic ListObjectPolicies
forall x. Rep ListObjectPolicies x -> ListObjectPolicies
forall x. ListObjectPolicies -> Rep ListObjectPolicies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListObjectPolicies x -> ListObjectPolicies
$cfrom :: forall x. ListObjectPolicies -> Rep ListObjectPolicies x
Prelude.Generic)

-- |
-- Create a value of 'ListObjectPolicies' 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', 'listObjectPolicies_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', 'listObjectPolicies_nextToken' - The pagination token.
--
-- 'maxResults', 'listObjectPolicies_maxResults' - The maximum number of items to be retrieved in a single call. This is an
-- approximate number.
--
-- 'directoryArn', 'listObjectPolicies_directoryArn' - The Amazon Resource Name (ARN) that is associated with the Directory
-- where objects reside. For more information, see arns.
--
-- 'objectReference', 'listObjectPolicies_objectReference' - Reference that identifies the object for which policies will be listed.
newListObjectPolicies ::
  -- | 'directoryArn'
  Prelude.Text ->
  -- | 'objectReference'
  ObjectReference ->
  ListObjectPolicies
newListObjectPolicies :: Text -> ObjectReference -> ListObjectPolicies
newListObjectPolicies
  Text
pDirectoryArn_
  ObjectReference
pObjectReference_ =
    ListObjectPolicies' :: Maybe ConsistencyLevel
-> Maybe Text
-> Maybe Natural
-> Text
-> ObjectReference
-> ListObjectPolicies
ListObjectPolicies'
      { $sel:consistencyLevel:ListObjectPolicies' :: Maybe ConsistencyLevel
consistencyLevel =
          Maybe ConsistencyLevel
forall a. Maybe a
Prelude.Nothing,
        $sel:nextToken:ListObjectPolicies' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:ListObjectPolicies' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:directoryArn:ListObjectPolicies' :: Text
directoryArn = Text
pDirectoryArn_,
        $sel:objectReference:ListObjectPolicies' :: ObjectReference
objectReference = ObjectReference
pObjectReference_
      }

-- | 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.
listObjectPolicies_consistencyLevel :: Lens.Lens' ListObjectPolicies (Prelude.Maybe ConsistencyLevel)
listObjectPolicies_consistencyLevel :: (Maybe ConsistencyLevel -> f (Maybe ConsistencyLevel))
-> ListObjectPolicies -> f ListObjectPolicies
listObjectPolicies_consistencyLevel = (ListObjectPolicies -> Maybe ConsistencyLevel)
-> (ListObjectPolicies
    -> Maybe ConsistencyLevel -> ListObjectPolicies)
-> Lens
     ListObjectPolicies
     ListObjectPolicies
     (Maybe ConsistencyLevel)
     (Maybe ConsistencyLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListObjectPolicies' {Maybe ConsistencyLevel
consistencyLevel :: Maybe ConsistencyLevel
$sel:consistencyLevel:ListObjectPolicies' :: ListObjectPolicies -> Maybe ConsistencyLevel
consistencyLevel} -> Maybe ConsistencyLevel
consistencyLevel) (\s :: ListObjectPolicies
s@ListObjectPolicies' {} Maybe ConsistencyLevel
a -> ListObjectPolicies
s {$sel:consistencyLevel:ListObjectPolicies' :: Maybe ConsistencyLevel
consistencyLevel = Maybe ConsistencyLevel
a} :: ListObjectPolicies)

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

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

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

-- | Reference that identifies the object for which policies will be listed.
listObjectPolicies_objectReference :: Lens.Lens' ListObjectPolicies ObjectReference
listObjectPolicies_objectReference :: (ObjectReference -> f ObjectReference)
-> ListObjectPolicies -> f ListObjectPolicies
listObjectPolicies_objectReference = (ListObjectPolicies -> ObjectReference)
-> (ListObjectPolicies -> ObjectReference -> ListObjectPolicies)
-> Lens
     ListObjectPolicies
     ListObjectPolicies
     ObjectReference
     ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListObjectPolicies' {ObjectReference
objectReference :: ObjectReference
$sel:objectReference:ListObjectPolicies' :: ListObjectPolicies -> ObjectReference
objectReference} -> ObjectReference
objectReference) (\s :: ListObjectPolicies
s@ListObjectPolicies' {} ObjectReference
a -> ListObjectPolicies
s {$sel:objectReference:ListObjectPolicies' :: ObjectReference
objectReference = ObjectReference
a} :: ListObjectPolicies)

instance Core.AWSPager ListObjectPolicies where
  page :: ListObjectPolicies
-> AWSResponse ListObjectPolicies -> Maybe ListObjectPolicies
page ListObjectPolicies
rq AWSResponse ListObjectPolicies
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListObjectPolicies
ListObjectPoliciesResponse
rs
            ListObjectPoliciesResponse
-> Getting (First Text) ListObjectPoliciesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListObjectPoliciesResponse
-> Const (First Text) ListObjectPoliciesResponse
Lens' ListObjectPoliciesResponse (Maybe Text)
listObjectPoliciesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListObjectPoliciesResponse
 -> Const (First Text) ListObjectPoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListObjectPoliciesResponse 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 ListObjectPolicies
forall a. Maybe a
Prelude.Nothing
    | Maybe [Text] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListObjectPolicies
ListObjectPoliciesResponse
rs
            ListObjectPoliciesResponse
-> Getting (First [Text]) ListObjectPoliciesResponse [Text]
-> Maybe [Text]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> ListObjectPoliciesResponse
-> Const (First [Text]) ListObjectPoliciesResponse
Lens' ListObjectPoliciesResponse (Maybe [Text])
listObjectPoliciesResponse_attachedPolicyIds
              ((Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
 -> ListObjectPoliciesResponse
 -> Const (First [Text]) ListObjectPoliciesResponse)
-> (([Text] -> Const (First [Text]) [Text])
    -> Maybe [Text] -> Const (First [Text]) (Maybe [Text]))
-> Getting (First [Text]) ListObjectPoliciesResponse [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 ListObjectPolicies
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListObjectPolicies -> Maybe ListObjectPolicies
forall a. a -> Maybe a
Prelude.Just (ListObjectPolicies -> Maybe ListObjectPolicies)
-> ListObjectPolicies -> Maybe ListObjectPolicies
forall a b. (a -> b) -> a -> b
Prelude.$
        ListObjectPolicies
rq
          ListObjectPolicies
-> (ListObjectPolicies -> ListObjectPolicies) -> ListObjectPolicies
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListObjectPolicies -> Identity ListObjectPolicies
Lens
  ListObjectPolicies ListObjectPolicies (Maybe Text) (Maybe Text)
listObjectPolicies_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListObjectPolicies -> Identity ListObjectPolicies)
-> Maybe Text -> ListObjectPolicies -> ListObjectPolicies
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListObjectPolicies
ListObjectPoliciesResponse
rs
          ListObjectPoliciesResponse
-> Getting (First Text) ListObjectPoliciesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListObjectPoliciesResponse
-> Const (First Text) ListObjectPoliciesResponse
Lens' ListObjectPoliciesResponse (Maybe Text)
listObjectPoliciesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListObjectPoliciesResponse
 -> Const (First Text) ListObjectPoliciesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListObjectPoliciesResponse 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 ListObjectPolicies where
  type
    AWSResponse ListObjectPolicies =
      ListObjectPoliciesResponse
  request :: ListObjectPolicies -> Request ListObjectPolicies
request = Service -> ListObjectPolicies -> Request ListObjectPolicies
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListObjectPolicies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListObjectPolicies)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListObjectPolicies))
-> Logger
-> Service
-> Proxy ListObjectPolicies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListObjectPolicies)))
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 -> ListObjectPoliciesResponse
ListObjectPoliciesResponse'
            (Maybe Text -> Maybe [Text] -> Int -> ListObjectPoliciesResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [Text] -> Int -> ListObjectPoliciesResponse)
forall (f :: * -> *) a b. Functor 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 (Maybe [Text] -> Int -> ListObjectPoliciesResponse)
-> Either String (Maybe [Text])
-> Either String (Int -> ListObjectPoliciesResponse)
forall (f :: * -> *) a b. Applicative f => 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
"AttachedPolicyIds"
                            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 (Int -> ListObjectPoliciesResponse)
-> Either String Int -> Either String ListObjectPoliciesResponse
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 ListObjectPolicies

instance Prelude.NFData ListObjectPolicies

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

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

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

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

-- |
-- Create a value of 'ListObjectPoliciesResponse' 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', 'listObjectPoliciesResponse_nextToken' - The pagination token.
--
-- 'attachedPolicyIds', 'listObjectPoliciesResponse_attachedPolicyIds' - A list of policy @ObjectIdentifiers@, that are attached to the object.
--
-- 'httpStatus', 'listObjectPoliciesResponse_httpStatus' - The response's http status code.
newListObjectPoliciesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListObjectPoliciesResponse
newListObjectPoliciesResponse :: Int -> ListObjectPoliciesResponse
newListObjectPoliciesResponse Int
pHttpStatus_ =
  ListObjectPoliciesResponse' :: Maybe Text -> Maybe [Text] -> Int -> ListObjectPoliciesResponse
ListObjectPoliciesResponse'
    { $sel:nextToken:ListObjectPoliciesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attachedPolicyIds:ListObjectPoliciesResponse' :: Maybe [Text]
attachedPolicyIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListObjectPoliciesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | A list of policy @ObjectIdentifiers@, that are attached to the object.
listObjectPoliciesResponse_attachedPolicyIds :: Lens.Lens' ListObjectPoliciesResponse (Prelude.Maybe [Prelude.Text])
listObjectPoliciesResponse_attachedPolicyIds :: (Maybe [Text] -> f (Maybe [Text]))
-> ListObjectPoliciesResponse -> f ListObjectPoliciesResponse
listObjectPoliciesResponse_attachedPolicyIds = (ListObjectPoliciesResponse -> Maybe [Text])
-> (ListObjectPoliciesResponse
    -> Maybe [Text] -> ListObjectPoliciesResponse)
-> Lens' ListObjectPoliciesResponse (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListObjectPoliciesResponse' {Maybe [Text]
attachedPolicyIds :: Maybe [Text]
$sel:attachedPolicyIds:ListObjectPoliciesResponse' :: ListObjectPoliciesResponse -> Maybe [Text]
attachedPolicyIds} -> Maybe [Text]
attachedPolicyIds) (\s :: ListObjectPoliciesResponse
s@ListObjectPoliciesResponse' {} Maybe [Text]
a -> ListObjectPoliciesResponse
s {$sel:attachedPolicyIds:ListObjectPoliciesResponse' :: Maybe [Text]
attachedPolicyIds = Maybe [Text]
a} :: ListObjectPoliciesResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> ListObjectPoliciesResponse -> f ListObjectPoliciesResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListObjectPoliciesResponse
-> f ListObjectPoliciesResponse
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 response's http status code.
listObjectPoliciesResponse_httpStatus :: Lens.Lens' ListObjectPoliciesResponse Prelude.Int
listObjectPoliciesResponse_httpStatus :: (Int -> f Int)
-> ListObjectPoliciesResponse -> f ListObjectPoliciesResponse
listObjectPoliciesResponse_httpStatus = (ListObjectPoliciesResponse -> Int)
-> (ListObjectPoliciesResponse
    -> Int -> ListObjectPoliciesResponse)
-> Lens
     ListObjectPoliciesResponse ListObjectPoliciesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListObjectPoliciesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListObjectPoliciesResponse' :: ListObjectPoliciesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListObjectPoliciesResponse
s@ListObjectPoliciesResponse' {} Int
a -> ListObjectPoliciesResponse
s {$sel:httpStatus:ListObjectPoliciesResponse' :: Int
httpStatus = Int
a} :: ListObjectPoliciesResponse)

instance Prelude.NFData ListObjectPoliciesResponse