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

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.ExplicitDeny
import Amazonka.IoT.Types.ImplicitDeny
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information that denied the authorization.
--
-- /See:/ 'newDenied' smart constructor.
data Denied = Denied'
  { -- | Information that implicitly denies the authorization. When a policy
    -- doesn\'t explicitly deny or allow an action on a resource it is
    -- considered an implicit deny.
    Denied -> Maybe ImplicitDeny
implicitDeny :: Prelude.Maybe ImplicitDeny,
    -- | Information that explicitly denies the authorization.
    Denied -> Maybe ExplicitDeny
explicitDeny :: Prelude.Maybe ExplicitDeny
  }
  deriving (Denied -> Denied -> Bool
(Denied -> Denied -> Bool)
-> (Denied -> Denied -> Bool) -> Eq Denied
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Denied -> Denied -> Bool
$c/= :: Denied -> Denied -> Bool
== :: Denied -> Denied -> Bool
$c== :: Denied -> Denied -> Bool
Prelude.Eq, ReadPrec [Denied]
ReadPrec Denied
Int -> ReadS Denied
ReadS [Denied]
(Int -> ReadS Denied)
-> ReadS [Denied]
-> ReadPrec Denied
-> ReadPrec [Denied]
-> Read Denied
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Denied]
$creadListPrec :: ReadPrec [Denied]
readPrec :: ReadPrec Denied
$creadPrec :: ReadPrec Denied
readList :: ReadS [Denied]
$creadList :: ReadS [Denied]
readsPrec :: Int -> ReadS Denied
$creadsPrec :: Int -> ReadS Denied
Prelude.Read, Int -> Denied -> ShowS
[Denied] -> ShowS
Denied -> String
(Int -> Denied -> ShowS)
-> (Denied -> String) -> ([Denied] -> ShowS) -> Show Denied
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Denied] -> ShowS
$cshowList :: [Denied] -> ShowS
show :: Denied -> String
$cshow :: Denied -> String
showsPrec :: Int -> Denied -> ShowS
$cshowsPrec :: Int -> Denied -> ShowS
Prelude.Show, (forall x. Denied -> Rep Denied x)
-> (forall x. Rep Denied x -> Denied) -> Generic Denied
forall x. Rep Denied x -> Denied
forall x. Denied -> Rep Denied x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Denied x -> Denied
$cfrom :: forall x. Denied -> Rep Denied x
Prelude.Generic)

-- |
-- Create a value of 'Denied' 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:
--
-- 'implicitDeny', 'denied_implicitDeny' - Information that implicitly denies the authorization. When a policy
-- doesn\'t explicitly deny or allow an action on a resource it is
-- considered an implicit deny.
--
-- 'explicitDeny', 'denied_explicitDeny' - Information that explicitly denies the authorization.
newDenied ::
  Denied
newDenied :: Denied
newDenied =
  Denied' :: Maybe ImplicitDeny -> Maybe ExplicitDeny -> Denied
Denied'
    { $sel:implicitDeny:Denied' :: Maybe ImplicitDeny
implicitDeny = Maybe ImplicitDeny
forall a. Maybe a
Prelude.Nothing,
      $sel:explicitDeny:Denied' :: Maybe ExplicitDeny
explicitDeny = Maybe ExplicitDeny
forall a. Maybe a
Prelude.Nothing
    }

-- | Information that implicitly denies the authorization. When a policy
-- doesn\'t explicitly deny or allow an action on a resource it is
-- considered an implicit deny.
denied_implicitDeny :: Lens.Lens' Denied (Prelude.Maybe ImplicitDeny)
denied_implicitDeny :: (Maybe ImplicitDeny -> f (Maybe ImplicitDeny))
-> Denied -> f Denied
denied_implicitDeny = (Denied -> Maybe ImplicitDeny)
-> (Denied -> Maybe ImplicitDeny -> Denied)
-> Lens Denied Denied (Maybe ImplicitDeny) (Maybe ImplicitDeny)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Denied' {Maybe ImplicitDeny
implicitDeny :: Maybe ImplicitDeny
$sel:implicitDeny:Denied' :: Denied -> Maybe ImplicitDeny
implicitDeny} -> Maybe ImplicitDeny
implicitDeny) (\s :: Denied
s@Denied' {} Maybe ImplicitDeny
a -> Denied
s {$sel:implicitDeny:Denied' :: Maybe ImplicitDeny
implicitDeny = Maybe ImplicitDeny
a} :: Denied)

-- | Information that explicitly denies the authorization.
denied_explicitDeny :: Lens.Lens' Denied (Prelude.Maybe ExplicitDeny)
denied_explicitDeny :: (Maybe ExplicitDeny -> f (Maybe ExplicitDeny))
-> Denied -> f Denied
denied_explicitDeny = (Denied -> Maybe ExplicitDeny)
-> (Denied -> Maybe ExplicitDeny -> Denied)
-> Lens Denied Denied (Maybe ExplicitDeny) (Maybe ExplicitDeny)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Denied' {Maybe ExplicitDeny
explicitDeny :: Maybe ExplicitDeny
$sel:explicitDeny:Denied' :: Denied -> Maybe ExplicitDeny
explicitDeny} -> Maybe ExplicitDeny
explicitDeny) (\s :: Denied
s@Denied' {} Maybe ExplicitDeny
a -> Denied
s {$sel:explicitDeny:Denied' :: Maybe ExplicitDeny
explicitDeny = Maybe ExplicitDeny
a} :: Denied)

instance Core.FromJSON Denied where
  parseJSON :: Value -> Parser Denied
parseJSON =
    String -> (Object -> Parser Denied) -> Value -> Parser Denied
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Denied"
      ( \Object
x ->
          Maybe ImplicitDeny -> Maybe ExplicitDeny -> Denied
Denied'
            (Maybe ImplicitDeny -> Maybe ExplicitDeny -> Denied)
-> Parser (Maybe ImplicitDeny)
-> Parser (Maybe ExplicitDeny -> Denied)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ImplicitDeny)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"implicitDeny")
            Parser (Maybe ExplicitDeny -> Denied)
-> Parser (Maybe ExplicitDeny) -> Parser Denied
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ExplicitDeny)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"explicitDeny")
      )

instance Prelude.Hashable Denied

instance Prelude.NFData Denied