{-# 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-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.ELBV2.Types.FixedResponseActionConfig where

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

-- | Information about an action that returns a custom HTTP response.
--
-- /See:/ 'newFixedResponseActionConfig' smart constructor.
data FixedResponseActionConfig = FixedResponseActionConfig'
  { -- | The message.
    FixedResponseActionConfig -> Maybe Text
messageBody :: Prelude.Maybe Prelude.Text,
    -- | The content type.
    --
    -- Valid Values: text\/plain | text\/css | text\/html |
    -- application\/javascript | application\/json
    FixedResponseActionConfig -> Maybe Text
contentType :: Prelude.Maybe Prelude.Text,
    -- | The HTTP response code (2XX, 4XX, or 5XX).
    FixedResponseActionConfig -> Text
statusCode :: Prelude.Text
  }
  deriving (FixedResponseActionConfig -> FixedResponseActionConfig -> Bool
(FixedResponseActionConfig -> FixedResponseActionConfig -> Bool)
-> (FixedResponseActionConfig -> FixedResponseActionConfig -> Bool)
-> Eq FixedResponseActionConfig
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]
(Int -> ReadS FixedResponseActionConfig)
-> ReadS [FixedResponseActionConfig]
-> ReadPrec FixedResponseActionConfig
-> ReadPrec [FixedResponseActionConfig]
-> Read 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
(Int -> FixedResponseActionConfig -> ShowS)
-> (FixedResponseActionConfig -> String)
-> ([FixedResponseActionConfig] -> ShowS)
-> Show FixedResponseActionConfig
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.
 FixedResponseActionConfig -> Rep FixedResponseActionConfig x)
-> (forall x.
    Rep FixedResponseActionConfig x -> FixedResponseActionConfig)
-> Generic FixedResponseActionConfig
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:
--
-- 'messageBody', 'fixedResponseActionConfig_messageBody' - The message.
--
-- 'contentType', 'fixedResponseActionConfig_contentType' - The content type.
--
-- Valid Values: text\/plain | text\/css | text\/html |
-- application\/javascript | application\/json
--
-- 'statusCode', 'fixedResponseActionConfig_statusCode' - The HTTP response code (2XX, 4XX, or 5XX).
newFixedResponseActionConfig ::
  -- | 'statusCode'
  Prelude.Text ->
  FixedResponseActionConfig
newFixedResponseActionConfig :: Text -> FixedResponseActionConfig
newFixedResponseActionConfig Text
pStatusCode_ =
  FixedResponseActionConfig' :: Maybe Text -> Maybe Text -> Text -> FixedResponseActionConfig
FixedResponseActionConfig'
    { $sel:messageBody:FixedResponseActionConfig' :: Maybe Text
messageBody =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contentType:FixedResponseActionConfig' :: Maybe Text
contentType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statusCode:FixedResponseActionConfig' :: Text
statusCode = Text
pStatusCode_
    }

-- | The message.
fixedResponseActionConfig_messageBody :: Lens.Lens' FixedResponseActionConfig (Prelude.Maybe Prelude.Text)
fixedResponseActionConfig_messageBody :: (Maybe Text -> f (Maybe Text))
-> FixedResponseActionConfig -> f FixedResponseActionConfig
fixedResponseActionConfig_messageBody = (FixedResponseActionConfig -> Maybe Text)
-> (FixedResponseActionConfig
    -> Maybe Text -> FixedResponseActionConfig)
-> Lens
     FixedResponseActionConfig
     FixedResponseActionConfig
     (Maybe Text)
     (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> FixedResponseActionConfig -> f FixedResponseActionConfig
fixedResponseActionConfig_contentType = (FixedResponseActionConfig -> Maybe Text)
-> (FixedResponseActionConfig
    -> Maybe Text -> FixedResponseActionConfig)
-> Lens
     FixedResponseActionConfig
     FixedResponseActionConfig
     (Maybe Text)
     (Maybe Text)
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 HTTP response code (2XX, 4XX, or 5XX).
fixedResponseActionConfig_statusCode :: Lens.Lens' FixedResponseActionConfig Prelude.Text
fixedResponseActionConfig_statusCode :: (Text -> f Text)
-> FixedResponseActionConfig -> f FixedResponseActionConfig
fixedResponseActionConfig_statusCode = (FixedResponseActionConfig -> Text)
-> (FixedResponseActionConfig -> Text -> FixedResponseActionConfig)
-> Lens
     FixedResponseActionConfig FixedResponseActionConfig Text Text
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 Core.FromXML FixedResponseActionConfig where
  parseXML :: [Node] -> Either String FixedResponseActionConfig
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Text -> FixedResponseActionConfig
FixedResponseActionConfig'
      (Maybe Text -> Maybe Text -> Text -> FixedResponseActionConfig)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Text -> FixedResponseActionConfig)
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
"MessageBody")
      Either String (Maybe Text -> Text -> FixedResponseActionConfig)
-> Either String (Maybe Text)
-> Either String (Text -> FixedResponseActionConfig)
forall (f :: * -> *) a b. Applicative f => 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
"ContentType")
      Either String (Text -> FixedResponseActionConfig)
-> Either String Text -> Either String FixedResponseActionConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"StatusCode")

instance Prelude.Hashable FixedResponseActionConfig

instance Prelude.NFData FixedResponseActionConfig

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