{-# 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.AppRunner.Types.CustomDomain
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppRunner.Types.CustomDomain where

import Amazonka.AppRunner.Types.CertificateValidationRecord
import Amazonka.AppRunner.Types.CustomDomainAssociationStatus
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

-- | Describes a custom domain that\'s associated with an App Runner service.
--
-- /See:/ 'newCustomDomain' smart constructor.
data CustomDomain = CustomDomain'
  { -- | A list of certificate CNAME records that\'s used for this domain name.
    CustomDomain -> Maybe [CertificateValidationRecord]
certificateValidationRecords :: Prelude.Maybe [CertificateValidationRecord],
    -- | An associated custom domain endpoint. It can be a root domain (for
    -- example, @example.com@), a subdomain (for example, @login.example.com@
    -- or @admin.login.example.com@), or a wildcard (for example,
    -- @*.example.com@).
    CustomDomain -> Text
domainName :: Prelude.Text,
    -- | When @true@, the subdomain @www.@/@DomainName@/@ @ is associated with
    -- the App Runner service in addition to the base domain.
    CustomDomain -> Bool
enableWWWSubdomain :: Prelude.Bool,
    -- | The current state of the domain name association.
    CustomDomain -> CustomDomainAssociationStatus
status :: CustomDomainAssociationStatus
  }
  deriving (CustomDomain -> CustomDomain -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomDomain -> CustomDomain -> Bool
$c/= :: CustomDomain -> CustomDomain -> Bool
== :: CustomDomain -> CustomDomain -> Bool
$c== :: CustomDomain -> CustomDomain -> Bool
Prelude.Eq, ReadPrec [CustomDomain]
ReadPrec CustomDomain
Int -> ReadS CustomDomain
ReadS [CustomDomain]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomDomain]
$creadListPrec :: ReadPrec [CustomDomain]
readPrec :: ReadPrec CustomDomain
$creadPrec :: ReadPrec CustomDomain
readList :: ReadS [CustomDomain]
$creadList :: ReadS [CustomDomain]
readsPrec :: Int -> ReadS CustomDomain
$creadsPrec :: Int -> ReadS CustomDomain
Prelude.Read, Int -> CustomDomain -> ShowS
[CustomDomain] -> ShowS
CustomDomain -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomDomain] -> ShowS
$cshowList :: [CustomDomain] -> ShowS
show :: CustomDomain -> String
$cshow :: CustomDomain -> String
showsPrec :: Int -> CustomDomain -> ShowS
$cshowsPrec :: Int -> CustomDomain -> ShowS
Prelude.Show, forall x. Rep CustomDomain x -> CustomDomain
forall x. CustomDomain -> Rep CustomDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomDomain x -> CustomDomain
$cfrom :: forall x. CustomDomain -> Rep CustomDomain x
Prelude.Generic)

-- |
-- Create a value of 'CustomDomain' 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:
--
-- 'certificateValidationRecords', 'customDomain_certificateValidationRecords' - A list of certificate CNAME records that\'s used for this domain name.
--
-- 'domainName', 'customDomain_domainName' - An associated custom domain endpoint. It can be a root domain (for
-- example, @example.com@), a subdomain (for example, @login.example.com@
-- or @admin.login.example.com@), or a wildcard (for example,
-- @*.example.com@).
--
-- 'enableWWWSubdomain', 'customDomain_enableWWWSubdomain' - When @true@, the subdomain @www.@/@DomainName@/@ @ is associated with
-- the App Runner service in addition to the base domain.
--
-- 'status', 'customDomain_status' - The current state of the domain name association.
newCustomDomain ::
  -- | 'domainName'
  Prelude.Text ->
  -- | 'enableWWWSubdomain'
  Prelude.Bool ->
  -- | 'status'
  CustomDomainAssociationStatus ->
  CustomDomain
newCustomDomain :: Text -> Bool -> CustomDomainAssociationStatus -> CustomDomain
newCustomDomain
  Text
pDomainName_
  Bool
pEnableWWWSubdomain_
  CustomDomainAssociationStatus
pStatus_ =
    CustomDomain'
      { $sel:certificateValidationRecords:CustomDomain' :: Maybe [CertificateValidationRecord]
certificateValidationRecords =
          forall a. Maybe a
Prelude.Nothing,
        $sel:domainName:CustomDomain' :: Text
domainName = Text
pDomainName_,
        $sel:enableWWWSubdomain:CustomDomain' :: Bool
enableWWWSubdomain = Bool
pEnableWWWSubdomain_,
        $sel:status:CustomDomain' :: CustomDomainAssociationStatus
status = CustomDomainAssociationStatus
pStatus_
      }

-- | A list of certificate CNAME records that\'s used for this domain name.
customDomain_certificateValidationRecords :: Lens.Lens' CustomDomain (Prelude.Maybe [CertificateValidationRecord])
customDomain_certificateValidationRecords :: Lens' CustomDomain (Maybe [CertificateValidationRecord])
customDomain_certificateValidationRecords = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDomain' {Maybe [CertificateValidationRecord]
certificateValidationRecords :: Maybe [CertificateValidationRecord]
$sel:certificateValidationRecords:CustomDomain' :: CustomDomain -> Maybe [CertificateValidationRecord]
certificateValidationRecords} -> Maybe [CertificateValidationRecord]
certificateValidationRecords) (\s :: CustomDomain
s@CustomDomain' {} Maybe [CertificateValidationRecord]
a -> CustomDomain
s {$sel:certificateValidationRecords:CustomDomain' :: Maybe [CertificateValidationRecord]
certificateValidationRecords = Maybe [CertificateValidationRecord]
a} :: CustomDomain) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An associated custom domain endpoint. It can be a root domain (for
-- example, @example.com@), a subdomain (for example, @login.example.com@
-- or @admin.login.example.com@), or a wildcard (for example,
-- @*.example.com@).
customDomain_domainName :: Lens.Lens' CustomDomain Prelude.Text
customDomain_domainName :: Lens' CustomDomain Text
customDomain_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDomain' {Text
domainName :: Text
$sel:domainName:CustomDomain' :: CustomDomain -> Text
domainName} -> Text
domainName) (\s :: CustomDomain
s@CustomDomain' {} Text
a -> CustomDomain
s {$sel:domainName:CustomDomain' :: Text
domainName = Text
a} :: CustomDomain)

-- | When @true@, the subdomain @www.@/@DomainName@/@ @ is associated with
-- the App Runner service in addition to the base domain.
customDomain_enableWWWSubdomain :: Lens.Lens' CustomDomain Prelude.Bool
customDomain_enableWWWSubdomain :: Lens' CustomDomain Bool
customDomain_enableWWWSubdomain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDomain' {Bool
enableWWWSubdomain :: Bool
$sel:enableWWWSubdomain:CustomDomain' :: CustomDomain -> Bool
enableWWWSubdomain} -> Bool
enableWWWSubdomain) (\s :: CustomDomain
s@CustomDomain' {} Bool
a -> CustomDomain
s {$sel:enableWWWSubdomain:CustomDomain' :: Bool
enableWWWSubdomain = Bool
a} :: CustomDomain)

-- | The current state of the domain name association.
customDomain_status :: Lens.Lens' CustomDomain CustomDomainAssociationStatus
customDomain_status :: Lens' CustomDomain CustomDomainAssociationStatus
customDomain_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDomain' {CustomDomainAssociationStatus
status :: CustomDomainAssociationStatus
$sel:status:CustomDomain' :: CustomDomain -> CustomDomainAssociationStatus
status} -> CustomDomainAssociationStatus
status) (\s :: CustomDomain
s@CustomDomain' {} CustomDomainAssociationStatus
a -> CustomDomain
s {$sel:status:CustomDomain' :: CustomDomainAssociationStatus
status = CustomDomainAssociationStatus
a} :: CustomDomain)

instance Data.FromJSON CustomDomain where
  parseJSON :: Value -> Parser CustomDomain
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomDomain"
      ( \Object
x ->
          Maybe [CertificateValidationRecord]
-> Text -> Bool -> CustomDomainAssociationStatus -> CustomDomain
CustomDomain'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CertificateValidationRecords"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DomainName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"EnableWWWSubdomain")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Status")
      )

instance Prelude.Hashable CustomDomain where
  hashWithSalt :: Int -> CustomDomain -> Int
hashWithSalt Int
_salt CustomDomain' {Bool
Maybe [CertificateValidationRecord]
Text
CustomDomainAssociationStatus
status :: CustomDomainAssociationStatus
enableWWWSubdomain :: Bool
domainName :: Text
certificateValidationRecords :: Maybe [CertificateValidationRecord]
$sel:status:CustomDomain' :: CustomDomain -> CustomDomainAssociationStatus
$sel:enableWWWSubdomain:CustomDomain' :: CustomDomain -> Bool
$sel:domainName:CustomDomain' :: CustomDomain -> Text
$sel:certificateValidationRecords:CustomDomain' :: CustomDomain -> Maybe [CertificateValidationRecord]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [CertificateValidationRecord]
certificateValidationRecords
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enableWWWSubdomain
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CustomDomainAssociationStatus
status

instance Prelude.NFData CustomDomain where
  rnf :: CustomDomain -> ()
rnf CustomDomain' {Bool
Maybe [CertificateValidationRecord]
Text
CustomDomainAssociationStatus
status :: CustomDomainAssociationStatus
enableWWWSubdomain :: Bool
domainName :: Text
certificateValidationRecords :: Maybe [CertificateValidationRecord]
$sel:status:CustomDomain' :: CustomDomain -> CustomDomainAssociationStatus
$sel:enableWWWSubdomain:CustomDomain' :: CustomDomain -> Bool
$sel:domainName:CustomDomain' :: CustomDomain -> Text
$sel:certificateValidationRecords:CustomDomain' :: CustomDomain -> Maybe [CertificateValidationRecord]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [CertificateValidationRecord]
certificateValidationRecords
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domainName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
enableWWWSubdomain
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CustomDomainAssociationStatus
status