{-# 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.DeleteAccessControlRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes an access control rule for the specified WorkMail organization.
--
-- Deleting already deleted and non-existing rules does not produce an
-- error. In those cases, the service sends back an HTTP 200 response with
-- an empty HTTP body.
module Amazonka.WorkMail.DeleteAccessControlRule
  ( -- * Creating a Request
    DeleteAccessControlRule (..),
    newDeleteAccessControlRule,

    -- * Request Lenses
    deleteAccessControlRule_organizationId,
    deleteAccessControlRule_name,

    -- * Destructuring the Response
    DeleteAccessControlRuleResponse (..),
    newDeleteAccessControlRuleResponse,

    -- * Response Lenses
    deleteAccessControlRuleResponse_httpStatus,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WorkMail.Types

-- | /See:/ 'newDeleteAccessControlRule' smart constructor.
data DeleteAccessControlRule = DeleteAccessControlRule'
  { -- | The identifier for the organization.
    DeleteAccessControlRule -> Text
organizationId :: Prelude.Text,
    -- | The name of the access control rule.
    DeleteAccessControlRule -> Text
name :: Prelude.Text
  }
  deriving (DeleteAccessControlRule -> DeleteAccessControlRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAccessControlRule -> DeleteAccessControlRule -> Bool
$c/= :: DeleteAccessControlRule -> DeleteAccessControlRule -> Bool
== :: DeleteAccessControlRule -> DeleteAccessControlRule -> Bool
$c== :: DeleteAccessControlRule -> DeleteAccessControlRule -> Bool
Prelude.Eq, ReadPrec [DeleteAccessControlRule]
ReadPrec DeleteAccessControlRule
Int -> ReadS DeleteAccessControlRule
ReadS [DeleteAccessControlRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAccessControlRule]
$creadListPrec :: ReadPrec [DeleteAccessControlRule]
readPrec :: ReadPrec DeleteAccessControlRule
$creadPrec :: ReadPrec DeleteAccessControlRule
readList :: ReadS [DeleteAccessControlRule]
$creadList :: ReadS [DeleteAccessControlRule]
readsPrec :: Int -> ReadS DeleteAccessControlRule
$creadsPrec :: Int -> ReadS DeleteAccessControlRule
Prelude.Read, Int -> DeleteAccessControlRule -> ShowS
[DeleteAccessControlRule] -> ShowS
DeleteAccessControlRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAccessControlRule] -> ShowS
$cshowList :: [DeleteAccessControlRule] -> ShowS
show :: DeleteAccessControlRule -> String
$cshow :: DeleteAccessControlRule -> String
showsPrec :: Int -> DeleteAccessControlRule -> ShowS
$cshowsPrec :: Int -> DeleteAccessControlRule -> ShowS
Prelude.Show, forall x. Rep DeleteAccessControlRule x -> DeleteAccessControlRule
forall x. DeleteAccessControlRule -> Rep DeleteAccessControlRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteAccessControlRule x -> DeleteAccessControlRule
$cfrom :: forall x. DeleteAccessControlRule -> Rep DeleteAccessControlRule x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAccessControlRule' 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:
--
-- 'organizationId', 'deleteAccessControlRule_organizationId' - The identifier for the organization.
--
-- 'name', 'deleteAccessControlRule_name' - The name of the access control rule.
newDeleteAccessControlRule ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  DeleteAccessControlRule
newDeleteAccessControlRule :: Text -> Text -> DeleteAccessControlRule
newDeleteAccessControlRule Text
pOrganizationId_ Text
pName_ =
  DeleteAccessControlRule'
    { $sel:organizationId:DeleteAccessControlRule' :: Text
organizationId =
        Text
pOrganizationId_,
      $sel:name:DeleteAccessControlRule' :: Text
name = Text
pName_
    }

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

-- | The name of the access control rule.
deleteAccessControlRule_name :: Lens.Lens' DeleteAccessControlRule Prelude.Text
deleteAccessControlRule_name :: Lens' DeleteAccessControlRule Text
deleteAccessControlRule_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAccessControlRule' {Text
name :: Text
$sel:name:DeleteAccessControlRule' :: DeleteAccessControlRule -> Text
name} -> Text
name) (\s :: DeleteAccessControlRule
s@DeleteAccessControlRule' {} Text
a -> DeleteAccessControlRule
s {$sel:name:DeleteAccessControlRule' :: Text
name = Text
a} :: DeleteAccessControlRule)

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

instance Prelude.Hashable DeleteAccessControlRule where
  hashWithSalt :: Int -> DeleteAccessControlRule -> Int
hashWithSalt Int
_salt DeleteAccessControlRule' {Text
name :: Text
organizationId :: Text
$sel:name:DeleteAccessControlRule' :: DeleteAccessControlRule -> Text
$sel:organizationId:DeleteAccessControlRule' :: DeleteAccessControlRule -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
organizationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData DeleteAccessControlRule where
  rnf :: DeleteAccessControlRule -> ()
rnf DeleteAccessControlRule' {Text
name :: Text
organizationId :: Text
$sel:name:DeleteAccessControlRule' :: DeleteAccessControlRule -> Text
$sel:organizationId:DeleteAccessControlRule' :: DeleteAccessControlRule -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
organizationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

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

instance Data.ToJSON DeleteAccessControlRule where
  toJSON :: DeleteAccessControlRule -> Value
toJSON DeleteAccessControlRule' {Text
name :: Text
organizationId :: Text
$sel:name:DeleteAccessControlRule' :: DeleteAccessControlRule -> Text
$sel:organizationId:DeleteAccessControlRule' :: DeleteAccessControlRule -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"OrganizationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
organizationId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    DeleteAccessControlRuleResponse
  where
  rnf :: DeleteAccessControlRuleResponse -> ()
rnf DeleteAccessControlRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteAccessControlRuleResponse' :: DeleteAccessControlRuleResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus