{-# 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.RDS.Types.ProcessorFeature
-- 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.RDS.Types.ProcessorFeature where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the processor features of a DB instance class.
--
-- To specify the number of CPU cores, use the @coreCount@ feature name for
-- the @Name@ parameter. To specify the number of threads per core, use the
-- @threadsPerCore@ feature name for the @Name@ parameter.
--
-- You can set the processor features of the DB instance class for a DB
-- instance when you call one of the following actions:
--
-- -   @CreateDBInstance@
--
-- -   @ModifyDBInstance@
--
-- -   @RestoreDBInstanceFromDBSnapshot@
--
-- -   @RestoreDBInstanceFromS3@
--
-- -   @RestoreDBInstanceToPointInTime@
--
-- You can view the valid processor values for a particular instance class
-- by calling the @DescribeOrderableDBInstanceOptions@ action and
-- specifying the instance class for the @DBInstanceClass@ parameter.
--
-- In addition, you can use the following actions for DB instance class
-- processor information:
--
-- -   @DescribeDBInstances@
--
-- -   @DescribeDBSnapshots@
--
-- -   @DescribeValidDBInstanceModifications@
--
-- If you call @DescribeDBInstances@, @ProcessorFeature@ returns non-null
-- values only if the following conditions are met:
--
-- -   You are accessing an Oracle DB instance.
--
-- -   Your Oracle DB instance class supports configuring the number of CPU
--     cores and threads per core.
--
-- -   The current number CPU cores and threads is set to a non-default
--     value.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html#USER_ConfigureProcessor Configuring the Processor of the DB Instance Class>
-- in the /Amazon RDS User Guide./
--
-- /See:/ 'newProcessorFeature' smart constructor.
data ProcessorFeature = ProcessorFeature'
  { -- | The value of a processor feature name.
    ProcessorFeature -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The name of the processor feature. Valid names are @coreCount@ and
    -- @threadsPerCore@.
    ProcessorFeature -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ProcessorFeature -> ProcessorFeature -> Bool
(ProcessorFeature -> ProcessorFeature -> Bool)
-> (ProcessorFeature -> ProcessorFeature -> Bool)
-> Eq ProcessorFeature
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProcessorFeature -> ProcessorFeature -> Bool
$c/= :: ProcessorFeature -> ProcessorFeature -> Bool
== :: ProcessorFeature -> ProcessorFeature -> Bool
$c== :: ProcessorFeature -> ProcessorFeature -> Bool
Prelude.Eq, ReadPrec [ProcessorFeature]
ReadPrec ProcessorFeature
Int -> ReadS ProcessorFeature
ReadS [ProcessorFeature]
(Int -> ReadS ProcessorFeature)
-> ReadS [ProcessorFeature]
-> ReadPrec ProcessorFeature
-> ReadPrec [ProcessorFeature]
-> Read ProcessorFeature
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProcessorFeature]
$creadListPrec :: ReadPrec [ProcessorFeature]
readPrec :: ReadPrec ProcessorFeature
$creadPrec :: ReadPrec ProcessorFeature
readList :: ReadS [ProcessorFeature]
$creadList :: ReadS [ProcessorFeature]
readsPrec :: Int -> ReadS ProcessorFeature
$creadsPrec :: Int -> ReadS ProcessorFeature
Prelude.Read, Int -> ProcessorFeature -> ShowS
[ProcessorFeature] -> ShowS
ProcessorFeature -> String
(Int -> ProcessorFeature -> ShowS)
-> (ProcessorFeature -> String)
-> ([ProcessorFeature] -> ShowS)
-> Show ProcessorFeature
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProcessorFeature] -> ShowS
$cshowList :: [ProcessorFeature] -> ShowS
show :: ProcessorFeature -> String
$cshow :: ProcessorFeature -> String
showsPrec :: Int -> ProcessorFeature -> ShowS
$cshowsPrec :: Int -> ProcessorFeature -> ShowS
Prelude.Show, (forall x. ProcessorFeature -> Rep ProcessorFeature x)
-> (forall x. Rep ProcessorFeature x -> ProcessorFeature)
-> Generic ProcessorFeature
forall x. Rep ProcessorFeature x -> ProcessorFeature
forall x. ProcessorFeature -> Rep ProcessorFeature x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProcessorFeature x -> ProcessorFeature
$cfrom :: forall x. ProcessorFeature -> Rep ProcessorFeature x
Prelude.Generic)

-- |
-- Create a value of 'ProcessorFeature' 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:
--
-- 'value', 'processorFeature_value' - The value of a processor feature name.
--
-- 'name', 'processorFeature_name' - The name of the processor feature. Valid names are @coreCount@ and
-- @threadsPerCore@.
newProcessorFeature ::
  ProcessorFeature
newProcessorFeature :: ProcessorFeature
newProcessorFeature =
  ProcessorFeature' :: Maybe Text -> Maybe Text -> ProcessorFeature
ProcessorFeature'
    { $sel:value:ProcessorFeature' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ProcessorFeature' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of a processor feature name.
processorFeature_value :: Lens.Lens' ProcessorFeature (Prelude.Maybe Prelude.Text)
processorFeature_value :: (Maybe Text -> f (Maybe Text))
-> ProcessorFeature -> f ProcessorFeature
processorFeature_value = (ProcessorFeature -> Maybe Text)
-> (ProcessorFeature -> Maybe Text -> ProcessorFeature)
-> Lens ProcessorFeature ProcessorFeature (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessorFeature' {Maybe Text
value :: Maybe Text
$sel:value:ProcessorFeature' :: ProcessorFeature -> Maybe Text
value} -> Maybe Text
value) (\s :: ProcessorFeature
s@ProcessorFeature' {} Maybe Text
a -> ProcessorFeature
s {$sel:value:ProcessorFeature' :: Maybe Text
value = Maybe Text
a} :: ProcessorFeature)

-- | The name of the processor feature. Valid names are @coreCount@ and
-- @threadsPerCore@.
processorFeature_name :: Lens.Lens' ProcessorFeature (Prelude.Maybe Prelude.Text)
processorFeature_name :: (Maybe Text -> f (Maybe Text))
-> ProcessorFeature -> f ProcessorFeature
processorFeature_name = (ProcessorFeature -> Maybe Text)
-> (ProcessorFeature -> Maybe Text -> ProcessorFeature)
-> Lens ProcessorFeature ProcessorFeature (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessorFeature' {Maybe Text
name :: Maybe Text
$sel:name:ProcessorFeature' :: ProcessorFeature -> Maybe Text
name} -> Maybe Text
name) (\s :: ProcessorFeature
s@ProcessorFeature' {} Maybe Text
a -> ProcessorFeature
s {$sel:name:ProcessorFeature' :: Maybe Text
name = Maybe Text
a} :: ProcessorFeature)

instance Core.FromXML ProcessorFeature where
  parseXML :: [Node] -> Either String ProcessorFeature
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> ProcessorFeature
ProcessorFeature'
      (Maybe Text -> Maybe Text -> ProcessorFeature)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> ProcessorFeature)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Value") Either String (Maybe Text -> ProcessorFeature)
-> Either String (Maybe Text) -> Either String ProcessorFeature
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Name")

instance Prelude.Hashable ProcessorFeature

instance Prelude.NFData ProcessorFeature

instance Core.ToQuery ProcessorFeature where
  toQuery :: ProcessorFeature -> QueryString
toQuery ProcessorFeature' {Maybe Text
name :: Maybe Text
value :: Maybe Text
$sel:name:ProcessorFeature' :: ProcessorFeature -> Maybe Text
$sel:value:ProcessorFeature' :: ProcessorFeature -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Value" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
value, ByteString
"Name" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
name]