{-# 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.ELBV2.Types.FixedResponseActionConfig
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ELBV2.Types.FixedResponseActionConfig where

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

-- | Information about an action that returns a custom HTTP response.
--
-- /See:/ 'newFixedResponseActionConfig' smart constructor.
data FixedResponseActionConfig = FixedResponseActionConfig'
  { -- | The content type.
    --
    -- Valid Values: text\/plain | text\/css | text\/html |
    -- application\/javascript | application\/json
    FixedResponseActionConfig -> Maybe Text
contentType :: Prelude.Maybe Prelude.Text,
    -- | The message.
    FixedResponseActionConfig -> Maybe Text
messageBody :: Prelude.Maybe Prelude.Text,
    -- | The HTTP response code (2XX, 4XX, or 5XX).
    FixedResponseActionConfig -> Text
statusCode :: Prelude.Text
  }
  deriving (FixedResponseActionConfig -> FixedResponseActionConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FixedResponseActionConfig -> FixedResponseActionConfig -> Bool
$c/= :: FixedResponseActionConfig -> FixedResponseActionConfig -> Bool
== :: FixedResponseActionConfig -> FixedResponseActionConfig -> Bool
$c== :: FixedResponseActionConfig -> FixedResponseActionConfig -> Bool
Prelude.Eq, ReadPrec [FixedResponseActionConfig]
ReadPrec FixedResponseActionConfig
Int -> ReadS FixedResponseActionConfig
ReadS [FixedResponseActionConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FixedResponseActionConfig]
$creadListPrec :: ReadPrec [FixedResponseActionConfig]
readPrec :: ReadPrec FixedResponseActionConfig
$creadPrec :: ReadPrec FixedResponseActionConfig
readList :: ReadS [FixedResponseActionConfig]
$creadList :: ReadS [FixedResponseActionConfig]
readsPrec :: Int -> ReadS FixedResponseActionConfig
$creadsPrec :: Int -> ReadS FixedResponseActionConfig
Prelude.Read, Int -> FixedResponseActionConfig -> ShowS
[FixedResponseActionConfig] -> ShowS
FixedResponseActionConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FixedResponseActionConfig] -> ShowS
$cshowList :: [FixedResponseActionConfig] -> ShowS
show :: FixedResponseActionConfig -> String
$cshow :: FixedResponseActionConfig -> String
showsPrec :: Int -> FixedResponseActionConfig -> ShowS
$cshowsPrec :: Int -> FixedResponseActionConfig -> ShowS
Prelude.Show, forall x.
Rep FixedResponseActionConfig x -> FixedResponseActionConfig
forall x.
FixedResponseActionConfig -> Rep FixedResponseActionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FixedResponseActionConfig x -> FixedResponseActionConfig
$cfrom :: forall x.
FixedResponseActionConfig -> Rep FixedResponseActionConfig x
Prelude.Generic)

-- |
-- Create a value of 'FixedResponseActionConfig' 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:
--
-- 'contentType', 'fixedResponseActionConfig_contentType' - The content type.
--
-- Valid Values: text\/plain | text\/css | text\/html |
-- application\/javascript | application\/json
--
-- 'messageBody', 'fixedResponseActionConfig_messageBody' - The message.
--
-- 'statusCode', 'fixedResponseActionConfig_statusCode' - The HTTP response code (2XX, 4XX, or 5XX).
newFixedResponseActionConfig ::
  -- | 'statusCode'
  Prelude.Text ->
  FixedResponseActionConfig
newFixedResponseActionConfig :: Text -> FixedResponseActionConfig
newFixedResponseActionConfig Text
pStatusCode_ =
  FixedResponseActionConfig'
    { $sel:contentType:FixedResponseActionConfig' :: Maybe Text
contentType =
        forall a. Maybe a
Prelude.Nothing,
      $sel:messageBody:FixedResponseActionConfig' :: Maybe Text
messageBody = forall a. Maybe a
Prelude.Nothing,
      $sel:statusCode:FixedResponseActionConfig' :: Text
statusCode = Text
pStatusCode_
    }

-- | The content type.
--
-- Valid Values: text\/plain | text\/css | text\/html |
-- application\/javascript | application\/json
fixedResponseActionConfig_contentType :: Lens.Lens' FixedResponseActionConfig (Prelude.Maybe Prelude.Text)
fixedResponseActionConfig_contentType :: Lens' FixedResponseActionConfig (Maybe Text)
fixedResponseActionConfig_contentType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FixedResponseActionConfig' {Maybe Text
contentType :: Maybe Text
$sel:contentType:FixedResponseActionConfig' :: FixedResponseActionConfig -> Maybe Text
contentType} -> Maybe Text
contentType) (\s :: FixedResponseActionConfig
s@FixedResponseActionConfig' {} Maybe Text
a -> FixedResponseActionConfig
s {$sel:contentType:FixedResponseActionConfig' :: Maybe Text
contentType = Maybe Text
a} :: FixedResponseActionConfig)

-- | The message.
fixedResponseActionConfig_messageBody :: Lens.Lens' FixedResponseActionConfig (Prelude.Maybe Prelude.Text)
fixedResponseActionConfig_messageBody :: Lens' FixedResponseActionConfig (Maybe Text)
fixedResponseActionConfig_messageBody = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FixedResponseActionConfig' {Maybe Text
messageBody :: Maybe Text
$sel:messageBody:FixedResponseActionConfig' :: FixedResponseActionConfig -> Maybe Text
messageBody} -> Maybe Text
messageBody) (\s :: FixedResponseActionConfig
s@FixedResponseActionConfig' {} Maybe Text
a -> FixedResponseActionConfig
s {$sel:messageBody:FixedResponseActionConfig' :: Maybe Text
messageBody = Maybe Text
a} :: FixedResponseActionConfig)

-- | The HTTP response code (2XX, 4XX, or 5XX).
fixedResponseActionConfig_statusCode :: Lens.Lens' FixedResponseActionConfig Prelude.Text
fixedResponseActionConfig_statusCode :: Lens' FixedResponseActionConfig Text
fixedResponseActionConfig_statusCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FixedResponseActionConfig' {Text
statusCode :: Text
$sel:statusCode:FixedResponseActionConfig' :: FixedResponseActionConfig -> Text
statusCode} -> Text
statusCode) (\s :: FixedResponseActionConfig
s@FixedResponseActionConfig' {} Text
a -> FixedResponseActionConfig
s {$sel:statusCode:FixedResponseActionConfig' :: Text
statusCode = Text
a} :: FixedResponseActionConfig)

instance Data.FromXML FixedResponseActionConfig where
  parseXML :: [Node] -> Either String FixedResponseActionConfig
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Text -> FixedResponseActionConfig
FixedResponseActionConfig'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ContentType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"MessageBody")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"StatusCode")

instance Prelude.Hashable FixedResponseActionConfig where
  hashWithSalt :: Int -> FixedResponseActionConfig -> Int
hashWithSalt Int
_salt FixedResponseActionConfig' {Maybe Text
Text
statusCode :: Text
messageBody :: Maybe Text
contentType :: Maybe Text
$sel:statusCode:FixedResponseActionConfig' :: FixedResponseActionConfig -> Text
$sel:messageBody:FixedResponseActionConfig' :: FixedResponseActionConfig -> Maybe Text
$sel:contentType:FixedResponseActionConfig' :: FixedResponseActionConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contentType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
messageBody
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
statusCode

instance Prelude.NFData FixedResponseActionConfig where
  rnf :: FixedResponseActionConfig -> ()
rnf FixedResponseActionConfig' {Maybe Text
Text
statusCode :: Text
messageBody :: Maybe Text
contentType :: Maybe Text
$sel:statusCode:FixedResponseActionConfig' :: FixedResponseActionConfig -> Text
$sel:messageBody:FixedResponseActionConfig' :: FixedResponseActionConfig -> Maybe Text
$sel:contentType:FixedResponseActionConfig' :: FixedResponseActionConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contentType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
messageBody
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
statusCode

instance Data.ToQuery FixedResponseActionConfig where
  toQuery :: FixedResponseActionConfig -> QueryString
toQuery FixedResponseActionConfig' {Maybe Text
Text
statusCode :: Text
messageBody :: Maybe Text
contentType :: Maybe Text
$sel:statusCode:FixedResponseActionConfig' :: FixedResponseActionConfig -> Text
$sel:messageBody:FixedResponseActionConfig' :: FixedResponseActionConfig -> Maybe Text
$sel:contentType:FixedResponseActionConfig' :: FixedResponseActionConfig -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"ContentType" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
contentType,
        ByteString
"MessageBody" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
messageBody,
        ByteString
"StatusCode" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
statusCode
      ]