{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 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
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]
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
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. 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 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'
      { $sel:organizationId:UpdateDefaultMailDomain' :: Text
organizationId =
          Text
pOrganizationId_,
        $sel:domainName:UpdateDefaultMailDomain' :: Text
domainName = Text
pDomainName_
      }

-- | The WorkMail organization for which to list domains.
updateDefaultMailDomain_organizationId :: Lens.Lens' UpdateDefaultMailDomain Prelude.Text
updateDefaultMailDomain_organizationId :: Lens' UpdateDefaultMailDomain Text
updateDefaultMailDomain_organizationId = 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 :: Lens' UpdateDefaultMailDomain Text
updateDefaultMailDomain_domainName = 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 :: (Service -> Service)
-> UpdateDefaultMailDomain -> Request UpdateDefaultMailDomain
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateDefaultMailDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateDefaultMailDomain)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateDefaultMailDomainResponse
UpdateDefaultMailDomainResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateDefaultMailDomain where
  hashWithSalt :: Int -> UpdateDefaultMailDomain -> Int
hashWithSalt Int
_salt UpdateDefaultMailDomain' {Text
domainName :: Text
organizationId :: Text
$sel:domainName:UpdateDefaultMailDomain' :: UpdateDefaultMailDomain -> Text
$sel:organizationId:UpdateDefaultMailDomain' :: UpdateDefaultMailDomain -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
organizationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData UpdateDefaultMailDomain where
  rnf :: UpdateDefaultMailDomain -> ()
rnf UpdateDefaultMailDomain' {Text
domainName :: Text
organizationId :: Text
$sel:domainName:UpdateDefaultMailDomain' :: UpdateDefaultMailDomain -> Text
$sel:organizationId:UpdateDefaultMailDomain' :: UpdateDefaultMailDomain -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
organizationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domainName

instance Data.ToHeaders UpdateDefaultMailDomain where
  toHeaders :: UpdateDefaultMailDomain -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"WorkMailService.UpdateDefaultMailDomain" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"OrganizationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
organizationId),
            forall a. a -> Maybe a
Prelude.Just (Key
"DomainName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
domainName)
          ]
      )

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

instance Data.ToQuery UpdateDefaultMailDomain where
  toQuery :: UpdateDefaultMailDomain -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:UpdateDefaultMailDomainResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateDefaultMailDomainResponse_httpStatus :: Lens.Lens' UpdateDefaultMailDomainResponse Prelude.Int
updateDefaultMailDomainResponse_httpStatus :: Lens' UpdateDefaultMailDomainResponse Int
updateDefaultMailDomainResponse_httpStatus = 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
  where
  rnf :: UpdateDefaultMailDomainResponse -> ()
rnf UpdateDefaultMailDomainResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateDefaultMailDomainResponse' :: UpdateDefaultMailDomainResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus