{-# 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 #-}
module Amazonka.CodeBuild.Types.ProjectCache where
import Amazonka.CodeBuild.Types.CacheMode
import Amazonka.CodeBuild.Types.CacheType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data ProjectCache = ProjectCache'
{
ProjectCache -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
ProjectCache -> Maybe [CacheMode]
modes :: Prelude.Maybe [CacheMode],
ProjectCache -> CacheType
type' :: CacheType
}
deriving (ProjectCache -> ProjectCache -> Bool
(ProjectCache -> ProjectCache -> Bool)
-> (ProjectCache -> ProjectCache -> Bool) -> Eq ProjectCache
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProjectCache -> ProjectCache -> Bool
$c/= :: ProjectCache -> ProjectCache -> Bool
== :: ProjectCache -> ProjectCache -> Bool
$c== :: ProjectCache -> ProjectCache -> Bool
Prelude.Eq, ReadPrec [ProjectCache]
ReadPrec ProjectCache
Int -> ReadS ProjectCache
ReadS [ProjectCache]
(Int -> ReadS ProjectCache)
-> ReadS [ProjectCache]
-> ReadPrec ProjectCache
-> ReadPrec [ProjectCache]
-> Read ProjectCache
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProjectCache]
$creadListPrec :: ReadPrec [ProjectCache]
readPrec :: ReadPrec ProjectCache
$creadPrec :: ReadPrec ProjectCache
readList :: ReadS [ProjectCache]
$creadList :: ReadS [ProjectCache]
readsPrec :: Int -> ReadS ProjectCache
$creadsPrec :: Int -> ReadS ProjectCache
Prelude.Read, Int -> ProjectCache -> ShowS
[ProjectCache] -> ShowS
ProjectCache -> String
(Int -> ProjectCache -> ShowS)
-> (ProjectCache -> String)
-> ([ProjectCache] -> ShowS)
-> Show ProjectCache
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProjectCache] -> ShowS
$cshowList :: [ProjectCache] -> ShowS
show :: ProjectCache -> String
$cshow :: ProjectCache -> String
showsPrec :: Int -> ProjectCache -> ShowS
$cshowsPrec :: Int -> ProjectCache -> ShowS
Prelude.Show, (forall x. ProjectCache -> Rep ProjectCache x)
-> (forall x. Rep ProjectCache x -> ProjectCache)
-> Generic ProjectCache
forall x. Rep ProjectCache x -> ProjectCache
forall x. ProjectCache -> Rep ProjectCache x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProjectCache x -> ProjectCache
$cfrom :: forall x. ProjectCache -> Rep ProjectCache x
Prelude.Generic)
newProjectCache ::
CacheType ->
ProjectCache
newProjectCache :: CacheType -> ProjectCache
newProjectCache CacheType
pType_ =
ProjectCache' :: Maybe Text -> Maybe [CacheMode] -> CacheType -> ProjectCache
ProjectCache'
{ $sel:location:ProjectCache' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:modes:ProjectCache' :: Maybe [CacheMode]
modes = Maybe [CacheMode]
forall a. Maybe a
Prelude.Nothing,
$sel:type':ProjectCache' :: CacheType
type' = CacheType
pType_
}
projectCache_location :: Lens.Lens' ProjectCache (Prelude.Maybe Prelude.Text)
projectCache_location :: (Maybe Text -> f (Maybe Text)) -> ProjectCache -> f ProjectCache
projectCache_location = (ProjectCache -> Maybe Text)
-> (ProjectCache -> Maybe Text -> ProjectCache)
-> Lens ProjectCache ProjectCache (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectCache' {Maybe Text
location :: Maybe Text
$sel:location:ProjectCache' :: ProjectCache -> Maybe Text
location} -> Maybe Text
location) (\s :: ProjectCache
s@ProjectCache' {} Maybe Text
a -> ProjectCache
s {$sel:location:ProjectCache' :: Maybe Text
location = Maybe Text
a} :: ProjectCache)
projectCache_modes :: Lens.Lens' ProjectCache (Prelude.Maybe [CacheMode])
projectCache_modes :: (Maybe [CacheMode] -> f (Maybe [CacheMode]))
-> ProjectCache -> f ProjectCache
projectCache_modes = (ProjectCache -> Maybe [CacheMode])
-> (ProjectCache -> Maybe [CacheMode] -> ProjectCache)
-> Lens
ProjectCache ProjectCache (Maybe [CacheMode]) (Maybe [CacheMode])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectCache' {Maybe [CacheMode]
modes :: Maybe [CacheMode]
$sel:modes:ProjectCache' :: ProjectCache -> Maybe [CacheMode]
modes} -> Maybe [CacheMode]
modes) (\s :: ProjectCache
s@ProjectCache' {} Maybe [CacheMode]
a -> ProjectCache
s {$sel:modes:ProjectCache' :: Maybe [CacheMode]
modes = Maybe [CacheMode]
a} :: ProjectCache) ((Maybe [CacheMode] -> f (Maybe [CacheMode]))
-> ProjectCache -> f ProjectCache)
-> ((Maybe [CacheMode] -> f (Maybe [CacheMode]))
-> Maybe [CacheMode] -> f (Maybe [CacheMode]))
-> (Maybe [CacheMode] -> f (Maybe [CacheMode]))
-> ProjectCache
-> f ProjectCache
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [CacheMode] [CacheMode] [CacheMode] [CacheMode]
-> Iso
(Maybe [CacheMode])
(Maybe [CacheMode])
(Maybe [CacheMode])
(Maybe [CacheMode])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [CacheMode] [CacheMode] [CacheMode] [CacheMode]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
projectCache_type :: Lens.Lens' ProjectCache CacheType
projectCache_type :: (CacheType -> f CacheType) -> ProjectCache -> f ProjectCache
projectCache_type = (ProjectCache -> CacheType)
-> (ProjectCache -> CacheType -> ProjectCache)
-> Lens ProjectCache ProjectCache CacheType CacheType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProjectCache' {CacheType
type' :: CacheType
$sel:type':ProjectCache' :: ProjectCache -> CacheType
type'} -> CacheType
type') (\s :: ProjectCache
s@ProjectCache' {} CacheType
a -> ProjectCache
s {$sel:type':ProjectCache' :: CacheType
type' = CacheType
a} :: ProjectCache)
instance Core.FromJSON ProjectCache where
parseJSON :: Value -> Parser ProjectCache
parseJSON =
String
-> (Object -> Parser ProjectCache) -> Value -> Parser ProjectCache
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"ProjectCache"
( \Object
x ->
Maybe Text -> Maybe [CacheMode] -> CacheType -> ProjectCache
ProjectCache'
(Maybe Text -> Maybe [CacheMode] -> CacheType -> ProjectCache)
-> Parser (Maybe Text)
-> Parser (Maybe [CacheMode] -> CacheType -> ProjectCache)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"location")
Parser (Maybe [CacheMode] -> CacheType -> ProjectCache)
-> Parser (Maybe [CacheMode]) -> Parser (CacheType -> ProjectCache)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [CacheMode]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"modes" Parser (Maybe (Maybe [CacheMode]))
-> Maybe [CacheMode] -> Parser (Maybe [CacheMode])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CacheMode]
forall a. Monoid a => a
Prelude.mempty)
Parser (CacheType -> ProjectCache)
-> Parser CacheType -> Parser ProjectCache
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser CacheType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
)
instance Prelude.Hashable ProjectCache
instance Prelude.NFData ProjectCache
instance Core.ToJSON ProjectCache where
toJSON :: ProjectCache -> Value
toJSON ProjectCache' {Maybe [CacheMode]
Maybe Text
CacheType
type' :: CacheType
modes :: Maybe [CacheMode]
location :: Maybe Text
$sel:type':ProjectCache' :: ProjectCache -> CacheType
$sel:modes:ProjectCache' :: ProjectCache -> Maybe [CacheMode]
$sel:location:ProjectCache' :: ProjectCache -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"location" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
location,
(Text
"modes" Text -> [CacheMode] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([CacheMode] -> Pair) -> Maybe [CacheMode] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CacheMode]
modes,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> CacheType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CacheType
type')
]
)