{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.BatchLookupPolicy
-- 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)
module Amazonka.CloudDirectory.Types.BatchLookupPolicy where

import Amazonka.CloudDirectory.Types.ObjectReference
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Lists all policies from the root of the Directory to the object
-- specified inside a BatchRead operation. For more information, see
-- LookupPolicy and BatchReadRequest$Operations.
--
-- /See:/ 'newBatchLookupPolicy' smart constructor.
data BatchLookupPolicy = BatchLookupPolicy'
  { -- | The pagination token.
    BatchLookupPolicy -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to retrieve.
    BatchLookupPolicy -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | Reference that identifies the object whose policies will be looked up.
    BatchLookupPolicy -> ObjectReference
objectReference :: ObjectReference
  }
  deriving (BatchLookupPolicy -> BatchLookupPolicy -> Bool
(BatchLookupPolicy -> BatchLookupPolicy -> Bool)
-> (BatchLookupPolicy -> BatchLookupPolicy -> Bool)
-> Eq BatchLookupPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchLookupPolicy -> BatchLookupPolicy -> Bool
$c/= :: BatchLookupPolicy -> BatchLookupPolicy -> Bool
== :: BatchLookupPolicy -> BatchLookupPolicy -> Bool
$c== :: BatchLookupPolicy -> BatchLookupPolicy -> Bool
Prelude.Eq, ReadPrec [BatchLookupPolicy]
ReadPrec BatchLookupPolicy
Int -> ReadS BatchLookupPolicy
ReadS [BatchLookupPolicy]
(Int -> ReadS BatchLookupPolicy)
-> ReadS [BatchLookupPolicy]
-> ReadPrec BatchLookupPolicy
-> ReadPrec [BatchLookupPolicy]
-> Read BatchLookupPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchLookupPolicy]
$creadListPrec :: ReadPrec [BatchLookupPolicy]
readPrec :: ReadPrec BatchLookupPolicy
$creadPrec :: ReadPrec BatchLookupPolicy
readList :: ReadS [BatchLookupPolicy]
$creadList :: ReadS [BatchLookupPolicy]
readsPrec :: Int -> ReadS BatchLookupPolicy
$creadsPrec :: Int -> ReadS BatchLookupPolicy
Prelude.Read, Int -> BatchLookupPolicy -> ShowS
[BatchLookupPolicy] -> ShowS
BatchLookupPolicy -> String
(Int -> BatchLookupPolicy -> ShowS)
-> (BatchLookupPolicy -> String)
-> ([BatchLookupPolicy] -> ShowS)
-> Show BatchLookupPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchLookupPolicy] -> ShowS
$cshowList :: [BatchLookupPolicy] -> ShowS
show :: BatchLookupPolicy -> String
$cshow :: BatchLookupPolicy -> String
showsPrec :: Int -> BatchLookupPolicy -> ShowS
$cshowsPrec :: Int -> BatchLookupPolicy -> ShowS
Prelude.Show, (forall x. BatchLookupPolicy -> Rep BatchLookupPolicy x)
-> (forall x. Rep BatchLookupPolicy x -> BatchLookupPolicy)
-> Generic BatchLookupPolicy
forall x. Rep BatchLookupPolicy x -> BatchLookupPolicy
forall x. BatchLookupPolicy -> Rep BatchLookupPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchLookupPolicy x -> BatchLookupPolicy
$cfrom :: forall x. BatchLookupPolicy -> Rep BatchLookupPolicy x
Prelude.Generic)

-- |
-- Create a value of 'BatchLookupPolicy' 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', 'batchLookupPolicy_nextToken' - The pagination token.
--
-- 'maxResults', 'batchLookupPolicy_maxResults' - The maximum number of results to retrieve.
--
-- 'objectReference', 'batchLookupPolicy_objectReference' - Reference that identifies the object whose policies will be looked up.
newBatchLookupPolicy ::
  -- | 'objectReference'
  ObjectReference ->
  BatchLookupPolicy
newBatchLookupPolicy :: ObjectReference -> BatchLookupPolicy
newBatchLookupPolicy ObjectReference
pObjectReference_ =
  BatchLookupPolicy' :: Maybe Text -> Maybe Natural -> ObjectReference -> BatchLookupPolicy
BatchLookupPolicy'
    { $sel:nextToken:BatchLookupPolicy' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:BatchLookupPolicy' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:objectReference:BatchLookupPolicy' :: ObjectReference
objectReference = ObjectReference
pObjectReference_
    }

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

-- | The maximum number of results to retrieve.
batchLookupPolicy_maxResults :: Lens.Lens' BatchLookupPolicy (Prelude.Maybe Prelude.Natural)
batchLookupPolicy_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> BatchLookupPolicy -> f BatchLookupPolicy
batchLookupPolicy_maxResults = (BatchLookupPolicy -> Maybe Natural)
-> (BatchLookupPolicy -> Maybe Natural -> BatchLookupPolicy)
-> Lens
     BatchLookupPolicy BatchLookupPolicy (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchLookupPolicy' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:BatchLookupPolicy' :: BatchLookupPolicy -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: BatchLookupPolicy
s@BatchLookupPolicy' {} Maybe Natural
a -> BatchLookupPolicy
s {$sel:maxResults:BatchLookupPolicy' :: Maybe Natural
maxResults = Maybe Natural
a} :: BatchLookupPolicy)

-- | Reference that identifies the object whose policies will be looked up.
batchLookupPolicy_objectReference :: Lens.Lens' BatchLookupPolicy ObjectReference
batchLookupPolicy_objectReference :: (ObjectReference -> f ObjectReference)
-> BatchLookupPolicy -> f BatchLookupPolicy
batchLookupPolicy_objectReference = (BatchLookupPolicy -> ObjectReference)
-> (BatchLookupPolicy -> ObjectReference -> BatchLookupPolicy)
-> Lens
     BatchLookupPolicy BatchLookupPolicy ObjectReference ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchLookupPolicy' {ObjectReference
objectReference :: ObjectReference
$sel:objectReference:BatchLookupPolicy' :: BatchLookupPolicy -> ObjectReference
objectReference} -> ObjectReference
objectReference) (\s :: BatchLookupPolicy
s@BatchLookupPolicy' {} ObjectReference
a -> BatchLookupPolicy
s {$sel:objectReference:BatchLookupPolicy' :: ObjectReference
objectReference = ObjectReference
a} :: BatchLookupPolicy)

instance Prelude.Hashable BatchLookupPolicy

instance Prelude.NFData BatchLookupPolicy

instance Core.ToJSON BatchLookupPolicy where
  toJSON :: BatchLookupPolicy -> Value
toJSON BatchLookupPolicy' {Maybe Natural
Maybe Text
ObjectReference
objectReference :: ObjectReference
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:objectReference:BatchLookupPolicy' :: BatchLookupPolicy -> ObjectReference
$sel:maxResults:BatchLookupPolicy' :: BatchLookupPolicy -> Maybe Natural
$sel:nextToken:BatchLookupPolicy' :: BatchLookupPolicy -> Maybe Text
..} =
    [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)
          ]
      )