{-# 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-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.AppRunner.Types.CustomDomain where

import Amazonka.AppRunner.Types.CertificateValidationRecord
import Amazonka.AppRunner.Types.CustomDomainAssociationStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(CustomDomain -> CustomDomain -> Bool)
-> (CustomDomain -> CustomDomain -> Bool) -> Eq CustomDomain
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]
(Int -> ReadS CustomDomain)
-> ReadS [CustomDomain]
-> ReadPrec CustomDomain
-> ReadPrec [CustomDomain]
-> Read 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
(Int -> CustomDomain -> ShowS)
-> (CustomDomain -> String)
-> ([CustomDomain] -> ShowS)
-> Show CustomDomain
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. CustomDomain -> Rep CustomDomain x)
-> (forall x. Rep CustomDomain x -> CustomDomain)
-> Generic CustomDomain
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' :: Maybe [CertificateValidationRecord]
-> Text -> Bool -> CustomDomainAssociationStatus -> CustomDomain
CustomDomain'
      { $sel:certificateValidationRecords:CustomDomain' :: Maybe [CertificateValidationRecord]
certificateValidationRecords =
          Maybe [CertificateValidationRecord]
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 :: (Maybe [CertificateValidationRecord]
 -> f (Maybe [CertificateValidationRecord]))
-> CustomDomain -> f CustomDomain
customDomain_certificateValidationRecords = (CustomDomain -> Maybe [CertificateValidationRecord])
-> (CustomDomain
    -> Maybe [CertificateValidationRecord] -> CustomDomain)
-> Lens
     CustomDomain
     CustomDomain
     (Maybe [CertificateValidationRecord])
     (Maybe [CertificateValidationRecord])
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) ((Maybe [CertificateValidationRecord]
  -> f (Maybe [CertificateValidationRecord]))
 -> CustomDomain -> f CustomDomain)
-> ((Maybe [CertificateValidationRecord]
     -> f (Maybe [CertificateValidationRecord]))
    -> Maybe [CertificateValidationRecord]
    -> f (Maybe [CertificateValidationRecord]))
-> (Maybe [CertificateValidationRecord]
    -> f (Maybe [CertificateValidationRecord]))
-> CustomDomain
-> f CustomDomain
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CertificateValidationRecord]
  [CertificateValidationRecord]
  [CertificateValidationRecord]
  [CertificateValidationRecord]
-> Iso
     (Maybe [CertificateValidationRecord])
     (Maybe [CertificateValidationRecord])
     (Maybe [CertificateValidationRecord])
     (Maybe [CertificateValidationRecord])
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 AnIso
  [CertificateValidationRecord]
  [CertificateValidationRecord]
  [CertificateValidationRecord]
  [CertificateValidationRecord]
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 :: (Text -> f Text) -> CustomDomain -> f CustomDomain
customDomain_domainName = (CustomDomain -> Text)
-> (CustomDomain -> Text -> CustomDomain)
-> Lens CustomDomain CustomDomain Text Text
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 :: (Bool -> f Bool) -> CustomDomain -> f CustomDomain
customDomain_enableWWWSubdomain = (CustomDomain -> Bool)
-> (CustomDomain -> Bool -> CustomDomain)
-> Lens CustomDomain CustomDomain Bool Bool
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 :: (CustomDomainAssociationStatus -> f CustomDomainAssociationStatus)
-> CustomDomain -> f CustomDomain
customDomain_status = (CustomDomain -> CustomDomainAssociationStatus)
-> (CustomDomain -> CustomDomainAssociationStatus -> CustomDomain)
-> Lens
     CustomDomain
     CustomDomain
     CustomDomainAssociationStatus
     CustomDomainAssociationStatus
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 Core.FromJSON CustomDomain where
  parseJSON :: Value -> Parser CustomDomain
parseJSON =
    String
-> (Object -> Parser CustomDomain) -> Value -> Parser CustomDomain
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CustomDomain"
      ( \Object
x ->
          Maybe [CertificateValidationRecord]
-> Text -> Bool -> CustomDomainAssociationStatus -> CustomDomain
CustomDomain'
            (Maybe [CertificateValidationRecord]
 -> Text -> Bool -> CustomDomainAssociationStatus -> CustomDomain)
-> Parser (Maybe [CertificateValidationRecord])
-> Parser
     (Text -> Bool -> CustomDomainAssociationStatus -> CustomDomain)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [CertificateValidationRecord]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CertificateValidationRecords"
                            Parser (Maybe (Maybe [CertificateValidationRecord]))
-> Maybe [CertificateValidationRecord]
-> Parser (Maybe [CertificateValidationRecord])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CertificateValidationRecord]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Text -> Bool -> CustomDomainAssociationStatus -> CustomDomain)
-> Parser Text
-> Parser (Bool -> CustomDomainAssociationStatus -> CustomDomain)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DomainName")
            Parser (Bool -> CustomDomainAssociationStatus -> CustomDomain)
-> Parser Bool
-> Parser (CustomDomainAssociationStatus -> CustomDomain)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EnableWWWSubdomain")
            Parser (CustomDomainAssociationStatus -> CustomDomain)
-> Parser CustomDomainAssociationStatus -> Parser CustomDomain
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser CustomDomainAssociationStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Status")
      )

instance Prelude.Hashable CustomDomain

instance Prelude.NFData CustomDomain