{-# 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.IoTAnalytics.Types.ResourceConfiguration
-- 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.IoTAnalytics.Types.ResourceConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.ComputeType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The configuration of the resource used to execute the @containerAction@.
--
-- /See:/ 'newResourceConfiguration' smart constructor.
data ResourceConfiguration = ResourceConfiguration'
  { -- | The type of the compute resource used to execute the @containerAction@.
    -- Possible values are: @ACU_1@ (vCPU=4, memory=16 GiB) or @ACU_2@ (vCPU=8,
    -- memory=32 GiB).
    ResourceConfiguration -> ComputeType
computeType :: ComputeType,
    -- | The size, in GB, of the persistent storage available to the resource
    -- instance used to execute the @containerAction@ (min: 1, max: 50).
    ResourceConfiguration -> Natural
volumeSizeInGB :: Prelude.Natural
  }
  deriving (ResourceConfiguration -> ResourceConfiguration -> Bool
(ResourceConfiguration -> ResourceConfiguration -> Bool)
-> (ResourceConfiguration -> ResourceConfiguration -> Bool)
-> Eq ResourceConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceConfiguration -> ResourceConfiguration -> Bool
$c/= :: ResourceConfiguration -> ResourceConfiguration -> Bool
== :: ResourceConfiguration -> ResourceConfiguration -> Bool
$c== :: ResourceConfiguration -> ResourceConfiguration -> Bool
Prelude.Eq, ReadPrec [ResourceConfiguration]
ReadPrec ResourceConfiguration
Int -> ReadS ResourceConfiguration
ReadS [ResourceConfiguration]
(Int -> ReadS ResourceConfiguration)
-> ReadS [ResourceConfiguration]
-> ReadPrec ResourceConfiguration
-> ReadPrec [ResourceConfiguration]
-> Read ResourceConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceConfiguration]
$creadListPrec :: ReadPrec [ResourceConfiguration]
readPrec :: ReadPrec ResourceConfiguration
$creadPrec :: ReadPrec ResourceConfiguration
readList :: ReadS [ResourceConfiguration]
$creadList :: ReadS [ResourceConfiguration]
readsPrec :: Int -> ReadS ResourceConfiguration
$creadsPrec :: Int -> ReadS ResourceConfiguration
Prelude.Read, Int -> ResourceConfiguration -> ShowS
[ResourceConfiguration] -> ShowS
ResourceConfiguration -> String
(Int -> ResourceConfiguration -> ShowS)
-> (ResourceConfiguration -> String)
-> ([ResourceConfiguration] -> ShowS)
-> Show ResourceConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceConfiguration] -> ShowS
$cshowList :: [ResourceConfiguration] -> ShowS
show :: ResourceConfiguration -> String
$cshow :: ResourceConfiguration -> String
showsPrec :: Int -> ResourceConfiguration -> ShowS
$cshowsPrec :: Int -> ResourceConfiguration -> ShowS
Prelude.Show, (forall x. ResourceConfiguration -> Rep ResourceConfiguration x)
-> (forall x. Rep ResourceConfiguration x -> ResourceConfiguration)
-> Generic ResourceConfiguration
forall x. Rep ResourceConfiguration x -> ResourceConfiguration
forall x. ResourceConfiguration -> Rep ResourceConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceConfiguration x -> ResourceConfiguration
$cfrom :: forall x. ResourceConfiguration -> Rep ResourceConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ResourceConfiguration' 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:
--
-- 'computeType', 'resourceConfiguration_computeType' - The type of the compute resource used to execute the @containerAction@.
-- Possible values are: @ACU_1@ (vCPU=4, memory=16 GiB) or @ACU_2@ (vCPU=8,
-- memory=32 GiB).
--
-- 'volumeSizeInGB', 'resourceConfiguration_volumeSizeInGB' - The size, in GB, of the persistent storage available to the resource
-- instance used to execute the @containerAction@ (min: 1, max: 50).
newResourceConfiguration ::
  -- | 'computeType'
  ComputeType ->
  -- | 'volumeSizeInGB'
  Prelude.Natural ->
  ResourceConfiguration
newResourceConfiguration :: ComputeType -> Natural -> ResourceConfiguration
newResourceConfiguration
  ComputeType
pComputeType_
  Natural
pVolumeSizeInGB_ =
    ResourceConfiguration' :: ComputeType -> Natural -> ResourceConfiguration
ResourceConfiguration'
      { $sel:computeType:ResourceConfiguration' :: ComputeType
computeType = ComputeType
pComputeType_,
        $sel:volumeSizeInGB:ResourceConfiguration' :: Natural
volumeSizeInGB = Natural
pVolumeSizeInGB_
      }

-- | The type of the compute resource used to execute the @containerAction@.
-- Possible values are: @ACU_1@ (vCPU=4, memory=16 GiB) or @ACU_2@ (vCPU=8,
-- memory=32 GiB).
resourceConfiguration_computeType :: Lens.Lens' ResourceConfiguration ComputeType
resourceConfiguration_computeType :: (ComputeType -> f ComputeType)
-> ResourceConfiguration -> f ResourceConfiguration
resourceConfiguration_computeType = (ResourceConfiguration -> ComputeType)
-> (ResourceConfiguration -> ComputeType -> ResourceConfiguration)
-> Lens
     ResourceConfiguration ResourceConfiguration ComputeType ComputeType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceConfiguration' {ComputeType
computeType :: ComputeType
$sel:computeType:ResourceConfiguration' :: ResourceConfiguration -> ComputeType
computeType} -> ComputeType
computeType) (\s :: ResourceConfiguration
s@ResourceConfiguration' {} ComputeType
a -> ResourceConfiguration
s {$sel:computeType:ResourceConfiguration' :: ComputeType
computeType = ComputeType
a} :: ResourceConfiguration)

-- | The size, in GB, of the persistent storage available to the resource
-- instance used to execute the @containerAction@ (min: 1, max: 50).
resourceConfiguration_volumeSizeInGB :: Lens.Lens' ResourceConfiguration Prelude.Natural
resourceConfiguration_volumeSizeInGB :: (Natural -> f Natural)
-> ResourceConfiguration -> f ResourceConfiguration
resourceConfiguration_volumeSizeInGB = (ResourceConfiguration -> Natural)
-> (ResourceConfiguration -> Natural -> ResourceConfiguration)
-> Lens ResourceConfiguration ResourceConfiguration Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceConfiguration' {Natural
volumeSizeInGB :: Natural
$sel:volumeSizeInGB:ResourceConfiguration' :: ResourceConfiguration -> Natural
volumeSizeInGB} -> Natural
volumeSizeInGB) (\s :: ResourceConfiguration
s@ResourceConfiguration' {} Natural
a -> ResourceConfiguration
s {$sel:volumeSizeInGB:ResourceConfiguration' :: Natural
volumeSizeInGB = Natural
a} :: ResourceConfiguration)

instance Core.FromJSON ResourceConfiguration where
  parseJSON :: Value -> Parser ResourceConfiguration
parseJSON =
    String
-> (Object -> Parser ResourceConfiguration)
-> Value
-> Parser ResourceConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceConfiguration"
      ( \Object
x ->
          ComputeType -> Natural -> ResourceConfiguration
ResourceConfiguration'
            (ComputeType -> Natural -> ResourceConfiguration)
-> Parser ComputeType -> Parser (Natural -> ResourceConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ComputeType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"computeType")
            Parser (Natural -> ResourceConfiguration)
-> Parser Natural -> Parser ResourceConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"volumeSizeInGB")
      )

instance Prelude.Hashable ResourceConfiguration

instance Prelude.NFData ResourceConfiguration

instance Core.ToJSON ResourceConfiguration where
  toJSON :: ResourceConfiguration -> Value
toJSON ResourceConfiguration' {Natural
ComputeType
volumeSizeInGB :: Natural
computeType :: ComputeType
$sel:volumeSizeInGB:ResourceConfiguration' :: ResourceConfiguration -> Natural
$sel:computeType:ResourceConfiguration' :: ResourceConfiguration -> ComputeType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"computeType" Text -> ComputeType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ComputeType
computeType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"volumeSizeInGB" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
volumeSizeInGB)
          ]
      )