{-# 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.PolicyToPath
-- 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.PolicyToPath where

import Amazonka.CloudDirectory.Types.PolicyAttachment
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

-- | Used when a regular object exists in a Directory and you want to find
-- all of the policies that are associated with that object and the parent
-- to that object.
--
-- /See:/ 'newPolicyToPath' smart constructor.
data PolicyToPath = PolicyToPath'
  { -- | The path that is referenced from the root.
    PolicyToPath -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | List of policy objects.
    PolicyToPath -> Maybe [PolicyAttachment]
policies :: Prelude.Maybe [PolicyAttachment]
  }
  deriving (PolicyToPath -> PolicyToPath -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyToPath -> PolicyToPath -> Bool
$c/= :: PolicyToPath -> PolicyToPath -> Bool
== :: PolicyToPath -> PolicyToPath -> Bool
$c== :: PolicyToPath -> PolicyToPath -> Bool
Prelude.Eq, ReadPrec [PolicyToPath]
ReadPrec PolicyToPath
Int -> ReadS PolicyToPath
ReadS [PolicyToPath]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyToPath]
$creadListPrec :: ReadPrec [PolicyToPath]
readPrec :: ReadPrec PolicyToPath
$creadPrec :: ReadPrec PolicyToPath
readList :: ReadS [PolicyToPath]
$creadList :: ReadS [PolicyToPath]
readsPrec :: Int -> ReadS PolicyToPath
$creadsPrec :: Int -> ReadS PolicyToPath
Prelude.Read, Int -> PolicyToPath -> ShowS
[PolicyToPath] -> ShowS
PolicyToPath -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyToPath] -> ShowS
$cshowList :: [PolicyToPath] -> ShowS
show :: PolicyToPath -> String
$cshow :: PolicyToPath -> String
showsPrec :: Int -> PolicyToPath -> ShowS
$cshowsPrec :: Int -> PolicyToPath -> ShowS
Prelude.Show, forall x. Rep PolicyToPath x -> PolicyToPath
forall x. PolicyToPath -> Rep PolicyToPath x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyToPath x -> PolicyToPath
$cfrom :: forall x. PolicyToPath -> Rep PolicyToPath x
Prelude.Generic)

-- |
-- Create a value of 'PolicyToPath' 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:
--
-- 'path', 'policyToPath_path' - The path that is referenced from the root.
--
-- 'policies', 'policyToPath_policies' - List of policy objects.
newPolicyToPath ::
  PolicyToPath
newPolicyToPath :: PolicyToPath
newPolicyToPath =
  PolicyToPath'
    { $sel:path:PolicyToPath' :: Maybe Text
path = forall a. Maybe a
Prelude.Nothing,
      $sel:policies:PolicyToPath' :: Maybe [PolicyAttachment]
policies = forall a. Maybe a
Prelude.Nothing
    }

-- | The path that is referenced from the root.
policyToPath_path :: Lens.Lens' PolicyToPath (Prelude.Maybe Prelude.Text)
policyToPath_path :: Lens' PolicyToPath (Maybe Text)
policyToPath_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyToPath' {Maybe Text
path :: Maybe Text
$sel:path:PolicyToPath' :: PolicyToPath -> Maybe Text
path} -> Maybe Text
path) (\s :: PolicyToPath
s@PolicyToPath' {} Maybe Text
a -> PolicyToPath
s {$sel:path:PolicyToPath' :: Maybe Text
path = Maybe Text
a} :: PolicyToPath)

-- | List of policy objects.
policyToPath_policies :: Lens.Lens' PolicyToPath (Prelude.Maybe [PolicyAttachment])
policyToPath_policies :: Lens' PolicyToPath (Maybe [PolicyAttachment])
policyToPath_policies = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyToPath' {Maybe [PolicyAttachment]
policies :: Maybe [PolicyAttachment]
$sel:policies:PolicyToPath' :: PolicyToPath -> Maybe [PolicyAttachment]
policies} -> Maybe [PolicyAttachment]
policies) (\s :: PolicyToPath
s@PolicyToPath' {} Maybe [PolicyAttachment]
a -> PolicyToPath
s {$sel:policies:PolicyToPath' :: Maybe [PolicyAttachment]
policies = Maybe [PolicyAttachment]
a} :: PolicyToPath) 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

instance Data.FromJSON PolicyToPath where
  parseJSON :: Value -> Parser PolicyToPath
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PolicyToPath"
      ( \Object
x ->
          Maybe Text -> Maybe [PolicyAttachment] -> PolicyToPath
PolicyToPath'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Path")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Policies" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PolicyToPath where
  hashWithSalt :: Int -> PolicyToPath -> Int
hashWithSalt Int
_salt PolicyToPath' {Maybe [PolicyAttachment]
Maybe Text
policies :: Maybe [PolicyAttachment]
path :: Maybe Text
$sel:policies:PolicyToPath' :: PolicyToPath -> Maybe [PolicyAttachment]
$sel:path:PolicyToPath' :: PolicyToPath -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PolicyAttachment]
policies

instance Prelude.NFData PolicyToPath where
  rnf :: PolicyToPath -> ()
rnf PolicyToPath' {Maybe [PolicyAttachment]
Maybe Text
policies :: Maybe [PolicyAttachment]
path :: Maybe Text
$sel:policies:PolicyToPath' :: PolicyToPath -> Maybe [PolicyAttachment]
$sel:path:PolicyToPath' :: PolicyToPath -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
path seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [PolicyAttachment]
policies