{-# 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.ElastiCache.Types.UserGroup
-- 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.ElastiCache.Types.UserGroup where

import qualified Amazonka.Core as Core
import Amazonka.ElastiCache.Types.UserGroupPendingChanges
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | /See:/ 'newUserGroup' smart constructor.
data UserGroup = UserGroup'
  { -- | Indicates user group status. Can be \"creating\", \"active\",
    -- \"modifying\", \"deleting\".
    UserGroup -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The list of user IDs that belong to the user group.
    UserGroup -> Maybe [Text]
userIds :: Prelude.Maybe [Prelude.Text],
    -- | The Amazon Resource Name (ARN) of the user group.
    UserGroup -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the user group.
    UserGroup -> Maybe Text
userGroupId :: Prelude.Maybe Prelude.Text,
    -- | The current supported value is Redis.
    UserGroup -> Maybe Text
engine :: Prelude.Maybe Prelude.Text,
    -- | A list of updates being applied to the user group.
    UserGroup -> Maybe UserGroupPendingChanges
pendingChanges :: Prelude.Maybe UserGroupPendingChanges,
    -- | A list of replication groups that the user group can access.
    UserGroup -> Maybe [Text]
replicationGroups :: Prelude.Maybe [Prelude.Text]
  }
  deriving (UserGroup -> UserGroup -> Bool
(UserGroup -> UserGroup -> Bool)
-> (UserGroup -> UserGroup -> Bool) -> Eq UserGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserGroup -> UserGroup -> Bool
$c/= :: UserGroup -> UserGroup -> Bool
== :: UserGroup -> UserGroup -> Bool
$c== :: UserGroup -> UserGroup -> Bool
Prelude.Eq, ReadPrec [UserGroup]
ReadPrec UserGroup
Int -> ReadS UserGroup
ReadS [UserGroup]
(Int -> ReadS UserGroup)
-> ReadS [UserGroup]
-> ReadPrec UserGroup
-> ReadPrec [UserGroup]
-> Read UserGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserGroup]
$creadListPrec :: ReadPrec [UserGroup]
readPrec :: ReadPrec UserGroup
$creadPrec :: ReadPrec UserGroup
readList :: ReadS [UserGroup]
$creadList :: ReadS [UserGroup]
readsPrec :: Int -> ReadS UserGroup
$creadsPrec :: Int -> ReadS UserGroup
Prelude.Read, Int -> UserGroup -> ShowS
[UserGroup] -> ShowS
UserGroup -> String
(Int -> UserGroup -> ShowS)
-> (UserGroup -> String)
-> ([UserGroup] -> ShowS)
-> Show UserGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserGroup] -> ShowS
$cshowList :: [UserGroup] -> ShowS
show :: UserGroup -> String
$cshow :: UserGroup -> String
showsPrec :: Int -> UserGroup -> ShowS
$cshowsPrec :: Int -> UserGroup -> ShowS
Prelude.Show, (forall x. UserGroup -> Rep UserGroup x)
-> (forall x. Rep UserGroup x -> UserGroup) -> Generic UserGroup
forall x. Rep UserGroup x -> UserGroup
forall x. UserGroup -> Rep UserGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserGroup x -> UserGroup
$cfrom :: forall x. UserGroup -> Rep UserGroup x
Prelude.Generic)

-- |
-- Create a value of 'UserGroup' 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:
--
-- 'status', 'userGroup_status' - Indicates user group status. Can be \"creating\", \"active\",
-- \"modifying\", \"deleting\".
--
-- 'userIds', 'userGroup_userIds' - The list of user IDs that belong to the user group.
--
-- 'arn', 'userGroup_arn' - The Amazon Resource Name (ARN) of the user group.
--
-- 'userGroupId', 'userGroup_userGroupId' - The ID of the user group.
--
-- 'engine', 'userGroup_engine' - The current supported value is Redis.
--
-- 'pendingChanges', 'userGroup_pendingChanges' - A list of updates being applied to the user group.
--
-- 'replicationGroups', 'userGroup_replicationGroups' - A list of replication groups that the user group can access.
newUserGroup ::
  UserGroup
newUserGroup :: UserGroup
newUserGroup =
  UserGroup' :: Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe UserGroupPendingChanges
-> Maybe [Text]
-> UserGroup
UserGroup'
    { $sel:status:UserGroup' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userIds:UserGroup' :: Maybe [Text]
userIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:UserGroup' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userGroupId:UserGroup' :: Maybe Text
userGroupId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:engine:UserGroup' :: Maybe Text
engine = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:pendingChanges:UserGroup' :: Maybe UserGroupPendingChanges
pendingChanges = Maybe UserGroupPendingChanges
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationGroups:UserGroup' :: Maybe [Text]
replicationGroups = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates user group status. Can be \"creating\", \"active\",
-- \"modifying\", \"deleting\".
userGroup_status :: Lens.Lens' UserGroup (Prelude.Maybe Prelude.Text)
userGroup_status :: (Maybe Text -> f (Maybe Text)) -> UserGroup -> f UserGroup
userGroup_status = (UserGroup -> Maybe Text)
-> (UserGroup -> Maybe Text -> UserGroup)
-> Lens UserGroup UserGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserGroup' {Maybe Text
status :: Maybe Text
$sel:status:UserGroup' :: UserGroup -> Maybe Text
status} -> Maybe Text
status) (\s :: UserGroup
s@UserGroup' {} Maybe Text
a -> UserGroup
s {$sel:status:UserGroup' :: Maybe Text
status = Maybe Text
a} :: UserGroup)

-- | The list of user IDs that belong to the user group.
userGroup_userIds :: Lens.Lens' UserGroup (Prelude.Maybe [Prelude.Text])
userGroup_userIds :: (Maybe [Text] -> f (Maybe [Text])) -> UserGroup -> f UserGroup
userGroup_userIds = (UserGroup -> Maybe [Text])
-> (UserGroup -> Maybe [Text] -> UserGroup)
-> Lens UserGroup UserGroup (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserGroup' {Maybe [Text]
userIds :: Maybe [Text]
$sel:userIds:UserGroup' :: UserGroup -> Maybe [Text]
userIds} -> Maybe [Text]
userIds) (\s :: UserGroup
s@UserGroup' {} Maybe [Text]
a -> UserGroup
s {$sel:userIds:UserGroup' :: Maybe [Text]
userIds = Maybe [Text]
a} :: UserGroup) ((Maybe [Text] -> f (Maybe [Text])) -> UserGroup -> f UserGroup)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UserGroup
-> f UserGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the user group.
userGroup_arn :: Lens.Lens' UserGroup (Prelude.Maybe Prelude.Text)
userGroup_arn :: (Maybe Text -> f (Maybe Text)) -> UserGroup -> f UserGroup
userGroup_arn = (UserGroup -> Maybe Text)
-> (UserGroup -> Maybe Text -> UserGroup)
-> Lens UserGroup UserGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserGroup' {Maybe Text
arn :: Maybe Text
$sel:arn:UserGroup' :: UserGroup -> Maybe Text
arn} -> Maybe Text
arn) (\s :: UserGroup
s@UserGroup' {} Maybe Text
a -> UserGroup
s {$sel:arn:UserGroup' :: Maybe Text
arn = Maybe Text
a} :: UserGroup)

-- | The ID of the user group.
userGroup_userGroupId :: Lens.Lens' UserGroup (Prelude.Maybe Prelude.Text)
userGroup_userGroupId :: (Maybe Text -> f (Maybe Text)) -> UserGroup -> f UserGroup
userGroup_userGroupId = (UserGroup -> Maybe Text)
-> (UserGroup -> Maybe Text -> UserGroup)
-> Lens UserGroup UserGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserGroup' {Maybe Text
userGroupId :: Maybe Text
$sel:userGroupId:UserGroup' :: UserGroup -> Maybe Text
userGroupId} -> Maybe Text
userGroupId) (\s :: UserGroup
s@UserGroup' {} Maybe Text
a -> UserGroup
s {$sel:userGroupId:UserGroup' :: Maybe Text
userGroupId = Maybe Text
a} :: UserGroup)

-- | The current supported value is Redis.
userGroup_engine :: Lens.Lens' UserGroup (Prelude.Maybe Prelude.Text)
userGroup_engine :: (Maybe Text -> f (Maybe Text)) -> UserGroup -> f UserGroup
userGroup_engine = (UserGroup -> Maybe Text)
-> (UserGroup -> Maybe Text -> UserGroup)
-> Lens UserGroup UserGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserGroup' {Maybe Text
engine :: Maybe Text
$sel:engine:UserGroup' :: UserGroup -> Maybe Text
engine} -> Maybe Text
engine) (\s :: UserGroup
s@UserGroup' {} Maybe Text
a -> UserGroup
s {$sel:engine:UserGroup' :: Maybe Text
engine = Maybe Text
a} :: UserGroup)

-- | A list of updates being applied to the user group.
userGroup_pendingChanges :: Lens.Lens' UserGroup (Prelude.Maybe UserGroupPendingChanges)
userGroup_pendingChanges :: (Maybe UserGroupPendingChanges
 -> f (Maybe UserGroupPendingChanges))
-> UserGroup -> f UserGroup
userGroup_pendingChanges = (UserGroup -> Maybe UserGroupPendingChanges)
-> (UserGroup -> Maybe UserGroupPendingChanges -> UserGroup)
-> Lens
     UserGroup
     UserGroup
     (Maybe UserGroupPendingChanges)
     (Maybe UserGroupPendingChanges)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserGroup' {Maybe UserGroupPendingChanges
pendingChanges :: Maybe UserGroupPendingChanges
$sel:pendingChanges:UserGroup' :: UserGroup -> Maybe UserGroupPendingChanges
pendingChanges} -> Maybe UserGroupPendingChanges
pendingChanges) (\s :: UserGroup
s@UserGroup' {} Maybe UserGroupPendingChanges
a -> UserGroup
s {$sel:pendingChanges:UserGroup' :: Maybe UserGroupPendingChanges
pendingChanges = Maybe UserGroupPendingChanges
a} :: UserGroup)

-- | A list of replication groups that the user group can access.
userGroup_replicationGroups :: Lens.Lens' UserGroup (Prelude.Maybe [Prelude.Text])
userGroup_replicationGroups :: (Maybe [Text] -> f (Maybe [Text])) -> UserGroup -> f UserGroup
userGroup_replicationGroups = (UserGroup -> Maybe [Text])
-> (UserGroup -> Maybe [Text] -> UserGroup)
-> Lens UserGroup UserGroup (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserGroup' {Maybe [Text]
replicationGroups :: Maybe [Text]
$sel:replicationGroups:UserGroup' :: UserGroup -> Maybe [Text]
replicationGroups} -> Maybe [Text]
replicationGroups) (\s :: UserGroup
s@UserGroup' {} Maybe [Text]
a -> UserGroup
s {$sel:replicationGroups:UserGroup' :: Maybe [Text]
replicationGroups = Maybe [Text]
a} :: UserGroup) ((Maybe [Text] -> f (Maybe [Text])) -> UserGroup -> f UserGroup)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UserGroup
-> f UserGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML UserGroup where
  parseXML :: [Node] -> Either String UserGroup
parseXML [Node]
x =
    Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe UserGroupPendingChanges
-> Maybe [Text]
-> UserGroup
UserGroup'
      (Maybe Text
 -> Maybe [Text]
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe UserGroupPendingChanges
 -> Maybe [Text]
 -> UserGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [Text]
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe UserGroupPendingChanges
      -> Maybe [Text]
      -> UserGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Status")
      Either
  String
  (Maybe [Text]
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe UserGroupPendingChanges
   -> Maybe [Text]
   -> UserGroup)
-> Either String (Maybe [Text])
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe UserGroupPendingChanges
      -> Maybe [Text]
      -> UserGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"UserIds" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe UserGroupPendingChanges
   -> Maybe [Text]
   -> UserGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe UserGroupPendingChanges
      -> Maybe [Text]
      -> UserGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ARN")
      Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe UserGroupPendingChanges
   -> Maybe [Text]
   -> UserGroup)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe UserGroupPendingChanges -> Maybe [Text] -> UserGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"UserGroupId")
      Either
  String
  (Maybe Text
   -> Maybe UserGroupPendingChanges -> Maybe [Text] -> UserGroup)
-> Either String (Maybe Text)
-> Either
     String (Maybe UserGroupPendingChanges -> Maybe [Text] -> UserGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Engine")
      Either
  String (Maybe UserGroupPendingChanges -> Maybe [Text] -> UserGroup)
-> Either String (Maybe UserGroupPendingChanges)
-> Either String (Maybe [Text] -> UserGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe UserGroupPendingChanges)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PendingChanges")
      Either String (Maybe [Text] -> UserGroup)
-> Either String (Maybe [Text]) -> Either String UserGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ReplicationGroups"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )

instance Prelude.Hashable UserGroup

instance Prelude.NFData UserGroup