{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoT.Types.Denied where

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

-- | Contains information that denied the authorization.
--
-- /See:/ 'newDenied' smart constructor.
data Denied = Denied'
  { -- | Information that explicitly denies the authorization.
    Denied -> Maybe ExplicitDeny
explicitDeny :: Prelude.Maybe ExplicitDeny,
    -- | 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
  }
  deriving (Denied -> Denied -> Bool
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]
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
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. 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:
--
-- 'explicitDeny', 'denied_explicitDeny' - Information that explicitly denies the authorization.
--
-- '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.
newDenied ::
  Denied
newDenied :: Denied
newDenied =
  Denied'
    { $sel:explicitDeny:Denied' :: Maybe ExplicitDeny
explicitDeny = forall a. Maybe a
Prelude.Nothing,
      $sel:implicitDeny:Denied' :: Maybe ImplicitDeny
implicitDeny = forall a. Maybe a
Prelude.Nothing
    }

-- | Information that explicitly denies the authorization.
denied_explicitDeny :: Lens.Lens' Denied (Prelude.Maybe ExplicitDeny)
denied_explicitDeny :: Lens' Denied (Maybe ExplicitDeny)
denied_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)

-- | 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 :: Lens' Denied (Maybe ImplicitDeny)
denied_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)

instance Data.FromJSON Denied where
  parseJSON :: Value -> Parser Denied
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Denied"
      ( \Object
x ->
          Maybe ExplicitDeny -> Maybe ImplicitDeny -> Denied
Denied'
            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
"explicitDeny")
            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
"implicitDeny")
      )

instance Prelude.Hashable Denied where
  hashWithSalt :: Int -> Denied -> Int
hashWithSalt Int
_salt Denied' {Maybe ImplicitDeny
Maybe ExplicitDeny
implicitDeny :: Maybe ImplicitDeny
explicitDeny :: Maybe ExplicitDeny
$sel:implicitDeny:Denied' :: Denied -> Maybe ImplicitDeny
$sel:explicitDeny:Denied' :: Denied -> Maybe ExplicitDeny
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ExplicitDeny
explicitDeny
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ImplicitDeny
implicitDeny

instance Prelude.NFData Denied where
  rnf :: Denied -> ()
rnf Denied' {Maybe ImplicitDeny
Maybe ExplicitDeny
implicitDeny :: Maybe ImplicitDeny
explicitDeny :: Maybe ExplicitDeny
$sel:implicitDeny:Denied' :: Denied -> Maybe ImplicitDeny
$sel:explicitDeny:Denied' :: Denied -> Maybe ExplicitDeny
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ExplicitDeny
explicitDeny
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ImplicitDeny
implicitDeny