{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.Domain
-- 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)
module Amazonka.WorkMail.Types.Domain where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The domain to associate with an Amazon WorkMail organization.
--
-- When you configure a domain hosted in Amazon Route 53 (Route 53), all
-- recommended DNS records are added to the organization when you create
-- it. For more information, see
-- <https://docs.aws.amazon.com/workmail/latest/adminguide/add_domain.html Adding a domain>
-- in the /Amazon WorkMail Administrator Guide/.
--
-- /See:/ 'newDomain' smart constructor.
data Domain = Domain'
  { -- | The hosted zone ID for a domain hosted in Route 53. Required when
    -- configuring a domain hosted in Route 53.
    Domain -> Maybe Text
hostedZoneId :: Prelude.Maybe Prelude.Text,
    -- | The fully qualified domain name.
    Domain -> Maybe Text
domainName :: Prelude.Maybe Prelude.Text
  }
  deriving (Domain -> Domain -> Bool
(Domain -> Domain -> Bool)
-> (Domain -> Domain -> Bool) -> Eq Domain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Domain -> Domain -> Bool
$c/= :: Domain -> Domain -> Bool
== :: Domain -> Domain -> Bool
$c== :: Domain -> Domain -> Bool
Prelude.Eq, ReadPrec [Domain]
ReadPrec Domain
Int -> ReadS Domain
ReadS [Domain]
(Int -> ReadS Domain)
-> ReadS [Domain]
-> ReadPrec Domain
-> ReadPrec [Domain]
-> Read Domain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Domain]
$creadListPrec :: ReadPrec [Domain]
readPrec :: ReadPrec Domain
$creadPrec :: ReadPrec Domain
readList :: ReadS [Domain]
$creadList :: ReadS [Domain]
readsPrec :: Int -> ReadS Domain
$creadsPrec :: Int -> ReadS Domain
Prelude.Read, Int -> Domain -> ShowS
[Domain] -> ShowS
Domain -> String
(Int -> Domain -> ShowS)
-> (Domain -> String) -> ([Domain] -> ShowS) -> Show Domain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Domain] -> ShowS
$cshowList :: [Domain] -> ShowS
show :: Domain -> String
$cshow :: Domain -> String
showsPrec :: Int -> Domain -> ShowS
$cshowsPrec :: Int -> Domain -> ShowS
Prelude.Show, (forall x. Domain -> Rep Domain x)
-> (forall x. Rep Domain x -> Domain) -> Generic Domain
forall x. Rep Domain x -> Domain
forall x. Domain -> Rep Domain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Domain x -> Domain
$cfrom :: forall x. Domain -> Rep Domain x
Prelude.Generic)

-- |
-- Create a value of 'Domain' 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:
--
-- 'hostedZoneId', 'domain_hostedZoneId' - The hosted zone ID for a domain hosted in Route 53. Required when
-- configuring a domain hosted in Route 53.
--
-- 'domainName', 'domain_domainName' - The fully qualified domain name.
newDomain ::
  Domain
newDomain :: Domain
newDomain =
  Domain' :: Maybe Text -> Maybe Text -> Domain
Domain'
    { $sel:hostedZoneId:Domain' :: Maybe Text
hostedZoneId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:Domain' :: Maybe Text
domainName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The hosted zone ID for a domain hosted in Route 53. Required when
-- configuring a domain hosted in Route 53.
domain_hostedZoneId :: Lens.Lens' Domain (Prelude.Maybe Prelude.Text)
domain_hostedZoneId :: (Maybe Text -> f (Maybe Text)) -> Domain -> f Domain
domain_hostedZoneId = (Domain -> Maybe Text)
-> (Domain -> Maybe Text -> Domain)
-> Lens Domain Domain (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Domain' {Maybe Text
hostedZoneId :: Maybe Text
$sel:hostedZoneId:Domain' :: Domain -> Maybe Text
hostedZoneId} -> Maybe Text
hostedZoneId) (\s :: Domain
s@Domain' {} Maybe Text
a -> Domain
s {$sel:hostedZoneId:Domain' :: Maybe Text
hostedZoneId = Maybe Text
a} :: Domain)

-- | The fully qualified domain name.
domain_domainName :: Lens.Lens' Domain (Prelude.Maybe Prelude.Text)
domain_domainName :: (Maybe Text -> f (Maybe Text)) -> Domain -> f Domain
domain_domainName = (Domain -> Maybe Text)
-> (Domain -> Maybe Text -> Domain)
-> Lens Domain Domain (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Domain' {Maybe Text
domainName :: Maybe Text
$sel:domainName:Domain' :: Domain -> Maybe Text
domainName} -> Maybe Text
domainName) (\s :: Domain
s@Domain' {} Maybe Text
a -> Domain
s {$sel:domainName:Domain' :: Maybe Text
domainName = Maybe Text
a} :: Domain)

instance Prelude.Hashable Domain

instance Prelude.NFData Domain

instance Core.ToJSON Domain where
  toJSON :: Domain -> Value
toJSON Domain' {Maybe Text
domainName :: Maybe Text
hostedZoneId :: Maybe Text
$sel:domainName:Domain' :: Domain -> Maybe Text
$sel:hostedZoneId:Domain' :: Domain -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"HostedZoneId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
hostedZoneId,
            (Text
"DomainName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
domainName
          ]
      )