{-# 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.FunctionSummary
-- 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.FunctionSummary where

import Amazonka.CloudFront.Types.FunctionConfig
import Amazonka.CloudFront.Types.FunctionMetadata
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains configuration information and metadata about a CloudFront
-- function.
--
-- /See:/ 'newFunctionSummary' smart constructor.
data FunctionSummary = FunctionSummary'
  { -- | The status of the CloudFront function.
    FunctionSummary -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The name of the CloudFront function.
    FunctionSummary -> Text
name :: Prelude.Text,
    -- | Contains configuration information about a CloudFront function.
    FunctionSummary -> FunctionConfig
functionConfig :: FunctionConfig,
    -- | Contains metadata about a CloudFront function.
    FunctionSummary -> FunctionMetadata
functionMetadata :: FunctionMetadata
  }
  deriving (FunctionSummary -> FunctionSummary -> Bool
(FunctionSummary -> FunctionSummary -> Bool)
-> (FunctionSummary -> FunctionSummary -> Bool)
-> Eq FunctionSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionSummary -> FunctionSummary -> Bool
$c/= :: FunctionSummary -> FunctionSummary -> Bool
== :: FunctionSummary -> FunctionSummary -> Bool
$c== :: FunctionSummary -> FunctionSummary -> Bool
Prelude.Eq, ReadPrec [FunctionSummary]
ReadPrec FunctionSummary
Int -> ReadS FunctionSummary
ReadS [FunctionSummary]
(Int -> ReadS FunctionSummary)
-> ReadS [FunctionSummary]
-> ReadPrec FunctionSummary
-> ReadPrec [FunctionSummary]
-> Read FunctionSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FunctionSummary]
$creadListPrec :: ReadPrec [FunctionSummary]
readPrec :: ReadPrec FunctionSummary
$creadPrec :: ReadPrec FunctionSummary
readList :: ReadS [FunctionSummary]
$creadList :: ReadS [FunctionSummary]
readsPrec :: Int -> ReadS FunctionSummary
$creadsPrec :: Int -> ReadS FunctionSummary
Prelude.Read, Int -> FunctionSummary -> ShowS
[FunctionSummary] -> ShowS
FunctionSummary -> String
(Int -> FunctionSummary -> ShowS)
-> (FunctionSummary -> String)
-> ([FunctionSummary] -> ShowS)
-> Show FunctionSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionSummary] -> ShowS
$cshowList :: [FunctionSummary] -> ShowS
show :: FunctionSummary -> String
$cshow :: FunctionSummary -> String
showsPrec :: Int -> FunctionSummary -> ShowS
$cshowsPrec :: Int -> FunctionSummary -> ShowS
Prelude.Show, (forall x. FunctionSummary -> Rep FunctionSummary x)
-> (forall x. Rep FunctionSummary x -> FunctionSummary)
-> Generic FunctionSummary
forall x. Rep FunctionSummary x -> FunctionSummary
forall x. FunctionSummary -> Rep FunctionSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FunctionSummary x -> FunctionSummary
$cfrom :: forall x. FunctionSummary -> Rep FunctionSummary x
Prelude.Generic)

-- |
-- Create a value of 'FunctionSummary' 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:
--
-- 'status', 'functionSummary_status' - The status of the CloudFront function.
--
-- 'name', 'functionSummary_name' - The name of the CloudFront function.
--
-- 'functionConfig', 'functionSummary_functionConfig' - Contains configuration information about a CloudFront function.
--
-- 'functionMetadata', 'functionSummary_functionMetadata' - Contains metadata about a CloudFront function.
newFunctionSummary ::
  -- | 'name'
  Prelude.Text ->
  -- | 'functionConfig'
  FunctionConfig ->
  -- | 'functionMetadata'
  FunctionMetadata ->
  FunctionSummary
newFunctionSummary :: Text -> FunctionConfig -> FunctionMetadata -> FunctionSummary
newFunctionSummary
  Text
pName_
  FunctionConfig
pFunctionConfig_
  FunctionMetadata
pFunctionMetadata_ =
    FunctionSummary' :: Maybe Text
-> Text -> FunctionConfig -> FunctionMetadata -> FunctionSummary
FunctionSummary'
      { $sel:status:FunctionSummary' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:name:FunctionSummary' :: Text
name = Text
pName_,
        $sel:functionConfig:FunctionSummary' :: FunctionConfig
functionConfig = FunctionConfig
pFunctionConfig_,
        $sel:functionMetadata:FunctionSummary' :: FunctionMetadata
functionMetadata = FunctionMetadata
pFunctionMetadata_
      }

-- | The status of the CloudFront function.
functionSummary_status :: Lens.Lens' FunctionSummary (Prelude.Maybe Prelude.Text)
functionSummary_status :: (Maybe Text -> f (Maybe Text))
-> FunctionSummary -> f FunctionSummary
functionSummary_status = (FunctionSummary -> Maybe Text)
-> (FunctionSummary -> Maybe Text -> FunctionSummary)
-> Lens FunctionSummary FunctionSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionSummary' {Maybe Text
status :: Maybe Text
$sel:status:FunctionSummary' :: FunctionSummary -> Maybe Text
status} -> Maybe Text
status) (\s :: FunctionSummary
s@FunctionSummary' {} Maybe Text
a -> FunctionSummary
s {$sel:status:FunctionSummary' :: Maybe Text
status = Maybe Text
a} :: FunctionSummary)

-- | The name of the CloudFront function.
functionSummary_name :: Lens.Lens' FunctionSummary Prelude.Text
functionSummary_name :: (Text -> f Text) -> FunctionSummary -> f FunctionSummary
functionSummary_name = (FunctionSummary -> Text)
-> (FunctionSummary -> Text -> FunctionSummary)
-> Lens FunctionSummary FunctionSummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionSummary' {Text
name :: Text
$sel:name:FunctionSummary' :: FunctionSummary -> Text
name} -> Text
name) (\s :: FunctionSummary
s@FunctionSummary' {} Text
a -> FunctionSummary
s {$sel:name:FunctionSummary' :: Text
name = Text
a} :: FunctionSummary)

-- | Contains configuration information about a CloudFront function.
functionSummary_functionConfig :: Lens.Lens' FunctionSummary FunctionConfig
functionSummary_functionConfig :: (FunctionConfig -> f FunctionConfig)
-> FunctionSummary -> f FunctionSummary
functionSummary_functionConfig = (FunctionSummary -> FunctionConfig)
-> (FunctionSummary -> FunctionConfig -> FunctionSummary)
-> Lens
     FunctionSummary FunctionSummary FunctionConfig FunctionConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionSummary' {FunctionConfig
functionConfig :: FunctionConfig
$sel:functionConfig:FunctionSummary' :: FunctionSummary -> FunctionConfig
functionConfig} -> FunctionConfig
functionConfig) (\s :: FunctionSummary
s@FunctionSummary' {} FunctionConfig
a -> FunctionSummary
s {$sel:functionConfig:FunctionSummary' :: FunctionConfig
functionConfig = FunctionConfig
a} :: FunctionSummary)

-- | Contains metadata about a CloudFront function.
functionSummary_functionMetadata :: Lens.Lens' FunctionSummary FunctionMetadata
functionSummary_functionMetadata :: (FunctionMetadata -> f FunctionMetadata)
-> FunctionSummary -> f FunctionSummary
functionSummary_functionMetadata = (FunctionSummary -> FunctionMetadata)
-> (FunctionSummary -> FunctionMetadata -> FunctionSummary)
-> Lens
     FunctionSummary FunctionSummary FunctionMetadata FunctionMetadata
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionSummary' {FunctionMetadata
functionMetadata :: FunctionMetadata
$sel:functionMetadata:FunctionSummary' :: FunctionSummary -> FunctionMetadata
functionMetadata} -> FunctionMetadata
functionMetadata) (\s :: FunctionSummary
s@FunctionSummary' {} FunctionMetadata
a -> FunctionSummary
s {$sel:functionMetadata:FunctionSummary' :: FunctionMetadata
functionMetadata = FunctionMetadata
a} :: FunctionSummary)

instance Core.FromXML FunctionSummary where
  parseXML :: [Node] -> Either String FunctionSummary
parseXML [Node]
x =
    Maybe Text
-> Text -> FunctionConfig -> FunctionMetadata -> FunctionSummary
FunctionSummary'
      (Maybe Text
 -> Text -> FunctionConfig -> FunctionMetadata -> FunctionSummary)
-> Either String (Maybe Text)
-> Either
     String
     (Text -> FunctionConfig -> FunctionMetadata -> FunctionSummary)
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
"Status")
      Either
  String
  (Text -> FunctionConfig -> FunctionMetadata -> FunctionSummary)
-> Either String Text
-> Either
     String (FunctionConfig -> FunctionMetadata -> FunctionSummary)
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
"Name")
      Either
  String (FunctionConfig -> FunctionMetadata -> FunctionSummary)
-> Either String FunctionConfig
-> Either String (FunctionMetadata -> FunctionSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String FunctionConfig
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"FunctionConfig")
      Either String (FunctionMetadata -> FunctionSummary)
-> Either String FunctionMetadata -> Either String FunctionSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String FunctionMetadata
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"FunctionMetadata")

instance Prelude.Hashable FunctionSummary

instance Prelude.NFData FunctionSummary