{-# 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.DeleteMobileDeviceAccessRule
-- 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 a mobile device access rule for the specified Amazon 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.DeleteMobileDeviceAccessRule
  ( -- * Creating a Request
    DeleteMobileDeviceAccessRule (..),
    newDeleteMobileDeviceAccessRule,

    -- * Request Lenses
    deleteMobileDeviceAccessRule_organizationId,
    deleteMobileDeviceAccessRule_mobileDeviceAccessRuleId,

    -- * Destructuring the Response
    DeleteMobileDeviceAccessRuleResponse (..),
    newDeleteMobileDeviceAccessRuleResponse,

    -- * Response Lenses
    deleteMobileDeviceAccessRuleResponse_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:/ 'newDeleteMobileDeviceAccessRule' smart constructor.
data DeleteMobileDeviceAccessRule = DeleteMobileDeviceAccessRule'
  { -- | The Amazon WorkMail organization under which the rule will be deleted.
    DeleteMobileDeviceAccessRule -> Text
organizationId :: Prelude.Text,
    -- | The identifier of the rule to be deleted.
    DeleteMobileDeviceAccessRule -> Text
mobileDeviceAccessRuleId :: Prelude.Text
  }
  deriving (DeleteMobileDeviceAccessRule
-> DeleteMobileDeviceAccessRule -> Bool
(DeleteMobileDeviceAccessRule
 -> DeleteMobileDeviceAccessRule -> Bool)
-> (DeleteMobileDeviceAccessRule
    -> DeleteMobileDeviceAccessRule -> Bool)
-> Eq DeleteMobileDeviceAccessRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteMobileDeviceAccessRule
-> DeleteMobileDeviceAccessRule -> Bool
$c/= :: DeleteMobileDeviceAccessRule
-> DeleteMobileDeviceAccessRule -> Bool
== :: DeleteMobileDeviceAccessRule
-> DeleteMobileDeviceAccessRule -> Bool
$c== :: DeleteMobileDeviceAccessRule
-> DeleteMobileDeviceAccessRule -> Bool
Prelude.Eq, ReadPrec [DeleteMobileDeviceAccessRule]
ReadPrec DeleteMobileDeviceAccessRule
Int -> ReadS DeleteMobileDeviceAccessRule
ReadS [DeleteMobileDeviceAccessRule]
(Int -> ReadS DeleteMobileDeviceAccessRule)
-> ReadS [DeleteMobileDeviceAccessRule]
-> ReadPrec DeleteMobileDeviceAccessRule
-> ReadPrec [DeleteMobileDeviceAccessRule]
-> Read DeleteMobileDeviceAccessRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteMobileDeviceAccessRule]
$creadListPrec :: ReadPrec [DeleteMobileDeviceAccessRule]
readPrec :: ReadPrec DeleteMobileDeviceAccessRule
$creadPrec :: ReadPrec DeleteMobileDeviceAccessRule
readList :: ReadS [DeleteMobileDeviceAccessRule]
$creadList :: ReadS [DeleteMobileDeviceAccessRule]
readsPrec :: Int -> ReadS DeleteMobileDeviceAccessRule
$creadsPrec :: Int -> ReadS DeleteMobileDeviceAccessRule
Prelude.Read, Int -> DeleteMobileDeviceAccessRule -> ShowS
[DeleteMobileDeviceAccessRule] -> ShowS
DeleteMobileDeviceAccessRule -> String
(Int -> DeleteMobileDeviceAccessRule -> ShowS)
-> (DeleteMobileDeviceAccessRule -> String)
-> ([DeleteMobileDeviceAccessRule] -> ShowS)
-> Show DeleteMobileDeviceAccessRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteMobileDeviceAccessRule] -> ShowS
$cshowList :: [DeleteMobileDeviceAccessRule] -> ShowS
show :: DeleteMobileDeviceAccessRule -> String
$cshow :: DeleteMobileDeviceAccessRule -> String
showsPrec :: Int -> DeleteMobileDeviceAccessRule -> ShowS
$cshowsPrec :: Int -> DeleteMobileDeviceAccessRule -> ShowS
Prelude.Show, (forall x.
 DeleteMobileDeviceAccessRule -> Rep DeleteMobileDeviceAccessRule x)
-> (forall x.
    Rep DeleteMobileDeviceAccessRule x -> DeleteMobileDeviceAccessRule)
-> Generic DeleteMobileDeviceAccessRule
forall x.
Rep DeleteMobileDeviceAccessRule x -> DeleteMobileDeviceAccessRule
forall x.
DeleteMobileDeviceAccessRule -> Rep DeleteMobileDeviceAccessRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteMobileDeviceAccessRule x -> DeleteMobileDeviceAccessRule
$cfrom :: forall x.
DeleteMobileDeviceAccessRule -> Rep DeleteMobileDeviceAccessRule x
Prelude.Generic)

-- |
-- Create a value of 'DeleteMobileDeviceAccessRule' 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', 'deleteMobileDeviceAccessRule_organizationId' - The Amazon WorkMail organization under which the rule will be deleted.
--
-- 'mobileDeviceAccessRuleId', 'deleteMobileDeviceAccessRule_mobileDeviceAccessRuleId' - The identifier of the rule to be deleted.
newDeleteMobileDeviceAccessRule ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'mobileDeviceAccessRuleId'
  Prelude.Text ->
  DeleteMobileDeviceAccessRule
newDeleteMobileDeviceAccessRule :: Text -> Text -> DeleteMobileDeviceAccessRule
newDeleteMobileDeviceAccessRule
  Text
pOrganizationId_
  Text
pMobileDeviceAccessRuleId_ =
    DeleteMobileDeviceAccessRule' :: Text -> Text -> DeleteMobileDeviceAccessRule
DeleteMobileDeviceAccessRule'
      { $sel:organizationId:DeleteMobileDeviceAccessRule' :: Text
organizationId =
          Text
pOrganizationId_,
        $sel:mobileDeviceAccessRuleId:DeleteMobileDeviceAccessRule' :: Text
mobileDeviceAccessRuleId =
          Text
pMobileDeviceAccessRuleId_
      }

-- | The Amazon WorkMail organization under which the rule will be deleted.
deleteMobileDeviceAccessRule_organizationId :: Lens.Lens' DeleteMobileDeviceAccessRule Prelude.Text
deleteMobileDeviceAccessRule_organizationId :: (Text -> f Text)
-> DeleteMobileDeviceAccessRule -> f DeleteMobileDeviceAccessRule
deleteMobileDeviceAccessRule_organizationId = (DeleteMobileDeviceAccessRule -> Text)
-> (DeleteMobileDeviceAccessRule
    -> Text -> DeleteMobileDeviceAccessRule)
-> Lens
     DeleteMobileDeviceAccessRule DeleteMobileDeviceAccessRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMobileDeviceAccessRule' {Text
organizationId :: Text
$sel:organizationId:DeleteMobileDeviceAccessRule' :: DeleteMobileDeviceAccessRule -> Text
organizationId} -> Text
organizationId) (\s :: DeleteMobileDeviceAccessRule
s@DeleteMobileDeviceAccessRule' {} Text
a -> DeleteMobileDeviceAccessRule
s {$sel:organizationId:DeleteMobileDeviceAccessRule' :: Text
organizationId = Text
a} :: DeleteMobileDeviceAccessRule)

-- | The identifier of the rule to be deleted.
deleteMobileDeviceAccessRule_mobileDeviceAccessRuleId :: Lens.Lens' DeleteMobileDeviceAccessRule Prelude.Text
deleteMobileDeviceAccessRule_mobileDeviceAccessRuleId :: (Text -> f Text)
-> DeleteMobileDeviceAccessRule -> f DeleteMobileDeviceAccessRule
deleteMobileDeviceAccessRule_mobileDeviceAccessRuleId = (DeleteMobileDeviceAccessRule -> Text)
-> (DeleteMobileDeviceAccessRule
    -> Text -> DeleteMobileDeviceAccessRule)
-> Lens
     DeleteMobileDeviceAccessRule DeleteMobileDeviceAccessRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMobileDeviceAccessRule' {Text
mobileDeviceAccessRuleId :: Text
$sel:mobileDeviceAccessRuleId:DeleteMobileDeviceAccessRule' :: DeleteMobileDeviceAccessRule -> Text
mobileDeviceAccessRuleId} -> Text
mobileDeviceAccessRuleId) (\s :: DeleteMobileDeviceAccessRule
s@DeleteMobileDeviceAccessRule' {} Text
a -> DeleteMobileDeviceAccessRule
s {$sel:mobileDeviceAccessRuleId:DeleteMobileDeviceAccessRule' :: Text
mobileDeviceAccessRuleId = Text
a} :: DeleteMobileDeviceAccessRule)

instance Core.AWSRequest DeleteMobileDeviceAccessRule where
  type
    AWSResponse DeleteMobileDeviceAccessRule =
      DeleteMobileDeviceAccessRuleResponse
  request :: DeleteMobileDeviceAccessRule
-> Request DeleteMobileDeviceAccessRule
request = Service
-> DeleteMobileDeviceAccessRule
-> Request DeleteMobileDeviceAccessRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteMobileDeviceAccessRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteMobileDeviceAccessRule)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteMobileDeviceAccessRule))
-> Logger
-> Service
-> Proxy DeleteMobileDeviceAccessRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteMobileDeviceAccessRule)))
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 -> DeleteMobileDeviceAccessRuleResponse
DeleteMobileDeviceAccessRuleResponse'
            (Int -> DeleteMobileDeviceAccessRuleResponse)
-> Either String Int
-> Either String DeleteMobileDeviceAccessRuleResponse
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
    DeleteMobileDeviceAccessRule

instance Prelude.NFData DeleteMobileDeviceAccessRule

instance Core.ToHeaders DeleteMobileDeviceAccessRule where
  toHeaders :: DeleteMobileDeviceAccessRule -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteMobileDeviceAccessRule -> 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.DeleteMobileDeviceAccessRule" ::
                          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 DeleteMobileDeviceAccessRule where
  toJSON :: DeleteMobileDeviceAccessRule -> Value
toJSON DeleteMobileDeviceAccessRule' {Text
mobileDeviceAccessRuleId :: Text
organizationId :: Text
$sel:mobileDeviceAccessRuleId:DeleteMobileDeviceAccessRule' :: DeleteMobileDeviceAccessRule -> Text
$sel:organizationId:DeleteMobileDeviceAccessRule' :: DeleteMobileDeviceAccessRule -> 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
"MobileDeviceAccessRuleId"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
mobileDeviceAccessRuleId
              )
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    DeleteMobileDeviceAccessRuleResponse