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

import Amazonka.CloudFront.Types.CachePolicy
import Amazonka.CloudFront.Types.CachePolicyType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains a cache policy.
--
-- /See:/ 'newCachePolicySummary' smart constructor.
data CachePolicySummary = CachePolicySummary'
  { -- | The type of cache policy, either @managed@ (created by Amazon Web
    -- Services) or @custom@ (created in this account).
    CachePolicySummary -> CachePolicyType
type' :: CachePolicyType,
    -- | The cache policy.
    CachePolicySummary -> CachePolicy
cachePolicy :: CachePolicy
  }
  deriving (CachePolicySummary -> CachePolicySummary -> Bool
(CachePolicySummary -> CachePolicySummary -> Bool)
-> (CachePolicySummary -> CachePolicySummary -> Bool)
-> Eq CachePolicySummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CachePolicySummary -> CachePolicySummary -> Bool
$c/= :: CachePolicySummary -> CachePolicySummary -> Bool
== :: CachePolicySummary -> CachePolicySummary -> Bool
$c== :: CachePolicySummary -> CachePolicySummary -> Bool
Prelude.Eq, ReadPrec [CachePolicySummary]
ReadPrec CachePolicySummary
Int -> ReadS CachePolicySummary
ReadS [CachePolicySummary]
(Int -> ReadS CachePolicySummary)
-> ReadS [CachePolicySummary]
-> ReadPrec CachePolicySummary
-> ReadPrec [CachePolicySummary]
-> Read CachePolicySummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CachePolicySummary]
$creadListPrec :: ReadPrec [CachePolicySummary]
readPrec :: ReadPrec CachePolicySummary
$creadPrec :: ReadPrec CachePolicySummary
readList :: ReadS [CachePolicySummary]
$creadList :: ReadS [CachePolicySummary]
readsPrec :: Int -> ReadS CachePolicySummary
$creadsPrec :: Int -> ReadS CachePolicySummary
Prelude.Read, Int -> CachePolicySummary -> ShowS
[CachePolicySummary] -> ShowS
CachePolicySummary -> String
(Int -> CachePolicySummary -> ShowS)
-> (CachePolicySummary -> String)
-> ([CachePolicySummary] -> ShowS)
-> Show CachePolicySummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CachePolicySummary] -> ShowS
$cshowList :: [CachePolicySummary] -> ShowS
show :: CachePolicySummary -> String
$cshow :: CachePolicySummary -> String
showsPrec :: Int -> CachePolicySummary -> ShowS
$cshowsPrec :: Int -> CachePolicySummary -> ShowS
Prelude.Show, (forall x. CachePolicySummary -> Rep CachePolicySummary x)
-> (forall x. Rep CachePolicySummary x -> CachePolicySummary)
-> Generic CachePolicySummary
forall x. Rep CachePolicySummary x -> CachePolicySummary
forall x. CachePolicySummary -> Rep CachePolicySummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CachePolicySummary x -> CachePolicySummary
$cfrom :: forall x. CachePolicySummary -> Rep CachePolicySummary x
Prelude.Generic)

-- |
-- Create a value of 'CachePolicySummary' 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:
--
-- 'type'', 'cachePolicySummary_type' - The type of cache policy, either @managed@ (created by Amazon Web
-- Services) or @custom@ (created in this account).
--
-- 'cachePolicy', 'cachePolicySummary_cachePolicy' - The cache policy.
newCachePolicySummary ::
  -- | 'type''
  CachePolicyType ->
  -- | 'cachePolicy'
  CachePolicy ->
  CachePolicySummary
newCachePolicySummary :: CachePolicyType -> CachePolicy -> CachePolicySummary
newCachePolicySummary CachePolicyType
pType_ CachePolicy
pCachePolicy_ =
  CachePolicySummary' :: CachePolicyType -> CachePolicy -> CachePolicySummary
CachePolicySummary'
    { $sel:type':CachePolicySummary' :: CachePolicyType
type' = CachePolicyType
pType_,
      $sel:cachePolicy:CachePolicySummary' :: CachePolicy
cachePolicy = CachePolicy
pCachePolicy_
    }

-- | The type of cache policy, either @managed@ (created by Amazon Web
-- Services) or @custom@ (created in this account).
cachePolicySummary_type :: Lens.Lens' CachePolicySummary CachePolicyType
cachePolicySummary_type :: (CachePolicyType -> f CachePolicyType)
-> CachePolicySummary -> f CachePolicySummary
cachePolicySummary_type = (CachePolicySummary -> CachePolicyType)
-> (CachePolicySummary -> CachePolicyType -> CachePolicySummary)
-> Lens
     CachePolicySummary
     CachePolicySummary
     CachePolicyType
     CachePolicyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicySummary' {CachePolicyType
type' :: CachePolicyType
$sel:type':CachePolicySummary' :: CachePolicySummary -> CachePolicyType
type'} -> CachePolicyType
type') (\s :: CachePolicySummary
s@CachePolicySummary' {} CachePolicyType
a -> CachePolicySummary
s {$sel:type':CachePolicySummary' :: CachePolicyType
type' = CachePolicyType
a} :: CachePolicySummary)

-- | The cache policy.
cachePolicySummary_cachePolicy :: Lens.Lens' CachePolicySummary CachePolicy
cachePolicySummary_cachePolicy :: (CachePolicy -> f CachePolicy)
-> CachePolicySummary -> f CachePolicySummary
cachePolicySummary_cachePolicy = (CachePolicySummary -> CachePolicy)
-> (CachePolicySummary -> CachePolicy -> CachePolicySummary)
-> Lens
     CachePolicySummary CachePolicySummary CachePolicy CachePolicy
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CachePolicySummary' {CachePolicy
cachePolicy :: CachePolicy
$sel:cachePolicy:CachePolicySummary' :: CachePolicySummary -> CachePolicy
cachePolicy} -> CachePolicy
cachePolicy) (\s :: CachePolicySummary
s@CachePolicySummary' {} CachePolicy
a -> CachePolicySummary
s {$sel:cachePolicy:CachePolicySummary' :: CachePolicy
cachePolicy = CachePolicy
a} :: CachePolicySummary)

instance Core.FromXML CachePolicySummary where
  parseXML :: [Node] -> Either String CachePolicySummary
parseXML [Node]
x =
    CachePolicyType -> CachePolicy -> CachePolicySummary
CachePolicySummary'
      (CachePolicyType -> CachePolicy -> CachePolicySummary)
-> Either String CachePolicyType
-> Either String (CachePolicy -> CachePolicySummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String CachePolicyType
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Type")
      Either String (CachePolicy -> CachePolicySummary)
-> Either String CachePolicy -> Either String CachePolicySummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String CachePolicy
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"CachePolicy")

instance Prelude.Hashable CachePolicySummary

instance Prelude.NFData CachePolicySummary