{-# 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.ApiGatewayV2.Types.DomainName
-- 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.ApiGatewayV2.Types.DomainName where

import Amazonka.ApiGatewayV2.Types.DomainNameConfiguration
import Amazonka.ApiGatewayV2.Types.MutualTlsAuthentication
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a domain name.
--
-- /See:/ 'newDomainName' smart constructor.
data DomainName = DomainName'
  { -- | The domain name configurations.
    DomainName -> Maybe [DomainNameConfiguration]
domainNameConfigurations :: Prelude.Maybe [DomainNameConfiguration],
    -- | The mutual TLS authentication configuration for a custom domain name.
    DomainName -> Maybe MutualTlsAuthentication
mutualTlsAuthentication :: Prelude.Maybe MutualTlsAuthentication,
    -- | The API mapping selection expression.
    DomainName -> Maybe Text
apiMappingSelectionExpression :: Prelude.Maybe Prelude.Text,
    -- | The collection of tags associated with a domain name.
    DomainName -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the DomainName resource.
    DomainName -> Text
domainName :: Prelude.Text
  }
  deriving (DomainName -> DomainName -> Bool
(DomainName -> DomainName -> Bool)
-> (DomainName -> DomainName -> Bool) -> Eq DomainName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DomainName -> DomainName -> Bool
$c/= :: DomainName -> DomainName -> Bool
== :: DomainName -> DomainName -> Bool
$c== :: DomainName -> DomainName -> Bool
Prelude.Eq, ReadPrec [DomainName]
ReadPrec DomainName
Int -> ReadS DomainName
ReadS [DomainName]
(Int -> ReadS DomainName)
-> ReadS [DomainName]
-> ReadPrec DomainName
-> ReadPrec [DomainName]
-> Read DomainName
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DomainName]
$creadListPrec :: ReadPrec [DomainName]
readPrec :: ReadPrec DomainName
$creadPrec :: ReadPrec DomainName
readList :: ReadS [DomainName]
$creadList :: ReadS [DomainName]
readsPrec :: Int -> ReadS DomainName
$creadsPrec :: Int -> ReadS DomainName
Prelude.Read, Int -> DomainName -> ShowS
[DomainName] -> ShowS
DomainName -> String
(Int -> DomainName -> ShowS)
-> (DomainName -> String)
-> ([DomainName] -> ShowS)
-> Show DomainName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DomainName] -> ShowS
$cshowList :: [DomainName] -> ShowS
show :: DomainName -> String
$cshow :: DomainName -> String
showsPrec :: Int -> DomainName -> ShowS
$cshowsPrec :: Int -> DomainName -> ShowS
Prelude.Show, (forall x. DomainName -> Rep DomainName x)
-> (forall x. Rep DomainName x -> DomainName) -> Generic DomainName
forall x. Rep DomainName x -> DomainName
forall x. DomainName -> Rep DomainName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DomainName x -> DomainName
$cfrom :: forall x. DomainName -> Rep DomainName x
Prelude.Generic)

-- |
-- Create a value of 'DomainName' 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:
--
-- 'domainNameConfigurations', 'domainName_domainNameConfigurations' - The domain name configurations.
--
-- 'mutualTlsAuthentication', 'domainName_mutualTlsAuthentication' - The mutual TLS authentication configuration for a custom domain name.
--
-- 'apiMappingSelectionExpression', 'domainName_apiMappingSelectionExpression' - The API mapping selection expression.
--
-- 'tags', 'domainName_tags' - The collection of tags associated with a domain name.
--
-- 'domainName', 'domainName_domainName' - The name of the DomainName resource.
newDomainName ::
  -- | 'domainName'
  Prelude.Text ->
  DomainName
newDomainName :: Text -> DomainName
newDomainName Text
pDomainName_ =
  DomainName' :: Maybe [DomainNameConfiguration]
-> Maybe MutualTlsAuthentication
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> DomainName
DomainName'
    { $sel:domainNameConfigurations:DomainName' :: Maybe [DomainNameConfiguration]
domainNameConfigurations =
        Maybe [DomainNameConfiguration]
forall a. Maybe a
Prelude.Nothing,
      $sel:mutualTlsAuthentication:DomainName' :: Maybe MutualTlsAuthentication
mutualTlsAuthentication = Maybe MutualTlsAuthentication
forall a. Maybe a
Prelude.Nothing,
      $sel:apiMappingSelectionExpression:DomainName' :: Maybe Text
apiMappingSelectionExpression = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:DomainName' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:DomainName' :: Text
domainName = Text
pDomainName_
    }

-- | The domain name configurations.
domainName_domainNameConfigurations :: Lens.Lens' DomainName (Prelude.Maybe [DomainNameConfiguration])
domainName_domainNameConfigurations :: (Maybe [DomainNameConfiguration]
 -> f (Maybe [DomainNameConfiguration]))
-> DomainName -> f DomainName
domainName_domainNameConfigurations = (DomainName -> Maybe [DomainNameConfiguration])
-> (DomainName -> Maybe [DomainNameConfiguration] -> DomainName)
-> Lens
     DomainName
     DomainName
     (Maybe [DomainNameConfiguration])
     (Maybe [DomainNameConfiguration])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainName' {Maybe [DomainNameConfiguration]
domainNameConfigurations :: Maybe [DomainNameConfiguration]
$sel:domainNameConfigurations:DomainName' :: DomainName -> Maybe [DomainNameConfiguration]
domainNameConfigurations} -> Maybe [DomainNameConfiguration]
domainNameConfigurations) (\s :: DomainName
s@DomainName' {} Maybe [DomainNameConfiguration]
a -> DomainName
s {$sel:domainNameConfigurations:DomainName' :: Maybe [DomainNameConfiguration]
domainNameConfigurations = Maybe [DomainNameConfiguration]
a} :: DomainName) ((Maybe [DomainNameConfiguration]
  -> f (Maybe [DomainNameConfiguration]))
 -> DomainName -> f DomainName)
-> ((Maybe [DomainNameConfiguration]
     -> f (Maybe [DomainNameConfiguration]))
    -> Maybe [DomainNameConfiguration]
    -> f (Maybe [DomainNameConfiguration]))
-> (Maybe [DomainNameConfiguration]
    -> f (Maybe [DomainNameConfiguration]))
-> DomainName
-> f DomainName
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DomainNameConfiguration]
  [DomainNameConfiguration]
  [DomainNameConfiguration]
  [DomainNameConfiguration]
-> Iso
     (Maybe [DomainNameConfiguration])
     (Maybe [DomainNameConfiguration])
     (Maybe [DomainNameConfiguration])
     (Maybe [DomainNameConfiguration])
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
  [DomainNameConfiguration]
  [DomainNameConfiguration]
  [DomainNameConfiguration]
  [DomainNameConfiguration]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The mutual TLS authentication configuration for a custom domain name.
domainName_mutualTlsAuthentication :: Lens.Lens' DomainName (Prelude.Maybe MutualTlsAuthentication)
domainName_mutualTlsAuthentication :: (Maybe MutualTlsAuthentication
 -> f (Maybe MutualTlsAuthentication))
-> DomainName -> f DomainName
domainName_mutualTlsAuthentication = (DomainName -> Maybe MutualTlsAuthentication)
-> (DomainName -> Maybe MutualTlsAuthentication -> DomainName)
-> Lens
     DomainName
     DomainName
     (Maybe MutualTlsAuthentication)
     (Maybe MutualTlsAuthentication)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainName' {Maybe MutualTlsAuthentication
mutualTlsAuthentication :: Maybe MutualTlsAuthentication
$sel:mutualTlsAuthentication:DomainName' :: DomainName -> Maybe MutualTlsAuthentication
mutualTlsAuthentication} -> Maybe MutualTlsAuthentication
mutualTlsAuthentication) (\s :: DomainName
s@DomainName' {} Maybe MutualTlsAuthentication
a -> DomainName
s {$sel:mutualTlsAuthentication:DomainName' :: Maybe MutualTlsAuthentication
mutualTlsAuthentication = Maybe MutualTlsAuthentication
a} :: DomainName)

-- | The API mapping selection expression.
domainName_apiMappingSelectionExpression :: Lens.Lens' DomainName (Prelude.Maybe Prelude.Text)
domainName_apiMappingSelectionExpression :: (Maybe Text -> f (Maybe Text)) -> DomainName -> f DomainName
domainName_apiMappingSelectionExpression = (DomainName -> Maybe Text)
-> (DomainName -> Maybe Text -> DomainName)
-> Lens DomainName DomainName (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainName' {Maybe Text
apiMappingSelectionExpression :: Maybe Text
$sel:apiMappingSelectionExpression:DomainName' :: DomainName -> Maybe Text
apiMappingSelectionExpression} -> Maybe Text
apiMappingSelectionExpression) (\s :: DomainName
s@DomainName' {} Maybe Text
a -> DomainName
s {$sel:apiMappingSelectionExpression:DomainName' :: Maybe Text
apiMappingSelectionExpression = Maybe Text
a} :: DomainName)

-- | The collection of tags associated with a domain name.
domainName_tags :: Lens.Lens' DomainName (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
domainName_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DomainName -> f DomainName
domainName_tags = (DomainName -> Maybe (HashMap Text Text))
-> (DomainName -> Maybe (HashMap Text Text) -> DomainName)
-> Lens
     DomainName
     DomainName
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainName' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:DomainName' :: DomainName -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: DomainName
s@DomainName' {} Maybe (HashMap Text Text)
a -> DomainName
s {$sel:tags:DomainName' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: DomainName) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> DomainName -> f DomainName)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DomainName
-> f DomainName
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the DomainName resource.
domainName_domainName :: Lens.Lens' DomainName Prelude.Text
domainName_domainName :: (Text -> f Text) -> DomainName -> f DomainName
domainName_domainName = (DomainName -> Text)
-> (DomainName -> Text -> DomainName)
-> Lens DomainName DomainName Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainName' {Text
domainName :: Text
$sel:domainName:DomainName' :: DomainName -> Text
domainName} -> Text
domainName) (\s :: DomainName
s@DomainName' {} Text
a -> DomainName
s {$sel:domainName:DomainName' :: Text
domainName = Text
a} :: DomainName)

instance Core.FromJSON DomainName where
  parseJSON :: Value -> Parser DomainName
parseJSON =
    String
-> (Object -> Parser DomainName) -> Value -> Parser DomainName
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DomainName"
      ( \Object
x ->
          Maybe [DomainNameConfiguration]
-> Maybe MutualTlsAuthentication
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> DomainName
DomainName'
            (Maybe [DomainNameConfiguration]
 -> Maybe MutualTlsAuthentication
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> Text
 -> DomainName)
-> Parser (Maybe [DomainNameConfiguration])
-> Parser
     (Maybe MutualTlsAuthentication
      -> Maybe Text -> Maybe (HashMap Text Text) -> Text -> DomainName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [DomainNameConfiguration]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"domainNameConfigurations"
                            Parser (Maybe (Maybe [DomainNameConfiguration]))
-> Maybe [DomainNameConfiguration]
-> Parser (Maybe [DomainNameConfiguration])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DomainNameConfiguration]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe MutualTlsAuthentication
   -> Maybe Text -> Maybe (HashMap Text Text) -> Text -> DomainName)
-> Parser (Maybe MutualTlsAuthentication)
-> Parser
     (Maybe Text -> Maybe (HashMap Text Text) -> Text -> DomainName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MutualTlsAuthentication)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"mutualTlsAuthentication")
            Parser
  (Maybe Text -> Maybe (HashMap Text Text) -> Text -> DomainName)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> Text -> DomainName)
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
"apiMappingSelectionExpression")
            Parser (Maybe (HashMap Text Text) -> Text -> DomainName)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Text -> DomainName)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tags" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> DomainName) -> Parser Text -> Parser DomainName
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 DomainName

instance Prelude.NFData DomainName