{-# 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.UpdateDefaultMailDomain
-- 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)
--
-- Updates the default mail domain for an organization. The default mail
-- domain is used by the WorkMail AWS Console to suggest an email address
-- when enabling a mail user. You can only have one default domain.
module Amazonka.WorkMail.UpdateDefaultMailDomain
  ( -- * Creating a Request
    UpdateDefaultMailDomain (..),
    newUpdateDefaultMailDomain,

    -- * Request Lenses
    updateDefaultMailDomain_organizationId,
    updateDefaultMailDomain_domainName,

    -- * Destructuring the Response
    UpdateDefaultMailDomainResponse (..),
    newUpdateDefaultMailDomainResponse,

    -- * Response Lenses
    updateDefaultMailDomainResponse_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:/ 'newUpdateDefaultMailDomain' smart constructor.
data UpdateDefaultMailDomain = UpdateDefaultMailDomain'
  { -- | The Amazon WorkMail organization for which to list domains.
    UpdateDefaultMailDomain -> Text
organizationId :: Prelude.Text,
    -- | The domain name that will become the default domain.
    UpdateDefaultMailDomain -> Text
domainName :: Prelude.Text
  }
  deriving (UpdateDefaultMailDomain -> UpdateDefaultMailDomain -> Bool
(UpdateDefaultMailDomain -> UpdateDefaultMailDomain -> Bool)
-> (UpdateDefaultMailDomain -> UpdateDefaultMailDomain -> Bool)
-> Eq UpdateDefaultMailDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDefaultMailDomain -> UpdateDefaultMailDomain -> Bool
$c/= :: UpdateDefaultMailDomain -> UpdateDefaultMailDomain -> Bool
== :: UpdateDefaultMailDomain -> UpdateDefaultMailDomain -> Bool
$c== :: UpdateDefaultMailDomain -> UpdateDefaultMailDomain -> Bool
Prelude.Eq, ReadPrec [UpdateDefaultMailDomain]
ReadPrec UpdateDefaultMailDomain
Int -> ReadS UpdateDefaultMailDomain
ReadS [UpdateDefaultMailDomain]
(Int -> ReadS UpdateDefaultMailDomain)
-> ReadS [UpdateDefaultMailDomain]
-> ReadPrec UpdateDefaultMailDomain
-> ReadPrec [UpdateDefaultMailDomain]
-> Read UpdateDefaultMailDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDefaultMailDomain]
$creadListPrec :: ReadPrec [UpdateDefaultMailDomain]
readPrec :: ReadPrec UpdateDefaultMailDomain
$creadPrec :: ReadPrec UpdateDefaultMailDomain
readList :: ReadS [UpdateDefaultMailDomain]
$creadList :: ReadS [UpdateDefaultMailDomain]
readsPrec :: Int -> ReadS UpdateDefaultMailDomain
$creadsPrec :: Int -> ReadS UpdateDefaultMailDomain
Prelude.Read, Int -> UpdateDefaultMailDomain -> ShowS
[UpdateDefaultMailDomain] -> ShowS
UpdateDefaultMailDomain -> String
(Int -> UpdateDefaultMailDomain -> ShowS)
-> (UpdateDefaultMailDomain -> String)
-> ([UpdateDefaultMailDomain] -> ShowS)
-> Show UpdateDefaultMailDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDefaultMailDomain] -> ShowS
$cshowList :: [UpdateDefaultMailDomain] -> ShowS
show :: UpdateDefaultMailDomain -> String
$cshow :: UpdateDefaultMailDomain -> String
showsPrec :: Int -> UpdateDefaultMailDomain -> ShowS
$cshowsPrec :: Int -> UpdateDefaultMailDomain -> ShowS
Prelude.Show, (forall x.
 UpdateDefaultMailDomain -> Rep UpdateDefaultMailDomain x)
-> (forall x.
    Rep UpdateDefaultMailDomain x -> UpdateDefaultMailDomain)
-> Generic UpdateDefaultMailDomain
forall x. Rep UpdateDefaultMailDomain x -> UpdateDefaultMailDomain
forall x. UpdateDefaultMailDomain -> Rep UpdateDefaultMailDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDefaultMailDomain x -> UpdateDefaultMailDomain
$cfrom :: forall x. UpdateDefaultMailDomain -> Rep UpdateDefaultMailDomain x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDefaultMailDomain' 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', 'updateDefaultMailDomain_organizationId' - The Amazon WorkMail organization for which to list domains.
--
-- 'domainName', 'updateDefaultMailDomain_domainName' - The domain name that will become the default domain.
newUpdateDefaultMailDomain ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'domainName'
  Prelude.Text ->
  UpdateDefaultMailDomain
newUpdateDefaultMailDomain :: Text -> Text -> UpdateDefaultMailDomain
newUpdateDefaultMailDomain
  Text
pOrganizationId_
  Text
pDomainName_ =
    UpdateDefaultMailDomain' :: Text -> Text -> UpdateDefaultMailDomain
UpdateDefaultMailDomain'
      { $sel:organizationId:UpdateDefaultMailDomain' :: Text
organizationId =
          Text
pOrganizationId_,
        $sel:domainName:UpdateDefaultMailDomain' :: Text
domainName = Text
pDomainName_
      }

-- | The Amazon WorkMail organization for which to list domains.
updateDefaultMailDomain_organizationId :: Lens.Lens' UpdateDefaultMailDomain Prelude.Text
updateDefaultMailDomain_organizationId :: (Text -> f Text)
-> UpdateDefaultMailDomain -> f UpdateDefaultMailDomain
updateDefaultMailDomain_organizationId = (UpdateDefaultMailDomain -> Text)
-> (UpdateDefaultMailDomain -> Text -> UpdateDefaultMailDomain)
-> Lens UpdateDefaultMailDomain UpdateDefaultMailDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDefaultMailDomain' {Text
organizationId :: Text
$sel:organizationId:UpdateDefaultMailDomain' :: UpdateDefaultMailDomain -> Text
organizationId} -> Text
organizationId) (\s :: UpdateDefaultMailDomain
s@UpdateDefaultMailDomain' {} Text
a -> UpdateDefaultMailDomain
s {$sel:organizationId:UpdateDefaultMailDomain' :: Text
organizationId = Text
a} :: UpdateDefaultMailDomain)

-- | The domain name that will become the default domain.
updateDefaultMailDomain_domainName :: Lens.Lens' UpdateDefaultMailDomain Prelude.Text
updateDefaultMailDomain_domainName :: (Text -> f Text)
-> UpdateDefaultMailDomain -> f UpdateDefaultMailDomain
updateDefaultMailDomain_domainName = (UpdateDefaultMailDomain -> Text)
-> (UpdateDefaultMailDomain -> Text -> UpdateDefaultMailDomain)
-> Lens UpdateDefaultMailDomain UpdateDefaultMailDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDefaultMailDomain' {Text
domainName :: Text
$sel:domainName:UpdateDefaultMailDomain' :: UpdateDefaultMailDomain -> Text
domainName} -> Text
domainName) (\s :: UpdateDefaultMailDomain
s@UpdateDefaultMailDomain' {} Text
a -> UpdateDefaultMailDomain
s {$sel:domainName:UpdateDefaultMailDomain' :: Text
domainName = Text
a} :: UpdateDefaultMailDomain)

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

instance Prelude.NFData UpdateDefaultMailDomain

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

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

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

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

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

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

instance
  Prelude.NFData
    UpdateDefaultMailDomainResponse