{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 maximum number of results to retrieve.
    BatchLookupPolicy -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token.
    BatchLookupPolicy -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Reference that identifies the object whose policies will be looked up.
    BatchLookupPolicy -> ObjectReference
objectReference :: ObjectReference
  }
  deriving (BatchLookupPolicy -> BatchLookupPolicy -> Bool
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]
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
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. 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:
--
-- 'maxResults', 'batchLookupPolicy_maxResults' - The maximum number of results to retrieve.
--
-- 'nextToken', 'batchLookupPolicy_nextToken' - The pagination token.
--
-- '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'
    { $sel:maxResults:BatchLookupPolicy' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:BatchLookupPolicy' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:objectReference:BatchLookupPolicy' :: ObjectReference
objectReference = ObjectReference
pObjectReference_
    }

-- | The maximum number of results to retrieve.
batchLookupPolicy_maxResults :: Lens.Lens' BatchLookupPolicy (Prelude.Maybe Prelude.Natural)
batchLookupPolicy_maxResults :: Lens' BatchLookupPolicy (Maybe Natural)
batchLookupPolicy_maxResults = 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)

-- | The pagination token.
batchLookupPolicy_nextToken :: Lens.Lens' BatchLookupPolicy (Prelude.Maybe Prelude.Text)
batchLookupPolicy_nextToken :: Lens' BatchLookupPolicy (Maybe Text)
batchLookupPolicy_nextToken = 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)

-- | Reference that identifies the object whose policies will be looked up.
batchLookupPolicy_objectReference :: Lens.Lens' BatchLookupPolicy ObjectReference
batchLookupPolicy_objectReference :: Lens' BatchLookupPolicy ObjectReference
batchLookupPolicy_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 where
  hashWithSalt :: Int -> BatchLookupPolicy -> Int
hashWithSalt Int
_salt BatchLookupPolicy' {Maybe Natural
Maybe Text
ObjectReference
objectReference :: ObjectReference
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:objectReference:BatchLookupPolicy' :: BatchLookupPolicy -> ObjectReference
$sel:nextToken:BatchLookupPolicy' :: BatchLookupPolicy -> Maybe Text
$sel:maxResults:BatchLookupPolicy' :: BatchLookupPolicy -> 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` ObjectReference
objectReference

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

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