{-# 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.EC2.Types.AuthorizationRule
-- 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.EC2.Types.AuthorizationRule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.ClientVpnAuthorizationRuleStatus
import qualified Amazonka.Prelude as Prelude

-- | Information about an authorization rule.
--
-- /See:/ 'newAuthorizationRule' smart constructor.
data AuthorizationRule = AuthorizationRule'
  { -- | Indicates whether the authorization rule grants access to all clients.
    AuthorizationRule -> Maybe Bool
accessAll :: Prelude.Maybe Prelude.Bool,
    -- | The ID of the Client VPN endpoint with which the authorization rule is
    -- associated.
    AuthorizationRule -> Maybe Text
clientVpnEndpointId :: Prelude.Maybe Prelude.Text,
    -- | A brief description of the authorization rule.
    AuthorizationRule -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The IPv4 address range, in CIDR notation, of the network to which the
    -- authorization rule applies.
    AuthorizationRule -> Maybe Text
destinationCidr :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Active Directory group to which the authorization rule
    -- grants access.
    AuthorizationRule -> Maybe Text
groupId :: Prelude.Maybe Prelude.Text,
    -- | The current state of the authorization rule.
    AuthorizationRule -> Maybe ClientVpnAuthorizationRuleStatus
status :: Prelude.Maybe ClientVpnAuthorizationRuleStatus
  }
  deriving (AuthorizationRule -> AuthorizationRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuthorizationRule -> AuthorizationRule -> Bool
$c/= :: AuthorizationRule -> AuthorizationRule -> Bool
== :: AuthorizationRule -> AuthorizationRule -> Bool
$c== :: AuthorizationRule -> AuthorizationRule -> Bool
Prelude.Eq, ReadPrec [AuthorizationRule]
ReadPrec AuthorizationRule
Int -> ReadS AuthorizationRule
ReadS [AuthorizationRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AuthorizationRule]
$creadListPrec :: ReadPrec [AuthorizationRule]
readPrec :: ReadPrec AuthorizationRule
$creadPrec :: ReadPrec AuthorizationRule
readList :: ReadS [AuthorizationRule]
$creadList :: ReadS [AuthorizationRule]
readsPrec :: Int -> ReadS AuthorizationRule
$creadsPrec :: Int -> ReadS AuthorizationRule
Prelude.Read, Int -> AuthorizationRule -> ShowS
[AuthorizationRule] -> ShowS
AuthorizationRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuthorizationRule] -> ShowS
$cshowList :: [AuthorizationRule] -> ShowS
show :: AuthorizationRule -> String
$cshow :: AuthorizationRule -> String
showsPrec :: Int -> AuthorizationRule -> ShowS
$cshowsPrec :: Int -> AuthorizationRule -> ShowS
Prelude.Show, forall x. Rep AuthorizationRule x -> AuthorizationRule
forall x. AuthorizationRule -> Rep AuthorizationRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AuthorizationRule x -> AuthorizationRule
$cfrom :: forall x. AuthorizationRule -> Rep AuthorizationRule x
Prelude.Generic)

-- |
-- Create a value of 'AuthorizationRule' 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:
--
-- 'accessAll', 'authorizationRule_accessAll' - Indicates whether the authorization rule grants access to all clients.
--
-- 'clientVpnEndpointId', 'authorizationRule_clientVpnEndpointId' - The ID of the Client VPN endpoint with which the authorization rule is
-- associated.
--
-- 'description', 'authorizationRule_description' - A brief description of the authorization rule.
--
-- 'destinationCidr', 'authorizationRule_destinationCidr' - The IPv4 address range, in CIDR notation, of the network to which the
-- authorization rule applies.
--
-- 'groupId', 'authorizationRule_groupId' - The ID of the Active Directory group to which the authorization rule
-- grants access.
--
-- 'status', 'authorizationRule_status' - The current state of the authorization rule.
newAuthorizationRule ::
  AuthorizationRule
newAuthorizationRule :: AuthorizationRule
newAuthorizationRule =
  AuthorizationRule'
    { $sel:accessAll:AuthorizationRule' :: Maybe Bool
accessAll = forall a. Maybe a
Prelude.Nothing,
      $sel:clientVpnEndpointId:AuthorizationRule' :: Maybe Text
clientVpnEndpointId = forall a. Maybe a
Prelude.Nothing,
      $sel:description:AuthorizationRule' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:destinationCidr:AuthorizationRule' :: Maybe Text
destinationCidr = forall a. Maybe a
Prelude.Nothing,
      $sel:groupId:AuthorizationRule' :: Maybe Text
groupId = forall a. Maybe a
Prelude.Nothing,
      $sel:status:AuthorizationRule' :: Maybe ClientVpnAuthorizationRuleStatus
status = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether the authorization rule grants access to all clients.
authorizationRule_accessAll :: Lens.Lens' AuthorizationRule (Prelude.Maybe Prelude.Bool)
authorizationRule_accessAll :: Lens' AuthorizationRule (Maybe Bool)
authorizationRule_accessAll = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationRule' {Maybe Bool
accessAll :: Maybe Bool
$sel:accessAll:AuthorizationRule' :: AuthorizationRule -> Maybe Bool
accessAll} -> Maybe Bool
accessAll) (\s :: AuthorizationRule
s@AuthorizationRule' {} Maybe Bool
a -> AuthorizationRule
s {$sel:accessAll:AuthorizationRule' :: Maybe Bool
accessAll = Maybe Bool
a} :: AuthorizationRule)

-- | The ID of the Client VPN endpoint with which the authorization rule is
-- associated.
authorizationRule_clientVpnEndpointId :: Lens.Lens' AuthorizationRule (Prelude.Maybe Prelude.Text)
authorizationRule_clientVpnEndpointId :: Lens' AuthorizationRule (Maybe Text)
authorizationRule_clientVpnEndpointId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationRule' {Maybe Text
clientVpnEndpointId :: Maybe Text
$sel:clientVpnEndpointId:AuthorizationRule' :: AuthorizationRule -> Maybe Text
clientVpnEndpointId} -> Maybe Text
clientVpnEndpointId) (\s :: AuthorizationRule
s@AuthorizationRule' {} Maybe Text
a -> AuthorizationRule
s {$sel:clientVpnEndpointId:AuthorizationRule' :: Maybe Text
clientVpnEndpointId = Maybe Text
a} :: AuthorizationRule)

-- | A brief description of the authorization rule.
authorizationRule_description :: Lens.Lens' AuthorizationRule (Prelude.Maybe Prelude.Text)
authorizationRule_description :: Lens' AuthorizationRule (Maybe Text)
authorizationRule_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationRule' {Maybe Text
description :: Maybe Text
$sel:description:AuthorizationRule' :: AuthorizationRule -> Maybe Text
description} -> Maybe Text
description) (\s :: AuthorizationRule
s@AuthorizationRule' {} Maybe Text
a -> AuthorizationRule
s {$sel:description:AuthorizationRule' :: Maybe Text
description = Maybe Text
a} :: AuthorizationRule)

-- | The IPv4 address range, in CIDR notation, of the network to which the
-- authorization rule applies.
authorizationRule_destinationCidr :: Lens.Lens' AuthorizationRule (Prelude.Maybe Prelude.Text)
authorizationRule_destinationCidr :: Lens' AuthorizationRule (Maybe Text)
authorizationRule_destinationCidr = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationRule' {Maybe Text
destinationCidr :: Maybe Text
$sel:destinationCidr:AuthorizationRule' :: AuthorizationRule -> Maybe Text
destinationCidr} -> Maybe Text
destinationCidr) (\s :: AuthorizationRule
s@AuthorizationRule' {} Maybe Text
a -> AuthorizationRule
s {$sel:destinationCidr:AuthorizationRule' :: Maybe Text
destinationCidr = Maybe Text
a} :: AuthorizationRule)

-- | The ID of the Active Directory group to which the authorization rule
-- grants access.
authorizationRule_groupId :: Lens.Lens' AuthorizationRule (Prelude.Maybe Prelude.Text)
authorizationRule_groupId :: Lens' AuthorizationRule (Maybe Text)
authorizationRule_groupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationRule' {Maybe Text
groupId :: Maybe Text
$sel:groupId:AuthorizationRule' :: AuthorizationRule -> Maybe Text
groupId} -> Maybe Text
groupId) (\s :: AuthorizationRule
s@AuthorizationRule' {} Maybe Text
a -> AuthorizationRule
s {$sel:groupId:AuthorizationRule' :: Maybe Text
groupId = Maybe Text
a} :: AuthorizationRule)

-- | The current state of the authorization rule.
authorizationRule_status :: Lens.Lens' AuthorizationRule (Prelude.Maybe ClientVpnAuthorizationRuleStatus)
authorizationRule_status :: Lens' AuthorizationRule (Maybe ClientVpnAuthorizationRuleStatus)
authorizationRule_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthorizationRule' {Maybe ClientVpnAuthorizationRuleStatus
status :: Maybe ClientVpnAuthorizationRuleStatus
$sel:status:AuthorizationRule' :: AuthorizationRule -> Maybe ClientVpnAuthorizationRuleStatus
status} -> Maybe ClientVpnAuthorizationRuleStatus
status) (\s :: AuthorizationRule
s@AuthorizationRule' {} Maybe ClientVpnAuthorizationRuleStatus
a -> AuthorizationRule
s {$sel:status:AuthorizationRule' :: Maybe ClientVpnAuthorizationRuleStatus
status = Maybe ClientVpnAuthorizationRuleStatus
a} :: AuthorizationRule)

instance Data.FromXML AuthorizationRule where
  parseXML :: [Node] -> Either String AuthorizationRule
parseXML [Node]
x =
    Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ClientVpnAuthorizationRuleStatus
-> AuthorizationRule
AuthorizationRule'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"accessAll")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"clientVpnEndpointId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"description")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"destinationCidr")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"groupId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"status")

instance Prelude.Hashable AuthorizationRule where
  hashWithSalt :: Int -> AuthorizationRule -> Int
hashWithSalt Int
_salt AuthorizationRule' {Maybe Bool
Maybe Text
Maybe ClientVpnAuthorizationRuleStatus
status :: Maybe ClientVpnAuthorizationRuleStatus
groupId :: Maybe Text
destinationCidr :: Maybe Text
description :: Maybe Text
clientVpnEndpointId :: Maybe Text
accessAll :: Maybe Bool
$sel:status:AuthorizationRule' :: AuthorizationRule -> Maybe ClientVpnAuthorizationRuleStatus
$sel:groupId:AuthorizationRule' :: AuthorizationRule -> Maybe Text
$sel:destinationCidr:AuthorizationRule' :: AuthorizationRule -> Maybe Text
$sel:description:AuthorizationRule' :: AuthorizationRule -> Maybe Text
$sel:clientVpnEndpointId:AuthorizationRule' :: AuthorizationRule -> Maybe Text
$sel:accessAll:AuthorizationRule' :: AuthorizationRule -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
accessAll
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientVpnEndpointId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destinationCidr
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ClientVpnAuthorizationRuleStatus
status

instance Prelude.NFData AuthorizationRule where
  rnf :: AuthorizationRule -> ()
rnf AuthorizationRule' {Maybe Bool
Maybe Text
Maybe ClientVpnAuthorizationRuleStatus
status :: Maybe ClientVpnAuthorizationRuleStatus
groupId :: Maybe Text
destinationCidr :: Maybe Text
description :: Maybe Text
clientVpnEndpointId :: Maybe Text
accessAll :: Maybe Bool
$sel:status:AuthorizationRule' :: AuthorizationRule -> Maybe ClientVpnAuthorizationRuleStatus
$sel:groupId:AuthorizationRule' :: AuthorizationRule -> Maybe Text
$sel:destinationCidr:AuthorizationRule' :: AuthorizationRule -> Maybe Text
$sel:description:AuthorizationRule' :: AuthorizationRule -> Maybe Text
$sel:clientVpnEndpointId:AuthorizationRule' :: AuthorizationRule -> Maybe Text
$sel:accessAll:AuthorizationRule' :: AuthorizationRule -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
accessAll
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientVpnEndpointId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destinationCidr
      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 ClientVpnAuthorizationRuleStatus
status