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

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

-- | Contains information that allowed the authorization.
--
-- /See:/ 'newAllowed' smart constructor.
data Allowed = Allowed'
  { -- | A list of policies that allowed the authentication.
    Allowed -> Maybe [Policy]
policies :: Prelude.Maybe [Policy]
  }
  deriving (Allowed -> Allowed -> Bool
(Allowed -> Allowed -> Bool)
-> (Allowed -> Allowed -> Bool) -> Eq Allowed
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Allowed -> Allowed -> Bool
$c/= :: Allowed -> Allowed -> Bool
== :: Allowed -> Allowed -> Bool
$c== :: Allowed -> Allowed -> Bool
Prelude.Eq, ReadPrec [Allowed]
ReadPrec Allowed
Int -> ReadS Allowed
ReadS [Allowed]
(Int -> ReadS Allowed)
-> ReadS [Allowed]
-> ReadPrec Allowed
-> ReadPrec [Allowed]
-> Read Allowed
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Allowed]
$creadListPrec :: ReadPrec [Allowed]
readPrec :: ReadPrec Allowed
$creadPrec :: ReadPrec Allowed
readList :: ReadS [Allowed]
$creadList :: ReadS [Allowed]
readsPrec :: Int -> ReadS Allowed
$creadsPrec :: Int -> ReadS Allowed
Prelude.Read, Int -> Allowed -> ShowS
[Allowed] -> ShowS
Allowed -> String
(Int -> Allowed -> ShowS)
-> (Allowed -> String) -> ([Allowed] -> ShowS) -> Show Allowed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Allowed] -> ShowS
$cshowList :: [Allowed] -> ShowS
show :: Allowed -> String
$cshow :: Allowed -> String
showsPrec :: Int -> Allowed -> ShowS
$cshowsPrec :: Int -> Allowed -> ShowS
Prelude.Show, (forall x. Allowed -> Rep Allowed x)
-> (forall x. Rep Allowed x -> Allowed) -> Generic Allowed
forall x. Rep Allowed x -> Allowed
forall x. Allowed -> Rep Allowed x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Allowed x -> Allowed
$cfrom :: forall x. Allowed -> Rep Allowed x
Prelude.Generic)

-- |
-- Create a value of 'Allowed' 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', 'allowed_policies' - A list of policies that allowed the authentication.
newAllowed ::
  Allowed
newAllowed :: Allowed
newAllowed = Allowed' :: Maybe [Policy] -> Allowed
Allowed' {$sel:policies:Allowed' :: Maybe [Policy]
policies = Maybe [Policy]
forall a. Maybe a
Prelude.Nothing}

-- | A list of policies that allowed the authentication.
allowed_policies :: Lens.Lens' Allowed (Prelude.Maybe [Policy])
allowed_policies :: (Maybe [Policy] -> f (Maybe [Policy])) -> Allowed -> f Allowed
allowed_policies = (Allowed -> Maybe [Policy])
-> (Allowed -> Maybe [Policy] -> Allowed)
-> Lens Allowed Allowed (Maybe [Policy]) (Maybe [Policy])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Allowed' {Maybe [Policy]
policies :: Maybe [Policy]
$sel:policies:Allowed' :: Allowed -> Maybe [Policy]
policies} -> Maybe [Policy]
policies) (\s :: Allowed
s@Allowed' {} Maybe [Policy]
a -> Allowed
s {$sel:policies:Allowed' :: Maybe [Policy]
policies = Maybe [Policy]
a} :: Allowed) ((Maybe [Policy] -> f (Maybe [Policy])) -> Allowed -> f Allowed)
-> ((Maybe [Policy] -> f (Maybe [Policy]))
    -> Maybe [Policy] -> f (Maybe [Policy]))
-> (Maybe [Policy] -> f (Maybe [Policy]))
-> Allowed
-> f Allowed
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 Allowed where
  parseJSON :: Value -> Parser Allowed
parseJSON =
    String -> (Object -> Parser Allowed) -> Value -> Parser Allowed
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Allowed"
      ( \Object
x ->
          Maybe [Policy] -> Allowed
Allowed'
            (Maybe [Policy] -> Allowed)
-> Parser (Maybe [Policy]) -> Parser Allowed
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 Allowed

instance Prelude.NFData Allowed