{-# 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.WorkSpaces.Types.WorkspacesIpGroup
-- 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.WorkSpaces.Types.WorkspacesIpGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkSpaces.Types.IpRuleItem

-- | Describes an IP access control group.
--
-- /See:/ 'newWorkspacesIpGroup' smart constructor.
data WorkspacesIpGroup = WorkspacesIpGroup'
  { -- | The description of the group.
    WorkspacesIpGroup -> Maybe Text
groupDesc :: Prelude.Maybe Prelude.Text,
    -- | The rules.
    WorkspacesIpGroup -> Maybe [IpRuleItem]
userRules :: Prelude.Maybe [IpRuleItem],
    -- | The identifier of the group.
    WorkspacesIpGroup -> Maybe Text
groupId :: Prelude.Maybe Prelude.Text,
    -- | The name of the group.
    WorkspacesIpGroup -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text
  }
  deriving (WorkspacesIpGroup -> WorkspacesIpGroup -> Bool
(WorkspacesIpGroup -> WorkspacesIpGroup -> Bool)
-> (WorkspacesIpGroup -> WorkspacesIpGroup -> Bool)
-> Eq WorkspacesIpGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkspacesIpGroup -> WorkspacesIpGroup -> Bool
$c/= :: WorkspacesIpGroup -> WorkspacesIpGroup -> Bool
== :: WorkspacesIpGroup -> WorkspacesIpGroup -> Bool
$c== :: WorkspacesIpGroup -> WorkspacesIpGroup -> Bool
Prelude.Eq, ReadPrec [WorkspacesIpGroup]
ReadPrec WorkspacesIpGroup
Int -> ReadS WorkspacesIpGroup
ReadS [WorkspacesIpGroup]
(Int -> ReadS WorkspacesIpGroup)
-> ReadS [WorkspacesIpGroup]
-> ReadPrec WorkspacesIpGroup
-> ReadPrec [WorkspacesIpGroup]
-> Read WorkspacesIpGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkspacesIpGroup]
$creadListPrec :: ReadPrec [WorkspacesIpGroup]
readPrec :: ReadPrec WorkspacesIpGroup
$creadPrec :: ReadPrec WorkspacesIpGroup
readList :: ReadS [WorkspacesIpGroup]
$creadList :: ReadS [WorkspacesIpGroup]
readsPrec :: Int -> ReadS WorkspacesIpGroup
$creadsPrec :: Int -> ReadS WorkspacesIpGroup
Prelude.Read, Int -> WorkspacesIpGroup -> ShowS
[WorkspacesIpGroup] -> ShowS
WorkspacesIpGroup -> String
(Int -> WorkspacesIpGroup -> ShowS)
-> (WorkspacesIpGroup -> String)
-> ([WorkspacesIpGroup] -> ShowS)
-> Show WorkspacesIpGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkspacesIpGroup] -> ShowS
$cshowList :: [WorkspacesIpGroup] -> ShowS
show :: WorkspacesIpGroup -> String
$cshow :: WorkspacesIpGroup -> String
showsPrec :: Int -> WorkspacesIpGroup -> ShowS
$cshowsPrec :: Int -> WorkspacesIpGroup -> ShowS
Prelude.Show, (forall x. WorkspacesIpGroup -> Rep WorkspacesIpGroup x)
-> (forall x. Rep WorkspacesIpGroup x -> WorkspacesIpGroup)
-> Generic WorkspacesIpGroup
forall x. Rep WorkspacesIpGroup x -> WorkspacesIpGroup
forall x. WorkspacesIpGroup -> Rep WorkspacesIpGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorkspacesIpGroup x -> WorkspacesIpGroup
$cfrom :: forall x. WorkspacesIpGroup -> Rep WorkspacesIpGroup x
Prelude.Generic)

-- |
-- Create a value of 'WorkspacesIpGroup' 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:
--
-- 'groupDesc', 'workspacesIpGroup_groupDesc' - The description of the group.
--
-- 'userRules', 'workspacesIpGroup_userRules' - The rules.
--
-- 'groupId', 'workspacesIpGroup_groupId' - The identifier of the group.
--
-- 'groupName', 'workspacesIpGroup_groupName' - The name of the group.
newWorkspacesIpGroup ::
  WorkspacesIpGroup
newWorkspacesIpGroup :: WorkspacesIpGroup
newWorkspacesIpGroup =
  WorkspacesIpGroup' :: Maybe Text
-> Maybe [IpRuleItem]
-> Maybe Text
-> Maybe Text
-> WorkspacesIpGroup
WorkspacesIpGroup'
    { $sel:groupDesc:WorkspacesIpGroup' :: Maybe Text
groupDesc = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userRules:WorkspacesIpGroup' :: Maybe [IpRuleItem]
userRules = Maybe [IpRuleItem]
forall a. Maybe a
Prelude.Nothing,
      $sel:groupId:WorkspacesIpGroup' :: Maybe Text
groupId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:WorkspacesIpGroup' :: Maybe Text
groupName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The description of the group.
workspacesIpGroup_groupDesc :: Lens.Lens' WorkspacesIpGroup (Prelude.Maybe Prelude.Text)
workspacesIpGroup_groupDesc :: (Maybe Text -> f (Maybe Text))
-> WorkspacesIpGroup -> f WorkspacesIpGroup
workspacesIpGroup_groupDesc = (WorkspacesIpGroup -> Maybe Text)
-> (WorkspacesIpGroup -> Maybe Text -> WorkspacesIpGroup)
-> Lens
     WorkspacesIpGroup WorkspacesIpGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkspacesIpGroup' {Maybe Text
groupDesc :: Maybe Text
$sel:groupDesc:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe Text
groupDesc} -> Maybe Text
groupDesc) (\s :: WorkspacesIpGroup
s@WorkspacesIpGroup' {} Maybe Text
a -> WorkspacesIpGroup
s {$sel:groupDesc:WorkspacesIpGroup' :: Maybe Text
groupDesc = Maybe Text
a} :: WorkspacesIpGroup)

-- | The rules.
workspacesIpGroup_userRules :: Lens.Lens' WorkspacesIpGroup (Prelude.Maybe [IpRuleItem])
workspacesIpGroup_userRules :: (Maybe [IpRuleItem] -> f (Maybe [IpRuleItem]))
-> WorkspacesIpGroup -> f WorkspacesIpGroup
workspacesIpGroup_userRules = (WorkspacesIpGroup -> Maybe [IpRuleItem])
-> (WorkspacesIpGroup -> Maybe [IpRuleItem] -> WorkspacesIpGroup)
-> Lens
     WorkspacesIpGroup
     WorkspacesIpGroup
     (Maybe [IpRuleItem])
     (Maybe [IpRuleItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkspacesIpGroup' {Maybe [IpRuleItem]
userRules :: Maybe [IpRuleItem]
$sel:userRules:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe [IpRuleItem]
userRules} -> Maybe [IpRuleItem]
userRules) (\s :: WorkspacesIpGroup
s@WorkspacesIpGroup' {} Maybe [IpRuleItem]
a -> WorkspacesIpGroup
s {$sel:userRules:WorkspacesIpGroup' :: Maybe [IpRuleItem]
userRules = Maybe [IpRuleItem]
a} :: WorkspacesIpGroup) ((Maybe [IpRuleItem] -> f (Maybe [IpRuleItem]))
 -> WorkspacesIpGroup -> f WorkspacesIpGroup)
-> ((Maybe [IpRuleItem] -> f (Maybe [IpRuleItem]))
    -> Maybe [IpRuleItem] -> f (Maybe [IpRuleItem]))
-> (Maybe [IpRuleItem] -> f (Maybe [IpRuleItem]))
-> WorkspacesIpGroup
-> f WorkspacesIpGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [IpRuleItem] [IpRuleItem] [IpRuleItem] [IpRuleItem]
-> Iso
     (Maybe [IpRuleItem])
     (Maybe [IpRuleItem])
     (Maybe [IpRuleItem])
     (Maybe [IpRuleItem])
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 [IpRuleItem] [IpRuleItem] [IpRuleItem] [IpRuleItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The identifier of the group.
workspacesIpGroup_groupId :: Lens.Lens' WorkspacesIpGroup (Prelude.Maybe Prelude.Text)
workspacesIpGroup_groupId :: (Maybe Text -> f (Maybe Text))
-> WorkspacesIpGroup -> f WorkspacesIpGroup
workspacesIpGroup_groupId = (WorkspacesIpGroup -> Maybe Text)
-> (WorkspacesIpGroup -> Maybe Text -> WorkspacesIpGroup)
-> Lens
     WorkspacesIpGroup WorkspacesIpGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkspacesIpGroup' {Maybe Text
groupId :: Maybe Text
$sel:groupId:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe Text
groupId} -> Maybe Text
groupId) (\s :: WorkspacesIpGroup
s@WorkspacesIpGroup' {} Maybe Text
a -> WorkspacesIpGroup
s {$sel:groupId:WorkspacesIpGroup' :: Maybe Text
groupId = Maybe Text
a} :: WorkspacesIpGroup)

-- | The name of the group.
workspacesIpGroup_groupName :: Lens.Lens' WorkspacesIpGroup (Prelude.Maybe Prelude.Text)
workspacesIpGroup_groupName :: (Maybe Text -> f (Maybe Text))
-> WorkspacesIpGroup -> f WorkspacesIpGroup
workspacesIpGroup_groupName = (WorkspacesIpGroup -> Maybe Text)
-> (WorkspacesIpGroup -> Maybe Text -> WorkspacesIpGroup)
-> Lens
     WorkspacesIpGroup WorkspacesIpGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkspacesIpGroup' {Maybe Text
groupName :: Maybe Text
$sel:groupName:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe Text
groupName} -> Maybe Text
groupName) (\s :: WorkspacesIpGroup
s@WorkspacesIpGroup' {} Maybe Text
a -> WorkspacesIpGroup
s {$sel:groupName:WorkspacesIpGroup' :: Maybe Text
groupName = Maybe Text
a} :: WorkspacesIpGroup)

instance Core.FromJSON WorkspacesIpGroup where
  parseJSON :: Value -> Parser WorkspacesIpGroup
parseJSON =
    String
-> (Object -> Parser WorkspacesIpGroup)
-> Value
-> Parser WorkspacesIpGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorkspacesIpGroup"
      ( \Object
x ->
          Maybe Text
-> Maybe [IpRuleItem]
-> Maybe Text
-> Maybe Text
-> WorkspacesIpGroup
WorkspacesIpGroup'
            (Maybe Text
 -> Maybe [IpRuleItem]
 -> Maybe Text
 -> Maybe Text
 -> WorkspacesIpGroup)
-> Parser (Maybe Text)
-> Parser
     (Maybe [IpRuleItem]
      -> Maybe Text -> Maybe Text -> WorkspacesIpGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"groupDesc")
            Parser
  (Maybe [IpRuleItem]
   -> Maybe Text -> Maybe Text -> WorkspacesIpGroup)
-> Parser (Maybe [IpRuleItem])
-> Parser (Maybe Text -> Maybe Text -> WorkspacesIpGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [IpRuleItem]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"userRules" Parser (Maybe (Maybe [IpRuleItem]))
-> Maybe [IpRuleItem] -> Parser (Maybe [IpRuleItem])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [IpRuleItem]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Text -> WorkspacesIpGroup)
-> Parser (Maybe Text) -> Parser (Maybe Text -> WorkspacesIpGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"groupId")
            Parser (Maybe Text -> WorkspacesIpGroup)
-> Parser (Maybe Text) -> Parser WorkspacesIpGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"groupName")
      )

instance Prelude.Hashable WorkspacesIpGroup

instance Prelude.NFData WorkspacesIpGroup