{-# 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.CertificateManager.Types.DomainValidation
-- 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.CertificateManager.Types.DomainValidation where

import Amazonka.CertificateManager.Types.DomainStatus
import Amazonka.CertificateManager.Types.ResourceRecord
import Amazonka.CertificateManager.Types.ValidationMethod
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the validation of each domain name in the
-- certificate.
--
-- /See:/ 'newDomainValidation' smart constructor.
data DomainValidation = DomainValidation'
  { -- | A list of email addresses that ACM used to send domain validation
    -- emails.
    DomainValidation -> Maybe [Text]
validationEmails :: Prelude.Maybe [Prelude.Text],
    -- | Specifies the domain validation method.
    DomainValidation -> Maybe ValidationMethod
validationMethod :: Prelude.Maybe ValidationMethod,
    -- | Contains the CNAME record that you add to your DNS database for domain
    -- validation. For more information, see
    -- <https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-validate-dns.html Use DNS to Validate Domain Ownership>.
    --
    -- Note: The CNAME information that you need does not include the name of
    -- your domain. If you include
 your domain name in the DNS database CNAME
    -- record, validation fails.
 For example, if the name is
    -- \"_a79865eb4cd1a6ab990a45779b4e0b96.yourdomain.com\", only
    -- \"_a79865eb4cd1a6ab990a45779b4e0b96\" must be used.
    DomainValidation -> Maybe ResourceRecord
resourceRecord :: Prelude.Maybe ResourceRecord,
    -- | The validation status of the domain name. This can be one of the
    -- following values:
    --
    -- -   @PENDING_VALIDATION@
    --
    -- -   @@SUCCESS
    --
    -- -   @@FAILED
    DomainValidation -> Maybe DomainStatus
validationStatus :: Prelude.Maybe DomainStatus,
    -- | The domain name that ACM used to send domain validation emails.
    DomainValidation -> Maybe Text
validationDomain :: Prelude.Maybe Prelude.Text,
    -- | A fully qualified domain name (FQDN) in the certificate. For example,
    -- @www.example.com@ or @example.com@.
    DomainValidation -> Text
domainName :: Prelude.Text
  }
  deriving (DomainValidation -> DomainValidation -> Bool
(DomainValidation -> DomainValidation -> Bool)
-> (DomainValidation -> DomainValidation -> Bool)
-> Eq DomainValidation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DomainValidation -> DomainValidation -> Bool
$c/= :: DomainValidation -> DomainValidation -> Bool
== :: DomainValidation -> DomainValidation -> Bool
$c== :: DomainValidation -> DomainValidation -> Bool
Prelude.Eq, ReadPrec [DomainValidation]
ReadPrec DomainValidation
Int -> ReadS DomainValidation
ReadS [DomainValidation]
(Int -> ReadS DomainValidation)
-> ReadS [DomainValidation]
-> ReadPrec DomainValidation
-> ReadPrec [DomainValidation]
-> Read DomainValidation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DomainValidation]
$creadListPrec :: ReadPrec [DomainValidation]
readPrec :: ReadPrec DomainValidation
$creadPrec :: ReadPrec DomainValidation
readList :: ReadS [DomainValidation]
$creadList :: ReadS [DomainValidation]
readsPrec :: Int -> ReadS DomainValidation
$creadsPrec :: Int -> ReadS DomainValidation
Prelude.Read, Int -> DomainValidation -> ShowS
[DomainValidation] -> ShowS
DomainValidation -> String
(Int -> DomainValidation -> ShowS)
-> (DomainValidation -> String)
-> ([DomainValidation] -> ShowS)
-> Show DomainValidation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DomainValidation] -> ShowS
$cshowList :: [DomainValidation] -> ShowS
show :: DomainValidation -> String
$cshow :: DomainValidation -> String
showsPrec :: Int -> DomainValidation -> ShowS
$cshowsPrec :: Int -> DomainValidation -> ShowS
Prelude.Show, (forall x. DomainValidation -> Rep DomainValidation x)
-> (forall x. Rep DomainValidation x -> DomainValidation)
-> Generic DomainValidation
forall x. Rep DomainValidation x -> DomainValidation
forall x. DomainValidation -> Rep DomainValidation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DomainValidation x -> DomainValidation
$cfrom :: forall x. DomainValidation -> Rep DomainValidation x
Prelude.Generic)

-- |
-- Create a value of 'DomainValidation' 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:
--
-- 'validationEmails', 'domainValidation_validationEmails' - A list of email addresses that ACM used to send domain validation
-- emails.
--
-- 'validationMethod', 'domainValidation_validationMethod' - Specifies the domain validation method.
--
-- 'resourceRecord', 'domainValidation_resourceRecord' - Contains the CNAME record that you add to your DNS database for domain
-- validation. For more information, see
-- <https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-validate-dns.html Use DNS to Validate Domain Ownership>.
--
-- Note: The CNAME information that you need does not include the name of
-- your domain. If you include
 your domain name in the DNS database CNAME
-- record, validation fails.
 For example, if the name is
-- \"_a79865eb4cd1a6ab990a45779b4e0b96.yourdomain.com\", only
-- \"_a79865eb4cd1a6ab990a45779b4e0b96\" must be used.
--
-- 'validationStatus', 'domainValidation_validationStatus' - The validation status of the domain name. This can be one of the
-- following values:
--
-- -   @PENDING_VALIDATION@
--
-- -   @@SUCCESS
--
-- -   @@FAILED
--
-- 'validationDomain', 'domainValidation_validationDomain' - The domain name that ACM used to send domain validation emails.
--
-- 'domainName', 'domainValidation_domainName' - A fully qualified domain name (FQDN) in the certificate. For example,
-- @www.example.com@ or @example.com@.
newDomainValidation ::
  -- | 'domainName'
  Prelude.Text ->
  DomainValidation
newDomainValidation :: Text -> DomainValidation
newDomainValidation Text
pDomainName_ =
  DomainValidation' :: Maybe [Text]
-> Maybe ValidationMethod
-> Maybe ResourceRecord
-> Maybe DomainStatus
-> Maybe Text
-> Text
-> DomainValidation
DomainValidation'
    { $sel:validationEmails:DomainValidation' :: Maybe [Text]
validationEmails =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:validationMethod:DomainValidation' :: Maybe ValidationMethod
validationMethod = Maybe ValidationMethod
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceRecord:DomainValidation' :: Maybe ResourceRecord
resourceRecord = Maybe ResourceRecord
forall a. Maybe a
Prelude.Nothing,
      $sel:validationStatus:DomainValidation' :: Maybe DomainStatus
validationStatus = Maybe DomainStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:validationDomain:DomainValidation' :: Maybe Text
validationDomain = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:DomainValidation' :: Text
domainName = Text
pDomainName_
    }

-- | A list of email addresses that ACM used to send domain validation
-- emails.
domainValidation_validationEmails :: Lens.Lens' DomainValidation (Prelude.Maybe [Prelude.Text])
domainValidation_validationEmails :: (Maybe [Text] -> f (Maybe [Text]))
-> DomainValidation -> f DomainValidation
domainValidation_validationEmails = (DomainValidation -> Maybe [Text])
-> (DomainValidation -> Maybe [Text] -> DomainValidation)
-> Lens
     DomainValidation DomainValidation (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainValidation' {Maybe [Text]
validationEmails :: Maybe [Text]
$sel:validationEmails:DomainValidation' :: DomainValidation -> Maybe [Text]
validationEmails} -> Maybe [Text]
validationEmails) (\s :: DomainValidation
s@DomainValidation' {} Maybe [Text]
a -> DomainValidation
s {$sel:validationEmails:DomainValidation' :: Maybe [Text]
validationEmails = Maybe [Text]
a} :: DomainValidation) ((Maybe [Text] -> f (Maybe [Text]))
 -> DomainValidation -> f DomainValidation)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DomainValidation
-> f DomainValidation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the domain validation method.
domainValidation_validationMethod :: Lens.Lens' DomainValidation (Prelude.Maybe ValidationMethod)
domainValidation_validationMethod :: (Maybe ValidationMethod -> f (Maybe ValidationMethod))
-> DomainValidation -> f DomainValidation
domainValidation_validationMethod = (DomainValidation -> Maybe ValidationMethod)
-> (DomainValidation -> Maybe ValidationMethod -> DomainValidation)
-> Lens
     DomainValidation
     DomainValidation
     (Maybe ValidationMethod)
     (Maybe ValidationMethod)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainValidation' {Maybe ValidationMethod
validationMethod :: Maybe ValidationMethod
$sel:validationMethod:DomainValidation' :: DomainValidation -> Maybe ValidationMethod
validationMethod} -> Maybe ValidationMethod
validationMethod) (\s :: DomainValidation
s@DomainValidation' {} Maybe ValidationMethod
a -> DomainValidation
s {$sel:validationMethod:DomainValidation' :: Maybe ValidationMethod
validationMethod = Maybe ValidationMethod
a} :: DomainValidation)

-- | Contains the CNAME record that you add to your DNS database for domain
-- validation. For more information, see
-- <https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-validate-dns.html Use DNS to Validate Domain Ownership>.
--
-- Note: The CNAME information that you need does not include the name of
-- your domain. If you include
 your domain name in the DNS database CNAME
-- record, validation fails.
 For example, if the name is
-- \"_a79865eb4cd1a6ab990a45779b4e0b96.yourdomain.com\", only
-- \"_a79865eb4cd1a6ab990a45779b4e0b96\" must be used.
domainValidation_resourceRecord :: Lens.Lens' DomainValidation (Prelude.Maybe ResourceRecord)
domainValidation_resourceRecord :: (Maybe ResourceRecord -> f (Maybe ResourceRecord))
-> DomainValidation -> f DomainValidation
domainValidation_resourceRecord = (DomainValidation -> Maybe ResourceRecord)
-> (DomainValidation -> Maybe ResourceRecord -> DomainValidation)
-> Lens
     DomainValidation
     DomainValidation
     (Maybe ResourceRecord)
     (Maybe ResourceRecord)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainValidation' {Maybe ResourceRecord
resourceRecord :: Maybe ResourceRecord
$sel:resourceRecord:DomainValidation' :: DomainValidation -> Maybe ResourceRecord
resourceRecord} -> Maybe ResourceRecord
resourceRecord) (\s :: DomainValidation
s@DomainValidation' {} Maybe ResourceRecord
a -> DomainValidation
s {$sel:resourceRecord:DomainValidation' :: Maybe ResourceRecord
resourceRecord = Maybe ResourceRecord
a} :: DomainValidation)

-- | The validation status of the domain name. This can be one of the
-- following values:
--
-- -   @PENDING_VALIDATION@
--
-- -   @@SUCCESS
--
-- -   @@FAILED
domainValidation_validationStatus :: Lens.Lens' DomainValidation (Prelude.Maybe DomainStatus)
domainValidation_validationStatus :: (Maybe DomainStatus -> f (Maybe DomainStatus))
-> DomainValidation -> f DomainValidation
domainValidation_validationStatus = (DomainValidation -> Maybe DomainStatus)
-> (DomainValidation -> Maybe DomainStatus -> DomainValidation)
-> Lens
     DomainValidation
     DomainValidation
     (Maybe DomainStatus)
     (Maybe DomainStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainValidation' {Maybe DomainStatus
validationStatus :: Maybe DomainStatus
$sel:validationStatus:DomainValidation' :: DomainValidation -> Maybe DomainStatus
validationStatus} -> Maybe DomainStatus
validationStatus) (\s :: DomainValidation
s@DomainValidation' {} Maybe DomainStatus
a -> DomainValidation
s {$sel:validationStatus:DomainValidation' :: Maybe DomainStatus
validationStatus = Maybe DomainStatus
a} :: DomainValidation)

-- | The domain name that ACM used to send domain validation emails.
domainValidation_validationDomain :: Lens.Lens' DomainValidation (Prelude.Maybe Prelude.Text)
domainValidation_validationDomain :: (Maybe Text -> f (Maybe Text))
-> DomainValidation -> f DomainValidation
domainValidation_validationDomain = (DomainValidation -> Maybe Text)
-> (DomainValidation -> Maybe Text -> DomainValidation)
-> Lens DomainValidation DomainValidation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainValidation' {Maybe Text
validationDomain :: Maybe Text
$sel:validationDomain:DomainValidation' :: DomainValidation -> Maybe Text
validationDomain} -> Maybe Text
validationDomain) (\s :: DomainValidation
s@DomainValidation' {} Maybe Text
a -> DomainValidation
s {$sel:validationDomain:DomainValidation' :: Maybe Text
validationDomain = Maybe Text
a} :: DomainValidation)

-- | A fully qualified domain name (FQDN) in the certificate. For example,
-- @www.example.com@ or @example.com@.
domainValidation_domainName :: Lens.Lens' DomainValidation Prelude.Text
domainValidation_domainName :: (Text -> f Text) -> DomainValidation -> f DomainValidation
domainValidation_domainName = (DomainValidation -> Text)
-> (DomainValidation -> Text -> DomainValidation)
-> Lens DomainValidation DomainValidation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainValidation' {Text
domainName :: Text
$sel:domainName:DomainValidation' :: DomainValidation -> Text
domainName} -> Text
domainName) (\s :: DomainValidation
s@DomainValidation' {} Text
a -> DomainValidation
s {$sel:domainName:DomainValidation' :: Text
domainName = Text
a} :: DomainValidation)

instance Core.FromJSON DomainValidation where
  parseJSON :: Value -> Parser DomainValidation
parseJSON =
    String
-> (Object -> Parser DomainValidation)
-> Value
-> Parser DomainValidation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DomainValidation"
      ( \Object
x ->
          Maybe [Text]
-> Maybe ValidationMethod
-> Maybe ResourceRecord
-> Maybe DomainStatus
-> Maybe Text
-> Text
-> DomainValidation
DomainValidation'
            (Maybe [Text]
 -> Maybe ValidationMethod
 -> Maybe ResourceRecord
 -> Maybe DomainStatus
 -> Maybe Text
 -> Text
 -> DomainValidation)
-> Parser (Maybe [Text])
-> Parser
     (Maybe ValidationMethod
      -> Maybe ResourceRecord
      -> Maybe DomainStatus
      -> Maybe Text
      -> Text
      -> DomainValidation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ValidationEmails"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe ValidationMethod
   -> Maybe ResourceRecord
   -> Maybe DomainStatus
   -> Maybe Text
   -> Text
   -> DomainValidation)
-> Parser (Maybe ValidationMethod)
-> Parser
     (Maybe ResourceRecord
      -> Maybe DomainStatus -> Maybe Text -> Text -> DomainValidation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ValidationMethod)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ValidationMethod")
            Parser
  (Maybe ResourceRecord
   -> Maybe DomainStatus -> Maybe Text -> Text -> DomainValidation)
-> Parser (Maybe ResourceRecord)
-> Parser
     (Maybe DomainStatus -> Maybe Text -> Text -> DomainValidation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResourceRecord)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceRecord")
            Parser
  (Maybe DomainStatus -> Maybe Text -> Text -> DomainValidation)
-> Parser (Maybe DomainStatus)
-> Parser (Maybe Text -> Text -> DomainValidation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DomainStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ValidationStatus")
            Parser (Maybe Text -> Text -> DomainValidation)
-> Parser (Maybe Text) -> Parser (Text -> DomainValidation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ValidationDomain")
            Parser (Text -> DomainValidation)
-> Parser Text -> Parser DomainValidation
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")
      )

instance Prelude.Hashable DomainValidation

instance Prelude.NFData DomainValidation