{-# 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.Organizations.Types.PolicyTypeSummary
-- 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.Organizations.Types.PolicyTypeSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types.PolicyType
import Amazonka.Organizations.Types.PolicyTypeStatus
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a policy type and its status in the
-- associated root.
--
-- /See:/ 'newPolicyTypeSummary' smart constructor.
data PolicyTypeSummary = PolicyTypeSummary'
  { -- | The status of the policy type as it relates to the associated root. To
    -- attach a policy of the specified type to a root or to an OU or account
    -- in that root, it must be available in the organization and enabled for
    -- that root.
    PolicyTypeSummary -> Maybe PolicyTypeStatus
status :: Prelude.Maybe PolicyTypeStatus,
    -- | The name of the policy type.
    PolicyTypeSummary -> Maybe PolicyType
type' :: Prelude.Maybe PolicyType
  }
  deriving (PolicyTypeSummary -> PolicyTypeSummary -> Bool
(PolicyTypeSummary -> PolicyTypeSummary -> Bool)
-> (PolicyTypeSummary -> PolicyTypeSummary -> Bool)
-> Eq PolicyTypeSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyTypeSummary -> PolicyTypeSummary -> Bool
$c/= :: PolicyTypeSummary -> PolicyTypeSummary -> Bool
== :: PolicyTypeSummary -> PolicyTypeSummary -> Bool
$c== :: PolicyTypeSummary -> PolicyTypeSummary -> Bool
Prelude.Eq, ReadPrec [PolicyTypeSummary]
ReadPrec PolicyTypeSummary
Int -> ReadS PolicyTypeSummary
ReadS [PolicyTypeSummary]
(Int -> ReadS PolicyTypeSummary)
-> ReadS [PolicyTypeSummary]
-> ReadPrec PolicyTypeSummary
-> ReadPrec [PolicyTypeSummary]
-> Read PolicyTypeSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyTypeSummary]
$creadListPrec :: ReadPrec [PolicyTypeSummary]
readPrec :: ReadPrec PolicyTypeSummary
$creadPrec :: ReadPrec PolicyTypeSummary
readList :: ReadS [PolicyTypeSummary]
$creadList :: ReadS [PolicyTypeSummary]
readsPrec :: Int -> ReadS PolicyTypeSummary
$creadsPrec :: Int -> ReadS PolicyTypeSummary
Prelude.Read, Int -> PolicyTypeSummary -> ShowS
[PolicyTypeSummary] -> ShowS
PolicyTypeSummary -> String
(Int -> PolicyTypeSummary -> ShowS)
-> (PolicyTypeSummary -> String)
-> ([PolicyTypeSummary] -> ShowS)
-> Show PolicyTypeSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyTypeSummary] -> ShowS
$cshowList :: [PolicyTypeSummary] -> ShowS
show :: PolicyTypeSummary -> String
$cshow :: PolicyTypeSummary -> String
showsPrec :: Int -> PolicyTypeSummary -> ShowS
$cshowsPrec :: Int -> PolicyTypeSummary -> ShowS
Prelude.Show, (forall x. PolicyTypeSummary -> Rep PolicyTypeSummary x)
-> (forall x. Rep PolicyTypeSummary x -> PolicyTypeSummary)
-> Generic PolicyTypeSummary
forall x. Rep PolicyTypeSummary x -> PolicyTypeSummary
forall x. PolicyTypeSummary -> Rep PolicyTypeSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyTypeSummary x -> PolicyTypeSummary
$cfrom :: forall x. PolicyTypeSummary -> Rep PolicyTypeSummary x
Prelude.Generic)

-- |
-- Create a value of 'PolicyTypeSummary' 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:
--
-- 'status', 'policyTypeSummary_status' - The status of the policy type as it relates to the associated root. To
-- attach a policy of the specified type to a root or to an OU or account
-- in that root, it must be available in the organization and enabled for
-- that root.
--
-- 'type'', 'policyTypeSummary_type' - The name of the policy type.
newPolicyTypeSummary ::
  PolicyTypeSummary
newPolicyTypeSummary :: PolicyTypeSummary
newPolicyTypeSummary =
  PolicyTypeSummary' :: Maybe PolicyTypeStatus -> Maybe PolicyType -> PolicyTypeSummary
PolicyTypeSummary'
    { $sel:status:PolicyTypeSummary' :: Maybe PolicyTypeStatus
status = Maybe PolicyTypeStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:type':PolicyTypeSummary' :: Maybe PolicyType
type' = Maybe PolicyType
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the policy type as it relates to the associated root. To
-- attach a policy of the specified type to a root or to an OU or account
-- in that root, it must be available in the organization and enabled for
-- that root.
policyTypeSummary_status :: Lens.Lens' PolicyTypeSummary (Prelude.Maybe PolicyTypeStatus)
policyTypeSummary_status :: (Maybe PolicyTypeStatus -> f (Maybe PolicyTypeStatus))
-> PolicyTypeSummary -> f PolicyTypeSummary
policyTypeSummary_status = (PolicyTypeSummary -> Maybe PolicyTypeStatus)
-> (PolicyTypeSummary
    -> Maybe PolicyTypeStatus -> PolicyTypeSummary)
-> Lens
     PolicyTypeSummary
     PolicyTypeSummary
     (Maybe PolicyTypeStatus)
     (Maybe PolicyTypeStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyTypeSummary' {Maybe PolicyTypeStatus
status :: Maybe PolicyTypeStatus
$sel:status:PolicyTypeSummary' :: PolicyTypeSummary -> Maybe PolicyTypeStatus
status} -> Maybe PolicyTypeStatus
status) (\s :: PolicyTypeSummary
s@PolicyTypeSummary' {} Maybe PolicyTypeStatus
a -> PolicyTypeSummary
s {$sel:status:PolicyTypeSummary' :: Maybe PolicyTypeStatus
status = Maybe PolicyTypeStatus
a} :: PolicyTypeSummary)

-- | The name of the policy type.
policyTypeSummary_type :: Lens.Lens' PolicyTypeSummary (Prelude.Maybe PolicyType)
policyTypeSummary_type :: (Maybe PolicyType -> f (Maybe PolicyType))
-> PolicyTypeSummary -> f PolicyTypeSummary
policyTypeSummary_type = (PolicyTypeSummary -> Maybe PolicyType)
-> (PolicyTypeSummary -> Maybe PolicyType -> PolicyTypeSummary)
-> Lens
     PolicyTypeSummary
     PolicyTypeSummary
     (Maybe PolicyType)
     (Maybe PolicyType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyTypeSummary' {Maybe PolicyType
type' :: Maybe PolicyType
$sel:type':PolicyTypeSummary' :: PolicyTypeSummary -> Maybe PolicyType
type'} -> Maybe PolicyType
type') (\s :: PolicyTypeSummary
s@PolicyTypeSummary' {} Maybe PolicyType
a -> PolicyTypeSummary
s {$sel:type':PolicyTypeSummary' :: Maybe PolicyType
type' = Maybe PolicyType
a} :: PolicyTypeSummary)

instance Core.FromJSON PolicyTypeSummary where
  parseJSON :: Value -> Parser PolicyTypeSummary
parseJSON =
    String
-> (Object -> Parser PolicyTypeSummary)
-> Value
-> Parser PolicyTypeSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PolicyTypeSummary"
      ( \Object
x ->
          Maybe PolicyTypeStatus -> Maybe PolicyType -> PolicyTypeSummary
PolicyTypeSummary'
            (Maybe PolicyTypeStatus -> Maybe PolicyType -> PolicyTypeSummary)
-> Parser (Maybe PolicyTypeStatus)
-> Parser (Maybe PolicyType -> PolicyTypeSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe PolicyTypeStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser (Maybe PolicyType -> PolicyTypeSummary)
-> Parser (Maybe PolicyType) -> Parser PolicyTypeSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe PolicyType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable PolicyTypeSummary

instance Prelude.NFData PolicyTypeSummary