{-# 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.WorkSpaces.Types.ComputeType
-- 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.WorkSpaces.Types.ComputeType where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkSpaces.Types.Compute

-- | Describes the compute type of the bundle.
--
-- /See:/ 'newComputeType' smart constructor.
data ComputeType = ComputeType'
  { -- | The compute type.
    ComputeType -> Maybe Compute
name :: Prelude.Maybe Compute
  }
  deriving (ComputeType -> ComputeType -> Bool
(ComputeType -> ComputeType -> Bool)
-> (ComputeType -> ComputeType -> Bool) -> Eq ComputeType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComputeType -> ComputeType -> Bool
$c/= :: ComputeType -> ComputeType -> Bool
== :: ComputeType -> ComputeType -> Bool
$c== :: ComputeType -> ComputeType -> Bool
Prelude.Eq, ReadPrec [ComputeType]
ReadPrec ComputeType
Int -> ReadS ComputeType
ReadS [ComputeType]
(Int -> ReadS ComputeType)
-> ReadS [ComputeType]
-> ReadPrec ComputeType
-> ReadPrec [ComputeType]
-> Read ComputeType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComputeType]
$creadListPrec :: ReadPrec [ComputeType]
readPrec :: ReadPrec ComputeType
$creadPrec :: ReadPrec ComputeType
readList :: ReadS [ComputeType]
$creadList :: ReadS [ComputeType]
readsPrec :: Int -> ReadS ComputeType
$creadsPrec :: Int -> ReadS ComputeType
Prelude.Read, Int -> ComputeType -> ShowS
[ComputeType] -> ShowS
ComputeType -> String
(Int -> ComputeType -> ShowS)
-> (ComputeType -> String)
-> ([ComputeType] -> ShowS)
-> Show ComputeType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComputeType] -> ShowS
$cshowList :: [ComputeType] -> ShowS
show :: ComputeType -> String
$cshow :: ComputeType -> String
showsPrec :: Int -> ComputeType -> ShowS
$cshowsPrec :: Int -> ComputeType -> ShowS
Prelude.Show, (forall x. ComputeType -> Rep ComputeType x)
-> (forall x. Rep ComputeType x -> ComputeType)
-> Generic ComputeType
forall x. Rep ComputeType x -> ComputeType
forall x. ComputeType -> Rep ComputeType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComputeType x -> ComputeType
$cfrom :: forall x. ComputeType -> Rep ComputeType x
Prelude.Generic)

-- |
-- Create a value of 'ComputeType' 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:
--
-- 'name', 'computeType_name' - The compute type.
newComputeType ::
  ComputeType
newComputeType :: ComputeType
newComputeType = ComputeType' :: Maybe Compute -> ComputeType
ComputeType' {$sel:name:ComputeType' :: Maybe Compute
name = Maybe Compute
forall a. Maybe a
Prelude.Nothing}

-- | The compute type.
computeType_name :: Lens.Lens' ComputeType (Prelude.Maybe Compute)
computeType_name :: (Maybe Compute -> f (Maybe Compute))
-> ComputeType -> f ComputeType
computeType_name = (ComputeType -> Maybe Compute)
-> (ComputeType -> Maybe Compute -> ComputeType)
-> Lens ComputeType ComputeType (Maybe Compute) (Maybe Compute)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeType' {Maybe Compute
name :: Maybe Compute
$sel:name:ComputeType' :: ComputeType -> Maybe Compute
name} -> Maybe Compute
name) (\s :: ComputeType
s@ComputeType' {} Maybe Compute
a -> ComputeType
s {$sel:name:ComputeType' :: Maybe Compute
name = Maybe Compute
a} :: ComputeType)

instance Core.FromJSON ComputeType where
  parseJSON :: Value -> Parser ComputeType
parseJSON =
    String
-> (Object -> Parser ComputeType) -> Value -> Parser ComputeType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ComputeType"
      (\Object
x -> Maybe Compute -> ComputeType
ComputeType' (Maybe Compute -> ComputeType)
-> Parser (Maybe Compute) -> Parser ComputeType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Compute)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name"))

instance Prelude.Hashable ComputeType

instance Prelude.NFData ComputeType

instance Core.ToJSON ComputeType where
  toJSON :: ComputeType -> Value
toJSON ComputeType' {Maybe Compute
name :: Maybe Compute
$sel:name:ComputeType' :: ComputeType -> Maybe Compute
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Name" Text -> Compute -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Compute -> Pair) -> Maybe Compute -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Compute
name]
      )