{-# 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.IoTSiteWise.Types.AccessPolicySummary
-- 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.IoTSiteWise.Types.AccessPolicySummary where

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.Identity
import Amazonka.IoTSiteWise.Types.Permission
import Amazonka.IoTSiteWise.Types.Resource
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains an access policy that defines an identity\'s access to an IoT
-- SiteWise Monitor resource.
--
-- /See:/ 'newAccessPolicySummary' smart constructor.
data AccessPolicySummary = AccessPolicySummary'
  { -- | The date the access policy was last updated, in Unix epoch time.
    AccessPolicySummary -> Maybe POSIX
lastUpdateDate :: Prelude.Maybe Core.POSIX,
    -- | The date the access policy was created, in Unix epoch time.
    AccessPolicySummary -> Maybe POSIX
creationDate :: Prelude.Maybe Core.POSIX,
    -- | The ID of the access policy.
    AccessPolicySummary -> Text
id :: Prelude.Text,
    -- | The identity (an Amazon Web Services SSO user, an Amazon Web Services
    -- SSO group, or an IAM user).
    AccessPolicySummary -> Identity
identity :: Identity,
    -- | The IoT SiteWise Monitor resource (a portal or project).
    AccessPolicySummary -> Resource
resource :: Resource,
    -- | The permissions for the access policy. Note that a project
    -- @ADMINISTRATOR@ is also known as a project owner.
    AccessPolicySummary -> Permission
permission :: Permission
  }
  deriving (AccessPolicySummary -> AccessPolicySummary -> Bool
(AccessPolicySummary -> AccessPolicySummary -> Bool)
-> (AccessPolicySummary -> AccessPolicySummary -> Bool)
-> Eq AccessPolicySummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessPolicySummary -> AccessPolicySummary -> Bool
$c/= :: AccessPolicySummary -> AccessPolicySummary -> Bool
== :: AccessPolicySummary -> AccessPolicySummary -> Bool
$c== :: AccessPolicySummary -> AccessPolicySummary -> Bool
Prelude.Eq, ReadPrec [AccessPolicySummary]
ReadPrec AccessPolicySummary
Int -> ReadS AccessPolicySummary
ReadS [AccessPolicySummary]
(Int -> ReadS AccessPolicySummary)
-> ReadS [AccessPolicySummary]
-> ReadPrec AccessPolicySummary
-> ReadPrec [AccessPolicySummary]
-> Read AccessPolicySummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccessPolicySummary]
$creadListPrec :: ReadPrec [AccessPolicySummary]
readPrec :: ReadPrec AccessPolicySummary
$creadPrec :: ReadPrec AccessPolicySummary
readList :: ReadS [AccessPolicySummary]
$creadList :: ReadS [AccessPolicySummary]
readsPrec :: Int -> ReadS AccessPolicySummary
$creadsPrec :: Int -> ReadS AccessPolicySummary
Prelude.Read, Int -> AccessPolicySummary -> ShowS
[AccessPolicySummary] -> ShowS
AccessPolicySummary -> String
(Int -> AccessPolicySummary -> ShowS)
-> (AccessPolicySummary -> String)
-> ([AccessPolicySummary] -> ShowS)
-> Show AccessPolicySummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessPolicySummary] -> ShowS
$cshowList :: [AccessPolicySummary] -> ShowS
show :: AccessPolicySummary -> String
$cshow :: AccessPolicySummary -> String
showsPrec :: Int -> AccessPolicySummary -> ShowS
$cshowsPrec :: Int -> AccessPolicySummary -> ShowS
Prelude.Show, (forall x. AccessPolicySummary -> Rep AccessPolicySummary x)
-> (forall x. Rep AccessPolicySummary x -> AccessPolicySummary)
-> Generic AccessPolicySummary
forall x. Rep AccessPolicySummary x -> AccessPolicySummary
forall x. AccessPolicySummary -> Rep AccessPolicySummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccessPolicySummary x -> AccessPolicySummary
$cfrom :: forall x. AccessPolicySummary -> Rep AccessPolicySummary x
Prelude.Generic)

-- |
-- Create a value of 'AccessPolicySummary' 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:
--
-- 'lastUpdateDate', 'accessPolicySummary_lastUpdateDate' - The date the access policy was last updated, in Unix epoch time.
--
-- 'creationDate', 'accessPolicySummary_creationDate' - The date the access policy was created, in Unix epoch time.
--
-- 'id', 'accessPolicySummary_id' - The ID of the access policy.
--
-- 'identity', 'accessPolicySummary_identity' - The identity (an Amazon Web Services SSO user, an Amazon Web Services
-- SSO group, or an IAM user).
--
-- 'resource', 'accessPolicySummary_resource' - The IoT SiteWise Monitor resource (a portal or project).
--
-- 'permission', 'accessPolicySummary_permission' - The permissions for the access policy. Note that a project
-- @ADMINISTRATOR@ is also known as a project owner.
newAccessPolicySummary ::
  -- | 'id'
  Prelude.Text ->
  -- | 'identity'
  Identity ->
  -- | 'resource'
  Resource ->
  -- | 'permission'
  Permission ->
  AccessPolicySummary
newAccessPolicySummary :: Text -> Identity -> Resource -> Permission -> AccessPolicySummary
newAccessPolicySummary
  Text
pId_
  Identity
pIdentity_
  Resource
pResource_
  Permission
pPermission_ =
    AccessPolicySummary' :: Maybe POSIX
-> Maybe POSIX
-> Text
-> Identity
-> Resource
-> Permission
-> AccessPolicySummary
AccessPolicySummary'
      { $sel:lastUpdateDate:AccessPolicySummary' :: Maybe POSIX
lastUpdateDate =
          Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:creationDate:AccessPolicySummary' :: Maybe POSIX
creationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:id:AccessPolicySummary' :: Text
id = Text
pId_,
        $sel:identity:AccessPolicySummary' :: Identity
identity = Identity
pIdentity_,
        $sel:resource:AccessPolicySummary' :: Resource
resource = Resource
pResource_,
        $sel:permission:AccessPolicySummary' :: Permission
permission = Permission
pPermission_
      }

-- | The date the access policy was last updated, in Unix epoch time.
accessPolicySummary_lastUpdateDate :: Lens.Lens' AccessPolicySummary (Prelude.Maybe Prelude.UTCTime)
accessPolicySummary_lastUpdateDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AccessPolicySummary -> f AccessPolicySummary
accessPolicySummary_lastUpdateDate = (AccessPolicySummary -> Maybe POSIX)
-> (AccessPolicySummary -> Maybe POSIX -> AccessPolicySummary)
-> Lens
     AccessPolicySummary AccessPolicySummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPolicySummary' {Maybe POSIX
lastUpdateDate :: Maybe POSIX
$sel:lastUpdateDate:AccessPolicySummary' :: AccessPolicySummary -> Maybe POSIX
lastUpdateDate} -> Maybe POSIX
lastUpdateDate) (\s :: AccessPolicySummary
s@AccessPolicySummary' {} Maybe POSIX
a -> AccessPolicySummary
s {$sel:lastUpdateDate:AccessPolicySummary' :: Maybe POSIX
lastUpdateDate = Maybe POSIX
a} :: AccessPolicySummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> AccessPolicySummary -> f AccessPolicySummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AccessPolicySummary
-> f AccessPolicySummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The date the access policy was created, in Unix epoch time.
accessPolicySummary_creationDate :: Lens.Lens' AccessPolicySummary (Prelude.Maybe Prelude.UTCTime)
accessPolicySummary_creationDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AccessPolicySummary -> f AccessPolicySummary
accessPolicySummary_creationDate = (AccessPolicySummary -> Maybe POSIX)
-> (AccessPolicySummary -> Maybe POSIX -> AccessPolicySummary)
-> Lens
     AccessPolicySummary AccessPolicySummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPolicySummary' {Maybe POSIX
creationDate :: Maybe POSIX
$sel:creationDate:AccessPolicySummary' :: AccessPolicySummary -> Maybe POSIX
creationDate} -> Maybe POSIX
creationDate) (\s :: AccessPolicySummary
s@AccessPolicySummary' {} Maybe POSIX
a -> AccessPolicySummary
s {$sel:creationDate:AccessPolicySummary' :: Maybe POSIX
creationDate = Maybe POSIX
a} :: AccessPolicySummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> AccessPolicySummary -> f AccessPolicySummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AccessPolicySummary
-> f AccessPolicySummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The ID of the access policy.
accessPolicySummary_id :: Lens.Lens' AccessPolicySummary Prelude.Text
accessPolicySummary_id :: (Text -> f Text) -> AccessPolicySummary -> f AccessPolicySummary
accessPolicySummary_id = (AccessPolicySummary -> Text)
-> (AccessPolicySummary -> Text -> AccessPolicySummary)
-> Lens AccessPolicySummary AccessPolicySummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPolicySummary' {Text
id :: Text
$sel:id:AccessPolicySummary' :: AccessPolicySummary -> Text
id} -> Text
id) (\s :: AccessPolicySummary
s@AccessPolicySummary' {} Text
a -> AccessPolicySummary
s {$sel:id:AccessPolicySummary' :: Text
id = Text
a} :: AccessPolicySummary)

-- | The identity (an Amazon Web Services SSO user, an Amazon Web Services
-- SSO group, or an IAM user).
accessPolicySummary_identity :: Lens.Lens' AccessPolicySummary Identity
accessPolicySummary_identity :: (Identity -> f Identity)
-> AccessPolicySummary -> f AccessPolicySummary
accessPolicySummary_identity = (AccessPolicySummary -> Identity)
-> (AccessPolicySummary -> Identity -> AccessPolicySummary)
-> Lens AccessPolicySummary AccessPolicySummary Identity Identity
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPolicySummary' {Identity
identity :: Identity
$sel:identity:AccessPolicySummary' :: AccessPolicySummary -> Identity
identity} -> Identity
identity) (\s :: AccessPolicySummary
s@AccessPolicySummary' {} Identity
a -> AccessPolicySummary
s {$sel:identity:AccessPolicySummary' :: Identity
identity = Identity
a} :: AccessPolicySummary)

-- | The IoT SiteWise Monitor resource (a portal or project).
accessPolicySummary_resource :: Lens.Lens' AccessPolicySummary Resource
accessPolicySummary_resource :: (Resource -> f Resource)
-> AccessPolicySummary -> f AccessPolicySummary
accessPolicySummary_resource = (AccessPolicySummary -> Resource)
-> (AccessPolicySummary -> Resource -> AccessPolicySummary)
-> Lens AccessPolicySummary AccessPolicySummary Resource Resource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPolicySummary' {Resource
resource :: Resource
$sel:resource:AccessPolicySummary' :: AccessPolicySummary -> Resource
resource} -> Resource
resource) (\s :: AccessPolicySummary
s@AccessPolicySummary' {} Resource
a -> AccessPolicySummary
s {$sel:resource:AccessPolicySummary' :: Resource
resource = Resource
a} :: AccessPolicySummary)

-- | The permissions for the access policy. Note that a project
-- @ADMINISTRATOR@ is also known as a project owner.
accessPolicySummary_permission :: Lens.Lens' AccessPolicySummary Permission
accessPolicySummary_permission :: (Permission -> f Permission)
-> AccessPolicySummary -> f AccessPolicySummary
accessPolicySummary_permission = (AccessPolicySummary -> Permission)
-> (AccessPolicySummary -> Permission -> AccessPolicySummary)
-> Lens
     AccessPolicySummary AccessPolicySummary Permission Permission
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessPolicySummary' {Permission
permission :: Permission
$sel:permission:AccessPolicySummary' :: AccessPolicySummary -> Permission
permission} -> Permission
permission) (\s :: AccessPolicySummary
s@AccessPolicySummary' {} Permission
a -> AccessPolicySummary
s {$sel:permission:AccessPolicySummary' :: Permission
permission = Permission
a} :: AccessPolicySummary)

instance Core.FromJSON AccessPolicySummary where
  parseJSON :: Value -> Parser AccessPolicySummary
parseJSON =
    String
-> (Object -> Parser AccessPolicySummary)
-> Value
-> Parser AccessPolicySummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AccessPolicySummary"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Text
-> Identity
-> Resource
-> Permission
-> AccessPolicySummary
AccessPolicySummary'
            (Maybe POSIX
 -> Maybe POSIX
 -> Text
 -> Identity
 -> Resource
 -> Permission
 -> AccessPolicySummary)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX
      -> Text
      -> Identity
      -> Resource
      -> Permission
      -> AccessPolicySummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastUpdateDate")
            Parser
  (Maybe POSIX
   -> Text
   -> Identity
   -> Resource
   -> Permission
   -> AccessPolicySummary)
-> Parser (Maybe POSIX)
-> Parser
     (Text -> Identity -> Resource -> Permission -> AccessPolicySummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"creationDate")
            Parser
  (Text -> Identity -> Resource -> Permission -> AccessPolicySummary)
-> Parser Text
-> Parser
     (Identity -> Resource -> Permission -> AccessPolicySummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"id")
            Parser (Identity -> Resource -> Permission -> AccessPolicySummary)
-> Parser Identity
-> Parser (Resource -> Permission -> AccessPolicySummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Identity
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"identity")
            Parser (Resource -> Permission -> AccessPolicySummary)
-> Parser Resource -> Parser (Permission -> AccessPolicySummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Resource
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"resource")
            Parser (Permission -> AccessPolicySummary)
-> Parser Permission -> Parser AccessPolicySummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Permission
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"permission")
      )

instance Prelude.Hashable AccessPolicySummary

instance Prelude.NFData AccessPolicySummary