{-# 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.AppSync.Types.ApiCache
-- 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.AppSync.Types.ApiCache where

import Amazonka.AppSync.Types.ApiCacheStatus
import Amazonka.AppSync.Types.ApiCacheType
import Amazonka.AppSync.Types.ApiCachingBehavior
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The @ApiCache@ object.
--
-- /See:/ 'newApiCache' smart constructor.
data ApiCache = ApiCache'
  { -- | TTL in seconds for cache entries.
    --
    -- Valid values are between 1 and 3600 seconds.
    ApiCache -> Maybe Integer
ttl :: Prelude.Maybe Prelude.Integer,
    -- | The cache instance status.
    --
    -- -   __AVAILABLE__: The instance is available for use.
    --
    -- -   __CREATING__: The instance is currently creating.
    --
    -- -   __DELETING__: The instance is currently deleting.
    --
    -- -   __MODIFYING__: The instance is currently modifying.
    --
    -- -   __FAILED__: The instance has failed creation.
    ApiCache -> Maybe ApiCacheStatus
status :: Prelude.Maybe ApiCacheStatus,
    -- | At rest encryption flag for cache. This setting cannot be updated after
    -- creation.
    ApiCache -> Maybe Bool
atRestEncryptionEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Transit encryption flag when connecting to cache. This setting cannot be
    -- updated after creation.
    ApiCache -> Maybe Bool
transitEncryptionEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Caching behavior.
    --
    -- -   __FULL_REQUEST_CACHING__: All requests are fully cached.
    --
    -- -   __PER_RESOLVER_CACHING__: Individual resolvers that you specify are
    --     cached.
    ApiCache -> Maybe ApiCachingBehavior
apiCachingBehavior :: Prelude.Maybe ApiCachingBehavior,
    -- | The cache instance type. Valid values are
    --
    -- -   @SMALL@
    --
    -- -   @MEDIUM@
    --
    -- -   @LARGE@
    --
    -- -   @XLARGE@
    --
    -- -   @LARGE_2X@
    --
    -- -   @LARGE_4X@
    --
    -- -   @LARGE_8X@ (not available in all regions)
    --
    -- -   @LARGE_12X@
    --
    -- Historically, instance types were identified by an EC2-style value. As
    -- of July 2020, this is deprecated, and the generic identifiers above
    -- should be used.
    --
    -- The following legacy instance types are available, but their use is
    -- discouraged:
    --
    -- -   __T2_SMALL__: A t2.small instance type.
    --
    -- -   __T2_MEDIUM__: A t2.medium instance type.
    --
    -- -   __R4_LARGE__: A r4.large instance type.
    --
    -- -   __R4_XLARGE__: A r4.xlarge instance type.
    --
    -- -   __R4_2XLARGE__: A r4.2xlarge instance type.
    --
    -- -   __R4_4XLARGE__: A r4.4xlarge instance type.
    --
    -- -   __R4_8XLARGE__: A r4.8xlarge instance type.
    ApiCache -> Maybe ApiCacheType
type' :: Prelude.Maybe ApiCacheType
  }
  deriving (ApiCache -> ApiCache -> Bool
(ApiCache -> ApiCache -> Bool)
-> (ApiCache -> ApiCache -> Bool) -> Eq ApiCache
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApiCache -> ApiCache -> Bool
$c/= :: ApiCache -> ApiCache -> Bool
== :: ApiCache -> ApiCache -> Bool
$c== :: ApiCache -> ApiCache -> Bool
Prelude.Eq, ReadPrec [ApiCache]
ReadPrec ApiCache
Int -> ReadS ApiCache
ReadS [ApiCache]
(Int -> ReadS ApiCache)
-> ReadS [ApiCache]
-> ReadPrec ApiCache
-> ReadPrec [ApiCache]
-> Read ApiCache
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApiCache]
$creadListPrec :: ReadPrec [ApiCache]
readPrec :: ReadPrec ApiCache
$creadPrec :: ReadPrec ApiCache
readList :: ReadS [ApiCache]
$creadList :: ReadS [ApiCache]
readsPrec :: Int -> ReadS ApiCache
$creadsPrec :: Int -> ReadS ApiCache
Prelude.Read, Int -> ApiCache -> ShowS
[ApiCache] -> ShowS
ApiCache -> String
(Int -> ApiCache -> ShowS)
-> (ApiCache -> String) -> ([ApiCache] -> ShowS) -> Show ApiCache
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApiCache] -> ShowS
$cshowList :: [ApiCache] -> ShowS
show :: ApiCache -> String
$cshow :: ApiCache -> String
showsPrec :: Int -> ApiCache -> ShowS
$cshowsPrec :: Int -> ApiCache -> ShowS
Prelude.Show, (forall x. ApiCache -> Rep ApiCache x)
-> (forall x. Rep ApiCache x -> ApiCache) -> Generic ApiCache
forall x. Rep ApiCache x -> ApiCache
forall x. ApiCache -> Rep ApiCache x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ApiCache x -> ApiCache
$cfrom :: forall x. ApiCache -> Rep ApiCache x
Prelude.Generic)

-- |
-- Create a value of 'ApiCache' 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:
--
-- 'ttl', 'apiCache_ttl' - TTL in seconds for cache entries.
--
-- Valid values are between 1 and 3600 seconds.
--
-- 'status', 'apiCache_status' - The cache instance status.
--
-- -   __AVAILABLE__: The instance is available for use.
--
-- -   __CREATING__: The instance is currently creating.
--
-- -   __DELETING__: The instance is currently deleting.
--
-- -   __MODIFYING__: The instance is currently modifying.
--
-- -   __FAILED__: The instance has failed creation.
--
-- 'atRestEncryptionEnabled', 'apiCache_atRestEncryptionEnabled' - At rest encryption flag for cache. This setting cannot be updated after
-- creation.
--
-- 'transitEncryptionEnabled', 'apiCache_transitEncryptionEnabled' - Transit encryption flag when connecting to cache. This setting cannot be
-- updated after creation.
--
-- 'apiCachingBehavior', 'apiCache_apiCachingBehavior' - Caching behavior.
--
-- -   __FULL_REQUEST_CACHING__: All requests are fully cached.
--
-- -   __PER_RESOLVER_CACHING__: Individual resolvers that you specify are
--     cached.
--
-- 'type'', 'apiCache_type' - The cache instance type. Valid values are
--
-- -   @SMALL@
--
-- -   @MEDIUM@
--
-- -   @LARGE@
--
-- -   @XLARGE@
--
-- -   @LARGE_2X@
--
-- -   @LARGE_4X@
--
-- -   @LARGE_8X@ (not available in all regions)
--
-- -   @LARGE_12X@
--
-- Historically, instance types were identified by an EC2-style value. As
-- of July 2020, this is deprecated, and the generic identifiers above
-- should be used.
--
-- The following legacy instance types are available, but their use is
-- discouraged:
--
-- -   __T2_SMALL__: A t2.small instance type.
--
-- -   __T2_MEDIUM__: A t2.medium instance type.
--
-- -   __R4_LARGE__: A r4.large instance type.
--
-- -   __R4_XLARGE__: A r4.xlarge instance type.
--
-- -   __R4_2XLARGE__: A r4.2xlarge instance type.
--
-- -   __R4_4XLARGE__: A r4.4xlarge instance type.
--
-- -   __R4_8XLARGE__: A r4.8xlarge instance type.
newApiCache ::
  ApiCache
newApiCache :: ApiCache
newApiCache =
  ApiCache' :: Maybe Integer
-> Maybe ApiCacheStatus
-> Maybe Bool
-> Maybe Bool
-> Maybe ApiCachingBehavior
-> Maybe ApiCacheType
-> ApiCache
ApiCache'
    { $sel:ttl:ApiCache' :: Maybe Integer
ttl = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:status:ApiCache' :: Maybe ApiCacheStatus
status = Maybe ApiCacheStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:atRestEncryptionEnabled:ApiCache' :: Maybe Bool
atRestEncryptionEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:transitEncryptionEnabled:ApiCache' :: Maybe Bool
transitEncryptionEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:apiCachingBehavior:ApiCache' :: Maybe ApiCachingBehavior
apiCachingBehavior = Maybe ApiCachingBehavior
forall a. Maybe a
Prelude.Nothing,
      $sel:type':ApiCache' :: Maybe ApiCacheType
type' = Maybe ApiCacheType
forall a. Maybe a
Prelude.Nothing
    }

-- | TTL in seconds for cache entries.
--
-- Valid values are between 1 and 3600 seconds.
apiCache_ttl :: Lens.Lens' ApiCache (Prelude.Maybe Prelude.Integer)
apiCache_ttl :: (Maybe Integer -> f (Maybe Integer)) -> ApiCache -> f ApiCache
apiCache_ttl = (ApiCache -> Maybe Integer)
-> (ApiCache -> Maybe Integer -> ApiCache)
-> Lens ApiCache ApiCache (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiCache' {Maybe Integer
ttl :: Maybe Integer
$sel:ttl:ApiCache' :: ApiCache -> Maybe Integer
ttl} -> Maybe Integer
ttl) (\s :: ApiCache
s@ApiCache' {} Maybe Integer
a -> ApiCache
s {$sel:ttl:ApiCache' :: Maybe Integer
ttl = Maybe Integer
a} :: ApiCache)

-- | The cache instance status.
--
-- -   __AVAILABLE__: The instance is available for use.
--
-- -   __CREATING__: The instance is currently creating.
--
-- -   __DELETING__: The instance is currently deleting.
--
-- -   __MODIFYING__: The instance is currently modifying.
--
-- -   __FAILED__: The instance has failed creation.
apiCache_status :: Lens.Lens' ApiCache (Prelude.Maybe ApiCacheStatus)
apiCache_status :: (Maybe ApiCacheStatus -> f (Maybe ApiCacheStatus))
-> ApiCache -> f ApiCache
apiCache_status = (ApiCache -> Maybe ApiCacheStatus)
-> (ApiCache -> Maybe ApiCacheStatus -> ApiCache)
-> Lens
     ApiCache ApiCache (Maybe ApiCacheStatus) (Maybe ApiCacheStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiCache' {Maybe ApiCacheStatus
status :: Maybe ApiCacheStatus
$sel:status:ApiCache' :: ApiCache -> Maybe ApiCacheStatus
status} -> Maybe ApiCacheStatus
status) (\s :: ApiCache
s@ApiCache' {} Maybe ApiCacheStatus
a -> ApiCache
s {$sel:status:ApiCache' :: Maybe ApiCacheStatus
status = Maybe ApiCacheStatus
a} :: ApiCache)

-- | At rest encryption flag for cache. This setting cannot be updated after
-- creation.
apiCache_atRestEncryptionEnabled :: Lens.Lens' ApiCache (Prelude.Maybe Prelude.Bool)
apiCache_atRestEncryptionEnabled :: (Maybe Bool -> f (Maybe Bool)) -> ApiCache -> f ApiCache
apiCache_atRestEncryptionEnabled = (ApiCache -> Maybe Bool)
-> (ApiCache -> Maybe Bool -> ApiCache)
-> Lens ApiCache ApiCache (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiCache' {Maybe Bool
atRestEncryptionEnabled :: Maybe Bool
$sel:atRestEncryptionEnabled:ApiCache' :: ApiCache -> Maybe Bool
atRestEncryptionEnabled} -> Maybe Bool
atRestEncryptionEnabled) (\s :: ApiCache
s@ApiCache' {} Maybe Bool
a -> ApiCache
s {$sel:atRestEncryptionEnabled:ApiCache' :: Maybe Bool
atRestEncryptionEnabled = Maybe Bool
a} :: ApiCache)

-- | Transit encryption flag when connecting to cache. This setting cannot be
-- updated after creation.
apiCache_transitEncryptionEnabled :: Lens.Lens' ApiCache (Prelude.Maybe Prelude.Bool)
apiCache_transitEncryptionEnabled :: (Maybe Bool -> f (Maybe Bool)) -> ApiCache -> f ApiCache
apiCache_transitEncryptionEnabled = (ApiCache -> Maybe Bool)
-> (ApiCache -> Maybe Bool -> ApiCache)
-> Lens ApiCache ApiCache (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiCache' {Maybe Bool
transitEncryptionEnabled :: Maybe Bool
$sel:transitEncryptionEnabled:ApiCache' :: ApiCache -> Maybe Bool
transitEncryptionEnabled} -> Maybe Bool
transitEncryptionEnabled) (\s :: ApiCache
s@ApiCache' {} Maybe Bool
a -> ApiCache
s {$sel:transitEncryptionEnabled:ApiCache' :: Maybe Bool
transitEncryptionEnabled = Maybe Bool
a} :: ApiCache)

-- | Caching behavior.
--
-- -   __FULL_REQUEST_CACHING__: All requests are fully cached.
--
-- -   __PER_RESOLVER_CACHING__: Individual resolvers that you specify are
--     cached.
apiCache_apiCachingBehavior :: Lens.Lens' ApiCache (Prelude.Maybe ApiCachingBehavior)
apiCache_apiCachingBehavior :: (Maybe ApiCachingBehavior -> f (Maybe ApiCachingBehavior))
-> ApiCache -> f ApiCache
apiCache_apiCachingBehavior = (ApiCache -> Maybe ApiCachingBehavior)
-> (ApiCache -> Maybe ApiCachingBehavior -> ApiCache)
-> Lens
     ApiCache
     ApiCache
     (Maybe ApiCachingBehavior)
     (Maybe ApiCachingBehavior)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiCache' {Maybe ApiCachingBehavior
apiCachingBehavior :: Maybe ApiCachingBehavior
$sel:apiCachingBehavior:ApiCache' :: ApiCache -> Maybe ApiCachingBehavior
apiCachingBehavior} -> Maybe ApiCachingBehavior
apiCachingBehavior) (\s :: ApiCache
s@ApiCache' {} Maybe ApiCachingBehavior
a -> ApiCache
s {$sel:apiCachingBehavior:ApiCache' :: Maybe ApiCachingBehavior
apiCachingBehavior = Maybe ApiCachingBehavior
a} :: ApiCache)

-- | The cache instance type. Valid values are
--
-- -   @SMALL@
--
-- -   @MEDIUM@
--
-- -   @LARGE@
--
-- -   @XLARGE@
--
-- -   @LARGE_2X@
--
-- -   @LARGE_4X@
--
-- -   @LARGE_8X@ (not available in all regions)
--
-- -   @LARGE_12X@
--
-- Historically, instance types were identified by an EC2-style value. As
-- of July 2020, this is deprecated, and the generic identifiers above
-- should be used.
--
-- The following legacy instance types are available, but their use is
-- discouraged:
--
-- -   __T2_SMALL__: A t2.small instance type.
--
-- -   __T2_MEDIUM__: A t2.medium instance type.
--
-- -   __R4_LARGE__: A r4.large instance type.
--
-- -   __R4_XLARGE__: A r4.xlarge instance type.
--
-- -   __R4_2XLARGE__: A r4.2xlarge instance type.
--
-- -   __R4_4XLARGE__: A r4.4xlarge instance type.
--
-- -   __R4_8XLARGE__: A r4.8xlarge instance type.
apiCache_type :: Lens.Lens' ApiCache (Prelude.Maybe ApiCacheType)
apiCache_type :: (Maybe ApiCacheType -> f (Maybe ApiCacheType))
-> ApiCache -> f ApiCache
apiCache_type = (ApiCache -> Maybe ApiCacheType)
-> (ApiCache -> Maybe ApiCacheType -> ApiCache)
-> Lens ApiCache ApiCache (Maybe ApiCacheType) (Maybe ApiCacheType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApiCache' {Maybe ApiCacheType
type' :: Maybe ApiCacheType
$sel:type':ApiCache' :: ApiCache -> Maybe ApiCacheType
type'} -> Maybe ApiCacheType
type') (\s :: ApiCache
s@ApiCache' {} Maybe ApiCacheType
a -> ApiCache
s {$sel:type':ApiCache' :: Maybe ApiCacheType
type' = Maybe ApiCacheType
a} :: ApiCache)

instance Core.FromJSON ApiCache where
  parseJSON :: Value -> Parser ApiCache
parseJSON =
    String -> (Object -> Parser ApiCache) -> Value -> Parser ApiCache
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ApiCache"
      ( \Object
x ->
          Maybe Integer
-> Maybe ApiCacheStatus
-> Maybe Bool
-> Maybe Bool
-> Maybe ApiCachingBehavior
-> Maybe ApiCacheType
-> ApiCache
ApiCache'
            (Maybe Integer
 -> Maybe ApiCacheStatus
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe ApiCachingBehavior
 -> Maybe ApiCacheType
 -> ApiCache)
-> Parser (Maybe Integer)
-> Parser
     (Maybe ApiCacheStatus
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe ApiCachingBehavior
      -> Maybe ApiCacheType
      -> ApiCache)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ttl")
            Parser
  (Maybe ApiCacheStatus
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe ApiCachingBehavior
   -> Maybe ApiCacheType
   -> ApiCache)
-> Parser (Maybe ApiCacheStatus)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe ApiCachingBehavior
      -> Maybe ApiCacheType
      -> ApiCache)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ApiCacheStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe ApiCachingBehavior
   -> Maybe ApiCacheType
   -> ApiCache)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe ApiCachingBehavior -> Maybe ApiCacheType -> ApiCache)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"atRestEncryptionEnabled")
            Parser
  (Maybe Bool
   -> Maybe ApiCachingBehavior -> Maybe ApiCacheType -> ApiCache)
-> Parser (Maybe Bool)
-> Parser
     (Maybe ApiCachingBehavior -> Maybe ApiCacheType -> ApiCache)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"transitEncryptionEnabled")
            Parser (Maybe ApiCachingBehavior -> Maybe ApiCacheType -> ApiCache)
-> Parser (Maybe ApiCachingBehavior)
-> Parser (Maybe ApiCacheType -> ApiCache)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ApiCachingBehavior)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"apiCachingBehavior")
            Parser (Maybe ApiCacheType -> ApiCache)
-> Parser (Maybe ApiCacheType) -> Parser ApiCache
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ApiCacheType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
      )

instance Prelude.Hashable ApiCache

instance Prelude.NFData ApiCache