{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.WorkMail.PutAccessControlRule
-- 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)
--
-- Adds a new access control rule for the specified organization. The rule
-- allows or denies access to the organization for the specified IPv4
-- addresses, access protocol actions, and user IDs. Adding a new rule with
-- the same name as an existing rule replaces the older rule.
module Amazonka.WorkMail.PutAccessControlRule
  ( -- * Creating a Request
    PutAccessControlRule (..),
    newPutAccessControlRule,

    -- * Request Lenses
    putAccessControlRule_userIds,
    putAccessControlRule_actions,
    putAccessControlRule_notUserIds,
    putAccessControlRule_ipRanges,
    putAccessControlRule_notIpRanges,
    putAccessControlRule_notActions,
    putAccessControlRule_name,
    putAccessControlRule_effect,
    putAccessControlRule_description,
    putAccessControlRule_organizationId,

    -- * Destructuring the Response
    PutAccessControlRuleResponse (..),
    newPutAccessControlRuleResponse,

    -- * Response Lenses
    putAccessControlRuleResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WorkMail.Types

-- | /See:/ 'newPutAccessControlRule' smart constructor.
data PutAccessControlRule = PutAccessControlRule'
  { -- | User IDs to include in the rule.
    PutAccessControlRule -> Maybe [Text]
userIds :: Prelude.Maybe [Prelude.Text],
    -- | Access protocol actions to include in the rule. Valid values include
    -- @ActiveSync@, @AutoDiscover@, @EWS@, @IMAP@, @SMTP@, @WindowsOutlook@,
    -- and @WebMail@.
    PutAccessControlRule -> Maybe [Text]
actions :: Prelude.Maybe [Prelude.Text],
    -- | User IDs to exclude from the rule.
    PutAccessControlRule -> Maybe [Text]
notUserIds :: Prelude.Maybe [Prelude.Text],
    -- | IPv4 CIDR ranges to include in the rule.
    PutAccessControlRule -> Maybe [Text]
ipRanges :: Prelude.Maybe [Prelude.Text],
    -- | IPv4 CIDR ranges to exclude from the rule.
    PutAccessControlRule -> Maybe [Text]
notIpRanges :: Prelude.Maybe [Prelude.Text],
    -- | Access protocol actions to exclude from the rule. Valid values include
    -- @ActiveSync@, @AutoDiscover@, @EWS@, @IMAP@, @SMTP@, @WindowsOutlook@,
    -- and @WebMail@.
    PutAccessControlRule -> Maybe [Text]
notActions :: Prelude.Maybe [Prelude.Text],
    -- | The rule name.
    PutAccessControlRule -> Text
name :: Prelude.Text,
    -- | The rule effect.
    PutAccessControlRule -> AccessControlRuleEffect
effect :: AccessControlRuleEffect,
    -- | The rule description.
    PutAccessControlRule -> Text
description :: Prelude.Text,
    -- | The identifier of the organization.
    PutAccessControlRule -> Text
organizationId :: Prelude.Text
  }
  deriving (PutAccessControlRule -> PutAccessControlRule -> Bool
(PutAccessControlRule -> PutAccessControlRule -> Bool)
-> (PutAccessControlRule -> PutAccessControlRule -> Bool)
-> Eq PutAccessControlRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutAccessControlRule -> PutAccessControlRule -> Bool
$c/= :: PutAccessControlRule -> PutAccessControlRule -> Bool
== :: PutAccessControlRule -> PutAccessControlRule -> Bool
$c== :: PutAccessControlRule -> PutAccessControlRule -> Bool
Prelude.Eq, ReadPrec [PutAccessControlRule]
ReadPrec PutAccessControlRule
Int -> ReadS PutAccessControlRule
ReadS [PutAccessControlRule]
(Int -> ReadS PutAccessControlRule)
-> ReadS [PutAccessControlRule]
-> ReadPrec PutAccessControlRule
-> ReadPrec [PutAccessControlRule]
-> Read PutAccessControlRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutAccessControlRule]
$creadListPrec :: ReadPrec [PutAccessControlRule]
readPrec :: ReadPrec PutAccessControlRule
$creadPrec :: ReadPrec PutAccessControlRule
readList :: ReadS [PutAccessControlRule]
$creadList :: ReadS [PutAccessControlRule]
readsPrec :: Int -> ReadS PutAccessControlRule
$creadsPrec :: Int -> ReadS PutAccessControlRule
Prelude.Read, Int -> PutAccessControlRule -> ShowS
[PutAccessControlRule] -> ShowS
PutAccessControlRule -> String
(Int -> PutAccessControlRule -> ShowS)
-> (PutAccessControlRule -> String)
-> ([PutAccessControlRule] -> ShowS)
-> Show PutAccessControlRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutAccessControlRule] -> ShowS
$cshowList :: [PutAccessControlRule] -> ShowS
show :: PutAccessControlRule -> String
$cshow :: PutAccessControlRule -> String
showsPrec :: Int -> PutAccessControlRule -> ShowS
$cshowsPrec :: Int -> PutAccessControlRule -> ShowS
Prelude.Show, (forall x. PutAccessControlRule -> Rep PutAccessControlRule x)
-> (forall x. Rep PutAccessControlRule x -> PutAccessControlRule)
-> Generic PutAccessControlRule
forall x. Rep PutAccessControlRule x -> PutAccessControlRule
forall x. PutAccessControlRule -> Rep PutAccessControlRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutAccessControlRule x -> PutAccessControlRule
$cfrom :: forall x. PutAccessControlRule -> Rep PutAccessControlRule x
Prelude.Generic)

-- |
-- Create a value of 'PutAccessControlRule' 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:
--
-- 'userIds', 'putAccessControlRule_userIds' - User IDs to include in the rule.
--
-- 'actions', 'putAccessControlRule_actions' - Access protocol actions to include in the rule. Valid values include
-- @ActiveSync@, @AutoDiscover@, @EWS@, @IMAP@, @SMTP@, @WindowsOutlook@,
-- and @WebMail@.
--
-- 'notUserIds', 'putAccessControlRule_notUserIds' - User IDs to exclude from the rule.
--
-- 'ipRanges', 'putAccessControlRule_ipRanges' - IPv4 CIDR ranges to include in the rule.
--
-- 'notIpRanges', 'putAccessControlRule_notIpRanges' - IPv4 CIDR ranges to exclude from the rule.
--
-- 'notActions', 'putAccessControlRule_notActions' - Access protocol actions to exclude from the rule. Valid values include
-- @ActiveSync@, @AutoDiscover@, @EWS@, @IMAP@, @SMTP@, @WindowsOutlook@,
-- and @WebMail@.
--
-- 'name', 'putAccessControlRule_name' - The rule name.
--
-- 'effect', 'putAccessControlRule_effect' - The rule effect.
--
-- 'description', 'putAccessControlRule_description' - The rule description.
--
-- 'organizationId', 'putAccessControlRule_organizationId' - The identifier of the organization.
newPutAccessControlRule ::
  -- | 'name'
  Prelude.Text ->
  -- | 'effect'
  AccessControlRuleEffect ->
  -- | 'description'
  Prelude.Text ->
  -- | 'organizationId'
  Prelude.Text ->
  PutAccessControlRule
newPutAccessControlRule :: Text
-> AccessControlRuleEffect -> Text -> Text -> PutAccessControlRule
newPutAccessControlRule
  Text
pName_
  AccessControlRuleEffect
pEffect_
  Text
pDescription_
  Text
pOrganizationId_ =
    PutAccessControlRule' :: Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Maybe [Text]
-> Text
-> AccessControlRuleEffect
-> Text
-> Text
-> PutAccessControlRule
PutAccessControlRule'
      { $sel:userIds:PutAccessControlRule' :: Maybe [Text]
userIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:actions:PutAccessControlRule' :: Maybe [Text]
actions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:notUserIds:PutAccessControlRule' :: Maybe [Text]
notUserIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:ipRanges:PutAccessControlRule' :: Maybe [Text]
ipRanges = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:notIpRanges:PutAccessControlRule' :: Maybe [Text]
notIpRanges = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:notActions:PutAccessControlRule' :: Maybe [Text]
notActions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:name:PutAccessControlRule' :: Text
name = Text
pName_,
        $sel:effect:PutAccessControlRule' :: AccessControlRuleEffect
effect = AccessControlRuleEffect
pEffect_,
        $sel:description:PutAccessControlRule' :: Text
description = Text
pDescription_,
        $sel:organizationId:PutAccessControlRule' :: Text
organizationId = Text
pOrganizationId_
      }

-- | User IDs to include in the rule.
putAccessControlRule_userIds :: Lens.Lens' PutAccessControlRule (Prelude.Maybe [Prelude.Text])
putAccessControlRule_userIds :: (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule -> f PutAccessControlRule
putAccessControlRule_userIds = (PutAccessControlRule -> Maybe [Text])
-> (PutAccessControlRule -> Maybe [Text] -> PutAccessControlRule)
-> Lens
     PutAccessControlRule
     PutAccessControlRule
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRule' {Maybe [Text]
userIds :: Maybe [Text]
$sel:userIds:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
userIds} -> Maybe [Text]
userIds) (\s :: PutAccessControlRule
s@PutAccessControlRule' {} Maybe [Text]
a -> PutAccessControlRule
s {$sel:userIds:PutAccessControlRule' :: Maybe [Text]
userIds = Maybe [Text]
a} :: PutAccessControlRule) ((Maybe [Text] -> f (Maybe [Text]))
 -> PutAccessControlRule -> f PutAccessControlRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule
-> f PutAccessControlRule
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

-- | Access protocol actions to include in the rule. Valid values include
-- @ActiveSync@, @AutoDiscover@, @EWS@, @IMAP@, @SMTP@, @WindowsOutlook@,
-- and @WebMail@.
putAccessControlRule_actions :: Lens.Lens' PutAccessControlRule (Prelude.Maybe [Prelude.Text])
putAccessControlRule_actions :: (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule -> f PutAccessControlRule
putAccessControlRule_actions = (PutAccessControlRule -> Maybe [Text])
-> (PutAccessControlRule -> Maybe [Text] -> PutAccessControlRule)
-> Lens
     PutAccessControlRule
     PutAccessControlRule
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRule' {Maybe [Text]
actions :: Maybe [Text]
$sel:actions:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
actions} -> Maybe [Text]
actions) (\s :: PutAccessControlRule
s@PutAccessControlRule' {} Maybe [Text]
a -> PutAccessControlRule
s {$sel:actions:PutAccessControlRule' :: Maybe [Text]
actions = Maybe [Text]
a} :: PutAccessControlRule) ((Maybe [Text] -> f (Maybe [Text]))
 -> PutAccessControlRule -> f PutAccessControlRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule
-> f PutAccessControlRule
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

-- | User IDs to exclude from the rule.
putAccessControlRule_notUserIds :: Lens.Lens' PutAccessControlRule (Prelude.Maybe [Prelude.Text])
putAccessControlRule_notUserIds :: (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule -> f PutAccessControlRule
putAccessControlRule_notUserIds = (PutAccessControlRule -> Maybe [Text])
-> (PutAccessControlRule -> Maybe [Text] -> PutAccessControlRule)
-> Lens
     PutAccessControlRule
     PutAccessControlRule
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRule' {Maybe [Text]
notUserIds :: Maybe [Text]
$sel:notUserIds:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
notUserIds} -> Maybe [Text]
notUserIds) (\s :: PutAccessControlRule
s@PutAccessControlRule' {} Maybe [Text]
a -> PutAccessControlRule
s {$sel:notUserIds:PutAccessControlRule' :: Maybe [Text]
notUserIds = Maybe [Text]
a} :: PutAccessControlRule) ((Maybe [Text] -> f (Maybe [Text]))
 -> PutAccessControlRule -> f PutAccessControlRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule
-> f PutAccessControlRule
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

-- | IPv4 CIDR ranges to include in the rule.
putAccessControlRule_ipRanges :: Lens.Lens' PutAccessControlRule (Prelude.Maybe [Prelude.Text])
putAccessControlRule_ipRanges :: (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule -> f PutAccessControlRule
putAccessControlRule_ipRanges = (PutAccessControlRule -> Maybe [Text])
-> (PutAccessControlRule -> Maybe [Text] -> PutAccessControlRule)
-> Lens
     PutAccessControlRule
     PutAccessControlRule
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRule' {Maybe [Text]
ipRanges :: Maybe [Text]
$sel:ipRanges:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
ipRanges} -> Maybe [Text]
ipRanges) (\s :: PutAccessControlRule
s@PutAccessControlRule' {} Maybe [Text]
a -> PutAccessControlRule
s {$sel:ipRanges:PutAccessControlRule' :: Maybe [Text]
ipRanges = Maybe [Text]
a} :: PutAccessControlRule) ((Maybe [Text] -> f (Maybe [Text]))
 -> PutAccessControlRule -> f PutAccessControlRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule
-> f PutAccessControlRule
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

-- | IPv4 CIDR ranges to exclude from the rule.
putAccessControlRule_notIpRanges :: Lens.Lens' PutAccessControlRule (Prelude.Maybe [Prelude.Text])
putAccessControlRule_notIpRanges :: (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule -> f PutAccessControlRule
putAccessControlRule_notIpRanges = (PutAccessControlRule -> Maybe [Text])
-> (PutAccessControlRule -> Maybe [Text] -> PutAccessControlRule)
-> Lens
     PutAccessControlRule
     PutAccessControlRule
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRule' {Maybe [Text]
notIpRanges :: Maybe [Text]
$sel:notIpRanges:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
notIpRanges} -> Maybe [Text]
notIpRanges) (\s :: PutAccessControlRule
s@PutAccessControlRule' {} Maybe [Text]
a -> PutAccessControlRule
s {$sel:notIpRanges:PutAccessControlRule' :: Maybe [Text]
notIpRanges = Maybe [Text]
a} :: PutAccessControlRule) ((Maybe [Text] -> f (Maybe [Text]))
 -> PutAccessControlRule -> f PutAccessControlRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule
-> f PutAccessControlRule
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

-- | Access protocol actions to exclude from the rule. Valid values include
-- @ActiveSync@, @AutoDiscover@, @EWS@, @IMAP@, @SMTP@, @WindowsOutlook@,
-- and @WebMail@.
putAccessControlRule_notActions :: Lens.Lens' PutAccessControlRule (Prelude.Maybe [Prelude.Text])
putAccessControlRule_notActions :: (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule -> f PutAccessControlRule
putAccessControlRule_notActions = (PutAccessControlRule -> Maybe [Text])
-> (PutAccessControlRule -> Maybe [Text] -> PutAccessControlRule)
-> Lens
     PutAccessControlRule
     PutAccessControlRule
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRule' {Maybe [Text]
notActions :: Maybe [Text]
$sel:notActions:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
notActions} -> Maybe [Text]
notActions) (\s :: PutAccessControlRule
s@PutAccessControlRule' {} Maybe [Text]
a -> PutAccessControlRule
s {$sel:notActions:PutAccessControlRule' :: Maybe [Text]
notActions = Maybe [Text]
a} :: PutAccessControlRule) ((Maybe [Text] -> f (Maybe [Text]))
 -> PutAccessControlRule -> f PutAccessControlRule)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PutAccessControlRule
-> f PutAccessControlRule
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 rule name.
putAccessControlRule_name :: Lens.Lens' PutAccessControlRule Prelude.Text
putAccessControlRule_name :: (Text -> f Text) -> PutAccessControlRule -> f PutAccessControlRule
putAccessControlRule_name = (PutAccessControlRule -> Text)
-> (PutAccessControlRule -> Text -> PutAccessControlRule)
-> Lens PutAccessControlRule PutAccessControlRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRule' {Text
name :: Text
$sel:name:PutAccessControlRule' :: PutAccessControlRule -> Text
name} -> Text
name) (\s :: PutAccessControlRule
s@PutAccessControlRule' {} Text
a -> PutAccessControlRule
s {$sel:name:PutAccessControlRule' :: Text
name = Text
a} :: PutAccessControlRule)

-- | The rule effect.
putAccessControlRule_effect :: Lens.Lens' PutAccessControlRule AccessControlRuleEffect
putAccessControlRule_effect :: (AccessControlRuleEffect -> f AccessControlRuleEffect)
-> PutAccessControlRule -> f PutAccessControlRule
putAccessControlRule_effect = (PutAccessControlRule -> AccessControlRuleEffect)
-> (PutAccessControlRule
    -> AccessControlRuleEffect -> PutAccessControlRule)
-> Lens
     PutAccessControlRule
     PutAccessControlRule
     AccessControlRuleEffect
     AccessControlRuleEffect
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRule' {AccessControlRuleEffect
effect :: AccessControlRuleEffect
$sel:effect:PutAccessControlRule' :: PutAccessControlRule -> AccessControlRuleEffect
effect} -> AccessControlRuleEffect
effect) (\s :: PutAccessControlRule
s@PutAccessControlRule' {} AccessControlRuleEffect
a -> PutAccessControlRule
s {$sel:effect:PutAccessControlRule' :: AccessControlRuleEffect
effect = AccessControlRuleEffect
a} :: PutAccessControlRule)

-- | The rule description.
putAccessControlRule_description :: Lens.Lens' PutAccessControlRule Prelude.Text
putAccessControlRule_description :: (Text -> f Text) -> PutAccessControlRule -> f PutAccessControlRule
putAccessControlRule_description = (PutAccessControlRule -> Text)
-> (PutAccessControlRule -> Text -> PutAccessControlRule)
-> Lens PutAccessControlRule PutAccessControlRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRule' {Text
description :: Text
$sel:description:PutAccessControlRule' :: PutAccessControlRule -> Text
description} -> Text
description) (\s :: PutAccessControlRule
s@PutAccessControlRule' {} Text
a -> PutAccessControlRule
s {$sel:description:PutAccessControlRule' :: Text
description = Text
a} :: PutAccessControlRule)

-- | The identifier of the organization.
putAccessControlRule_organizationId :: Lens.Lens' PutAccessControlRule Prelude.Text
putAccessControlRule_organizationId :: (Text -> f Text) -> PutAccessControlRule -> f PutAccessControlRule
putAccessControlRule_organizationId = (PutAccessControlRule -> Text)
-> (PutAccessControlRule -> Text -> PutAccessControlRule)
-> Lens PutAccessControlRule PutAccessControlRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRule' {Text
organizationId :: Text
$sel:organizationId:PutAccessControlRule' :: PutAccessControlRule -> Text
organizationId} -> Text
organizationId) (\s :: PutAccessControlRule
s@PutAccessControlRule' {} Text
a -> PutAccessControlRule
s {$sel:organizationId:PutAccessControlRule' :: Text
organizationId = Text
a} :: PutAccessControlRule)

instance Core.AWSRequest PutAccessControlRule where
  type
    AWSResponse PutAccessControlRule =
      PutAccessControlRuleResponse
  request :: PutAccessControlRule -> Request PutAccessControlRule
request = Service -> PutAccessControlRule -> Request PutAccessControlRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutAccessControlRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutAccessControlRule)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutAccessControlRule))
-> Logger
-> Service
-> Proxy PutAccessControlRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutAccessControlRule)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutAccessControlRuleResponse
PutAccessControlRuleResponse'
            (Int -> PutAccessControlRuleResponse)
-> Either String Int -> Either String PutAccessControlRuleResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable PutAccessControlRule

instance Prelude.NFData PutAccessControlRule

instance Core.ToHeaders PutAccessControlRule where
  toHeaders :: PutAccessControlRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutAccessControlRule -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"WorkMailService.PutAccessControlRule" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON PutAccessControlRule where
  toJSON :: PutAccessControlRule -> Value
toJSON PutAccessControlRule' {Maybe [Text]
Text
AccessControlRuleEffect
organizationId :: Text
description :: Text
effect :: AccessControlRuleEffect
name :: Text
notActions :: Maybe [Text]
notIpRanges :: Maybe [Text]
ipRanges :: Maybe [Text]
notUserIds :: Maybe [Text]
actions :: Maybe [Text]
userIds :: Maybe [Text]
$sel:organizationId:PutAccessControlRule' :: PutAccessControlRule -> Text
$sel:description:PutAccessControlRule' :: PutAccessControlRule -> Text
$sel:effect:PutAccessControlRule' :: PutAccessControlRule -> AccessControlRuleEffect
$sel:name:PutAccessControlRule' :: PutAccessControlRule -> Text
$sel:notActions:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
$sel:notIpRanges:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
$sel:ipRanges:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
$sel:notUserIds:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
$sel:actions:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
$sel:userIds:PutAccessControlRule' :: PutAccessControlRule -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"UserIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
userIds,
            (Text
"Actions" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
actions,
            (Text
"NotUserIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
notUserIds,
            (Text
"IpRanges" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
ipRanges,
            (Text
"NotIpRanges" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
notIpRanges,
            (Text
"NotActions" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
notActions,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Effect" Text -> AccessControlRuleEffect -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AccessControlRuleEffect
effect),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
description),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"OrganizationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
organizationId)
          ]
      )

instance Core.ToPath PutAccessControlRule where
  toPath :: PutAccessControlRule -> ByteString
toPath = ByteString -> PutAccessControlRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery PutAccessControlRule where
  toQuery :: PutAccessControlRule -> QueryString
toQuery = QueryString -> PutAccessControlRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newPutAccessControlRuleResponse' smart constructor.
data PutAccessControlRuleResponse = PutAccessControlRuleResponse'
  { -- | The response's http status code.
    PutAccessControlRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutAccessControlRuleResponse
-> PutAccessControlRuleResponse -> Bool
(PutAccessControlRuleResponse
 -> PutAccessControlRuleResponse -> Bool)
-> (PutAccessControlRuleResponse
    -> PutAccessControlRuleResponse -> Bool)
-> Eq PutAccessControlRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutAccessControlRuleResponse
-> PutAccessControlRuleResponse -> Bool
$c/= :: PutAccessControlRuleResponse
-> PutAccessControlRuleResponse -> Bool
== :: PutAccessControlRuleResponse
-> PutAccessControlRuleResponse -> Bool
$c== :: PutAccessControlRuleResponse
-> PutAccessControlRuleResponse -> Bool
Prelude.Eq, ReadPrec [PutAccessControlRuleResponse]
ReadPrec PutAccessControlRuleResponse
Int -> ReadS PutAccessControlRuleResponse
ReadS [PutAccessControlRuleResponse]
(Int -> ReadS PutAccessControlRuleResponse)
-> ReadS [PutAccessControlRuleResponse]
-> ReadPrec PutAccessControlRuleResponse
-> ReadPrec [PutAccessControlRuleResponse]
-> Read PutAccessControlRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutAccessControlRuleResponse]
$creadListPrec :: ReadPrec [PutAccessControlRuleResponse]
readPrec :: ReadPrec PutAccessControlRuleResponse
$creadPrec :: ReadPrec PutAccessControlRuleResponse
readList :: ReadS [PutAccessControlRuleResponse]
$creadList :: ReadS [PutAccessControlRuleResponse]
readsPrec :: Int -> ReadS PutAccessControlRuleResponse
$creadsPrec :: Int -> ReadS PutAccessControlRuleResponse
Prelude.Read, Int -> PutAccessControlRuleResponse -> ShowS
[PutAccessControlRuleResponse] -> ShowS
PutAccessControlRuleResponse -> String
(Int -> PutAccessControlRuleResponse -> ShowS)
-> (PutAccessControlRuleResponse -> String)
-> ([PutAccessControlRuleResponse] -> ShowS)
-> Show PutAccessControlRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutAccessControlRuleResponse] -> ShowS
$cshowList :: [PutAccessControlRuleResponse] -> ShowS
show :: PutAccessControlRuleResponse -> String
$cshow :: PutAccessControlRuleResponse -> String
showsPrec :: Int -> PutAccessControlRuleResponse -> ShowS
$cshowsPrec :: Int -> PutAccessControlRuleResponse -> ShowS
Prelude.Show, (forall x.
 PutAccessControlRuleResponse -> Rep PutAccessControlRuleResponse x)
-> (forall x.
    Rep PutAccessControlRuleResponse x -> PutAccessControlRuleResponse)
-> Generic PutAccessControlRuleResponse
forall x.
Rep PutAccessControlRuleResponse x -> PutAccessControlRuleResponse
forall x.
PutAccessControlRuleResponse -> Rep PutAccessControlRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutAccessControlRuleResponse x -> PutAccessControlRuleResponse
$cfrom :: forall x.
PutAccessControlRuleResponse -> Rep PutAccessControlRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutAccessControlRuleResponse' 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:
--
-- 'httpStatus', 'putAccessControlRuleResponse_httpStatus' - The response's http status code.
newPutAccessControlRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutAccessControlRuleResponse
newPutAccessControlRuleResponse :: Int -> PutAccessControlRuleResponse
newPutAccessControlRuleResponse Int
pHttpStatus_ =
  PutAccessControlRuleResponse' :: Int -> PutAccessControlRuleResponse
PutAccessControlRuleResponse'
    { $sel:httpStatus:PutAccessControlRuleResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
putAccessControlRuleResponse_httpStatus :: Lens.Lens' PutAccessControlRuleResponse Prelude.Int
putAccessControlRuleResponse_httpStatus :: (Int -> f Int)
-> PutAccessControlRuleResponse -> f PutAccessControlRuleResponse
putAccessControlRuleResponse_httpStatus = (PutAccessControlRuleResponse -> Int)
-> (PutAccessControlRuleResponse
    -> Int -> PutAccessControlRuleResponse)
-> Lens
     PutAccessControlRuleResponse PutAccessControlRuleResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccessControlRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutAccessControlRuleResponse' :: PutAccessControlRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutAccessControlRuleResponse
s@PutAccessControlRuleResponse' {} Int
a -> PutAccessControlRuleResponse
s {$sel:httpStatus:PutAccessControlRuleResponse' :: Int
httpStatus = Int
a} :: PutAccessControlRuleResponse)

instance Prelude.NFData PutAccessControlRuleResponse