{-# 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.DeleteAlias
-- 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)
--
-- Remove one or more specified aliases from a set of aliases for a given
-- user.
module Amazonka.WorkMail.DeleteAlias
  ( -- * Creating a Request
    DeleteAlias (..),
    newDeleteAlias,

    -- * Request Lenses
    deleteAlias_organizationId,
    deleteAlias_entityId,
    deleteAlias_alias,

    -- * Destructuring the Response
    DeleteAliasResponse (..),
    newDeleteAliasResponse,

    -- * Response Lenses
    deleteAliasResponse_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:/ 'newDeleteAlias' smart constructor.
data DeleteAlias = DeleteAlias'
  { -- | The identifier for the organization under which the user exists.
    DeleteAlias -> Text
organizationId :: Prelude.Text,
    -- | The identifier for the member (user or group) from which to have the
    -- aliases removed.
    DeleteAlias -> Text
entityId :: Prelude.Text,
    -- | The aliases to be removed from the user\'s set of aliases. Duplicate
    -- entries in the list are collapsed into single entries (the list is
    -- transformed into a set).
    DeleteAlias -> Text
alias :: Prelude.Text
  }
  deriving (DeleteAlias -> DeleteAlias -> Bool
(DeleteAlias -> DeleteAlias -> Bool)
-> (DeleteAlias -> DeleteAlias -> Bool) -> Eq DeleteAlias
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAlias -> DeleteAlias -> Bool
$c/= :: DeleteAlias -> DeleteAlias -> Bool
== :: DeleteAlias -> DeleteAlias -> Bool
$c== :: DeleteAlias -> DeleteAlias -> Bool
Prelude.Eq, ReadPrec [DeleteAlias]
ReadPrec DeleteAlias
Int -> ReadS DeleteAlias
ReadS [DeleteAlias]
(Int -> ReadS DeleteAlias)
-> ReadS [DeleteAlias]
-> ReadPrec DeleteAlias
-> ReadPrec [DeleteAlias]
-> Read DeleteAlias
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAlias]
$creadListPrec :: ReadPrec [DeleteAlias]
readPrec :: ReadPrec DeleteAlias
$creadPrec :: ReadPrec DeleteAlias
readList :: ReadS [DeleteAlias]
$creadList :: ReadS [DeleteAlias]
readsPrec :: Int -> ReadS DeleteAlias
$creadsPrec :: Int -> ReadS DeleteAlias
Prelude.Read, Int -> DeleteAlias -> ShowS
[DeleteAlias] -> ShowS
DeleteAlias -> String
(Int -> DeleteAlias -> ShowS)
-> (DeleteAlias -> String)
-> ([DeleteAlias] -> ShowS)
-> Show DeleteAlias
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAlias] -> ShowS
$cshowList :: [DeleteAlias] -> ShowS
show :: DeleteAlias -> String
$cshow :: DeleteAlias -> String
showsPrec :: Int -> DeleteAlias -> ShowS
$cshowsPrec :: Int -> DeleteAlias -> ShowS
Prelude.Show, (forall x. DeleteAlias -> Rep DeleteAlias x)
-> (forall x. Rep DeleteAlias x -> DeleteAlias)
-> Generic DeleteAlias
forall x. Rep DeleteAlias x -> DeleteAlias
forall x. DeleteAlias -> Rep DeleteAlias x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteAlias x -> DeleteAlias
$cfrom :: forall x. DeleteAlias -> Rep DeleteAlias x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAlias' 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', 'deleteAlias_organizationId' - The identifier for the organization under which the user exists.
--
-- 'entityId', 'deleteAlias_entityId' - The identifier for the member (user or group) from which to have the
-- aliases removed.
--
-- 'alias', 'deleteAlias_alias' - The aliases to be removed from the user\'s set of aliases. Duplicate
-- entries in the list are collapsed into single entries (the list is
-- transformed into a set).
newDeleteAlias ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'entityId'
  Prelude.Text ->
  -- | 'alias'
  Prelude.Text ->
  DeleteAlias
newDeleteAlias :: Text -> Text -> Text -> DeleteAlias
newDeleteAlias Text
pOrganizationId_ Text
pEntityId_ Text
pAlias_ =
  DeleteAlias' :: Text -> Text -> Text -> DeleteAlias
DeleteAlias'
    { $sel:organizationId:DeleteAlias' :: Text
organizationId = Text
pOrganizationId_,
      $sel:entityId:DeleteAlias' :: Text
entityId = Text
pEntityId_,
      $sel:alias:DeleteAlias' :: Text
alias = Text
pAlias_
    }

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

-- | The identifier for the member (user or group) from which to have the
-- aliases removed.
deleteAlias_entityId :: Lens.Lens' DeleteAlias Prelude.Text
deleteAlias_entityId :: (Text -> f Text) -> DeleteAlias -> f DeleteAlias
deleteAlias_entityId = (DeleteAlias -> Text)
-> (DeleteAlias -> Text -> DeleteAlias)
-> Lens DeleteAlias DeleteAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAlias' {Text
entityId :: Text
$sel:entityId:DeleteAlias' :: DeleteAlias -> Text
entityId} -> Text
entityId) (\s :: DeleteAlias
s@DeleteAlias' {} Text
a -> DeleteAlias
s {$sel:entityId:DeleteAlias' :: Text
entityId = Text
a} :: DeleteAlias)

-- | The aliases to be removed from the user\'s set of aliases. Duplicate
-- entries in the list are collapsed into single entries (the list is
-- transformed into a set).
deleteAlias_alias :: Lens.Lens' DeleteAlias Prelude.Text
deleteAlias_alias :: (Text -> f Text) -> DeleteAlias -> f DeleteAlias
deleteAlias_alias = (DeleteAlias -> Text)
-> (DeleteAlias -> Text -> DeleteAlias)
-> Lens DeleteAlias DeleteAlias Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAlias' {Text
alias :: Text
$sel:alias:DeleteAlias' :: DeleteAlias -> Text
alias} -> Text
alias) (\s :: DeleteAlias
s@DeleteAlias' {} Text
a -> DeleteAlias
s {$sel:alias:DeleteAlias' :: Text
alias = Text
a} :: DeleteAlias)

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

instance Prelude.NFData DeleteAlias

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

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

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

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

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

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

instance Prelude.NFData DeleteAliasResponse