{-# 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.IoT.Types.ExplicitDeny
-- 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.IoT.Types.ExplicitDeny where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.Policy
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information that explicitly denies authorization.
--
-- /See:/ 'newExplicitDeny' smart constructor.
data ExplicitDeny = ExplicitDeny'
  { -- | The policies that denied the authorization.
    ExplicitDeny -> Maybe [Policy]
policies :: Prelude.Maybe [Policy]
  }
  deriving (ExplicitDeny -> ExplicitDeny -> Bool
(ExplicitDeny -> ExplicitDeny -> Bool)
-> (ExplicitDeny -> ExplicitDeny -> Bool) -> Eq ExplicitDeny
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExplicitDeny -> ExplicitDeny -> Bool
$c/= :: ExplicitDeny -> ExplicitDeny -> Bool
== :: ExplicitDeny -> ExplicitDeny -> Bool
$c== :: ExplicitDeny -> ExplicitDeny -> Bool
Prelude.Eq, ReadPrec [ExplicitDeny]
ReadPrec ExplicitDeny
Int -> ReadS ExplicitDeny
ReadS [ExplicitDeny]
(Int -> ReadS ExplicitDeny)
-> ReadS [ExplicitDeny]
-> ReadPrec ExplicitDeny
-> ReadPrec [ExplicitDeny]
-> Read ExplicitDeny
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExplicitDeny]
$creadListPrec :: ReadPrec [ExplicitDeny]
readPrec :: ReadPrec ExplicitDeny
$creadPrec :: ReadPrec ExplicitDeny
readList :: ReadS [ExplicitDeny]
$creadList :: ReadS [ExplicitDeny]
readsPrec :: Int -> ReadS ExplicitDeny
$creadsPrec :: Int -> ReadS ExplicitDeny
Prelude.Read, Int -> ExplicitDeny -> ShowS
[ExplicitDeny] -> ShowS
ExplicitDeny -> String
(Int -> ExplicitDeny -> ShowS)
-> (ExplicitDeny -> String)
-> ([ExplicitDeny] -> ShowS)
-> Show ExplicitDeny
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExplicitDeny] -> ShowS
$cshowList :: [ExplicitDeny] -> ShowS
show :: ExplicitDeny -> String
$cshow :: ExplicitDeny -> String
showsPrec :: Int -> ExplicitDeny -> ShowS
$cshowsPrec :: Int -> ExplicitDeny -> ShowS
Prelude.Show, (forall x. ExplicitDeny -> Rep ExplicitDeny x)
-> (forall x. Rep ExplicitDeny x -> ExplicitDeny)
-> Generic ExplicitDeny
forall x. Rep ExplicitDeny x -> ExplicitDeny
forall x. ExplicitDeny -> Rep ExplicitDeny x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExplicitDeny x -> ExplicitDeny
$cfrom :: forall x. ExplicitDeny -> Rep ExplicitDeny x
Prelude.Generic)

-- |
-- Create a value of 'ExplicitDeny' 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:
--
-- 'policies', 'explicitDeny_policies' - The policies that denied the authorization.
newExplicitDeny ::
  ExplicitDeny
newExplicitDeny :: ExplicitDeny
newExplicitDeny =
  ExplicitDeny' :: Maybe [Policy] -> ExplicitDeny
ExplicitDeny' {$sel:policies:ExplicitDeny' :: Maybe [Policy]
policies = Maybe [Policy]
forall a. Maybe a
Prelude.Nothing}

-- | The policies that denied the authorization.
explicitDeny_policies :: Lens.Lens' ExplicitDeny (Prelude.Maybe [Policy])
explicitDeny_policies :: (Maybe [Policy] -> f (Maybe [Policy]))
-> ExplicitDeny -> f ExplicitDeny
explicitDeny_policies = (ExplicitDeny -> Maybe [Policy])
-> (ExplicitDeny -> Maybe [Policy] -> ExplicitDeny)
-> Lens ExplicitDeny ExplicitDeny (Maybe [Policy]) (Maybe [Policy])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExplicitDeny' {Maybe [Policy]
policies :: Maybe [Policy]
$sel:policies:ExplicitDeny' :: ExplicitDeny -> Maybe [Policy]
policies} -> Maybe [Policy]
policies) (\s :: ExplicitDeny
s@ExplicitDeny' {} Maybe [Policy]
a -> ExplicitDeny
s {$sel:policies:ExplicitDeny' :: Maybe [Policy]
policies = Maybe [Policy]
a} :: ExplicitDeny) ((Maybe [Policy] -> f (Maybe [Policy]))
 -> ExplicitDeny -> f ExplicitDeny)
-> ((Maybe [Policy] -> f (Maybe [Policy]))
    -> Maybe [Policy] -> f (Maybe [Policy]))
-> (Maybe [Policy] -> f (Maybe [Policy]))
-> ExplicitDeny
-> f ExplicitDeny
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Policy] [Policy] [Policy] [Policy]
-> Iso
     (Maybe [Policy]) (Maybe [Policy]) (Maybe [Policy]) (Maybe [Policy])
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 [Policy] [Policy] [Policy] [Policy]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ExplicitDeny where
  parseJSON :: Value -> Parser ExplicitDeny
parseJSON =
    String
-> (Object -> Parser ExplicitDeny) -> Value -> Parser ExplicitDeny
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExplicitDeny"
      ( \Object
x ->
          Maybe [Policy] -> ExplicitDeny
ExplicitDeny'
            (Maybe [Policy] -> ExplicitDeny)
-> Parser (Maybe [Policy]) -> Parser ExplicitDeny
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Policy]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"policies" Parser (Maybe (Maybe [Policy]))
-> Maybe [Policy] -> Parser (Maybe [Policy])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Policy]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ExplicitDeny

instance Prelude.NFData ExplicitDeny