{-# 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.DeregisterFromWorkMail
-- 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)
--
-- Mark a user, group, or resource as no longer used in Amazon WorkMail.
-- This action disassociates the mailbox and schedules it for clean-up.
-- WorkMail keeps mailboxes for 30 days before they are permanently
-- removed. The functionality in the console is /Disable/.
module Amazonka.WorkMail.DeregisterFromWorkMail
  ( -- * Creating a Request
    DeregisterFromWorkMail (..),
    newDeregisterFromWorkMail,

    -- * Request Lenses
    deregisterFromWorkMail_organizationId,
    deregisterFromWorkMail_entityId,

    -- * Destructuring the Response
    DeregisterFromWorkMailResponse (..),
    newDeregisterFromWorkMailResponse,

    -- * Response Lenses
    deregisterFromWorkMailResponse_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:/ 'newDeregisterFromWorkMail' smart constructor.
data DeregisterFromWorkMail = DeregisterFromWorkMail'
  { -- | The identifier for the organization under which the Amazon WorkMail
    -- entity exists.
    DeregisterFromWorkMail -> Text
organizationId :: Prelude.Text,
    -- | The identifier for the member (user or group) to be updated.
    DeregisterFromWorkMail -> Text
entityId :: Prelude.Text
  }
  deriving (DeregisterFromWorkMail -> DeregisterFromWorkMail -> Bool
(DeregisterFromWorkMail -> DeregisterFromWorkMail -> Bool)
-> (DeregisterFromWorkMail -> DeregisterFromWorkMail -> Bool)
-> Eq DeregisterFromWorkMail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeregisterFromWorkMail -> DeregisterFromWorkMail -> Bool
$c/= :: DeregisterFromWorkMail -> DeregisterFromWorkMail -> Bool
== :: DeregisterFromWorkMail -> DeregisterFromWorkMail -> Bool
$c== :: DeregisterFromWorkMail -> DeregisterFromWorkMail -> Bool
Prelude.Eq, ReadPrec [DeregisterFromWorkMail]
ReadPrec DeregisterFromWorkMail
Int -> ReadS DeregisterFromWorkMail
ReadS [DeregisterFromWorkMail]
(Int -> ReadS DeregisterFromWorkMail)
-> ReadS [DeregisterFromWorkMail]
-> ReadPrec DeregisterFromWorkMail
-> ReadPrec [DeregisterFromWorkMail]
-> Read DeregisterFromWorkMail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeregisterFromWorkMail]
$creadListPrec :: ReadPrec [DeregisterFromWorkMail]
readPrec :: ReadPrec DeregisterFromWorkMail
$creadPrec :: ReadPrec DeregisterFromWorkMail
readList :: ReadS [DeregisterFromWorkMail]
$creadList :: ReadS [DeregisterFromWorkMail]
readsPrec :: Int -> ReadS DeregisterFromWorkMail
$creadsPrec :: Int -> ReadS DeregisterFromWorkMail
Prelude.Read, Int -> DeregisterFromWorkMail -> ShowS
[DeregisterFromWorkMail] -> ShowS
DeregisterFromWorkMail -> String
(Int -> DeregisterFromWorkMail -> ShowS)
-> (DeregisterFromWorkMail -> String)
-> ([DeregisterFromWorkMail] -> ShowS)
-> Show DeregisterFromWorkMail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeregisterFromWorkMail] -> ShowS
$cshowList :: [DeregisterFromWorkMail] -> ShowS
show :: DeregisterFromWorkMail -> String
$cshow :: DeregisterFromWorkMail -> String
showsPrec :: Int -> DeregisterFromWorkMail -> ShowS
$cshowsPrec :: Int -> DeregisterFromWorkMail -> ShowS
Prelude.Show, (forall x. DeregisterFromWorkMail -> Rep DeregisterFromWorkMail x)
-> (forall x.
    Rep DeregisterFromWorkMail x -> DeregisterFromWorkMail)
-> Generic DeregisterFromWorkMail
forall x. Rep DeregisterFromWorkMail x -> DeregisterFromWorkMail
forall x. DeregisterFromWorkMail -> Rep DeregisterFromWorkMail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeregisterFromWorkMail x -> DeregisterFromWorkMail
$cfrom :: forall x. DeregisterFromWorkMail -> Rep DeregisterFromWorkMail x
Prelude.Generic)

-- |
-- Create a value of 'DeregisterFromWorkMail' 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', 'deregisterFromWorkMail_organizationId' - The identifier for the organization under which the Amazon WorkMail
-- entity exists.
--
-- 'entityId', 'deregisterFromWorkMail_entityId' - The identifier for the member (user or group) to be updated.
newDeregisterFromWorkMail ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'entityId'
  Prelude.Text ->
  DeregisterFromWorkMail
newDeregisterFromWorkMail :: Text -> Text -> DeregisterFromWorkMail
newDeregisterFromWorkMail Text
pOrganizationId_ Text
pEntityId_ =
  DeregisterFromWorkMail' :: Text -> Text -> DeregisterFromWorkMail
DeregisterFromWorkMail'
    { $sel:organizationId:DeregisterFromWorkMail' :: Text
organizationId =
        Text
pOrganizationId_,
      $sel:entityId:DeregisterFromWorkMail' :: Text
entityId = Text
pEntityId_
    }

-- | The identifier for the organization under which the Amazon WorkMail
-- entity exists.
deregisterFromWorkMail_organizationId :: Lens.Lens' DeregisterFromWorkMail Prelude.Text
deregisterFromWorkMail_organizationId :: (Text -> f Text)
-> DeregisterFromWorkMail -> f DeregisterFromWorkMail
deregisterFromWorkMail_organizationId = (DeregisterFromWorkMail -> Text)
-> (DeregisterFromWorkMail -> Text -> DeregisterFromWorkMail)
-> Lens DeregisterFromWorkMail DeregisterFromWorkMail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterFromWorkMail' {Text
organizationId :: Text
$sel:organizationId:DeregisterFromWorkMail' :: DeregisterFromWorkMail -> Text
organizationId} -> Text
organizationId) (\s :: DeregisterFromWorkMail
s@DeregisterFromWorkMail' {} Text
a -> DeregisterFromWorkMail
s {$sel:organizationId:DeregisterFromWorkMail' :: Text
organizationId = Text
a} :: DeregisterFromWorkMail)

-- | The identifier for the member (user or group) to be updated.
deregisterFromWorkMail_entityId :: Lens.Lens' DeregisterFromWorkMail Prelude.Text
deregisterFromWorkMail_entityId :: (Text -> f Text)
-> DeregisterFromWorkMail -> f DeregisterFromWorkMail
deregisterFromWorkMail_entityId = (DeregisterFromWorkMail -> Text)
-> (DeregisterFromWorkMail -> Text -> DeregisterFromWorkMail)
-> Lens DeregisterFromWorkMail DeregisterFromWorkMail Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeregisterFromWorkMail' {Text
entityId :: Text
$sel:entityId:DeregisterFromWorkMail' :: DeregisterFromWorkMail -> Text
entityId} -> Text
entityId) (\s :: DeregisterFromWorkMail
s@DeregisterFromWorkMail' {} Text
a -> DeregisterFromWorkMail
s {$sel:entityId:DeregisterFromWorkMail' :: Text
entityId = Text
a} :: DeregisterFromWorkMail)

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

instance Prelude.NFData DeregisterFromWorkMail

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

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

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

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

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

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

instance
  Prelude.NFData
    DeregisterFromWorkMailResponse