{-# 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.Cloud9.Types.EnvironmentMember
-- 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.Cloud9.Types.EnvironmentMember where

import Amazonka.Cloud9.Types.Permissions
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about an environment member for an Cloud9 development
-- environment.
--
-- /See:/ 'newEnvironmentMember' smart constructor.
data EnvironmentMember = EnvironmentMember'
  { -- | The time, expressed in epoch time format, when the environment member
    -- last opened the environment.
    EnvironmentMember -> Maybe POSIX
lastAccess :: Prelude.Maybe Core.POSIX,
    -- | The type of environment member permissions associated with this
    -- environment member. Available values include:
    --
    -- -   @owner@: Owns the environment.
    --
    -- -   @read-only@: Has read-only access to the environment.
    --
    -- -   @read-write@: Has read-write access to the environment.
    EnvironmentMember -> Permissions
permissions :: Permissions,
    -- | The user ID in Identity and Access Management (IAM) of the environment
    -- member.
    EnvironmentMember -> Text
userId :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the environment member.
    EnvironmentMember -> Text
userArn :: Prelude.Text,
    -- | The ID of the environment for the environment member.
    EnvironmentMember -> Text
environmentId :: Prelude.Text
  }
  deriving (EnvironmentMember -> EnvironmentMember -> Bool
(EnvironmentMember -> EnvironmentMember -> Bool)
-> (EnvironmentMember -> EnvironmentMember -> Bool)
-> Eq EnvironmentMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnvironmentMember -> EnvironmentMember -> Bool
$c/= :: EnvironmentMember -> EnvironmentMember -> Bool
== :: EnvironmentMember -> EnvironmentMember -> Bool
$c== :: EnvironmentMember -> EnvironmentMember -> Bool
Prelude.Eq, ReadPrec [EnvironmentMember]
ReadPrec EnvironmentMember
Int -> ReadS EnvironmentMember
ReadS [EnvironmentMember]
(Int -> ReadS EnvironmentMember)
-> ReadS [EnvironmentMember]
-> ReadPrec EnvironmentMember
-> ReadPrec [EnvironmentMember]
-> Read EnvironmentMember
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnvironmentMember]
$creadListPrec :: ReadPrec [EnvironmentMember]
readPrec :: ReadPrec EnvironmentMember
$creadPrec :: ReadPrec EnvironmentMember
readList :: ReadS [EnvironmentMember]
$creadList :: ReadS [EnvironmentMember]
readsPrec :: Int -> ReadS EnvironmentMember
$creadsPrec :: Int -> ReadS EnvironmentMember
Prelude.Read, Int -> EnvironmentMember -> ShowS
[EnvironmentMember] -> ShowS
EnvironmentMember -> String
(Int -> EnvironmentMember -> ShowS)
-> (EnvironmentMember -> String)
-> ([EnvironmentMember] -> ShowS)
-> Show EnvironmentMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnvironmentMember] -> ShowS
$cshowList :: [EnvironmentMember] -> ShowS
show :: EnvironmentMember -> String
$cshow :: EnvironmentMember -> String
showsPrec :: Int -> EnvironmentMember -> ShowS
$cshowsPrec :: Int -> EnvironmentMember -> ShowS
Prelude.Show, (forall x. EnvironmentMember -> Rep EnvironmentMember x)
-> (forall x. Rep EnvironmentMember x -> EnvironmentMember)
-> Generic EnvironmentMember
forall x. Rep EnvironmentMember x -> EnvironmentMember
forall x. EnvironmentMember -> Rep EnvironmentMember x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnvironmentMember x -> EnvironmentMember
$cfrom :: forall x. EnvironmentMember -> Rep EnvironmentMember x
Prelude.Generic)

-- |
-- Create a value of 'EnvironmentMember' 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:
--
-- 'lastAccess', 'environmentMember_lastAccess' - The time, expressed in epoch time format, when the environment member
-- last opened the environment.
--
-- 'permissions', 'environmentMember_permissions' - The type of environment member permissions associated with this
-- environment member. Available values include:
--
-- -   @owner@: Owns the environment.
--
-- -   @read-only@: Has read-only access to the environment.
--
-- -   @read-write@: Has read-write access to the environment.
--
-- 'userId', 'environmentMember_userId' - The user ID in Identity and Access Management (IAM) of the environment
-- member.
--
-- 'userArn', 'environmentMember_userArn' - The Amazon Resource Name (ARN) of the environment member.
--
-- 'environmentId', 'environmentMember_environmentId' - The ID of the environment for the environment member.
newEnvironmentMember ::
  -- | 'permissions'
  Permissions ->
  -- | 'userId'
  Prelude.Text ->
  -- | 'userArn'
  Prelude.Text ->
  -- | 'environmentId'
  Prelude.Text ->
  EnvironmentMember
newEnvironmentMember :: Permissions -> Text -> Text -> Text -> EnvironmentMember
newEnvironmentMember
  Permissions
pPermissions_
  Text
pUserId_
  Text
pUserArn_
  Text
pEnvironmentId_ =
    EnvironmentMember' :: Maybe POSIX
-> Permissions -> Text -> Text -> Text -> EnvironmentMember
EnvironmentMember'
      { $sel:lastAccess:EnvironmentMember' :: Maybe POSIX
lastAccess = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
        $sel:permissions:EnvironmentMember' :: Permissions
permissions = Permissions
pPermissions_,
        $sel:userId:EnvironmentMember' :: Text
userId = Text
pUserId_,
        $sel:userArn:EnvironmentMember' :: Text
userArn = Text
pUserArn_,
        $sel:environmentId:EnvironmentMember' :: Text
environmentId = Text
pEnvironmentId_
      }

-- | The time, expressed in epoch time format, when the environment member
-- last opened the environment.
environmentMember_lastAccess :: Lens.Lens' EnvironmentMember (Prelude.Maybe Prelude.UTCTime)
environmentMember_lastAccess :: (Maybe UTCTime -> f (Maybe UTCTime))
-> EnvironmentMember -> f EnvironmentMember
environmentMember_lastAccess = (EnvironmentMember -> Maybe POSIX)
-> (EnvironmentMember -> Maybe POSIX -> EnvironmentMember)
-> Lens
     EnvironmentMember EnvironmentMember (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentMember' {Maybe POSIX
lastAccess :: Maybe POSIX
$sel:lastAccess:EnvironmentMember' :: EnvironmentMember -> Maybe POSIX
lastAccess} -> Maybe POSIX
lastAccess) (\s :: EnvironmentMember
s@EnvironmentMember' {} Maybe POSIX
a -> EnvironmentMember
s {$sel:lastAccess:EnvironmentMember' :: Maybe POSIX
lastAccess = Maybe POSIX
a} :: EnvironmentMember) ((Maybe POSIX -> f (Maybe POSIX))
 -> EnvironmentMember -> f EnvironmentMember)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EnvironmentMember
-> f EnvironmentMember
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 type of environment member permissions associated with this
-- environment member. Available values include:
--
-- -   @owner@: Owns the environment.
--
-- -   @read-only@: Has read-only access to the environment.
--
-- -   @read-write@: Has read-write access to the environment.
environmentMember_permissions :: Lens.Lens' EnvironmentMember Permissions
environmentMember_permissions :: (Permissions -> f Permissions)
-> EnvironmentMember -> f EnvironmentMember
environmentMember_permissions = (EnvironmentMember -> Permissions)
-> (EnvironmentMember -> Permissions -> EnvironmentMember)
-> Lens EnvironmentMember EnvironmentMember Permissions Permissions
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentMember' {Permissions
permissions :: Permissions
$sel:permissions:EnvironmentMember' :: EnvironmentMember -> Permissions
permissions} -> Permissions
permissions) (\s :: EnvironmentMember
s@EnvironmentMember' {} Permissions
a -> EnvironmentMember
s {$sel:permissions:EnvironmentMember' :: Permissions
permissions = Permissions
a} :: EnvironmentMember)

-- | The user ID in Identity and Access Management (IAM) of the environment
-- member.
environmentMember_userId :: Lens.Lens' EnvironmentMember Prelude.Text
environmentMember_userId :: (Text -> f Text) -> EnvironmentMember -> f EnvironmentMember
environmentMember_userId = (EnvironmentMember -> Text)
-> (EnvironmentMember -> Text -> EnvironmentMember)
-> Lens EnvironmentMember EnvironmentMember Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentMember' {Text
userId :: Text
$sel:userId:EnvironmentMember' :: EnvironmentMember -> Text
userId} -> Text
userId) (\s :: EnvironmentMember
s@EnvironmentMember' {} Text
a -> EnvironmentMember
s {$sel:userId:EnvironmentMember' :: Text
userId = Text
a} :: EnvironmentMember)

-- | The Amazon Resource Name (ARN) of the environment member.
environmentMember_userArn :: Lens.Lens' EnvironmentMember Prelude.Text
environmentMember_userArn :: (Text -> f Text) -> EnvironmentMember -> f EnvironmentMember
environmentMember_userArn = (EnvironmentMember -> Text)
-> (EnvironmentMember -> Text -> EnvironmentMember)
-> Lens EnvironmentMember EnvironmentMember Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentMember' {Text
userArn :: Text
$sel:userArn:EnvironmentMember' :: EnvironmentMember -> Text
userArn} -> Text
userArn) (\s :: EnvironmentMember
s@EnvironmentMember' {} Text
a -> EnvironmentMember
s {$sel:userArn:EnvironmentMember' :: Text
userArn = Text
a} :: EnvironmentMember)

-- | The ID of the environment for the environment member.
environmentMember_environmentId :: Lens.Lens' EnvironmentMember Prelude.Text
environmentMember_environmentId :: (Text -> f Text) -> EnvironmentMember -> f EnvironmentMember
environmentMember_environmentId = (EnvironmentMember -> Text)
-> (EnvironmentMember -> Text -> EnvironmentMember)
-> Lens EnvironmentMember EnvironmentMember Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentMember' {Text
environmentId :: Text
$sel:environmentId:EnvironmentMember' :: EnvironmentMember -> Text
environmentId} -> Text
environmentId) (\s :: EnvironmentMember
s@EnvironmentMember' {} Text
a -> EnvironmentMember
s {$sel:environmentId:EnvironmentMember' :: Text
environmentId = Text
a} :: EnvironmentMember)

instance Core.FromJSON EnvironmentMember where
  parseJSON :: Value -> Parser EnvironmentMember
parseJSON =
    String
-> (Object -> Parser EnvironmentMember)
-> Value
-> Parser EnvironmentMember
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EnvironmentMember"
      ( \Object
x ->
          Maybe POSIX
-> Permissions -> Text -> Text -> Text -> EnvironmentMember
EnvironmentMember'
            (Maybe POSIX
 -> Permissions -> Text -> Text -> Text -> EnvironmentMember)
-> Parser (Maybe POSIX)
-> Parser
     (Permissions -> Text -> Text -> Text -> EnvironmentMember)
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
"lastAccess")
            Parser (Permissions -> Text -> Text -> Text -> EnvironmentMember)
-> Parser Permissions
-> Parser (Text -> Text -> Text -> EnvironmentMember)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Permissions
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"permissions")
            Parser (Text -> Text -> Text -> EnvironmentMember)
-> Parser Text -> Parser (Text -> Text -> EnvironmentMember)
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
"userId")
            Parser (Text -> Text -> EnvironmentMember)
-> Parser Text -> Parser (Text -> EnvironmentMember)
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
"userArn")
            Parser (Text -> EnvironmentMember)
-> Parser Text -> Parser EnvironmentMember
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
"environmentId")
      )

instance Prelude.Hashable EnvironmentMember

instance Prelude.NFData EnvironmentMember