{-# 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-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.Allowed 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.Policy
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
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]
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
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. 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' {$sel:policies:Allowed' :: Maybe [Policy]
policies = forall a. Maybe a
Prelude.Nothing}

-- | A list of policies that allowed the authentication.
allowed_policies :: Lens.Lens' Allowed (Prelude.Maybe [Policy])
allowed_policies :: Lens' Allowed (Maybe [Policy])
allowed_policies = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON Allowed where
  parseJSON :: Value -> Parser Allowed
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Allowed"
      ( \Object
x ->
          Maybe [Policy] -> Allowed
Allowed'
            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
"policies" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Allowed where
  hashWithSalt :: Int -> Allowed -> Int
hashWithSalt Int
_salt Allowed' {Maybe [Policy]
policies :: Maybe [Policy]
$sel:policies:Allowed' :: Allowed -> Maybe [Policy]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Policy]
policies

instance Prelude.NFData Allowed where
  rnf :: Allowed -> ()
rnf Allowed' {Maybe [Policy]
policies :: Maybe [Policy]
$sel:policies:Allowed' :: Allowed -> Maybe [Policy]
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe [Policy]
policies