{-# 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.EC2.Types.ReservedInstancesConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EC2.Types.ReservedInstancesConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.InstanceType
import Amazonka.EC2.Types.Scope
import qualified Amazonka.Prelude as Prelude

-- | Describes the configuration settings for the modified Reserved
-- Instances.
--
-- /See:/ 'newReservedInstancesConfiguration' smart constructor.
data ReservedInstancesConfiguration = ReservedInstancesConfiguration'
  { -- | The Availability Zone for the modified Reserved Instances.
    ReservedInstancesConfiguration -> Maybe Text
availabilityZone :: Prelude.Maybe Prelude.Text,
    -- | The number of modified Reserved Instances.
    --
    -- This is a required field for a request.
    ReservedInstancesConfiguration -> Maybe Int
instanceCount :: Prelude.Maybe Prelude.Int,
    -- | The instance type for the modified Reserved Instances.
    ReservedInstancesConfiguration -> Maybe InstanceType
instanceType :: Prelude.Maybe InstanceType,
    -- | The network platform of the modified Reserved Instances, which is either
    -- EC2-Classic or EC2-VPC.
    ReservedInstancesConfiguration -> Maybe Text
platform :: Prelude.Maybe Prelude.Text,
    -- | Whether the Reserved Instance is applied to instances in a Region or
    -- instances in a specific Availability Zone.
    ReservedInstancesConfiguration -> Maybe Scope
scope :: Prelude.Maybe Scope
  }
  deriving (ReservedInstancesConfiguration
-> ReservedInstancesConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReservedInstancesConfiguration
-> ReservedInstancesConfiguration -> Bool
$c/= :: ReservedInstancesConfiguration
-> ReservedInstancesConfiguration -> Bool
== :: ReservedInstancesConfiguration
-> ReservedInstancesConfiguration -> Bool
$c== :: ReservedInstancesConfiguration
-> ReservedInstancesConfiguration -> Bool
Prelude.Eq, ReadPrec [ReservedInstancesConfiguration]
ReadPrec ReservedInstancesConfiguration
Int -> ReadS ReservedInstancesConfiguration
ReadS [ReservedInstancesConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReservedInstancesConfiguration]
$creadListPrec :: ReadPrec [ReservedInstancesConfiguration]
readPrec :: ReadPrec ReservedInstancesConfiguration
$creadPrec :: ReadPrec ReservedInstancesConfiguration
readList :: ReadS [ReservedInstancesConfiguration]
$creadList :: ReadS [ReservedInstancesConfiguration]
readsPrec :: Int -> ReadS ReservedInstancesConfiguration
$creadsPrec :: Int -> ReadS ReservedInstancesConfiguration
Prelude.Read, Int -> ReservedInstancesConfiguration -> ShowS
[ReservedInstancesConfiguration] -> ShowS
ReservedInstancesConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReservedInstancesConfiguration] -> ShowS
$cshowList :: [ReservedInstancesConfiguration] -> ShowS
show :: ReservedInstancesConfiguration -> String
$cshow :: ReservedInstancesConfiguration -> String
showsPrec :: Int -> ReservedInstancesConfiguration -> ShowS
$cshowsPrec :: Int -> ReservedInstancesConfiguration -> ShowS
Prelude.Show, forall x.
Rep ReservedInstancesConfiguration x
-> ReservedInstancesConfiguration
forall x.
ReservedInstancesConfiguration
-> Rep ReservedInstancesConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ReservedInstancesConfiguration x
-> ReservedInstancesConfiguration
$cfrom :: forall x.
ReservedInstancesConfiguration
-> Rep ReservedInstancesConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ReservedInstancesConfiguration' 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:
--
-- 'availabilityZone', 'reservedInstancesConfiguration_availabilityZone' - The Availability Zone for the modified Reserved Instances.
--
-- 'instanceCount', 'reservedInstancesConfiguration_instanceCount' - The number of modified Reserved Instances.
--
-- This is a required field for a request.
--
-- 'instanceType', 'reservedInstancesConfiguration_instanceType' - The instance type for the modified Reserved Instances.
--
-- 'platform', 'reservedInstancesConfiguration_platform' - The network platform of the modified Reserved Instances, which is either
-- EC2-Classic or EC2-VPC.
--
-- 'scope', 'reservedInstancesConfiguration_scope' - Whether the Reserved Instance is applied to instances in a Region or
-- instances in a specific Availability Zone.
newReservedInstancesConfiguration ::
  ReservedInstancesConfiguration
newReservedInstancesConfiguration :: ReservedInstancesConfiguration
newReservedInstancesConfiguration =
  ReservedInstancesConfiguration'
    { $sel:availabilityZone:ReservedInstancesConfiguration' :: Maybe Text
availabilityZone =
        forall a. Maybe a
Prelude.Nothing,
      $sel:instanceCount:ReservedInstancesConfiguration' :: Maybe Int
instanceCount = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:ReservedInstancesConfiguration' :: Maybe InstanceType
instanceType = forall a. Maybe a
Prelude.Nothing,
      $sel:platform:ReservedInstancesConfiguration' :: Maybe Text
platform = forall a. Maybe a
Prelude.Nothing,
      $sel:scope:ReservedInstancesConfiguration' :: Maybe Scope
scope = forall a. Maybe a
Prelude.Nothing
    }

-- | The Availability Zone for the modified Reserved Instances.
reservedInstancesConfiguration_availabilityZone :: Lens.Lens' ReservedInstancesConfiguration (Prelude.Maybe Prelude.Text)
reservedInstancesConfiguration_availabilityZone :: Lens' ReservedInstancesConfiguration (Maybe Text)
reservedInstancesConfiguration_availabilityZone = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservedInstancesConfiguration' {Maybe Text
availabilityZone :: Maybe Text
$sel:availabilityZone:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Text
availabilityZone} -> Maybe Text
availabilityZone) (\s :: ReservedInstancesConfiguration
s@ReservedInstancesConfiguration' {} Maybe Text
a -> ReservedInstancesConfiguration
s {$sel:availabilityZone:ReservedInstancesConfiguration' :: Maybe Text
availabilityZone = Maybe Text
a} :: ReservedInstancesConfiguration)

-- | The number of modified Reserved Instances.
--
-- This is a required field for a request.
reservedInstancesConfiguration_instanceCount :: Lens.Lens' ReservedInstancesConfiguration (Prelude.Maybe Prelude.Int)
reservedInstancesConfiguration_instanceCount :: Lens' ReservedInstancesConfiguration (Maybe Int)
reservedInstancesConfiguration_instanceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservedInstancesConfiguration' {Maybe Int
instanceCount :: Maybe Int
$sel:instanceCount:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Int
instanceCount} -> Maybe Int
instanceCount) (\s :: ReservedInstancesConfiguration
s@ReservedInstancesConfiguration' {} Maybe Int
a -> ReservedInstancesConfiguration
s {$sel:instanceCount:ReservedInstancesConfiguration' :: Maybe Int
instanceCount = Maybe Int
a} :: ReservedInstancesConfiguration)

-- | The instance type for the modified Reserved Instances.
reservedInstancesConfiguration_instanceType :: Lens.Lens' ReservedInstancesConfiguration (Prelude.Maybe InstanceType)
reservedInstancesConfiguration_instanceType :: Lens' ReservedInstancesConfiguration (Maybe InstanceType)
reservedInstancesConfiguration_instanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservedInstancesConfiguration' {Maybe InstanceType
instanceType :: Maybe InstanceType
$sel:instanceType:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe InstanceType
instanceType} -> Maybe InstanceType
instanceType) (\s :: ReservedInstancesConfiguration
s@ReservedInstancesConfiguration' {} Maybe InstanceType
a -> ReservedInstancesConfiguration
s {$sel:instanceType:ReservedInstancesConfiguration' :: Maybe InstanceType
instanceType = Maybe InstanceType
a} :: ReservedInstancesConfiguration)

-- | The network platform of the modified Reserved Instances, which is either
-- EC2-Classic or EC2-VPC.
reservedInstancesConfiguration_platform :: Lens.Lens' ReservedInstancesConfiguration (Prelude.Maybe Prelude.Text)
reservedInstancesConfiguration_platform :: Lens' ReservedInstancesConfiguration (Maybe Text)
reservedInstancesConfiguration_platform = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservedInstancesConfiguration' {Maybe Text
platform :: Maybe Text
$sel:platform:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Text
platform} -> Maybe Text
platform) (\s :: ReservedInstancesConfiguration
s@ReservedInstancesConfiguration' {} Maybe Text
a -> ReservedInstancesConfiguration
s {$sel:platform:ReservedInstancesConfiguration' :: Maybe Text
platform = Maybe Text
a} :: ReservedInstancesConfiguration)

-- | Whether the Reserved Instance is applied to instances in a Region or
-- instances in a specific Availability Zone.
reservedInstancesConfiguration_scope :: Lens.Lens' ReservedInstancesConfiguration (Prelude.Maybe Scope)
reservedInstancesConfiguration_scope :: Lens' ReservedInstancesConfiguration (Maybe Scope)
reservedInstancesConfiguration_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservedInstancesConfiguration' {Maybe Scope
scope :: Maybe Scope
$sel:scope:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Scope
scope} -> Maybe Scope
scope) (\s :: ReservedInstancesConfiguration
s@ReservedInstancesConfiguration' {} Maybe Scope
a -> ReservedInstancesConfiguration
s {$sel:scope:ReservedInstancesConfiguration' :: Maybe Scope
scope = Maybe Scope
a} :: ReservedInstancesConfiguration)

instance Data.FromXML ReservedInstancesConfiguration where
  parseXML :: [Node] -> Either String ReservedInstancesConfiguration
parseXML [Node]
x =
    Maybe Text
-> Maybe Int
-> Maybe InstanceType
-> Maybe Text
-> Maybe Scope
-> ReservedInstancesConfiguration
ReservedInstancesConfiguration'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"availabilityZone")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"instanceCount")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"instanceType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"platform")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"scope")

instance
  Prelude.Hashable
    ReservedInstancesConfiguration
  where
  hashWithSalt :: Int -> ReservedInstancesConfiguration -> Int
hashWithSalt
    Int
_salt
    ReservedInstancesConfiguration' {Maybe Int
Maybe Text
Maybe InstanceType
Maybe Scope
scope :: Maybe Scope
platform :: Maybe Text
instanceType :: Maybe InstanceType
instanceCount :: Maybe Int
availabilityZone :: Maybe Text
$sel:scope:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Scope
$sel:platform:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Text
$sel:instanceType:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe InstanceType
$sel:instanceCount:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Int
$sel:availabilityZone:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
availabilityZone
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
instanceCount
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InstanceType
instanceType
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
platform
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Scope
scope

instance
  Prelude.NFData
    ReservedInstancesConfiguration
  where
  rnf :: ReservedInstancesConfiguration -> ()
rnf ReservedInstancesConfiguration' {Maybe Int
Maybe Text
Maybe InstanceType
Maybe Scope
scope :: Maybe Scope
platform :: Maybe Text
instanceType :: Maybe InstanceType
instanceCount :: Maybe Int
availabilityZone :: Maybe Text
$sel:scope:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Scope
$sel:platform:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Text
$sel:instanceType:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe InstanceType
$sel:instanceCount:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Int
$sel:availabilityZone:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
availabilityZone
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
instanceCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceType
instanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
platform
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Scope
scope

instance Data.ToQuery ReservedInstancesConfiguration where
  toQuery :: ReservedInstancesConfiguration -> QueryString
toQuery ReservedInstancesConfiguration' {Maybe Int
Maybe Text
Maybe InstanceType
Maybe Scope
scope :: Maybe Scope
platform :: Maybe Text
instanceType :: Maybe InstanceType
instanceCount :: Maybe Int
availabilityZone :: Maybe Text
$sel:scope:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Scope
$sel:platform:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Text
$sel:instanceType:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe InstanceType
$sel:instanceCount:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Int
$sel:availabilityZone:ReservedInstancesConfiguration' :: ReservedInstancesConfiguration -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"AvailabilityZone" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
availabilityZone,
        ByteString
"InstanceCount" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
instanceCount,
        ByteString
"InstanceType" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe InstanceType
instanceType,
        ByteString
"Platform" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
platform,
        ByteString
"Scope" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Scope
scope
      ]