{-# 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-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)
--
-- 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.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:/ '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
(DeleteAccessControlRule -> DeleteAccessControlRule -> Bool)
-> (DeleteAccessControlRule -> DeleteAccessControlRule -> Bool)
-> Eq DeleteAccessControlRule
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]
(Int -> ReadS DeleteAccessControlRule)
-> ReadS [DeleteAccessControlRule]
-> ReadPrec DeleteAccessControlRule
-> ReadPrec [DeleteAccessControlRule]
-> Read 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
(Int -> DeleteAccessControlRule -> ShowS)
-> (DeleteAccessControlRule -> String)
-> ([DeleteAccessControlRule] -> ShowS)
-> Show DeleteAccessControlRule
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.
 DeleteAccessControlRule -> Rep DeleteAccessControlRule x)
-> (forall x.
    Rep DeleteAccessControlRule x -> DeleteAccessControlRule)
-> Generic DeleteAccessControlRule
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' :: Text -> Text -> DeleteAccessControlRule
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 :: (Text -> f Text)
-> DeleteAccessControlRule -> f DeleteAccessControlRule
deleteAccessControlRule_organizationId = (DeleteAccessControlRule -> Text)
-> (DeleteAccessControlRule -> Text -> DeleteAccessControlRule)
-> Lens DeleteAccessControlRule DeleteAccessControlRule Text Text
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 :: (Text -> f Text)
-> DeleteAccessControlRule -> f DeleteAccessControlRule
deleteAccessControlRule_name = (DeleteAccessControlRule -> Text)
-> (DeleteAccessControlRule -> Text -> DeleteAccessControlRule)
-> Lens DeleteAccessControlRule DeleteAccessControlRule Text Text
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 :: DeleteAccessControlRule -> Request DeleteAccessControlRule
request = Service
-> DeleteAccessControlRule -> Request DeleteAccessControlRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteAccessControlRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteAccessControlRule)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteAccessControlRule))
-> Logger
-> Service
-> Proxy DeleteAccessControlRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteAccessControlRule)))
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 -> DeleteAccessControlRuleResponse
DeleteAccessControlRuleResponse'
            (Int -> DeleteAccessControlRuleResponse)
-> Either String Int
-> Either String DeleteAccessControlRuleResponse
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 DeleteAccessControlRule

instance Prelude.NFData DeleteAccessControlRule

instance Core.ToHeaders DeleteAccessControlRule where
  toHeaders :: DeleteAccessControlRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteAccessControlRule -> 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.DeleteAccessControlRule" ::
                          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 DeleteAccessControlRule where
  toJSON :: DeleteAccessControlRule -> Value
toJSON DeleteAccessControlRule' {Text
name :: Text
organizationId :: Text
$sel:name:DeleteAccessControlRule' :: DeleteAccessControlRule -> Text
$sel:organizationId:DeleteAccessControlRule' :: DeleteAccessControlRule -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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),
            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)
          ]
      )

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

instance Core.ToQuery DeleteAccessControlRule where
  toQuery :: DeleteAccessControlRule -> QueryString
toQuery = QueryString -> DeleteAccessControlRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteAccessControlRuleResponse
 -> DeleteAccessControlRuleResponse -> Bool)
-> (DeleteAccessControlRuleResponse
    -> DeleteAccessControlRuleResponse -> Bool)
-> Eq DeleteAccessControlRuleResponse
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]
(Int -> ReadS DeleteAccessControlRuleResponse)
-> ReadS [DeleteAccessControlRuleResponse]
-> ReadPrec DeleteAccessControlRuleResponse
-> ReadPrec [DeleteAccessControlRuleResponse]
-> Read 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
(Int -> DeleteAccessControlRuleResponse -> ShowS)
-> (DeleteAccessControlRuleResponse -> String)
-> ([DeleteAccessControlRuleResponse] -> ShowS)
-> Show DeleteAccessControlRuleResponse
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.
 DeleteAccessControlRuleResponse
 -> Rep DeleteAccessControlRuleResponse x)
-> (forall x.
    Rep DeleteAccessControlRuleResponse x
    -> DeleteAccessControlRuleResponse)
-> Generic DeleteAccessControlRuleResponse
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' :: Int -> DeleteAccessControlRuleResponse
DeleteAccessControlRuleResponse'
    { $sel:httpStatus:DeleteAccessControlRuleResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteAccessControlRuleResponse_httpStatus :: Lens.Lens' DeleteAccessControlRuleResponse Prelude.Int
deleteAccessControlRuleResponse_httpStatus :: (Int -> f Int)
-> DeleteAccessControlRuleResponse
-> f DeleteAccessControlRuleResponse
deleteAccessControlRuleResponse_httpStatus = (DeleteAccessControlRuleResponse -> Int)
-> (DeleteAccessControlRuleResponse
    -> Int -> DeleteAccessControlRuleResponse)
-> Lens
     DeleteAccessControlRuleResponse
     DeleteAccessControlRuleResponse
     Int
     Int
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