{-# 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.Amplify.Types.SubDomainSetting
-- 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.Amplify.Types.SubDomainSetting where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the settings for the subdomain.
--
-- /See:/ 'newSubDomainSetting' smart constructor.
data SubDomainSetting = SubDomainSetting'
  { -- | The prefix setting for the subdomain.
    SubDomainSetting -> Text
prefix :: Prelude.Text,
    -- | The branch name setting for the subdomain.
    SubDomainSetting -> Text
branchName :: Prelude.Text
  }
  deriving (SubDomainSetting -> SubDomainSetting -> Bool
(SubDomainSetting -> SubDomainSetting -> Bool)
-> (SubDomainSetting -> SubDomainSetting -> Bool)
-> Eq SubDomainSetting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubDomainSetting -> SubDomainSetting -> Bool
$c/= :: SubDomainSetting -> SubDomainSetting -> Bool
== :: SubDomainSetting -> SubDomainSetting -> Bool
$c== :: SubDomainSetting -> SubDomainSetting -> Bool
Prelude.Eq, ReadPrec [SubDomainSetting]
ReadPrec SubDomainSetting
Int -> ReadS SubDomainSetting
ReadS [SubDomainSetting]
(Int -> ReadS SubDomainSetting)
-> ReadS [SubDomainSetting]
-> ReadPrec SubDomainSetting
-> ReadPrec [SubDomainSetting]
-> Read SubDomainSetting
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubDomainSetting]
$creadListPrec :: ReadPrec [SubDomainSetting]
readPrec :: ReadPrec SubDomainSetting
$creadPrec :: ReadPrec SubDomainSetting
readList :: ReadS [SubDomainSetting]
$creadList :: ReadS [SubDomainSetting]
readsPrec :: Int -> ReadS SubDomainSetting
$creadsPrec :: Int -> ReadS SubDomainSetting
Prelude.Read, Int -> SubDomainSetting -> ShowS
[SubDomainSetting] -> ShowS
SubDomainSetting -> String
(Int -> SubDomainSetting -> ShowS)
-> (SubDomainSetting -> String)
-> ([SubDomainSetting] -> ShowS)
-> Show SubDomainSetting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubDomainSetting] -> ShowS
$cshowList :: [SubDomainSetting] -> ShowS
show :: SubDomainSetting -> String
$cshow :: SubDomainSetting -> String
showsPrec :: Int -> SubDomainSetting -> ShowS
$cshowsPrec :: Int -> SubDomainSetting -> ShowS
Prelude.Show, (forall x. SubDomainSetting -> Rep SubDomainSetting x)
-> (forall x. Rep SubDomainSetting x -> SubDomainSetting)
-> Generic SubDomainSetting
forall x. Rep SubDomainSetting x -> SubDomainSetting
forall x. SubDomainSetting -> Rep SubDomainSetting x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubDomainSetting x -> SubDomainSetting
$cfrom :: forall x. SubDomainSetting -> Rep SubDomainSetting x
Prelude.Generic)

-- |
-- Create a value of 'SubDomainSetting' 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:
--
-- 'prefix', 'subDomainSetting_prefix' - The prefix setting for the subdomain.
--
-- 'branchName', 'subDomainSetting_branchName' - The branch name setting for the subdomain.
newSubDomainSetting ::
  -- | 'prefix'
  Prelude.Text ->
  -- | 'branchName'
  Prelude.Text ->
  SubDomainSetting
newSubDomainSetting :: Text -> Text -> SubDomainSetting
newSubDomainSetting Text
pPrefix_ Text
pBranchName_ =
  SubDomainSetting' :: Text -> Text -> SubDomainSetting
SubDomainSetting'
    { $sel:prefix:SubDomainSetting' :: Text
prefix = Text
pPrefix_,
      $sel:branchName:SubDomainSetting' :: Text
branchName = Text
pBranchName_
    }

-- | The prefix setting for the subdomain.
subDomainSetting_prefix :: Lens.Lens' SubDomainSetting Prelude.Text
subDomainSetting_prefix :: (Text -> f Text) -> SubDomainSetting -> f SubDomainSetting
subDomainSetting_prefix = (SubDomainSetting -> Text)
-> (SubDomainSetting -> Text -> SubDomainSetting)
-> Lens SubDomainSetting SubDomainSetting Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubDomainSetting' {Text
prefix :: Text
$sel:prefix:SubDomainSetting' :: SubDomainSetting -> Text
prefix} -> Text
prefix) (\s :: SubDomainSetting
s@SubDomainSetting' {} Text
a -> SubDomainSetting
s {$sel:prefix:SubDomainSetting' :: Text
prefix = Text
a} :: SubDomainSetting)

-- | The branch name setting for the subdomain.
subDomainSetting_branchName :: Lens.Lens' SubDomainSetting Prelude.Text
subDomainSetting_branchName :: (Text -> f Text) -> SubDomainSetting -> f SubDomainSetting
subDomainSetting_branchName = (SubDomainSetting -> Text)
-> (SubDomainSetting -> Text -> SubDomainSetting)
-> Lens SubDomainSetting SubDomainSetting Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubDomainSetting' {Text
branchName :: Text
$sel:branchName:SubDomainSetting' :: SubDomainSetting -> Text
branchName} -> Text
branchName) (\s :: SubDomainSetting
s@SubDomainSetting' {} Text
a -> SubDomainSetting
s {$sel:branchName:SubDomainSetting' :: Text
branchName = Text
a} :: SubDomainSetting)

instance Core.FromJSON SubDomainSetting where
  parseJSON :: Value -> Parser SubDomainSetting
parseJSON =
    String
-> (Object -> Parser SubDomainSetting)
-> Value
-> Parser SubDomainSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SubDomainSetting"
      ( \Object
x ->
          Text -> Text -> SubDomainSetting
SubDomainSetting'
            (Text -> Text -> SubDomainSetting)
-> Parser Text -> Parser (Text -> SubDomainSetting)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"prefix")
            Parser (Text -> SubDomainSetting)
-> Parser Text -> Parser SubDomainSetting
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
"branchName")
      )

instance Prelude.Hashable SubDomainSetting

instance Prelude.NFData SubDomainSetting

instance Core.ToJSON SubDomainSetting where
  toJSON :: SubDomainSetting -> Value
toJSON SubDomainSetting' {Text
branchName :: Text
prefix :: Text
$sel:branchName:SubDomainSetting' :: SubDomainSetting -> Text
$sel:prefix:SubDomainSetting' :: SubDomainSetting -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"prefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
prefix),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"branchName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
branchName)
          ]
      )