{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.WorkSpaces.Types.WorkspacesIpGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 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,
    -- | The rules.
    WorkspacesIpGroup -> Maybe [IpRuleItem]
userRules :: Prelude.Maybe [IpRuleItem]
  }
  deriving (WorkspacesIpGroup -> WorkspacesIpGroup -> Bool
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]
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
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. 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.
--
-- 'groupId', 'workspacesIpGroup_groupId' - The identifier of the group.
--
-- 'groupName', 'workspacesIpGroup_groupName' - The name of the group.
--
-- 'userRules', 'workspacesIpGroup_userRules' - The rules.
newWorkspacesIpGroup ::
  WorkspacesIpGroup
newWorkspacesIpGroup :: WorkspacesIpGroup
newWorkspacesIpGroup =
  WorkspacesIpGroup'
    { $sel:groupDesc:WorkspacesIpGroup' :: Maybe Text
groupDesc = forall a. Maybe a
Prelude.Nothing,
      $sel:groupId:WorkspacesIpGroup' :: Maybe Text
groupId = forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:WorkspacesIpGroup' :: Maybe Text
groupName = forall a. Maybe a
Prelude.Nothing,
      $sel:userRules:WorkspacesIpGroup' :: Maybe [IpRuleItem]
userRules = forall a. Maybe a
Prelude.Nothing
    }

-- | The description of the group.
workspacesIpGroup_groupDesc :: Lens.Lens' WorkspacesIpGroup (Prelude.Maybe Prelude.Text)
workspacesIpGroup_groupDesc :: Lens' WorkspacesIpGroup (Maybe Text)
workspacesIpGroup_groupDesc = 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 identifier of the group.
workspacesIpGroup_groupId :: Lens.Lens' WorkspacesIpGroup (Prelude.Maybe Prelude.Text)
workspacesIpGroup_groupId :: Lens' WorkspacesIpGroup (Maybe Text)
workspacesIpGroup_groupId = 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 :: Lens' WorkspacesIpGroup (Maybe Text)
workspacesIpGroup_groupName = 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)

-- | The rules.
workspacesIpGroup_userRules :: Lens.Lens' WorkspacesIpGroup (Prelude.Maybe [IpRuleItem])
workspacesIpGroup_userRules :: Lens' WorkspacesIpGroup (Maybe [IpRuleItem])
workspacesIpGroup_userRules = 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) 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 WorkspacesIpGroup where
  parseJSON :: Value -> Parser WorkspacesIpGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WorkspacesIpGroup"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [IpRuleItem]
-> WorkspacesIpGroup
WorkspacesIpGroup'
            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
"groupDesc")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"groupId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"groupName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"userRules" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable WorkspacesIpGroup where
  hashWithSalt :: Int -> WorkspacesIpGroup -> Int
hashWithSalt Int
_salt WorkspacesIpGroup' {Maybe [IpRuleItem]
Maybe Text
userRules :: Maybe [IpRuleItem]
groupName :: Maybe Text
groupId :: Maybe Text
groupDesc :: Maybe Text
$sel:userRules:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe [IpRuleItem]
$sel:groupName:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe Text
$sel:groupId:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe Text
$sel:groupDesc:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupDesc
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [IpRuleItem]
userRules

instance Prelude.NFData WorkspacesIpGroup where
  rnf :: WorkspacesIpGroup -> ()
rnf WorkspacesIpGroup' {Maybe [IpRuleItem]
Maybe Text
userRules :: Maybe [IpRuleItem]
groupName :: Maybe Text
groupId :: Maybe Text
groupDesc :: Maybe Text
$sel:userRules:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe [IpRuleItem]
$sel:groupName:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe Text
$sel:groupId:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe Text
$sel:groupDesc:WorkspacesIpGroup' :: WorkspacesIpGroup -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groupDesc
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [IpRuleItem]
userRules