{-# 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.CloudFront.Types.AliasICPRecordal
-- 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.CloudFront.Types.AliasICPRecordal where

import Amazonka.CloudFront.Types.ICPRecordalStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Amazon Web Services services in China customers must file for an
-- Internet Content Provider (ICP) recordal if they want to serve content
-- publicly on an alternate domain name, also known as a CNAME, that
-- they\'ve added to CloudFront. AliasICPRecordal provides the ICP recordal
-- status for CNAMEs associated with distributions. The status is returned
-- in the CloudFront response; you can\'t configure it yourself.
--
-- For more information about ICP recordals, see
-- <https://docs.amazonaws.cn/en_us/aws/latest/userguide/accounts-and-credentials.html Signup, Accounts, and Credentials>
-- in /Getting Started with Amazon Web Services services in China/.
--
-- /See:/ 'newAliasICPRecordal' smart constructor.
data AliasICPRecordal = AliasICPRecordal'
  { -- | A domain name associated with a distribution.
    AliasICPRecordal -> Maybe Text
cname :: Prelude.Maybe Prelude.Text,
    -- | The Internet Content Provider (ICP) recordal status for a CNAME. The
    -- ICPRecordalStatus is set to APPROVED for all CNAMEs (aliases) in regions
    -- outside of China.
    --
    -- The status values returned are the following:
    --
    -- -   __APPROVED__ indicates that the associated CNAME has a valid ICP
    --     recordal number. Multiple CNAMEs can be associated with a
    --     distribution, and CNAMEs can correspond to different ICP recordals.
    --     To be marked as APPROVED, that is, valid to use with China region, a
    --     CNAME must have one ICP recordal number associated with it.
    --
    -- -   __SUSPENDED__ indicates that the associated CNAME does not have a
    --     valid ICP recordal number.
    --
    -- -   __PENDING__ indicates that CloudFront can\'t determine the ICP
    --     recordal status of the CNAME associated with the distribution
    --     because there was an error in trying to determine the status. You
    --     can try again to see if the error is resolved in which case
    --     CloudFront returns an APPROVED or SUSPENDED status.
    AliasICPRecordal -> Maybe ICPRecordalStatus
iCPRecordalStatus :: Prelude.Maybe ICPRecordalStatus
  }
  deriving (AliasICPRecordal -> AliasICPRecordal -> Bool
(AliasICPRecordal -> AliasICPRecordal -> Bool)
-> (AliasICPRecordal -> AliasICPRecordal -> Bool)
-> Eq AliasICPRecordal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AliasICPRecordal -> AliasICPRecordal -> Bool
$c/= :: AliasICPRecordal -> AliasICPRecordal -> Bool
== :: AliasICPRecordal -> AliasICPRecordal -> Bool
$c== :: AliasICPRecordal -> AliasICPRecordal -> Bool
Prelude.Eq, ReadPrec [AliasICPRecordal]
ReadPrec AliasICPRecordal
Int -> ReadS AliasICPRecordal
ReadS [AliasICPRecordal]
(Int -> ReadS AliasICPRecordal)
-> ReadS [AliasICPRecordal]
-> ReadPrec AliasICPRecordal
-> ReadPrec [AliasICPRecordal]
-> Read AliasICPRecordal
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AliasICPRecordal]
$creadListPrec :: ReadPrec [AliasICPRecordal]
readPrec :: ReadPrec AliasICPRecordal
$creadPrec :: ReadPrec AliasICPRecordal
readList :: ReadS [AliasICPRecordal]
$creadList :: ReadS [AliasICPRecordal]
readsPrec :: Int -> ReadS AliasICPRecordal
$creadsPrec :: Int -> ReadS AliasICPRecordal
Prelude.Read, Int -> AliasICPRecordal -> ShowS
[AliasICPRecordal] -> ShowS
AliasICPRecordal -> String
(Int -> AliasICPRecordal -> ShowS)
-> (AliasICPRecordal -> String)
-> ([AliasICPRecordal] -> ShowS)
-> Show AliasICPRecordal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AliasICPRecordal] -> ShowS
$cshowList :: [AliasICPRecordal] -> ShowS
show :: AliasICPRecordal -> String
$cshow :: AliasICPRecordal -> String
showsPrec :: Int -> AliasICPRecordal -> ShowS
$cshowsPrec :: Int -> AliasICPRecordal -> ShowS
Prelude.Show, (forall x. AliasICPRecordal -> Rep AliasICPRecordal x)
-> (forall x. Rep AliasICPRecordal x -> AliasICPRecordal)
-> Generic AliasICPRecordal
forall x. Rep AliasICPRecordal x -> AliasICPRecordal
forall x. AliasICPRecordal -> Rep AliasICPRecordal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AliasICPRecordal x -> AliasICPRecordal
$cfrom :: forall x. AliasICPRecordal -> Rep AliasICPRecordal x
Prelude.Generic)

-- |
-- Create a value of 'AliasICPRecordal' 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:
--
-- 'cname', 'aliasICPRecordal_cname' - A domain name associated with a distribution.
--
-- 'iCPRecordalStatus', 'aliasICPRecordal_iCPRecordalStatus' - The Internet Content Provider (ICP) recordal status for a CNAME. The
-- ICPRecordalStatus is set to APPROVED for all CNAMEs (aliases) in regions
-- outside of China.
--
-- The status values returned are the following:
--
-- -   __APPROVED__ indicates that the associated CNAME has a valid ICP
--     recordal number. Multiple CNAMEs can be associated with a
--     distribution, and CNAMEs can correspond to different ICP recordals.
--     To be marked as APPROVED, that is, valid to use with China region, a
--     CNAME must have one ICP recordal number associated with it.
--
-- -   __SUSPENDED__ indicates that the associated CNAME does not have a
--     valid ICP recordal number.
--
-- -   __PENDING__ indicates that CloudFront can\'t determine the ICP
--     recordal status of the CNAME associated with the distribution
--     because there was an error in trying to determine the status. You
--     can try again to see if the error is resolved in which case
--     CloudFront returns an APPROVED or SUSPENDED status.
newAliasICPRecordal ::
  AliasICPRecordal
newAliasICPRecordal :: AliasICPRecordal
newAliasICPRecordal =
  AliasICPRecordal' :: Maybe Text -> Maybe ICPRecordalStatus -> AliasICPRecordal
AliasICPRecordal'
    { $sel:cname:AliasICPRecordal' :: Maybe Text
cname = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iCPRecordalStatus:AliasICPRecordal' :: Maybe ICPRecordalStatus
iCPRecordalStatus = Maybe ICPRecordalStatus
forall a. Maybe a
Prelude.Nothing
    }

-- | A domain name associated with a distribution.
aliasICPRecordal_cname :: Lens.Lens' AliasICPRecordal (Prelude.Maybe Prelude.Text)
aliasICPRecordal_cname :: (Maybe Text -> f (Maybe Text))
-> AliasICPRecordal -> f AliasICPRecordal
aliasICPRecordal_cname = (AliasICPRecordal -> Maybe Text)
-> (AliasICPRecordal -> Maybe Text -> AliasICPRecordal)
-> Lens AliasICPRecordal AliasICPRecordal (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AliasICPRecordal' {Maybe Text
cname :: Maybe Text
$sel:cname:AliasICPRecordal' :: AliasICPRecordal -> Maybe Text
cname} -> Maybe Text
cname) (\s :: AliasICPRecordal
s@AliasICPRecordal' {} Maybe Text
a -> AliasICPRecordal
s {$sel:cname:AliasICPRecordal' :: Maybe Text
cname = Maybe Text
a} :: AliasICPRecordal)

-- | The Internet Content Provider (ICP) recordal status for a CNAME. The
-- ICPRecordalStatus is set to APPROVED for all CNAMEs (aliases) in regions
-- outside of China.
--
-- The status values returned are the following:
--
-- -   __APPROVED__ indicates that the associated CNAME has a valid ICP
--     recordal number. Multiple CNAMEs can be associated with a
--     distribution, and CNAMEs can correspond to different ICP recordals.
--     To be marked as APPROVED, that is, valid to use with China region, a
--     CNAME must have one ICP recordal number associated with it.
--
-- -   __SUSPENDED__ indicates that the associated CNAME does not have a
--     valid ICP recordal number.
--
-- -   __PENDING__ indicates that CloudFront can\'t determine the ICP
--     recordal status of the CNAME associated with the distribution
--     because there was an error in trying to determine the status. You
--     can try again to see if the error is resolved in which case
--     CloudFront returns an APPROVED or SUSPENDED status.
aliasICPRecordal_iCPRecordalStatus :: Lens.Lens' AliasICPRecordal (Prelude.Maybe ICPRecordalStatus)
aliasICPRecordal_iCPRecordalStatus :: (Maybe ICPRecordalStatus -> f (Maybe ICPRecordalStatus))
-> AliasICPRecordal -> f AliasICPRecordal
aliasICPRecordal_iCPRecordalStatus = (AliasICPRecordal -> Maybe ICPRecordalStatus)
-> (AliasICPRecordal
    -> Maybe ICPRecordalStatus -> AliasICPRecordal)
-> Lens
     AliasICPRecordal
     AliasICPRecordal
     (Maybe ICPRecordalStatus)
     (Maybe ICPRecordalStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AliasICPRecordal' {Maybe ICPRecordalStatus
iCPRecordalStatus :: Maybe ICPRecordalStatus
$sel:iCPRecordalStatus:AliasICPRecordal' :: AliasICPRecordal -> Maybe ICPRecordalStatus
iCPRecordalStatus} -> Maybe ICPRecordalStatus
iCPRecordalStatus) (\s :: AliasICPRecordal
s@AliasICPRecordal' {} Maybe ICPRecordalStatus
a -> AliasICPRecordal
s {$sel:iCPRecordalStatus:AliasICPRecordal' :: Maybe ICPRecordalStatus
iCPRecordalStatus = Maybe ICPRecordalStatus
a} :: AliasICPRecordal)

instance Core.FromXML AliasICPRecordal where
  parseXML :: [Node] -> Either String AliasICPRecordal
parseXML [Node]
x =
    Maybe Text -> Maybe ICPRecordalStatus -> AliasICPRecordal
AliasICPRecordal'
      (Maybe Text -> Maybe ICPRecordalStatus -> AliasICPRecordal)
-> Either String (Maybe Text)
-> Either String (Maybe ICPRecordalStatus -> AliasICPRecordal)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CNAME")
      Either String (Maybe ICPRecordalStatus -> AliasICPRecordal)
-> Either String (Maybe ICPRecordalStatus)
-> Either String AliasICPRecordal
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ICPRecordalStatus)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ICPRecordalStatus")

instance Prelude.Hashable AliasICPRecordal

instance Prelude.NFData AliasICPRecordal